google_spanner1/
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    /// Administer your Spanner databases
20    Admin,
21
22    /// See, edit, configure, and delete your Google Cloud Spanner data and see the email address for your Google Account
23    Data,
24}
25
26impl AsRef<str> for Scope {
27    fn as_ref(&self) -> &str {
28        match *self {
29            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
30            Scope::Admin => "https://www.googleapis.com/auth/spanner.admin",
31            Scope::Data => "https://www.googleapis.com/auth/spanner.data",
32        }
33    }
34}
35
36#[allow(clippy::derivable_impls)]
37impl Default for Scope {
38    fn default() -> Scope {
39        Scope::Data
40    }
41}
42
43// ########
44// HUB ###
45// ######
46
47/// Central instance to access all Spanner related resource activities
48///
49/// # Examples
50///
51/// Instantiate a new hub
52///
53/// ```test_harness,no_run
54/// extern crate hyper;
55/// extern crate hyper_rustls;
56/// extern crate google_spanner1 as spanner1;
57/// use spanner1::api::Backup;
58/// use spanner1::{Result, Error};
59/// # async fn dox() {
60/// use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
61///
62/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
63/// // `client_secret`, among other things.
64/// let secret: yup_oauth2::ApplicationSecret = Default::default();
65/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
66/// // unless you replace  `None` with the desired Flow.
67/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
68/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
69/// // retrieve them from storage.
70/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
71///     .with_native_roots()
72///     .unwrap()
73///     .https_only()
74///     .enable_http2()
75///     .build();
76///
77/// let executor = hyper_util::rt::TokioExecutor::new();
78/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
79///     secret,
80///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
81///     yup_oauth2::client::CustomHyperClientBuilder::from(
82///         hyper_util::client::legacy::Client::builder(executor).build(connector),
83///     ),
84/// ).build().await.unwrap();
85///
86/// let client = hyper_util::client::legacy::Client::builder(
87///     hyper_util::rt::TokioExecutor::new()
88/// )
89/// .build(
90///     hyper_rustls::HttpsConnectorBuilder::new()
91///         .with_native_roots()
92///         .unwrap()
93///         .https_or_http()
94///         .enable_http2()
95///         .build()
96/// );
97/// let mut hub = Spanner::new(client, auth);
98/// // As the method needs a request, you would usually fill it with the desired information
99/// // into the respective structure. Some of the parts shown here might not be applicable !
100/// // Values shown here are possibly random and not representative !
101/// let mut req = Backup::default();
102///
103/// // You can configure optional parameters by calling the respective setters at will, and
104/// // execute the final call using `doit()`.
105/// // Values shown here are possibly random and not representative !
106/// let result = hub.projects().instances_backups_create(req, "parent")
107///              .add_encryption_config_kms_key_names("duo")
108///              .encryption_config_kms_key_name("ipsum")
109///              .encryption_config_encryption_type("gubergren")
110///              .backup_id("Lorem")
111///              .doit().await;
112///
113/// match result {
114///     Err(e) => match e {
115///         // The Error enum provides details about what exactly happened.
116///         // You can also just use its `Debug`, `Display` or `Error` traits
117///          Error::HttpError(_)
118///         |Error::Io(_)
119///         |Error::MissingAPIKey
120///         |Error::MissingToken(_)
121///         |Error::Cancelled
122///         |Error::UploadSizeLimitExceeded(_, _)
123///         |Error::Failure(_)
124///         |Error::BadRequest(_)
125///         |Error::FieldClash(_)
126///         |Error::JsonDecodeError(_, _) => println!("{}", e),
127///     },
128///     Ok(res) => println!("Success: {:?}", res),
129/// }
130/// # }
131/// ```
132#[derive(Clone)]
133pub struct Spanner<C> {
134    pub client: common::Client<C>,
135    pub auth: Box<dyn common::GetToken>,
136    _user_agent: String,
137    _base_url: String,
138    _root_url: String,
139}
140
141impl<C> common::Hub for Spanner<C> {}
142
143impl<'a, C> Spanner<C> {
144    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Spanner<C> {
145        Spanner {
146            client,
147            auth: Box::new(auth),
148            _user_agent: "google-api-rust-client/7.0.0".to_string(),
149            _base_url: "https://spanner.googleapis.com/".to_string(),
150            _root_url: "https://spanner.googleapis.com/".to_string(),
151        }
152    }
153
154    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
155        ProjectMethods { hub: self }
156    }
157    pub fn scans(&'a self) -> ScanMethods<'a, C> {
158        ScanMethods { hub: self }
159    }
160
161    /// Set the user-agent header field to use in all requests to the server.
162    /// It defaults to `google-api-rust-client/7.0.0`.
163    ///
164    /// Returns the previously set user-agent.
165    pub fn user_agent(&mut self, agent_name: String) -> String {
166        std::mem::replace(&mut self._user_agent, agent_name)
167    }
168
169    /// Set the base url to use in all requests to the server.
170    /// It defaults to `https://spanner.googleapis.com/`.
171    ///
172    /// Returns the previously set base url.
173    pub fn base_url(&mut self, new_base_url: String) -> String {
174        std::mem::replace(&mut self._base_url, new_base_url)
175    }
176
177    /// Set the root url to use in all requests to the server.
178    /// It defaults to `https://spanner.googleapis.com/`.
179    ///
180    /// Returns the previously set root url.
181    pub fn root_url(&mut self, new_root_url: String) -> String {
182        std::mem::replace(&mut self._root_url, new_root_url)
183    }
184}
185
186// ############
187// SCHEMAS ###
188// ##########
189/// Arguments to ack operations.
190///
191/// This type is not used in any activity, and only used as *part* of another schema.
192///
193#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
194#[serde_with::serde_as]
195#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
196pub struct Ack {
197    /// By default, an attempt to ack a message that does not exist will fail with a `NOT_FOUND` error. With `ignore_not_found` set to true, the ack will succeed even if the message does not exist. This is useful for unconditionally acking a message, even if it is missing or has already been acked.
198    #[serde(rename = "ignoreNotFound")]
199    pub ignore_not_found: Option<bool>,
200    /// Required. The primary key of the message to be acked.
201    pub key: Option<Vec<serde_json::Value>>,
202    /// Required. The queue where the message to be acked is stored.
203    pub queue: Option<String>,
204}
205
206impl common::Part for Ack {}
207
208/// Message sent by the client to the adapter.
209///
210/// # Activities
211///
212/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
213/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
214///
215/// * [instances databases sessions adapt message projects](ProjectInstanceDatabaseSessionAdaptMessageCall) (request)
216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
217#[serde_with::serde_as]
218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
219pub struct AdaptMessageRequest {
220    /// Optional. Opaque request state passed by the client to the server.
221    pub attachments: Option<HashMap<String, String>>,
222    /// Optional. Uninterpreted bytes from the underlying wire protocol.
223    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
224    pub payload: Option<Vec<u8>>,
225    /// Required. Identifier for the underlying wire protocol.
226    pub protocol: Option<String>,
227}
228
229impl common::RequestValue for AdaptMessageRequest {}
230
231/// Message sent by the adapter to the client.
232///
233/// # Activities
234///
235/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
236/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
237///
238/// * [instances databases sessions adapt message projects](ProjectInstanceDatabaseSessionAdaptMessageCall) (response)
239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
240#[serde_with::serde_as]
241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
242pub struct AdaptMessageResponse {
243    /// Optional. Indicates whether this is the last AdaptMessageResponse in the stream. This field may be optionally set by the server. Clients should not rely on this field being set in all cases.
244    pub last: Option<bool>,
245    /// Optional. Uninterpreted bytes from the underlying wire protocol.
246    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
247    pub payload: Option<Vec<u8>>,
248    /// Optional. Opaque state updates to be applied by the client.
249    #[serde(rename = "stateUpdates")]
250    pub state_updates: Option<HashMap<String, String>>,
251}
252
253impl common::ResponseResult for AdaptMessageResponse {}
254
255/// A session in the Cloud Spanner Adapter API.
256///
257/// # Activities
258///
259/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
260/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
261///
262/// * [instances databases sessions adapter projects](ProjectInstanceDatabaseSessionAdapterCall) (request|response)
263#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
264#[serde_with::serde_as]
265#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
266pub struct AdapterSession {
267    /// Identifier. The name of the session. This is always system-assigned.
268    pub name: Option<String>,
269}
270
271impl common::RequestValue for AdapterSession {}
272impl common::ResponseResult for AdapterSession {}
273
274/// The request for AddSplitPoints.
275///
276/// # Activities
277///
278/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
279/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
280///
281/// * [instances databases add split points projects](ProjectInstanceDatabaseAddSplitPointCall) (request)
282#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
283#[serde_with::serde_as]
284#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
285pub struct AddSplitPointsRequest {
286    /// Optional. A user-supplied tag associated with the split points. For example, "initial_data_load", "special_event_1". Defaults to "CloudAddSplitPointsAPI" if not specified. The length of the tag must not exceed 50 characters, or else it is trimmed. Only valid UTF8 characters are allowed.
287    pub initiator: Option<String>,
288    /// Required. The split points to add.
289    #[serde(rename = "splitPoints")]
290    pub split_points: Option<Vec<SplitPoints>>,
291}
292
293impl common::RequestValue for AddSplitPointsRequest {}
294
295/// The response for AddSplitPoints.
296///
297/// # Activities
298///
299/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
300/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
301///
302/// * [instances databases add split points projects](ProjectInstanceDatabaseAddSplitPointCall) (response)
303#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
304#[serde_with::serde_as]
305#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
306pub struct AddSplitPointsResponse {
307    _never_set: Option<bool>,
308}
309
310impl common::ResponseResult for AddSplitPointsResponse {}
311
312/// AsymmetricAutoscalingOption specifies the scaling of replicas identified by the given selection.
313///
314/// This type is not used in any activity, and only used as *part* of another schema.
315///
316#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
317#[serde_with::serde_as]
318#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
319pub struct AsymmetricAutoscalingOption {
320    /// Optional. Overrides applied to the top-level autoscaling configuration for the selected replicas.
321    pub overrides: Option<AutoscalingConfigOverrides>,
322    /// Required. Selects the replicas to which this AsymmetricAutoscalingOption applies. Only read-only replicas are supported.
323    #[serde(rename = "replicaSelection")]
324    pub replica_selection: Option<InstanceReplicaSelection>,
325}
326
327impl common::Part for AsymmetricAutoscalingOption {}
328
329/// Autoscaling configuration for an instance.
330///
331/// This type is not used in any activity, and only used as *part* of another schema.
332///
333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
334#[serde_with::serde_as]
335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
336pub struct AutoscalingConfig {
337    /// Optional. Optional asymmetric autoscaling options. Replicas matching the replica selection criteria will be autoscaled independently from other replicas. The autoscaler will scale the replicas based on the utilization of replicas identified by the replica selection. Replica selections should not overlap with each other. Other replicas (those do not match any replica selection) will be autoscaled together and will have the same compute capacity allocated to them.
338    #[serde(rename = "asymmetricAutoscalingOptions")]
339    pub asymmetric_autoscaling_options: Option<Vec<AsymmetricAutoscalingOption>>,
340    /// Required. Autoscaling limits for an instance.
341    #[serde(rename = "autoscalingLimits")]
342    pub autoscaling_limits: Option<AutoscalingLimits>,
343    /// Required. The autoscaling targets for an instance.
344    #[serde(rename = "autoscalingTargets")]
345    pub autoscaling_targets: Option<AutoscalingTargets>,
346}
347
348impl common::Part for AutoscalingConfig {}
349
350/// Overrides the top-level autoscaling configuration for the replicas identified by `replica_selection`. All fields in this message are optional. Any unspecified fields will use the corresponding values from the top-level autoscaling configuration.
351///
352/// This type is not used in any activity, and only used as *part* of another schema.
353///
354#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
355#[serde_with::serde_as]
356#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
357pub struct AutoscalingConfigOverrides {
358    /// Optional. If specified, overrides the min/max limit in the top-level autoscaling configuration for the selected replicas.
359    #[serde(rename = "autoscalingLimits")]
360    pub autoscaling_limits: Option<AutoscalingLimits>,
361    /// Optional. If specified, overrides the autoscaling target high_priority_cpu_utilization_percent in the top-level autoscaling configuration for the selected replicas.
362    #[serde(rename = "autoscalingTargetHighPriorityCpuUtilizationPercent")]
363    pub autoscaling_target_high_priority_cpu_utilization_percent: Option<i32>,
364}
365
366impl common::Part for AutoscalingConfigOverrides {}
367
368/// The autoscaling limits for the instance. Users can define the minimum and maximum compute capacity allocated to the instance, and the autoscaler will only scale within that range. Users can either use nodes or processing units to specify the limits, but should use the same unit to set both the min_limit and max_limit.
369///
370/// This type is not used in any activity, and only used as *part* of another schema.
371///
372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
373#[serde_with::serde_as]
374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
375pub struct AutoscalingLimits {
376    /// Maximum number of nodes allocated to the instance. If set, this number should be greater than or equal to min_nodes.
377    #[serde(rename = "maxNodes")]
378    pub max_nodes: Option<i32>,
379    /// Maximum number of processing units allocated to the instance. If set, this number should be multiples of 1000 and be greater than or equal to min_processing_units.
380    #[serde(rename = "maxProcessingUnits")]
381    pub max_processing_units: Option<i32>,
382    /// Minimum number of nodes allocated to the instance. If set, this number should be greater than or equal to 1.
383    #[serde(rename = "minNodes")]
384    pub min_nodes: Option<i32>,
385    /// Minimum number of processing units allocated to the instance. If set, this number should be multiples of 1000.
386    #[serde(rename = "minProcessingUnits")]
387    pub min_processing_units: Option<i32>,
388}
389
390impl common::Part for AutoscalingLimits {}
391
392/// The autoscaling targets for an instance.
393///
394/// This type is not used in any activity, and only used as *part* of another schema.
395///
396#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
397#[serde_with::serde_as]
398#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
399pub struct AutoscalingTargets {
400    /// Required. The target high priority cpu utilization percentage that the autoscaler should be trying to achieve for the instance. This number is on a scale from 0 (no utilization) to 100 (full utilization). The valid range is [10, 90] inclusive.
401    #[serde(rename = "highPriorityCpuUtilizationPercent")]
402    pub high_priority_cpu_utilization_percent: Option<i32>,
403    /// Required. The target storage utilization percentage that the autoscaler should be trying to achieve for the instance. This number is on a scale from 0 (no utilization) to 100 (full utilization). The valid range is [10, 99] inclusive.
404    #[serde(rename = "storageUtilizationPercent")]
405    pub storage_utilization_percent: Option<i32>,
406}
407
408impl common::Part for AutoscalingTargets {}
409
410/// A backup of a Cloud Spanner database.
411///
412/// # Activities
413///
414/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
415/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
416///
417/// * [instances backups create projects](ProjectInstanceBackupCreateCall) (request)
418/// * [instances backups get projects](ProjectInstanceBackupGetCall) (response)
419/// * [instances backups patch projects](ProjectInstanceBackupPatchCall) (request|response)
420#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
421#[serde_with::serde_as]
422#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
423pub struct Backup {
424    /// Output only. List of backup schedule URIs that are associated with creating this backup. This is only applicable for scheduled backups, and is empty for on-demand backups. To optimize for storage, whenever possible, multiple schedules are collapsed together to create one backup. In such cases, this field captures the list of all backup schedule URIs that are associated with creating this backup. If collapsing is not done, then this field captures the single backup schedule URI associated with creating this backup.
425    #[serde(rename = "backupSchedules")]
426    pub backup_schedules: Option<Vec<String>>,
427    /// Output only. The time the CreateBackup request is received. If the request does not specify `version_time`, the `version_time` of the backup will be equivalent to the `create_time`.
428    #[serde(rename = "createTime")]
429    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
430    /// Required for the CreateBackup operation. Name of the database from which this backup was created. This needs to be in the same instance as the backup. Values are of the form `projects//instances//databases/`.
431    pub database: Option<String>,
432    /// Output only. The database dialect information for the backup.
433    #[serde(rename = "databaseDialect")]
434    pub database_dialect: Option<String>,
435    /// Output only. The encryption information for the backup.
436    #[serde(rename = "encryptionInfo")]
437    pub encryption_info: Option<EncryptionInfo>,
438    /// Output only. The encryption information for the backup, whether it is protected by one or more KMS keys. The information includes all Cloud KMS key versions used to encrypt the backup. The `encryption_status` field inside of each `EncryptionInfo` is not populated. At least one of the key versions must be available for the backup to be restored. If a key version is revoked in the middle of a restore, the restore behavior is undefined.
439    #[serde(rename = "encryptionInformation")]
440    pub encryption_information: Option<Vec<EncryptionInfo>>,
441    /// Output only. For a backup in an incremental backup chain, this is the storage space needed to keep the data that has changed since the previous backup. For all other backups, this is always the size of the backup. This value may change if backups on the same chain get deleted or expired. This field can be used to calculate the total storage space used by a set of backups. For example, the total space used by all backups of a database can be computed by summing up this field.
442    #[serde(rename = "exclusiveSizeBytes")]
443    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
444    pub exclusive_size_bytes: Option<i64>,
445    /// Required for the CreateBackup operation. The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 366 days from the time the CreateBackup request is processed. Once the `expire_time` has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.
446    #[serde(rename = "expireTime")]
447    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
448    /// Output only. The number of bytes that will be freed by deleting this backup. This value will be zero if, for example, this backup is part of an incremental backup chain and younger backups in the chain require that we keep its data. For backups not in an incremental backup chain, this is always the size of the backup. This value may change if backups on the same chain get created, deleted or expired.
449    #[serde(rename = "freeableSizeBytes")]
450    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
451    pub freeable_size_bytes: Option<i64>,
452    /// Output only. Populated only for backups in an incremental backup chain. Backups share the same chain id if and only if they belong to the same incremental backup chain. Use this field to determine which backups are part of the same incremental backup chain. The ordering of backups in the chain can be determined by ordering the backup `version_time`.
453    #[serde(rename = "incrementalBackupChainId")]
454    pub incremental_backup_chain_id: Option<String>,
455    /// Output only. The instance partition storing the backup. This is the same as the list of the instance partitions that the database recorded at the backup's `version_time`.
456    #[serde(rename = "instancePartitions")]
457    pub instance_partitions: Option<Vec<BackupInstancePartition>>,
458    /// Output only. The max allowed expiration time of the backup, with microseconds granularity. A backup's expiration time can be configured in multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or copying an existing backup, the expiration time specified must be less than `Backup.max_expire_time`.
459    #[serde(rename = "maxExpireTime")]
460    pub max_expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
461    /// Output only for the CreateBackup operation. Required for the UpdateBackup operation. A globally unique identifier for the backup which cannot be changed. Values are of the form `projects//instances//backups/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length. The backup is stored in the location(s) specified in the instance configuration of the instance containing the backup, identified by the prefix of the backup name of the form `projects//instances/`.
462    pub name: Option<String>,
463    /// Output only. Data deleted at a time older than this is guaranteed not to be retained in order to support this backup. For a backup in an incremental backup chain, this is the version time of the oldest backup that exists or ever existed in the chain. For all other backups, this is the version time of the backup. This field can be used to understand what data is being retained by the backup system.
464    #[serde(rename = "oldestVersionTime")]
465    pub oldest_version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
466    /// Output only. The names of the destination backups being created by copying this source backup. The backup names are of the form `projects//instances//backups/`. Referencing backups may exist in different instances. The existence of any referencing backup prevents the backup from being deleted. When the copy operation is done (either successfully completed or cancelled or the destination backup is deleted), the reference to the backup is removed.
467    #[serde(rename = "referencingBackups")]
468    pub referencing_backups: Option<Vec<String>>,
469    /// Output only. The names of the restored databases that reference the backup. The database names are of the form `projects//instances//databases/`. Referencing databases may exist in different instances. The existence of any referencing database prevents the backup from being deleted. When a restored database from the backup enters the `READY` state, the reference to the backup is removed.
470    #[serde(rename = "referencingDatabases")]
471    pub referencing_databases: Option<Vec<String>>,
472    /// Output only. Size of the backup in bytes. For a backup in an incremental backup chain, this is the sum of the `exclusive_size_bytes` of itself and all older backups in the chain.
473    #[serde(rename = "sizeBytes")]
474    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
475    pub size_bytes: Option<i64>,
476    /// Output only. The current state of the backup.
477    pub state: Option<String>,
478    /// The backup will contain an externally consistent copy of the database at the timestamp specified by `version_time`. If `version_time` is not specified, the system will set `version_time` to the `create_time` of the backup.
479    #[serde(rename = "versionTime")]
480    pub version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
481}
482
483impl common::RequestValue for Backup {}
484impl common::ResponseResult for Backup {}
485
486/// Information about a backup.
487///
488/// This type is not used in any activity, and only used as *part* of another schema.
489///
490#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
491#[serde_with::serde_as]
492#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
493pub struct BackupInfo {
494    /// Name of the backup.
495    pub backup: Option<String>,
496    /// The time the CreateBackup request was received.
497    #[serde(rename = "createTime")]
498    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
499    /// Name of the database the backup was created from.
500    #[serde(rename = "sourceDatabase")]
501    pub source_database: Option<String>,
502    /// The backup contains an externally consistent copy of `source_database` at the timestamp specified by `version_time`. If the CreateBackup request did not specify `version_time`, the `version_time` of the backup is equivalent to the `create_time`.
503    #[serde(rename = "versionTime")]
504    pub version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
505}
506
507impl common::Part for BackupInfo {}
508
509/// Instance partition information for the backup.
510///
511/// This type is not used in any activity, and only used as *part* of another schema.
512///
513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
514#[serde_with::serde_as]
515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
516pub struct BackupInstancePartition {
517    /// A unique identifier for the instance partition. Values are of the form `projects//instances//instancePartitions/`
518    #[serde(rename = "instancePartition")]
519    pub instance_partition: Option<String>,
520}
521
522impl common::Part for BackupInstancePartition {}
523
524/// BackupSchedule expresses the automated backup creation specification for a Spanner database.
525///
526/// # Activities
527///
528/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
529/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
530///
531/// * [instances databases backup schedules create projects](ProjectInstanceDatabaseBackupScheduleCreateCall) (request|response)
532/// * [instances databases backup schedules get projects](ProjectInstanceDatabaseBackupScheduleGetCall) (response)
533/// * [instances databases backup schedules patch projects](ProjectInstanceDatabaseBackupSchedulePatchCall) (request|response)
534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
535#[serde_with::serde_as]
536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
537pub struct BackupSchedule {
538    /// Optional. The encryption configuration that is used to encrypt the backup. If this field is not specified, the backup uses the same encryption configuration as the database.
539    #[serde(rename = "encryptionConfig")]
540    pub encryption_config: Option<CreateBackupEncryptionConfig>,
541    /// The schedule creates only full backups.
542    #[serde(rename = "fullBackupSpec")]
543    pub full_backup_spec: Option<FullBackupSpec>,
544    /// The schedule creates incremental backup chains.
545    #[serde(rename = "incrementalBackupSpec")]
546    pub incremental_backup_spec: Option<IncrementalBackupSpec>,
547    /// Identifier. Output only for the CreateBackupSchedule operation. Required for the UpdateBackupSchedule operation. A globally unique identifier for the backup schedule which cannot be changed. Values are of the form `projects//instances//databases//backupSchedules/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length.
548    pub name: Option<String>,
549    /// Optional. The retention duration of a backup that must be at least 6 hours and at most 366 days. The backup is eligible to be automatically deleted once the retention period has elapsed.
550    #[serde(rename = "retentionDuration")]
551    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
552    pub retention_duration: Option<chrono::Duration>,
553    /// Optional. The schedule specification based on which the backup creations are triggered.
554    pub spec: Option<BackupScheduleSpec>,
555    /// Output only. The timestamp at which the schedule was last updated. If the schedule has never been updated, this field contains the timestamp when the schedule was first created.
556    #[serde(rename = "updateTime")]
557    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
558}
559
560impl common::RequestValue for BackupSchedule {}
561impl common::ResponseResult for BackupSchedule {}
562
563/// Defines specifications of the backup schedule.
564///
565/// This type is not used in any activity, and only used as *part* of another schema.
566///
567#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
568#[serde_with::serde_as]
569#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
570pub struct BackupScheduleSpec {
571    /// Cron style schedule specification.
572    #[serde(rename = "cronSpec")]
573    pub cron_spec: Option<CrontabSpec>,
574}
575
576impl common::Part for BackupScheduleSpec {}
577
578/// The request for BatchCreateSessions.
579///
580/// # Activities
581///
582/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
583/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
584///
585/// * [instances databases sessions batch create projects](ProjectInstanceDatabaseSessionBatchCreateCall) (request)
586#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
587#[serde_with::serde_as]
588#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
589pub struct BatchCreateSessionsRequest {
590    /// Required. The number of sessions to be created in this batch call. At least one session is created. The API can return fewer than the requested number of sessions. If a specific number of sessions are desired, the client can make additional calls to `BatchCreateSessions` (adjusting session_count as necessary).
591    #[serde(rename = "sessionCount")]
592    pub session_count: Option<i32>,
593    /// Parameters to apply to each created session.
594    #[serde(rename = "sessionTemplate")]
595    pub session_template: Option<Session>,
596}
597
598impl common::RequestValue for BatchCreateSessionsRequest {}
599
600/// The response for BatchCreateSessions.
601///
602/// # Activities
603///
604/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
605/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
606///
607/// * [instances databases sessions batch create projects](ProjectInstanceDatabaseSessionBatchCreateCall) (response)
608#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
609#[serde_with::serde_as]
610#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
611pub struct BatchCreateSessionsResponse {
612    /// The freshly created sessions.
613    pub session: Option<Vec<Session>>,
614}
615
616impl common::ResponseResult for BatchCreateSessionsResponse {}
617
618/// The request for BatchWrite.
619///
620/// # Activities
621///
622/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
623/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
624///
625/// * [instances databases sessions batch write projects](ProjectInstanceDatabaseSessionBatchWriteCall) (request)
626#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
627#[serde_with::serde_as]
628#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
629pub struct BatchWriteRequest {
630    /// Optional. If you don't set the `exclude_txn_from_change_streams` option or if it's set to `false`, then any change streams monitoring columns modified by transactions will capture the updates made within that transaction.
631    #[serde(rename = "excludeTxnFromChangeStreams")]
632    pub exclude_txn_from_change_streams: Option<bool>,
633    /// Required. The groups of mutations to be applied.
634    #[serde(rename = "mutationGroups")]
635    pub mutation_groups: Option<Vec<MutationGroup>>,
636    /// Common options for this request.
637    #[serde(rename = "requestOptions")]
638    pub request_options: Option<RequestOptions>,
639}
640
641impl common::RequestValue for BatchWriteRequest {}
642
643/// The result of applying a batch of mutations.
644///
645/// # Activities
646///
647/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
648/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
649///
650/// * [instances databases sessions batch write projects](ProjectInstanceDatabaseSessionBatchWriteCall) (response)
651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
652#[serde_with::serde_as]
653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
654pub struct BatchWriteResponse {
655    /// The commit timestamp of the transaction that applied this batch. Present if `status` is `OK`, absent otherwise.
656    #[serde(rename = "commitTimestamp")]
657    pub commit_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
658    /// The mutation groups applied in this batch. The values index into the `mutation_groups` field in the corresponding `BatchWriteRequest`.
659    pub indexes: Option<Vec<i32>>,
660    /// An `OK` status indicates success. Any other status indicates a failure.
661    pub status: Option<Status>,
662}
663
664impl common::ResponseResult for BatchWriteResponse {}
665
666/// The request for BeginTransaction.
667///
668/// # Activities
669///
670/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
671/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
672///
673/// * [instances databases sessions begin transaction projects](ProjectInstanceDatabaseSessionBeginTransactionCall) (request)
674#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
675#[serde_with::serde_as]
676#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
677pub struct BeginTransactionRequest {
678    /// Optional. Required for read-write transactions on a multiplexed session that commit mutations but don't perform any reads or queries. You must randomly select one of the mutations from the mutation set and send it as a part of this request.
679    #[serde(rename = "mutationKey")]
680    pub mutation_key: Option<Mutation>,
681    /// Required. Options for the new transaction.
682    pub options: Option<TransactionOptions>,
683    /// Common options for this request. Priority is ignored for this request. Setting the priority in this `request_options` struct doesn't do anything. To set the priority for a transaction, set it on the reads and writes that are part of this transaction instead.
684    #[serde(rename = "requestOptions")]
685    pub request_options: Option<RequestOptions>,
686}
687
688impl common::RequestValue for BeginTransactionRequest {}
689
690/// Associates `members`, or principals, with a `role`.
691///
692/// This type is not used in any activity, and only used as *part* of another schema.
693///
694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
695#[serde_with::serde_as]
696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
697pub struct Binding {
698    /// 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).
699    pub condition: Option<Expr>,
700    /// 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`.
701    pub members: Option<Vec<String>>,
702    /// 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).
703    pub role: Option<String>,
704}
705
706impl common::Part for Binding {}
707
708/// The request for ChangeQuorum.
709///
710/// # Activities
711///
712/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
713/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
714///
715/// * [instances databases changequorum projects](ProjectInstanceDatabaseChangequorumCall) (request)
716#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
717#[serde_with::serde_as]
718#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
719pub struct ChangeQuorumRequest {
720    /// Optional. The etag is the hash of the `QuorumInfo`. The `ChangeQuorum` operation is only performed if the etag matches that of the `QuorumInfo` in the current database resource. Otherwise the API returns an `ABORTED` error. The etag is used for optimistic concurrency control as a way to help prevent simultaneous change quorum requests that could create a race condition.
721    pub etag: Option<String>,
722    /// Required. Name of the database in which to apply `ChangeQuorum`. Values are of the form `projects//instances//databases/`.
723    pub name: Option<String>,
724    /// Required. The type of this quorum.
725    #[serde(rename = "quorumType")]
726    pub quorum_type: Option<QuorumType>,
727}
728
729impl common::RequestValue for ChangeQuorumRequest {}
730
731/// Metadata associated with a parent-child relationship appearing in a PlanNode.
732///
733/// This type is not used in any activity, and only used as *part* of another schema.
734///
735#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
736#[serde_with::serde_as]
737#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
738pub struct ChildLink {
739    /// The node to which the link points.
740    #[serde(rename = "childIndex")]
741    pub child_index: Option<i32>,
742    /// The type of the link. For example, in Hash Joins this could be used to distinguish between the build child and the probe child, or in the case of the child being an output variable, to represent the tag associated with the output variable.
743    #[serde(rename = "type")]
744    pub type_: Option<String>,
745    /// Only present if the child node is SCALAR and corresponds to an output variable of the parent node. The field carries the name of the output variable. For example, a `TableScan` operator that reads rows from a table will have child links to the `SCALAR` nodes representing the output variables created for each column that is read by the operator. The corresponding `variable` fields will be set to the variable names assigned to the columns.
746    pub variable: Option<String>,
747}
748
749impl common::Part for ChildLink {}
750
751/// The request for Commit.
752///
753/// # Activities
754///
755/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
756/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
757///
758/// * [instances databases sessions commit projects](ProjectInstanceDatabaseSessionCommitCall) (request)
759#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
760#[serde_with::serde_as]
761#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
762pub struct CommitRequest {
763    /// Optional. The amount of latency this request is configured to incur in order to improve throughput. If this field isn't set, Spanner assumes requests are relatively latency sensitive and automatically determines an appropriate delay time. You can specify a commit delay value between 0 and 500 ms.
764    #[serde(rename = "maxCommitDelay")]
765    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
766    pub max_commit_delay: Option<chrono::Duration>,
767    /// The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.
768    pub mutations: Option<Vec<Mutation>>,
769    /// Optional. If the read-write transaction was executed on a multiplexed session, then you must include the precommit token with the highest sequence number received in this transaction attempt. Failing to do so results in a `FailedPrecondition` error.
770    #[serde(rename = "precommitToken")]
771    pub precommit_token: Option<MultiplexedSessionPrecommitToken>,
772    /// Common options for this request.
773    #[serde(rename = "requestOptions")]
774    pub request_options: Option<RequestOptions>,
775    /// If `true`, then statistics related to the transaction is included in the CommitResponse. Default value is `false`.
776    #[serde(rename = "returnCommitStats")]
777    pub return_commit_stats: Option<bool>,
778    /// Execute mutations in a temporary transaction. Note that unlike commit of a previously-started transaction, commit with a temporary transaction is non-idempotent. That is, if the `CommitRequest` is sent to Cloud Spanner more than once (for instance, due to retries in the application, or in the transport library), it's possible that the mutations are executed more than once. If this is undesirable, use BeginTransaction and Commit instead.
779    #[serde(rename = "singleUseTransaction")]
780    pub single_use_transaction: Option<TransactionOptions>,
781    /// Commit a previously-started transaction.
782    #[serde(rename = "transactionId")]
783    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
784    pub transaction_id: Option<Vec<u8>>,
785}
786
787impl common::RequestValue for CommitRequest {}
788
789/// The response for Commit.
790///
791/// # Activities
792///
793/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
794/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
795///
796/// * [instances databases sessions commit projects](ProjectInstanceDatabaseSessionCommitCall) (response)
797#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
798#[serde_with::serde_as]
799#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
800pub struct CommitResponse {
801    /// The statistics about this `Commit`. Not returned by default. For more information, see CommitRequest.return_commit_stats.
802    #[serde(rename = "commitStats")]
803    pub commit_stats: Option<CommitStats>,
804    /// The Cloud Spanner timestamp at which the transaction committed.
805    #[serde(rename = "commitTimestamp")]
806    pub commit_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
807    /// If specified, transaction has not committed yet. You must retry the commit with the new precommit token.
808    #[serde(rename = "precommitToken")]
809    pub precommit_token: Option<MultiplexedSessionPrecommitToken>,
810    /// If `TransactionOptions.isolation_level` is set to `IsolationLevel.REPEATABLE_READ`, then the snapshot timestamp is the timestamp at which all reads in the transaction ran. This timestamp is never returned.
811    #[serde(rename = "snapshotTimestamp")]
812    pub snapshot_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
813}
814
815impl common::ResponseResult for CommitResponse {}
816
817/// Additional statistics about a commit.
818///
819/// This type is not used in any activity, and only used as *part* of another schema.
820///
821#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
822#[serde_with::serde_as]
823#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
824pub struct CommitStats {
825    /// The total number of mutations for the transaction. Knowing the `mutation_count` value can help you maximize the number of mutations in a transaction and minimize the number of API round trips. You can also monitor this value to prevent transactions from exceeding the system [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data). If the number of mutations exceeds the limit, the server returns [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT).
826    #[serde(rename = "mutationCount")]
827    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
828    pub mutation_count: Option<i64>,
829}
830
831impl common::Part for CommitStats {}
832
833/// A message representing context for a KeyRangeInfo, including a label, value, unit, and severity.
834///
835/// This type is not used in any activity, and only used as *part* of another schema.
836///
837#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
838#[serde_with::serde_as]
839#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
840pub struct ContextValue {
841    /// The label for the context value. e.g. "latency".
842    pub label: Option<LocalizedString>,
843    /// The severity of this context.
844    pub severity: Option<String>,
845    /// The unit of the context value.
846    pub unit: Option<String>,
847    /// The value for the context.
848    pub value: Option<f32>,
849}
850
851impl common::Part for ContextValue {}
852
853/// Encryption configuration for the copied backup.
854///
855/// This type is not used in any activity, and only used as *part* of another schema.
856///
857#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
858#[serde_with::serde_as]
859#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
860pub struct CopyBackupEncryptionConfig {
861    /// Required. The encryption type of the backup.
862    #[serde(rename = "encryptionType")]
863    pub encryption_type: Option<String>,
864    /// Optional. This field is maintained for backwards compatibility. For new callers, we recommend using `kms_key_names` to specify the KMS key. Only use `kms_key_name` if the location of the KMS key matches the database instance's configuration (location) exactly. For example, if the KMS location is in `us-central1` or `nam3`, then the database instance must also be in `us-central1` or `nam3`. The Cloud KMS key that is used to encrypt and decrypt the restored database. Set this field only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
865    #[serde(rename = "kmsKeyName")]
866    pub kms_key_name: Option<String>,
867    /// Optional. Specifies the KMS configuration for the one or more keys used to protect the backup. Values are of the form `projects//locations//keyRings//cryptoKeys/`. KMS keys specified can be in any order. The keys referenced by `kms_key_names` must fully cover all regions of the backup's instance configuration. Some examples: * For regional (single-region) instance configurations, specify a regional location KMS key. * For multi-region instance configurations of type `GOOGLE_MANAGED`, either specify a multi-region location KMS key or multiple regional location KMS keys that cover all regions in the instance configuration. * For an instance configuration of type `USER_MANAGED`, specify only regional location KMS keys to cover each region in the instance configuration. Multi-region location KMS keys aren't supported for `USER_MANAGED` type instance configurations.
868    #[serde(rename = "kmsKeyNames")]
869    pub kms_key_names: Option<Vec<String>>,
870}
871
872impl common::Part for CopyBackupEncryptionConfig {}
873
874/// The request for CopyBackup.
875///
876/// # Activities
877///
878/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
879/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
880///
881/// * [instances backups copy projects](ProjectInstanceBackupCopyCall) (request)
882#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
883#[serde_with::serde_as]
884#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
885pub struct CopyBackupRequest {
886    /// Required. The id of the backup copy. The `backup_id` appended to `parent` forms the full backup_uri of the form `projects//instances//backups/`.
887    #[serde(rename = "backupId")]
888    pub backup_id: Option<String>,
889    /// Optional. The encryption configuration used to encrypt the backup. If this field is not specified, the backup will use the same encryption configuration as the source backup by default, namely encryption_type = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
890    #[serde(rename = "encryptionConfig")]
891    pub encryption_config: Option<CopyBackupEncryptionConfig>,
892    /// Required. The expiration time of the backup in microsecond granularity. The expiration time must be at least 6 hours and at most 366 days from the `create_time` of the source backup. Once the `expire_time` has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.
893    #[serde(rename = "expireTime")]
894    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
895    /// Required. The source backup to be copied. The source backup needs to be in READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the form: `projects//instances//backups/`.
896    #[serde(rename = "sourceBackup")]
897    pub source_backup: Option<String>,
898}
899
900impl common::RequestValue for CopyBackupRequest {}
901
902/// Encryption configuration for the backup to create.
903///
904/// This type is not used in any activity, and only used as *part* of another schema.
905///
906#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
907#[serde_with::serde_as]
908#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
909pub struct CreateBackupEncryptionConfig {
910    /// Required. The encryption type of the backup.
911    #[serde(rename = "encryptionType")]
912    pub encryption_type: Option<String>,
913    /// Optional. This field is maintained for backwards compatibility. For new callers, we recommend using `kms_key_names` to specify the KMS key. Only use `kms_key_name` if the location of the KMS key matches the database instance's configuration (location) exactly. For example, if the KMS location is in `us-central1` or `nam3`, then the database instance must also be in `us-central1` or `nam3`. The Cloud KMS key that is used to encrypt and decrypt the restored database. Set this field only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
914    #[serde(rename = "kmsKeyName")]
915    pub kms_key_name: Option<String>,
916    /// Optional. Specifies the KMS configuration for the one or more keys used to protect the backup. Values are of the form `projects//locations//keyRings//cryptoKeys/`. The keys referenced by `kms_key_names` must fully cover all regions of the backup's instance configuration. Some examples: * For regional (single-region) instance configurations, specify a regional location KMS key. * For multi-region instance configurations of type `GOOGLE_MANAGED`, either specify a multi-region location KMS key or multiple regional location KMS keys that cover all regions in the instance configuration. * For an instance configuration of type `USER_MANAGED`, specify only regional location KMS keys to cover each region in the instance configuration. Multi-region location KMS keys aren't supported for `USER_MANAGED` type instance configurations.
917    #[serde(rename = "kmsKeyNames")]
918    pub kms_key_names: Option<Vec<String>>,
919}
920
921impl common::Part for CreateBackupEncryptionConfig {}
922
923/// The request for CreateDatabase.
924///
925/// # Activities
926///
927/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
928/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
929///
930/// * [instances databases create projects](ProjectInstanceDatabaseCreateCall) (request)
931#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
932#[serde_with::serde_as]
933#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
934pub struct CreateDatabaseRequest {
935    /// Required. A `CREATE DATABASE` statement, which specifies the ID of the new database. The database ID must conform to the regular expression `a-z*[a-z0-9]` and be between 2 and 30 characters in length. If the database ID is a reserved word or if it contains a hyphen, the database ID must be enclosed in backticks (`` ` ``).
936    #[serde(rename = "createStatement")]
937    pub create_statement: Option<String>,
938    /// Optional. The dialect of the Cloud Spanner Database.
939    #[serde(rename = "databaseDialect")]
940    pub database_dialect: Option<String>,
941    /// Optional. The encryption configuration for the database. If this field is not specified, Cloud Spanner will encrypt/decrypt all data at rest using Google default encryption.
942    #[serde(rename = "encryptionConfig")]
943    pub encryption_config: Option<EncryptionConfig>,
944    /// Optional. A list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.
945    #[serde(rename = "extraStatements")]
946    pub extra_statements: Option<Vec<String>>,
947    /// Optional. Proto descriptors used by `CREATE/ALTER PROTO BUNDLE` statements in 'extra_statements'. Contains a protobuf-serialized [`google.protobuf.FileDescriptorSet`](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto) descriptor set. To generate it, [install](https://grpc.io/docs/protoc-installation/) and run `protoc` with --include_imports and --descriptor_set_out. For example, to generate for moon/shot/app.proto, run ``` $protoc --proto_path=/app_path --proto_path=/lib_path \ --include_imports \ --descriptor_set_out=descriptors.data \ moon/shot/app.proto ``` For more details, see protobuffer [self description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
948    #[serde(rename = "protoDescriptors")]
949    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
950    pub proto_descriptors: Option<Vec<u8>>,
951}
952
953impl common::RequestValue for CreateDatabaseRequest {}
954
955/// The request for CreateInstanceConfig.
956///
957/// # Activities
958///
959/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
960/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
961///
962/// * [instance configs create projects](ProjectInstanceConfigCreateCall) (request)
963#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
964#[serde_with::serde_as]
965#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
966pub struct CreateInstanceConfigRequest {
967    /// Required. The `InstanceConfig` proto of the configuration to create. `instance_config.name` must be `/instanceConfigs/`. `instance_config.base_config` must be a Google-managed configuration name, e.g. /instanceConfigs/us-east1, /instanceConfigs/nam3.
968    #[serde(rename = "instanceConfig")]
969    pub instance_config: Option<InstanceConfig>,
970    /// Required. The ID of the instance configuration to create. Valid identifiers are of the form `custom-[-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in length. The `custom-` prefix is required to avoid name conflicts with Google-managed configurations.
971    #[serde(rename = "instanceConfigId")]
972    pub instance_config_id: Option<String>,
973    /// An option to validate, but not actually execute, a request, and provide the same response.
974    #[serde(rename = "validateOnly")]
975    pub validate_only: Option<bool>,
976}
977
978impl common::RequestValue for CreateInstanceConfigRequest {}
979
980/// The request for CreateInstancePartition.
981///
982/// # Activities
983///
984/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
985/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
986///
987/// * [instances instance partitions create projects](ProjectInstanceInstancePartitionCreateCall) (request)
988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
989#[serde_with::serde_as]
990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
991pub struct CreateInstancePartitionRequest {
992    /// Required. The instance partition to create. The instance_partition.name may be omitted, but if specified must be `/instancePartitions/`.
993    #[serde(rename = "instancePartition")]
994    pub instance_partition: Option<InstancePartition>,
995    /// Required. The ID of the instance partition to create. Valid identifiers are of the form `a-z*[a-z0-9]` and must be between 2 and 64 characters in length.
996    #[serde(rename = "instancePartitionId")]
997    pub instance_partition_id: Option<String>,
998}
999
1000impl common::RequestValue for CreateInstancePartitionRequest {}
1001
1002/// The request for CreateInstance.
1003///
1004/// # Activities
1005///
1006/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1007/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1008///
1009/// * [instances create projects](ProjectInstanceCreateCall) (request)
1010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1011#[serde_with::serde_as]
1012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1013pub struct CreateInstanceRequest {
1014    /// Required. The instance to create. The name may be omitted, but if specified must be `/instances/`.
1015    pub instance: Option<Instance>,
1016    /// Required. The ID of the instance to create. Valid identifiers are of the form `a-z*[a-z0-9]` and must be between 2 and 64 characters in length.
1017    #[serde(rename = "instanceId")]
1018    pub instance_id: Option<String>,
1019}
1020
1021impl common::RequestValue for CreateInstanceRequest {}
1022
1023/// The request for CreateSession.
1024///
1025/// # Activities
1026///
1027/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1028/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1029///
1030/// * [instances databases sessions create projects](ProjectInstanceDatabaseSessionCreateCall) (request)
1031#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1032#[serde_with::serde_as]
1033#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1034pub struct CreateSessionRequest {
1035    /// Required. The session to create.
1036    pub session: Option<Session>,
1037}
1038
1039impl common::RequestValue for CreateSessionRequest {}
1040
1041/// CrontabSpec can be used to specify the version time and frequency at which the backup is created.
1042///
1043/// This type is not used in any activity, and only used as *part* of another schema.
1044///
1045#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1046#[serde_with::serde_as]
1047#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1048pub struct CrontabSpec {
1049    /// Output only. Scheduled backups contain an externally consistent copy of the database at the version time specified in `schedule_spec.cron_spec`. However, Spanner might not initiate the creation of the scheduled backups at that version time. Spanner initiates the creation of scheduled backups within the time window bounded by the version_time specified in `schedule_spec.cron_spec` and version_time + `creation_window`.
1050    #[serde(rename = "creationWindow")]
1051    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1052    pub creation_window: Option<chrono::Duration>,
1053    /// Required. Textual representation of the crontab. User can customize the backup frequency and the backup version time using the cron expression. The version time must be in UTC timezone. The backup will contain an externally consistent copy of the database at the version time. Full backups must be scheduled a minimum of 12 hours apart and incremental backups must be scheduled a minimum of 4 hours apart. Examples of valid cron specifications: * `0 2/12 * * *` : every 12 hours at (2, 14) hours past midnight in UTC. * `0 2,14 * * *` : every 12 hours at (2, 14) hours past midnight in UTC. * `0 */4 * * *` : (incremental backups only) every 4 hours at (0, 4, 8, 12, 16, 20) hours past midnight in UTC. * `0 2 * * *` : once a day at 2 past midnight in UTC. * `0 2 * * 0` : once a week every Sunday at 2 past midnight in UTC. * `0 2 8 * *` : once a month on 8th day at 2 past midnight in UTC.
1054    pub text: Option<String>,
1055    /// Output only. The time zone of the times in `CrontabSpec.text`. Currently, only UTC is supported.
1056    #[serde(rename = "timeZone")]
1057    pub time_zone: Option<String>,
1058}
1059
1060impl common::Part for CrontabSpec {}
1061
1062/// A Cloud Spanner database.
1063///
1064/// # Activities
1065///
1066/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1067/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1068///
1069/// * [instances databases get projects](ProjectInstanceDatabaseGetCall) (response)
1070/// * [instances databases patch projects](ProjectInstanceDatabasePatchCall) (request)
1071#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1072#[serde_with::serde_as]
1073#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1074pub struct Database {
1075    /// Output only. If exists, the time at which the database creation started.
1076    #[serde(rename = "createTime")]
1077    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1078    /// Output only. The dialect of the Cloud Spanner Database.
1079    #[serde(rename = "databaseDialect")]
1080    pub database_dialect: Option<String>,
1081    /// Output only. The read-write region which contains the database's leader replicas. This is the same as the value of default_leader database option set using DatabaseAdmin.CreateDatabase or DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.
1082    #[serde(rename = "defaultLeader")]
1083    pub default_leader: Option<String>,
1084    /// Output only. Earliest timestamp at which older versions of the data can be read. This value is continuously updated by Cloud Spanner and becomes stale the moment it is queried. If you are using this value to recover data, make sure to account for the time from the moment when the value is queried to the moment when you initiate the recovery.
1085    #[serde(rename = "earliestVersionTime")]
1086    pub earliest_version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1087    /// Optional. Whether drop protection is enabled for this database. Defaults to false, if not set. For more details, please see how to [prevent accidental database deletion](https://cloud.google.com/spanner/docs/prevent-database-deletion).
1088    #[serde(rename = "enableDropProtection")]
1089    pub enable_drop_protection: Option<bool>,
1090    /// Output only. For databases that are using customer managed encryption, this field contains the encryption configuration for the database. For databases that are using Google default or other types of encryption, this field is empty.
1091    #[serde(rename = "encryptionConfig")]
1092    pub encryption_config: Option<EncryptionConfig>,
1093    /// Output only. For databases that are using customer managed encryption, this field contains the encryption information for the database, such as all Cloud KMS key versions that are in use. The `encryption_status` field inside of each `EncryptionInfo` is not populated. For databases that are using Google default or other types of encryption, this field is empty. This field is propagated lazily from the backend. There might be a delay from when a key version is being used and when it appears in this field.
1094    #[serde(rename = "encryptionInfo")]
1095    pub encryption_info: Option<Vec<EncryptionInfo>>,
1096    /// Required. The name of the database. Values are of the form `projects//instances//databases/`, where `` is as specified in the `CREATE DATABASE` statement. This name can be passed to other API methods to identify the database.
1097    pub name: Option<String>,
1098    /// Output only. Applicable only for databases that use dual-region instance configurations. Contains information about the quorum.
1099    #[serde(rename = "quorumInfo")]
1100    pub quorum_info: Option<QuorumInfo>,
1101    /// Output only. If true, the database is being updated. If false, there are no ongoing update operations for the database.
1102    pub reconciling: Option<bool>,
1103    /// Output only. Applicable only for restored databases. Contains information about the restore source.
1104    #[serde(rename = "restoreInfo")]
1105    pub restore_info: Option<RestoreInfo>,
1106    /// Output only. The current database state.
1107    pub state: Option<String>,
1108    /// Output only. The period in which Cloud Spanner retains all versions of data for the database. This is the same as the value of version_retention_period database option set using UpdateDatabaseDdl. Defaults to 1 hour, if not set.
1109    #[serde(rename = "versionRetentionPeriod")]
1110    pub version_retention_period: Option<String>,
1111}
1112
1113impl common::RequestValue for Database {}
1114impl common::ResponseResult for Database {}
1115
1116/// The configuration for each database in the target instance configuration.
1117///
1118/// This type is not used in any activity, and only used as *part* of another schema.
1119///
1120#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1121#[serde_with::serde_as]
1122#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1123pub struct DatabaseMoveConfig {
1124    /// Required. The unique identifier of the database resource in the Instance. For example, if the database uri is `projects/foo/instances/bar/databases/baz`, then the id to supply here is baz.
1125    #[serde(rename = "databaseId")]
1126    pub database_id: Option<String>,
1127    /// Optional. Encryption configuration to be used for the database in the target configuration. The encryption configuration must be specified for every database which currently uses CMEK encryption. If a database currently uses Google-managed encryption and a target encryption configuration is not specified, then the database defaults to Google-managed encryption. If a database currently uses Google-managed encryption and a target CMEK encryption is specified, the request is rejected. If a database currently uses CMEK encryption, then a target encryption configuration must be specified. You can't move a CMEK database to a Google-managed encryption database using the MoveInstance API.
1128    #[serde(rename = "encryptionConfig")]
1129    pub encryption_config: Option<InstanceEncryptionConfig>,
1130}
1131
1132impl common::Part for DatabaseMoveConfig {}
1133
1134/// A Cloud Spanner database role.
1135///
1136/// This type is not used in any activity, and only used as *part* of another schema.
1137///
1138#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1139#[serde_with::serde_as]
1140#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1141pub struct DatabaseRole {
1142    /// Required. The name of the database role. Values are of the form `projects//instances//databases//databaseRoles/` where `` is as specified in the `CREATE ROLE` DDL statement.
1143    pub name: Option<String>,
1144}
1145
1146impl common::Part for DatabaseRole {}
1147
1148/// Arguments to delete operations.
1149///
1150/// This type is not used in any activity, and only used as *part* of another schema.
1151///
1152#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1153#[serde_with::serde_as]
1154#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1155pub struct Delete {
1156    /// Required. The primary keys of the rows within table to delete. The primary keys must be specified in the order in which they appear in the `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL statement used to create the table). Delete is idempotent. The transaction will succeed even if some or all rows do not exist.
1157    #[serde(rename = "keySet")]
1158    pub key_set: Option<KeySet>,
1159    /// Required. The table whose rows will be deleted.
1160    pub table: Option<String>,
1161}
1162
1163impl common::Part for Delete {}
1164
1165/// A message representing a derived metric.
1166///
1167/// This type is not used in any activity, and only used as *part* of another schema.
1168///
1169#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1170#[serde_with::serde_as]
1171#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1172pub struct DerivedMetric {
1173    /// The name of the denominator metric. e.g. "rows".
1174    pub denominator: Option<LocalizedString>,
1175    /// The name of the numerator metric. e.g. "latency".
1176    pub numerator: Option<LocalizedString>,
1177}
1178
1179impl common::Part for DerivedMetric {}
1180
1181/// A message representing the key visualizer diagnostic messages.
1182///
1183/// This type is not used in any activity, and only used as *part* of another schema.
1184///
1185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1186#[serde_with::serde_as]
1187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1188pub struct DiagnosticMessage {
1189    /// Information about this diagnostic information.
1190    pub info: Option<LocalizedString>,
1191    /// The metric.
1192    pub metric: Option<LocalizedString>,
1193    /// Whether this message is specific only for the current metric. By default Diagnostics are shown for all metrics, regardless which metric is the currently selected metric in the UI. However occasionally a metric will generate so many messages that the resulting visual clutter becomes overwhelming. In this case setting this to true, will show the diagnostic messages for that metric only if it is the currently selected metric.
1194    #[serde(rename = "metricSpecific")]
1195    pub metric_specific: Option<bool>,
1196    /// The severity of the diagnostic message.
1197    pub severity: Option<String>,
1198    /// The short message.
1199    #[serde(rename = "shortMessage")]
1200    pub short_message: Option<LocalizedString>,
1201}
1202
1203impl common::Part for DiagnosticMessage {}
1204
1205/// The `DirectedReadOptions` can be used to indicate which replicas or regions should be used for non-transactional reads or queries. `DirectedReadOptions` can only be specified for a read-only transaction, otherwise the API returns an `INVALID_ARGUMENT` error.
1206///
1207/// This type is not used in any activity, and only used as *part* of another schema.
1208///
1209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1210#[serde_with::serde_as]
1211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1212pub struct DirectedReadOptions {
1213    /// `Exclude_replicas` indicates that specified replicas should be excluded from serving requests. Spanner doesn't route requests to the replicas in this list.
1214    #[serde(rename = "excludeReplicas")]
1215    pub exclude_replicas: Option<ExcludeReplicas>,
1216    /// `Include_replicas` indicates the order of replicas (as they appear in this list) to process the request. If `auto_failover_disabled` is set to `true` and all replicas are exhausted without finding a healthy replica, Spanner waits for a replica in the list to become available, requests might fail due to `DEADLINE_EXCEEDED` errors.
1217    #[serde(rename = "includeReplicas")]
1218    pub include_replicas: Option<IncludeReplicas>,
1219}
1220
1221impl common::Part for DirectedReadOptions {}
1222
1223/// Message type for a dual-region quorum. Currently this type has no options.
1224///
1225/// This type is not used in any activity, and only used as *part* of another schema.
1226///
1227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1228#[serde_with::serde_as]
1229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1230pub struct DualRegionQuorum {
1231    _never_set: Option<bool>,
1232}
1233
1234impl common::Part for DualRegionQuorum {}
1235
1236/// 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); }
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/// * [instance configs operations cancel projects](ProjectInstanceConfigOperationCancelCall) (response)
1244/// * [instance configs operations delete projects](ProjectInstanceConfigOperationDeleteCall) (response)
1245/// * [instance configs ssd caches operations cancel projects](ProjectInstanceConfigSsdCachOperationCancelCall) (response)
1246/// * [instance configs ssd caches operations delete projects](ProjectInstanceConfigSsdCachOperationDeleteCall) (response)
1247/// * [instance configs delete projects](ProjectInstanceConfigDeleteCall) (response)
1248/// * [instances backups operations cancel projects](ProjectInstanceBackupOperationCancelCall) (response)
1249/// * [instances backups operations delete projects](ProjectInstanceBackupOperationDeleteCall) (response)
1250/// * [instances backups delete projects](ProjectInstanceBackupDeleteCall) (response)
1251/// * [instances databases backup schedules delete projects](ProjectInstanceDatabaseBackupScheduleDeleteCall) (response)
1252/// * [instances databases operations cancel projects](ProjectInstanceDatabaseOperationCancelCall) (response)
1253/// * [instances databases operations delete projects](ProjectInstanceDatabaseOperationDeleteCall) (response)
1254/// * [instances databases sessions delete projects](ProjectInstanceDatabaseSessionDeleteCall) (response)
1255/// * [instances databases sessions rollback projects](ProjectInstanceDatabaseSessionRollbackCall) (response)
1256/// * [instances databases drop database projects](ProjectInstanceDatabaseDropDatabaseCall) (response)
1257/// * [instances instance partitions operations cancel projects](ProjectInstanceInstancePartitionOperationCancelCall) (response)
1258/// * [instances instance partitions operations delete projects](ProjectInstanceInstancePartitionOperationDeleteCall) (response)
1259/// * [instances instance partitions delete projects](ProjectInstanceInstancePartitionDeleteCall) (response)
1260/// * [instances operations cancel projects](ProjectInstanceOperationCancelCall) (response)
1261/// * [instances operations delete projects](ProjectInstanceOperationDeleteCall) (response)
1262/// * [instances delete projects](ProjectInstanceDeleteCall) (response)
1263#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1264#[serde_with::serde_as]
1265#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1266pub struct Empty {
1267    _never_set: Option<bool>,
1268}
1269
1270impl common::ResponseResult for Empty {}
1271
1272/// Encryption configuration for a Cloud Spanner database.
1273///
1274/// This type is not used in any activity, and only used as *part* of another schema.
1275///
1276#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1277#[serde_with::serde_as]
1278#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1279pub struct EncryptionConfig {
1280    /// The Cloud KMS key to be used for encrypting and decrypting the database. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
1281    #[serde(rename = "kmsKeyName")]
1282    pub kms_key_name: Option<String>,
1283    /// Specifies the KMS configuration for one or more keys used to encrypt the database. Values are of the form `projects//locations//keyRings//cryptoKeys/`. The keys referenced by `kms_key_names` must fully cover all regions of the database's instance configuration. Some examples: * For regional (single-region) instance configurations, specify a regional location KMS key. * For multi-region instance configurations of type `GOOGLE_MANAGED`, either specify a multi-region location KMS key or multiple regional location KMS keys that cover all regions in the instance configuration. * For an instance configuration of type `USER_MANAGED`, specify only regional location KMS keys to cover each region in the instance configuration. Multi-region location KMS keys aren't supported for `USER_MANAGED` type instance configurations.
1284    #[serde(rename = "kmsKeyNames")]
1285    pub kms_key_names: Option<Vec<String>>,
1286}
1287
1288impl common::Part for EncryptionConfig {}
1289
1290/// Encryption information for a Cloud Spanner database or backup.
1291///
1292/// This type is not used in any activity, and only used as *part* of another schema.
1293///
1294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1295#[serde_with::serde_as]
1296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1297pub struct EncryptionInfo {
1298    /// Output only. If present, the status of a recent encrypt/decrypt call on underlying data for this database or backup. Regardless of status, data is always encrypted at rest.
1299    #[serde(rename = "encryptionStatus")]
1300    pub encryption_status: Option<Status>,
1301    /// Output only. The type of encryption.
1302    #[serde(rename = "encryptionType")]
1303    pub encryption_type: Option<String>,
1304    /// Output only. A Cloud KMS key version that is being used to protect the database or backup.
1305    #[serde(rename = "kmsKeyVersion")]
1306    pub kms_key_version: Option<String>,
1307}
1308
1309impl common::Part for EncryptionInfo {}
1310
1311/// An ExcludeReplicas contains a repeated set of ReplicaSelection that should be excluded from serving requests.
1312///
1313/// This type is not used in any activity, and only used as *part* of another schema.
1314///
1315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1316#[serde_with::serde_as]
1317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1318pub struct ExcludeReplicas {
1319    /// The directed read replica selector.
1320    #[serde(rename = "replicaSelections")]
1321    pub replica_selections: Option<Vec<ReplicaSelection>>,
1322}
1323
1324impl common::Part for ExcludeReplicas {}
1325
1326/// The request for ExecuteBatchDml.
1327///
1328/// # Activities
1329///
1330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1332///
1333/// * [instances databases sessions execute batch dml projects](ProjectInstanceDatabaseSessionExecuteBatchDmlCall) (request)
1334#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1335#[serde_with::serde_as]
1336#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1337pub struct ExecuteBatchDmlRequest {
1338    /// Optional. If set to `true`, this request marks the end of the transaction. After these statements execute, you must commit or abort the transaction. Attempts to execute any other requests against this transaction (including reads and queries) are rejected. Setting this option might cause some error reporting to be deferred until commit time (for example, validation of unique constraints). Given this, successful execution of statements shouldn't be assumed until a subsequent `Commit` call completes successfully.
1339    #[serde(rename = "lastStatements")]
1340    pub last_statements: Option<bool>,
1341    /// Common options for this request.
1342    #[serde(rename = "requestOptions")]
1343    pub request_options: Option<RequestOptions>,
1344    /// Required. A per-transaction sequence number used to identify this request. This field makes each request idempotent such that if the request is received multiple times, at most one succeeds. The sequence number must be monotonically increasing within the transaction. If a request arrives for the first time with an out-of-order sequence number, the transaction might be aborted. Replays of previously handled requests yield the same response as the first execution.
1345    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1346    pub seqno: Option<i64>,
1347    /// Required. The list of statements to execute in this batch. Statements are executed serially, such that the effects of statement `i` are visible to statement `i+1`. Each statement must be a DML statement. Execution stops at the first failed statement; the remaining statements are not executed. Callers must provide at least one statement.
1348    pub statements: Option<Vec<Statement>>,
1349    /// Required. The transaction to use. Must be a read-write transaction. To protect against replays, single-use transactions are not supported. The caller must either supply an existing transaction ID or begin a new transaction.
1350    pub transaction: Option<TransactionSelector>,
1351}
1352
1353impl common::RequestValue for ExecuteBatchDmlRequest {}
1354
1355/// The response for ExecuteBatchDml. Contains a list of ResultSet messages, one for each DML statement that has successfully executed, in the same order as the statements in the request. If a statement fails, the status in the response body identifies the cause of the failure. To check for DML statements that failed, use the following approach: 1. Check the status in the response message. The google.rpc.Code enum value `OK` indicates that all statements were executed successfully. 2. If the status was not `OK`, check the number of result sets in the response. If the response contains `N` ResultSet messages, then statement `N+1` in the request failed. Example 1: * Request: 5 DML statements, all executed successfully. * Response: 5 ResultSet messages, with the status `OK`. Example 2: * Request: 5 DML statements. The third statement has a syntax error. * Response: 2 ResultSet messages, and a syntax error (`INVALID_ARGUMENT`) status. The number of ResultSet messages indicates that the third statement failed, and the fourth and fifth statements were not executed.
1356///
1357/// # Activities
1358///
1359/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1360/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1361///
1362/// * [instances databases sessions execute batch dml projects](ProjectInstanceDatabaseSessionExecuteBatchDmlCall) (response)
1363#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1364#[serde_with::serde_as]
1365#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1366pub struct ExecuteBatchDmlResponse {
1367    /// Optional. A precommit token is included if the read-write transaction is on a multiplexed session. Pass the precommit token with the highest sequence number from this transaction attempt should be passed to the Commit request for this transaction.
1368    #[serde(rename = "precommitToken")]
1369    pub precommit_token: Option<MultiplexedSessionPrecommitToken>,
1370    /// One ResultSet for each statement in the request that ran successfully, in the same order as the statements in the request. Each ResultSet does not contain any rows. The ResultSetStats in each ResultSet contain the number of rows modified by the statement. Only the first ResultSet in the response contains valid ResultSetMetadata.
1371    #[serde(rename = "resultSets")]
1372    pub result_sets: Option<Vec<ResultSet>>,
1373    /// If all DML statements are executed successfully, the status is `OK`. Otherwise, the error status of the first failed statement.
1374    pub status: Option<Status>,
1375}
1376
1377impl common::ResponseResult for ExecuteBatchDmlResponse {}
1378
1379/// The request for ExecuteSql and ExecuteStreamingSql.
1380///
1381/// # Activities
1382///
1383/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1384/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1385///
1386/// * [instances databases sessions execute sql projects](ProjectInstanceDatabaseSessionExecuteSqlCall) (request)
1387/// * [instances databases sessions execute streaming sql projects](ProjectInstanceDatabaseSessionExecuteStreamingSqlCall) (request)
1388#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1389#[serde_with::serde_as]
1390#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1391pub struct ExecuteSqlRequest {
1392    /// If this is for a partitioned query and this field is set to `true`, the request is executed with Spanner Data Boost independent compute resources. If the field is set to `true` but the request doesn't set `partition_token`, the API returns an `INVALID_ARGUMENT` error.
1393    #[serde(rename = "dataBoostEnabled")]
1394    pub data_boost_enabled: Option<bool>,
1395    /// Directed read options for this request.
1396    #[serde(rename = "directedReadOptions")]
1397    pub directed_read_options: Option<DirectedReadOptions>,
1398    /// Optional. If set to `true`, this statement marks the end of the transaction. After this statement executes, you must commit or abort the transaction. Attempts to execute any other requests against this transaction (including reads and queries) are rejected. For DML statements, setting this option might cause some error reporting to be deferred until commit time (for example, validation of unique constraints). Given this, successful execution of a DML statement shouldn't be assumed until a subsequent `Commit` call completes successfully.
1399    #[serde(rename = "lastStatement")]
1400    pub last_statement: Option<bool>,
1401    /// It isn't always possible for Cloud Spanner to infer the right SQL type from a JSON value. For example, values of type `BYTES` and values of type `STRING` both appear in params as JSON strings. In these cases, you can use `param_types` to specify the exact SQL type for some or all of the SQL statement parameters. See the definition of Type for more information about SQL types.
1402    #[serde(rename = "paramTypes")]
1403    pub param_types: Option<HashMap<String, Type>>,
1404    /// Parameter names and values that bind to placeholders in the SQL string. A parameter placeholder consists of the `@` character followed by the parameter name (for example, `@firstName`). Parameter names must conform to the naming requirements of identifiers as specified at https://cloud.google.com/spanner/docs/lexical#identifiers. Parameters can appear anywhere that a literal value is expected. The same parameter name can be used more than once, for example: `"WHERE id > @msg_id AND id < @msg_id + 100"` It's an error to execute a SQL statement with unbound parameters.
1405    pub params: Option<HashMap<String, serde_json::Value>>,
1406    /// If present, results are restricted to the specified partition previously created using `PartitionQuery`. There must be an exact match for the values of fields common to this message and the `PartitionQueryRequest` message used to create this `partition_token`.
1407    #[serde(rename = "partitionToken")]
1408    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1409    pub partition_token: Option<Vec<u8>>,
1410    /// Used to control the amount of debugging information returned in ResultSetStats. If partition_token is set, query_mode can only be set to QueryMode.NORMAL.
1411    #[serde(rename = "queryMode")]
1412    pub query_mode: Option<String>,
1413    /// Query optimizer configuration to use for the given query.
1414    #[serde(rename = "queryOptions")]
1415    pub query_options: Option<QueryOptions>,
1416    /// Common options for this request.
1417    #[serde(rename = "requestOptions")]
1418    pub request_options: Option<RequestOptions>,
1419    /// If this request is resuming a previously interrupted SQL statement execution, `resume_token` should be copied from the last PartialResultSet yielded before the interruption. Doing this enables the new SQL statement execution to resume where the last one left off. The rest of the request parameters must exactly match the request that yielded this token.
1420    #[serde(rename = "resumeToken")]
1421    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1422    pub resume_token: Option<Vec<u8>>,
1423    /// A per-transaction sequence number used to identify this request. This field makes each request idempotent such that if the request is received multiple times, at most one succeeds. The sequence number must be monotonically increasing within the transaction. If a request arrives for the first time with an out-of-order sequence number, the transaction can be aborted. Replays of previously handled requests yield the same response as the first execution. Required for DML statements. Ignored for queries.
1424    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1425    pub seqno: Option<i64>,
1426    /// Required. The SQL string.
1427    pub sql: Option<String>,
1428    /// The transaction to use. For queries, if none is provided, the default is a temporary read-only transaction with strong concurrency. Standard DML statements require a read-write transaction. To protect against replays, single-use transactions are not supported. The caller must either supply an existing transaction ID or begin a new transaction. Partitioned DML requires an existing Partitioned DML transaction ID.
1429    pub transaction: Option<TransactionSelector>,
1430}
1431
1432impl common::RequestValue for ExecuteSqlRequest {}
1433
1434/// 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.
1435///
1436/// This type is not used in any activity, and only used as *part* of another schema.
1437///
1438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1439#[serde_with::serde_as]
1440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1441pub struct Expr {
1442    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
1443    pub description: Option<String>,
1444    /// Textual representation of an expression in Common Expression Language syntax.
1445    pub expression: Option<String>,
1446    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
1447    pub location: Option<String>,
1448    /// 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.
1449    pub title: Option<String>,
1450}
1451
1452impl common::Part for Expr {}
1453
1454/// Message representing a single field of a struct.
1455///
1456/// This type is not used in any activity, and only used as *part* of another schema.
1457///
1458#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1459#[serde_with::serde_as]
1460#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1461pub struct Field {
1462    /// The name of the field. For reads, this is the column name. For SQL queries, it is the column alias (e.g., `"Word"` in the query `"SELECT 'hello' AS Word"`), or the column name (e.g., `"ColName"` in the query `"SELECT ColName FROM Table"`). Some columns might have an empty name (e.g., `"SELECT UPPER(ColName)"`). Note that a query result can contain multiple fields with the same name.
1463    pub name: Option<String>,
1464    /// The type of the field.
1465    #[serde(rename = "type")]
1466    pub type_: Option<Type>,
1467}
1468
1469impl common::Part for Field {}
1470
1471/// Free instance specific metadata that is kept even after an instance has been upgraded for tracking purposes.
1472///
1473/// This type is not used in any activity, and only used as *part* of another schema.
1474///
1475#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1476#[serde_with::serde_as]
1477#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1478pub struct FreeInstanceMetadata {
1479    /// Specifies the expiration behavior of a free instance. The default of ExpireBehavior is `REMOVE_AFTER_GRACE_PERIOD`. This can be modified during or after creation, and before expiration.
1480    #[serde(rename = "expireBehavior")]
1481    pub expire_behavior: Option<String>,
1482    /// Output only. Timestamp after which the instance will either be upgraded or scheduled for deletion after a grace period. ExpireBehavior is used to choose between upgrading or scheduling the free instance for deletion. This timestamp is set during the creation of a free instance.
1483    #[serde(rename = "expireTime")]
1484    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1485    /// Output only. If present, the timestamp at which the free instance was upgraded to a provisioned instance.
1486    #[serde(rename = "upgradeTime")]
1487    pub upgrade_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1488}
1489
1490impl common::Part for FreeInstanceMetadata {}
1491
1492/// The specification for full backups. A full backup stores the entire contents of the database at a given version time.
1493///
1494/// This type is not used in any activity, and only used as *part* of another schema.
1495///
1496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1497#[serde_with::serde_as]
1498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1499pub struct FullBackupSpec {
1500    _never_set: Option<bool>,
1501}
1502
1503impl common::Part for FullBackupSpec {}
1504
1505/// The response for GetDatabaseDdl.
1506///
1507/// # Activities
1508///
1509/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1510/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1511///
1512/// * [instances databases get ddl projects](ProjectInstanceDatabaseGetDdlCall) (response)
1513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1514#[serde_with::serde_as]
1515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1516pub struct GetDatabaseDdlResponse {
1517    /// Proto descriptors stored in the database. Contains a protobuf-serialized [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). For more details, see protobuffer [self description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
1518    #[serde(rename = "protoDescriptors")]
1519    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1520    pub proto_descriptors: Option<Vec<u8>>,
1521    /// A list of formatted DDL statements defining the schema of the database specified in the request.
1522    pub statements: Option<Vec<String>>,
1523}
1524
1525impl common::ResponseResult for GetDatabaseDdlResponse {}
1526
1527/// Request message for `GetIamPolicy` method.
1528///
1529/// # Activities
1530///
1531/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1532/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1533///
1534/// * [instances backups get iam policy projects](ProjectInstanceBackupGetIamPolicyCall) (request)
1535/// * [instances databases backup schedules get iam policy projects](ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall) (request)
1536/// * [instances databases get iam policy projects](ProjectInstanceDatabaseGetIamPolicyCall) (request)
1537/// * [instances get iam policy projects](ProjectInstanceGetIamPolicyCall) (request)
1538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1539#[serde_with::serde_as]
1540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1541pub struct GetIamPolicyRequest {
1542    /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
1543    pub options: Option<GetPolicyOptions>,
1544}
1545
1546impl common::RequestValue for GetIamPolicyRequest {}
1547
1548/// Encapsulates settings provided to GetIamPolicy.
1549///
1550/// This type is not used in any activity, and only used as *part* of another schema.
1551///
1552#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1553#[serde_with::serde_as]
1554#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1555pub struct GetPolicyOptions {
1556    /// 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).
1557    #[serde(rename = "requestedPolicyVersion")]
1558    pub requested_policy_version: Option<i32>,
1559}
1560
1561impl common::Part for GetPolicyOptions {}
1562
1563/// An `IncludeReplicas` contains a repeated set of `ReplicaSelection` which indicates the order in which replicas should be considered.
1564///
1565/// This type is not used in any activity, and only used as *part* of another schema.
1566///
1567#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1568#[serde_with::serde_as]
1569#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1570pub struct IncludeReplicas {
1571    /// If `true`, Spanner doesn't route requests to a replica outside the <`include_replicas` list when all of the specified replicas are unavailable or unhealthy. Default value is `false`.
1572    #[serde(rename = "autoFailoverDisabled")]
1573    pub auto_failover_disabled: Option<bool>,
1574    /// The directed read replica selector.
1575    #[serde(rename = "replicaSelections")]
1576    pub replica_selections: Option<Vec<ReplicaSelection>>,
1577}
1578
1579impl common::Part for IncludeReplicas {}
1580
1581/// The specification for incremental backup chains. An incremental backup stores the delta of changes between a previous backup and the database contents at a given version time. An incremental backup chain consists of a full backup and zero or more successive incremental backups. The first backup created for an incremental backup chain is always a full backup.
1582///
1583/// This type is not used in any activity, and only used as *part* of another schema.
1584///
1585#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1586#[serde_with::serde_as]
1587#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1588pub struct IncrementalBackupSpec {
1589    _never_set: Option<bool>,
1590}
1591
1592impl common::Part for IncrementalBackupSpec {}
1593
1594/// Recommendation to add new indexes to run queries more efficiently.
1595///
1596/// This type is not used in any activity, and only used as *part* of another schema.
1597///
1598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1599#[serde_with::serde_as]
1600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1601pub struct IndexAdvice {
1602    /// Optional. DDL statements to add new indexes that will improve the query.
1603    pub ddl: Option<Vec<String>>,
1604    /// Optional. Estimated latency improvement factor. For example if the query currently takes 500 ms to run and the estimated latency with new indexes is 100 ms this field will be 5.
1605    #[serde(rename = "improvementFactor")]
1606    pub improvement_factor: Option<f64>,
1607}
1608
1609impl common::Part for IndexAdvice {}
1610
1611/// A message representing a (sparse) collection of hot keys for specific key buckets.
1612///
1613/// This type is not used in any activity, and only used as *part* of another schema.
1614///
1615#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1616#[serde_with::serde_as]
1617#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1618pub struct IndexedHotKey {
1619    /// A (sparse) mapping from key bucket index to the index of the specific hot row key for that key bucket. The index of the hot row key can be translated to the actual row key via the ScanData.VisualizationData.indexed_keys repeated field.
1620    #[serde(rename = "sparseHotKeys")]
1621    pub sparse_hot_keys: Option<HashMap<String, i32>>,
1622}
1623
1624impl common::Part for IndexedHotKey {}
1625
1626/// A message representing a (sparse) collection of KeyRangeInfos for specific key buckets.
1627///
1628/// This type is not used in any activity, and only used as *part* of another schema.
1629///
1630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1631#[serde_with::serde_as]
1632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1633pub struct IndexedKeyRangeInfos {
1634    /// A (sparse) mapping from key bucket index to the KeyRangeInfos for that key bucket.
1635    #[serde(rename = "keyRangeInfos")]
1636    pub key_range_infos: Option<HashMap<String, KeyRangeInfos>>,
1637}
1638
1639impl common::Part for IndexedKeyRangeInfos {}
1640
1641/// An isolated set of Cloud Spanner resources on which databases can be hosted.
1642///
1643/// # Activities
1644///
1645/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1646/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1647///
1648/// * [instances get projects](ProjectInstanceGetCall) (response)
1649#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1650#[serde_with::serde_as]
1651#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1652pub struct Instance {
1653    /// Optional. The autoscaling configuration. Autoscaling is enabled if this field is set. When autoscaling is enabled, node_count and processing_units are treated as OUTPUT_ONLY fields and reflect the current compute capacity allocated to the instance.
1654    #[serde(rename = "autoscalingConfig")]
1655    pub autoscaling_config: Option<AutoscalingConfig>,
1656    /// Required. The name of the instance's configuration. Values are of the form `projects//instanceConfigs/`. See also InstanceConfig and ListInstanceConfigs.
1657    pub config: Option<String>,
1658    /// Output only. The time at which the instance was created.
1659    #[serde(rename = "createTime")]
1660    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1661    /// Optional. Controls the default backup schedule behavior for new databases within the instance. By default, a backup schedule is created automatically when a new database is created in a new instance. Note that the `AUTOMATIC` value isn't permitted for free instances, as backups and backup schedules aren't supported for free instances. In the `GetInstance` or `ListInstances` response, if the value of `default_backup_schedule_type` isn't set, or set to `NONE`, Spanner doesn't create a default backup schedule for new databases in the instance.
1662    #[serde(rename = "defaultBackupScheduleType")]
1663    pub default_backup_schedule_type: Option<String>,
1664    /// Required. The descriptive name for this instance as it appears in UIs. Must be unique per project and between 4 and 30 characters in length.
1665    #[serde(rename = "displayName")]
1666    pub display_name: Option<String>,
1667    /// Optional. The `Edition` of the current instance.
1668    pub edition: Option<String>,
1669    /// Deprecated. This field is not populated.
1670    #[serde(rename = "endpointUris")]
1671    pub endpoint_uris: Option<Vec<String>>,
1672    /// Free instance metadata. Only populated for free instances.
1673    #[serde(rename = "freeInstanceMetadata")]
1674    pub free_instance_metadata: Option<FreeInstanceMetadata>,
1675    /// The `InstanceType` of the current instance.
1676    #[serde(rename = "instanceType")]
1677    pub instance_type: Option<String>,
1678    /// Cloud Labels are a flexible and lightweight mechanism for organizing cloud resources into groups that reflect a customer's organizational needs and deployment strategies. Cloud Labels can be used to filter collections of resources. They can be used to control how resource metrics are aggregated. And they can be used as arguments to policy management rules (e.g. route, firewall, load balancing, etc.). * Label keys must be between 1 and 63 characters long and must conform to the following regular expression: `a-z{0,62}`. * Label values must be between 0 and 63 characters long and must conform to the regular expression `[a-z0-9_-]{0,63}`. * No more than 64 labels can be associated with a given resource. See https://goo.gl/xmQnxf for more information on and examples of labels. If you plan to use labels in your own code, please note that additional characters may be allowed in the future. And so you are advised to use an internal label representation, such as JSON, which doesn't rely upon specific characters being disallowed. For example, representing labels as the string: name + "_" + value would prove problematic if we were to allow "_" in a future release.
1679    pub labels: Option<HashMap<String, String>>,
1680    /// Required. A unique identifier for the instance, which cannot be changed after the instance is created. Values are of the form `projects//instances/a-z*[a-z0-9]`. The final segment of the name must be between 2 and 64 characters in length.
1681    pub name: Option<String>,
1682    /// The number of nodes allocated to this instance. At most, one of either `node_count` or `processing_units` should be present in the message. Users can set the `node_count` field to specify the target number of nodes allocated to the instance. If autoscaling is enabled, `node_count` is treated as an `OUTPUT_ONLY` field and reflects the current number of nodes allocated to the instance. This might be zero in API responses for instances that are not yet in the `READY` state. If the instance has varying node count across replicas (achieved by setting `asymmetric_autoscaling_options` in the autoscaling configuration), the `node_count` set here is the maximum node count across all replicas. For more information, see [Compute capacity, nodes, and processing units](https://cloud.google.com/spanner/docs/compute-capacity).
1683    #[serde(rename = "nodeCount")]
1684    pub node_count: Option<i32>,
1685    /// The number of processing units allocated to this instance. At most, one of either `processing_units` or `node_count` should be present in the message. Users can set the `processing_units` field to specify the target number of processing units allocated to the instance. If autoscaling is enabled, `processing_units` is treated as an `OUTPUT_ONLY` field and reflects the current number of processing units allocated to the instance. This might be zero in API responses for instances that are not yet in the `READY` state. If the instance has varying processing units per replica (achieved by setting `asymmetric_autoscaling_options` in the autoscaling configuration), the `processing_units` set here is the maximum processing units across all replicas. For more information, see [Compute capacity, nodes and processing units](https://cloud.google.com/spanner/docs/compute-capacity).
1686    #[serde(rename = "processingUnits")]
1687    pub processing_units: Option<i32>,
1688    /// Output only. Lists the compute capacity per ReplicaSelection. A replica selection identifies a set of replicas with common properties. Replicas identified by a ReplicaSelection are scaled with the same compute capacity.
1689    #[serde(rename = "replicaComputeCapacity")]
1690    pub replica_compute_capacity: Option<Vec<ReplicaComputeCapacity>>,
1691    /// Output only. The current instance state. For CreateInstance, the state must be either omitted or set to `CREATING`. For UpdateInstance, the state must be either omitted or set to `READY`.
1692    pub state: Option<String>,
1693    /// Output only. The time at which the instance was most recently updated.
1694    #[serde(rename = "updateTime")]
1695    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1696}
1697
1698impl common::ResponseResult for Instance {}
1699
1700/// A possible configuration for a Cloud Spanner instance. Configurations define the geographic placement of nodes and their replication.
1701///
1702/// # Activities
1703///
1704/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1705/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1706///
1707/// * [instance configs get projects](ProjectInstanceConfigGetCall) (response)
1708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1709#[serde_with::serde_as]
1710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1711pub struct InstanceConfig {
1712    /// Base configuration name, e.g. projects//instanceConfigs/nam3, based on which this configuration is created. Only set for user-managed configurations. `base_config` must refer to a configuration of type `GOOGLE_MANAGED` in the same project as this configuration.
1713    #[serde(rename = "baseConfig")]
1714    pub base_config: Option<String>,
1715    /// Output only. Whether this instance configuration is a Google-managed or user-managed configuration.
1716    #[serde(rename = "configType")]
1717    pub config_type: Option<String>,
1718    /// The name of this instance configuration as it appears in UIs.
1719    #[serde(rename = "displayName")]
1720    pub display_name: Option<String>,
1721    /// etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a instance configuration from overwriting each other. It is strongly suggested that systems make use of the etag in the read-modify-write cycle to perform instance configuration updates in order to avoid race conditions: An etag is returned in the response which contains instance configurations, and systems are expected to put that etag in the request to update instance configuration to ensure that their change is applied to the same version of the instance configuration. If no etag is provided in the call to update the instance configuration, then the existing instance configuration is overwritten blindly.
1722    pub etag: Option<String>,
1723    /// Output only. Describes whether free instances are available to be created in this instance configuration.
1724    #[serde(rename = "freeInstanceAvailability")]
1725    pub free_instance_availability: Option<String>,
1726    /// Cloud Labels are a flexible and lightweight mechanism for organizing cloud resources into groups that reflect a customer's organizational needs and deployment strategies. Cloud Labels can be used to filter collections of resources. They can be used to control how resource metrics are aggregated. And they can be used as arguments to policy management rules (e.g. route, firewall, load balancing, etc.). * Label keys must be between 1 and 63 characters long and must conform to the following regular expression: `a-z{0,62}`. * Label values must be between 0 and 63 characters long and must conform to the regular expression `[a-z0-9_-]{0,63}`. * No more than 64 labels can be associated with a given resource. See https://goo.gl/xmQnxf for more information on and examples of labels. If you plan to use labels in your own code, please note that additional characters may be allowed in the future. Therefore, you are advised to use an internal label representation, such as JSON, which doesn't rely upon specific characters being disallowed. For example, representing labels as the string: name + "_" + value would prove problematic if we were to allow "_" in a future release.
1727    pub labels: Option<HashMap<String, String>>,
1728    /// Allowed values of the "default_leader" schema option for databases in instances that use this instance configuration.
1729    #[serde(rename = "leaderOptions")]
1730    pub leader_options: Option<Vec<String>>,
1731    /// A unique identifier for the instance configuration. Values are of the form `projects//instanceConfigs/a-z*`. User instance configuration must start with `custom-`.
1732    pub name: Option<String>,
1733    /// Output only. The available optional replicas to choose from for user-managed configurations. Populated for Google-managed configurations.
1734    #[serde(rename = "optionalReplicas")]
1735    pub optional_replicas: Option<Vec<ReplicaInfo>>,
1736    /// Output only. The `QuorumType` of the instance configuration.
1737    #[serde(rename = "quorumType")]
1738    pub quorum_type: Option<String>,
1739    /// Output only. If true, the instance configuration is being created or updated. If false, there are no ongoing operations for the instance configuration.
1740    pub reconciling: Option<bool>,
1741    /// The geographic placement of nodes in this instance configuration and their replication properties. To create user-managed configurations, input `replicas` must include all replicas in `replicas` of the `base_config` and include one or more replicas in the `optional_replicas` of the `base_config`.
1742    pub replicas: Option<Vec<ReplicaInfo>>,
1743    /// Output only. The current instance configuration state. Applicable only for `USER_MANAGED` configurations.
1744    pub state: Option<String>,
1745    /// Output only. The storage limit in bytes per processing unit.
1746    #[serde(rename = "storageLimitPerProcessingUnit")]
1747    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1748    pub storage_limit_per_processing_unit: Option<i64>,
1749}
1750
1751impl common::ResponseResult for InstanceConfig {}
1752
1753/// Encryption configuration for a Cloud Spanner database.
1754///
1755/// This type is not used in any activity, and only used as *part* of another schema.
1756///
1757#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1758#[serde_with::serde_as]
1759#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1760pub struct InstanceEncryptionConfig {
1761    /// Optional. This field is maintained for backwards compatibility. For new callers, we recommend using `kms_key_names` to specify the KMS key. Only use `kms_key_name` if the location of the KMS key matches the database instance's configuration (location) exactly. For example, if the KMS location is in `us-central1` or `nam3`, then the database instance must also be in `us-central1` or `nam3`. The Cloud KMS key that is used to encrypt and decrypt the restored database. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
1762    #[serde(rename = "kmsKeyName")]
1763    pub kms_key_name: Option<String>,
1764    /// Optional. Specifies the KMS configuration for one or more keys used to encrypt the database. Values are of the form `projects//locations//keyRings//cryptoKeys/`. The keys referenced by `kms_key_names` must fully cover all regions of the database's instance configuration. Some examples: * For regional (single-region) instance configurations, specify a regional location KMS key. * For multi-region instance configurations of type `GOOGLE_MANAGED`, either specify a multi-region location KMS key or multiple regional location KMS keys that cover all regions in the instance configuration. * For an instance configuration of type `USER_MANAGED`, specify only regional location KMS keys to cover each region in the instance configuration. Multi-region location KMS keys aren't supported for `USER_MANAGED` type instance configurations.
1765    #[serde(rename = "kmsKeyNames")]
1766    pub kms_key_names: Option<Vec<String>>,
1767}
1768
1769impl common::Part for InstanceEncryptionConfig {}
1770
1771/// An isolated set of Cloud Spanner resources that databases can define placements on.
1772///
1773/// # Activities
1774///
1775/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1776/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1777///
1778/// * [instances instance partitions get projects](ProjectInstanceInstancePartitionGetCall) (response)
1779#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1780#[serde_with::serde_as]
1781#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1782pub struct InstancePartition {
1783    /// Optional. The autoscaling configuration. Autoscaling is enabled if this field is set. When autoscaling is enabled, fields in compute_capacity are treated as OUTPUT_ONLY fields and reflect the current compute capacity allocated to the instance partition.
1784    #[serde(rename = "autoscalingConfig")]
1785    pub autoscaling_config: Option<AutoscalingConfig>,
1786    /// Required. The name of the instance partition's configuration. Values are of the form `projects//instanceConfigs/`. See also InstanceConfig and ListInstanceConfigs.
1787    pub config: Option<String>,
1788    /// Output only. The time at which the instance partition was created.
1789    #[serde(rename = "createTime")]
1790    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1791    /// Required. The descriptive name for this instance partition as it appears in UIs. Must be unique per project and between 4 and 30 characters in length.
1792    #[serde(rename = "displayName")]
1793    pub display_name: Option<String>,
1794    /// Used for optimistic concurrency control as a way to help prevent simultaneous updates of a instance partition from overwriting each other. It is strongly suggested that systems make use of the etag in the read-modify-write cycle to perform instance partition updates in order to avoid race conditions: An etag is returned in the response which contains instance partitions, and systems are expected to put that etag in the request to update instance partitions to ensure that their change will be applied to the same version of the instance partition. If no etag is provided in the call to update instance partition, then the existing instance partition is overwritten blindly.
1795    pub etag: Option<String>,
1796    /// Required. A unique identifier for the instance partition. Values are of the form `projects//instances//instancePartitions/a-z*[a-z0-9]`. The final segment of the name must be between 2 and 64 characters in length. An instance partition's name cannot be changed after the instance partition is created.
1797    pub name: Option<String>,
1798    /// The number of nodes allocated to this instance partition. Users can set the `node_count` field to specify the target number of nodes allocated to the instance partition. This may be zero in API responses for instance partitions that are not yet in state `READY`.
1799    #[serde(rename = "nodeCount")]
1800    pub node_count: Option<i32>,
1801    /// The number of processing units allocated to this instance partition. Users can set the `processing_units` field to specify the target number of processing units allocated to the instance partition. This might be zero in API responses for instance partitions that are not yet in the `READY` state.
1802    #[serde(rename = "processingUnits")]
1803    pub processing_units: Option<i32>,
1804    /// Output only. Deprecated: This field is not populated. Output only. The names of the backups that reference this instance partition. Referencing backups should share the parent instance. The existence of any referencing backup prevents the instance partition from being deleted.
1805    #[serde(rename = "referencingBackups")]
1806    pub referencing_backups: Option<Vec<String>>,
1807    /// Output only. The names of the databases that reference this instance partition. Referencing databases should share the parent instance. The existence of any referencing database prevents the instance partition from being deleted.
1808    #[serde(rename = "referencingDatabases")]
1809    pub referencing_databases: Option<Vec<String>>,
1810    /// Output only. The current instance partition state.
1811    pub state: Option<String>,
1812    /// Output only. The time at which the instance partition was most recently updated.
1813    #[serde(rename = "updateTime")]
1814    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1815}
1816
1817impl common::ResponseResult for InstancePartition {}
1818
1819/// ReplicaSelection identifies replicas with common properties.
1820///
1821/// This type is not used in any activity, and only used as *part* of another schema.
1822///
1823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1824#[serde_with::serde_as]
1825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1826pub struct InstanceReplicaSelection {
1827    /// Required. Name of the location of the replicas (for example, "us-central1").
1828    pub location: Option<String>,
1829}
1830
1831impl common::Part for InstanceReplicaSelection {}
1832
1833/// A split key.
1834///
1835/// This type is not used in any activity, and only used as *part* of another schema.
1836///
1837#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1838#[serde_with::serde_as]
1839#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1840pub struct Key {
1841    /// Required. The column values making up the split key.
1842    #[serde(rename = "keyParts")]
1843    pub key_parts: Option<Vec<serde_json::Value>>,
1844}
1845
1846impl common::Part for Key {}
1847
1848/// KeyRange represents a range of rows in a table or index. A range has a start key and an end key. These keys can be open or closed, indicating if the range includes rows with that key. Keys are represented by lists, where the ith value in the list corresponds to the ith component of the table or index primary key. Individual values are encoded as described here. For example, consider the following table definition: CREATE TABLE UserEvents ( UserName STRING(MAX), EventDate STRING(10) ) PRIMARY KEY(UserName, EventDate); The following keys name rows in this table: "Bob", "2014-09-23" Since the `UserEvents` table's `PRIMARY KEY` clause names two columns, each `UserEvents` key has two elements; the first is the `UserName`, and the second is the `EventDate`. Key ranges with multiple components are interpreted lexicographically by component using the table or index key's declared sort order. For example, the following range returns all events for user `"Bob"` that occurred in the year 2015: "start_closed": ["Bob", "2015-01-01"] "end_closed": ["Bob", "2015-12-31"] Start and end keys can omit trailing key components. This affects the inclusion and exclusion of rows that exactly match the provided key components: if the key is closed, then rows that exactly match the provided components are included; if the key is open, then rows that exactly match are not included. For example, the following range includes all events for `"Bob"` that occurred during and after the year 2000: "start_closed": ["Bob", "2000-01-01"] "end_closed": ["Bob"] The next example retrieves all events for `"Bob"`: "start_closed": ["Bob"] "end_closed": ["Bob"] To retrieve events before the year 2000: "start_closed": ["Bob"] "end_open": ["Bob", "2000-01-01"] The following range includes all rows in the table: "start_closed": [] "end_closed": [] This range returns all users whose `UserName` begins with any character from A to C: "start_closed": ["A"] "end_open": ["D"] This range returns all users whose `UserName` begins with B: "start_closed": ["B"] "end_open": ["C"] Key ranges honor column sort order. For example, suppose a table is defined as follows: CREATE TABLE DescendingSortedTable { Key INT64, ... ) PRIMARY KEY(Key DESC); The following range retrieves all rows with key values between 1 and 100 inclusive: "start_closed": ["100"] "end_closed": ["1"] Note that 100 is passed as the start, and 1 is passed as the end, because `Key` is a descending column in the schema.
1849///
1850/// This type is not used in any activity, and only used as *part* of another schema.
1851///
1852#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1853#[serde_with::serde_as]
1854#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1855pub struct KeyRange {
1856    /// If the end is closed, then the range includes all rows whose first `len(end_closed)` key columns exactly match `end_closed`.
1857    #[serde(rename = "endClosed")]
1858    pub end_closed: Option<Vec<serde_json::Value>>,
1859    /// If the end is open, then the range excludes rows whose first `len(end_open)` key columns exactly match `end_open`.
1860    #[serde(rename = "endOpen")]
1861    pub end_open: Option<Vec<serde_json::Value>>,
1862    /// If the start is closed, then the range includes all rows whose first `len(start_closed)` key columns exactly match `start_closed`.
1863    #[serde(rename = "startClosed")]
1864    pub start_closed: Option<Vec<serde_json::Value>>,
1865    /// If the start is open, then the range excludes rows whose first `len(start_open)` key columns exactly match `start_open`.
1866    #[serde(rename = "startOpen")]
1867    pub start_open: Option<Vec<serde_json::Value>>,
1868}
1869
1870impl common::Part for KeyRange {}
1871
1872/// A message representing information for a key range (possibly one key).
1873///
1874/// This type is not used in any activity, and only used as *part* of another schema.
1875///
1876#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1877#[serde_with::serde_as]
1878#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1879pub struct KeyRangeInfo {
1880    /// The list of context values for this key range.
1881    #[serde(rename = "contextValues")]
1882    pub context_values: Option<Vec<ContextValue>>,
1883    /// The index of the end key in indexed_keys.
1884    #[serde(rename = "endKeyIndex")]
1885    pub end_key_index: Option<i32>,
1886    /// Information about this key range, for all metrics.
1887    pub info: Option<LocalizedString>,
1888    /// The number of keys this range covers.
1889    #[serde(rename = "keysCount")]
1890    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1891    pub keys_count: Option<i64>,
1892    /// The name of the metric. e.g. "latency".
1893    pub metric: Option<LocalizedString>,
1894    /// The index of the start key in indexed_keys.
1895    #[serde(rename = "startKeyIndex")]
1896    pub start_key_index: Option<i32>,
1897    /// The time offset. This is the time since the start of the time interval.
1898    #[serde(rename = "timeOffset")]
1899    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1900    pub time_offset: Option<chrono::Duration>,
1901    /// The unit of the metric. This is an unstructured field and will be mapped as is to the user.
1902    pub unit: Option<LocalizedString>,
1903    /// The value of the metric.
1904    pub value: Option<f32>,
1905}
1906
1907impl common::Part for KeyRangeInfo {}
1908
1909/// A message representing a list of specific information for multiple key ranges.
1910///
1911/// This type is not used in any activity, and only used as *part* of another schema.
1912///
1913#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1914#[serde_with::serde_as]
1915#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1916pub struct KeyRangeInfos {
1917    /// The list individual KeyRangeInfos.
1918    pub infos: Option<Vec<KeyRangeInfo>>,
1919    /// The total size of the list of all KeyRangeInfos. This may be larger than the number of repeated messages above. If that is the case, this number may be used to determine how many are not being shown.
1920    #[serde(rename = "totalSize")]
1921    pub total_size: Option<i32>,
1922}
1923
1924impl common::Part for KeyRangeInfos {}
1925
1926/// `KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All the keys are expected to be in the same table or index. The keys need not be sorted in any particular way. If the same key is specified multiple times in the set (for example if two ranges, two keys, or a key and a range overlap), Cloud Spanner behaves as if the key were only specified once.
1927///
1928/// This type is not used in any activity, and only used as *part* of another schema.
1929///
1930#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1931#[serde_with::serde_as]
1932#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1933pub struct KeySet {
1934    /// For convenience `all` can be set to `true` to indicate that this `KeySet` matches all keys in the table or index. Note that any keys specified in `keys` or `ranges` are only yielded once.
1935    pub all: Option<bool>,
1936    /// A list of specific keys. Entries in `keys` should have exactly as many elements as there are columns in the primary or index key with which this `KeySet` is used. Individual key values are encoded as described here.
1937    pub keys: Option<Vec<Vec<serde_json::Value>>>,
1938    /// A list of key ranges. See KeyRange for more information about key range specifications.
1939    pub ranges: Option<Vec<KeyRange>>,
1940}
1941
1942impl common::Part for KeySet {}
1943
1944/// The response for ListBackupOperations.
1945///
1946/// # Activities
1947///
1948/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1949/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1950///
1951/// * [instances backup operations list projects](ProjectInstanceBackupOperationListCall) (response)
1952#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1953#[serde_with::serde_as]
1954#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1955pub struct ListBackupOperationsResponse {
1956    /// `next_page_token` can be sent in a subsequent ListBackupOperations call to fetch more of the matching metadata.
1957    #[serde(rename = "nextPageToken")]
1958    pub next_page_token: Option<String>,
1959    /// The list of matching backup long-running operations. Each operation's name will be prefixed by the backup's name. The operation's metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that are pending or have completed/failed/canceled within the last 7 days. Operations returned are ordered by `operation.metadata.value.progress.start_time` in descending order starting from the most recently started operation.
1960    pub operations: Option<Vec<Operation>>,
1961}
1962
1963impl common::ResponseResult for ListBackupOperationsResponse {}
1964
1965/// The response for ListBackupSchedules.
1966///
1967/// # Activities
1968///
1969/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1970/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1971///
1972/// * [instances databases backup schedules list projects](ProjectInstanceDatabaseBackupScheduleListCall) (response)
1973#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1974#[serde_with::serde_as]
1975#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1976pub struct ListBackupSchedulesResponse {
1977    /// The list of backup schedules for a database.
1978    #[serde(rename = "backupSchedules")]
1979    pub backup_schedules: Option<Vec<BackupSchedule>>,
1980    /// `next_page_token` can be sent in a subsequent ListBackupSchedules call to fetch more of the schedules.
1981    #[serde(rename = "nextPageToken")]
1982    pub next_page_token: Option<String>,
1983}
1984
1985impl common::ResponseResult for ListBackupSchedulesResponse {}
1986
1987/// The response for ListBackups.
1988///
1989/// # Activities
1990///
1991/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1992/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1993///
1994/// * [instances backups list projects](ProjectInstanceBackupListCall) (response)
1995#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1996#[serde_with::serde_as]
1997#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1998pub struct ListBackupsResponse {
1999    /// The list of matching backups. Backups returned are ordered by `create_time` in descending order, starting from the most recent `create_time`.
2000    pub backups: Option<Vec<Backup>>,
2001    /// `next_page_token` can be sent in a subsequent ListBackups call to fetch more of the matching backups.
2002    #[serde(rename = "nextPageToken")]
2003    pub next_page_token: Option<String>,
2004}
2005
2006impl common::ResponseResult for ListBackupsResponse {}
2007
2008/// The response for ListDatabaseOperations.
2009///
2010/// # Activities
2011///
2012/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2013/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2014///
2015/// * [instances database operations list projects](ProjectInstanceDatabaseOperationListCall) (response)
2016#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2017#[serde_with::serde_as]
2018#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2019pub struct ListDatabaseOperationsResponse {
2020    /// `next_page_token` can be sent in a subsequent ListDatabaseOperations call to fetch more of the matching metadata.
2021    #[serde(rename = "nextPageToken")]
2022    pub next_page_token: Option<String>,
2023    /// The list of matching database long-running operations. Each operation's name will be prefixed by the database's name. The operation's metadata field type `metadata.type_url` describes the type of the metadata.
2024    pub operations: Option<Vec<Operation>>,
2025}
2026
2027impl common::ResponseResult for ListDatabaseOperationsResponse {}
2028
2029/// The response for ListDatabaseRoles.
2030///
2031/// # Activities
2032///
2033/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2034/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2035///
2036/// * [instances databases database roles list projects](ProjectInstanceDatabaseDatabaseRoleListCall) (response)
2037#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2038#[serde_with::serde_as]
2039#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2040pub struct ListDatabaseRolesResponse {
2041    /// Database roles that matched the request.
2042    #[serde(rename = "databaseRoles")]
2043    pub database_roles: Option<Vec<DatabaseRole>>,
2044    /// `next_page_token` can be sent in a subsequent ListDatabaseRoles call to fetch more of the matching roles.
2045    #[serde(rename = "nextPageToken")]
2046    pub next_page_token: Option<String>,
2047}
2048
2049impl common::ResponseResult for ListDatabaseRolesResponse {}
2050
2051/// The response for ListDatabases.
2052///
2053/// # Activities
2054///
2055/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2056/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2057///
2058/// * [instances databases list projects](ProjectInstanceDatabaseListCall) (response)
2059#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2060#[serde_with::serde_as]
2061#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2062pub struct ListDatabasesResponse {
2063    /// Databases that matched the request.
2064    pub databases: Option<Vec<Database>>,
2065    /// `next_page_token` can be sent in a subsequent ListDatabases call to fetch more of the matching databases.
2066    #[serde(rename = "nextPageToken")]
2067    pub next_page_token: Option<String>,
2068}
2069
2070impl common::ResponseResult for ListDatabasesResponse {}
2071
2072/// The response for ListInstanceConfigOperations.
2073///
2074/// # Activities
2075///
2076/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2077/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2078///
2079/// * [instance config operations list projects](ProjectInstanceConfigOperationListCall) (response)
2080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2081#[serde_with::serde_as]
2082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2083pub struct ListInstanceConfigOperationsResponse {
2084    /// `next_page_token` can be sent in a subsequent ListInstanceConfigOperations call to fetch more of the matching metadata.
2085    #[serde(rename = "nextPageToken")]
2086    pub next_page_token: Option<String>,
2087    /// The list of matching instance configuration long-running operations. Each operation's name will be prefixed by the name of the instance configuration. The operation's metadata field type `metadata.type_url` describes the type of the metadata.
2088    pub operations: Option<Vec<Operation>>,
2089}
2090
2091impl common::ResponseResult for ListInstanceConfigOperationsResponse {}
2092
2093/// The response for ListInstanceConfigs.
2094///
2095/// # Activities
2096///
2097/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2098/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2099///
2100/// * [instance configs list projects](ProjectInstanceConfigListCall) (response)
2101#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2102#[serde_with::serde_as]
2103#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2104pub struct ListInstanceConfigsResponse {
2105    /// The list of requested instance configurations.
2106    #[serde(rename = "instanceConfigs")]
2107    pub instance_configs: Option<Vec<InstanceConfig>>,
2108    /// `next_page_token` can be sent in a subsequent ListInstanceConfigs call to fetch more of the matching instance configurations.
2109    #[serde(rename = "nextPageToken")]
2110    pub next_page_token: Option<String>,
2111}
2112
2113impl common::ResponseResult for ListInstanceConfigsResponse {}
2114
2115/// The response for ListInstancePartitionOperations.
2116///
2117/// # Activities
2118///
2119/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2120/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2121///
2122/// * [instances instance partition operations list projects](ProjectInstanceInstancePartitionOperationListCall) (response)
2123#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2124#[serde_with::serde_as]
2125#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2126pub struct ListInstancePartitionOperationsResponse {
2127    /// `next_page_token` can be sent in a subsequent ListInstancePartitionOperations call to fetch more of the matching metadata.
2128    #[serde(rename = "nextPageToken")]
2129    pub next_page_token: Option<String>,
2130    /// The list of matching instance partition long-running operations. Each operation's name will be prefixed by the instance partition's name. The operation's metadata field type `metadata.type_url` describes the type of the metadata.
2131    pub operations: Option<Vec<Operation>>,
2132    /// The list of unreachable instance partitions. It includes the names of instance partitions whose operation metadata could not be retrieved within instance_partition_deadline.
2133    #[serde(rename = "unreachableInstancePartitions")]
2134    pub unreachable_instance_partitions: Option<Vec<String>>,
2135}
2136
2137impl common::ResponseResult for ListInstancePartitionOperationsResponse {}
2138
2139/// The response for ListInstancePartitions.
2140///
2141/// # Activities
2142///
2143/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2144/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2145///
2146/// * [instances instance partitions list projects](ProjectInstanceInstancePartitionListCall) (response)
2147#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2148#[serde_with::serde_as]
2149#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2150pub struct ListInstancePartitionsResponse {
2151    /// The list of requested instancePartitions.
2152    #[serde(rename = "instancePartitions")]
2153    pub instance_partitions: Option<Vec<InstancePartition>>,
2154    /// `next_page_token` can be sent in a subsequent ListInstancePartitions call to fetch more of the matching instance partitions.
2155    #[serde(rename = "nextPageToken")]
2156    pub next_page_token: Option<String>,
2157    /// The list of unreachable instances or instance partitions. It includes the names of instances or instance partitions whose metadata could not be retrieved within instance_partition_deadline.
2158    pub unreachable: Option<Vec<String>>,
2159}
2160
2161impl common::ResponseResult for ListInstancePartitionsResponse {}
2162
2163/// The response for ListInstances.
2164///
2165/// # Activities
2166///
2167/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2168/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2169///
2170/// * [instances list projects](ProjectInstanceListCall) (response)
2171#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2172#[serde_with::serde_as]
2173#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2174pub struct ListInstancesResponse {
2175    /// The list of requested instances.
2176    pub instances: Option<Vec<Instance>>,
2177    /// `next_page_token` can be sent in a subsequent ListInstances call to fetch more of the matching instances.
2178    #[serde(rename = "nextPageToken")]
2179    pub next_page_token: Option<String>,
2180    /// The list of unreachable instances. It includes the names of instances whose metadata could not be retrieved within instance_deadline.
2181    pub unreachable: Option<Vec<String>>,
2182}
2183
2184impl common::ResponseResult for ListInstancesResponse {}
2185
2186/// The response message for Operations.ListOperations.
2187///
2188/// # Activities
2189///
2190/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2191/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2192///
2193/// * [instance configs operations list projects](ProjectInstanceConfigOperationListCall1) (response)
2194/// * [instance configs ssd caches operations list projects](ProjectInstanceConfigSsdCachOperationListCall) (response)
2195/// * [instances backups operations list projects](ProjectInstanceBackupOperationListCall1) (response)
2196/// * [instances databases operations list projects](ProjectInstanceDatabaseOperationListCall1) (response)
2197/// * [instances instance partitions operations list projects](ProjectInstanceInstancePartitionOperationListCall1) (response)
2198/// * [instances operations list projects](ProjectInstanceOperationListCall) (response)
2199#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2200#[serde_with::serde_as]
2201#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2202pub struct ListOperationsResponse {
2203    /// The standard List next-page token.
2204    #[serde(rename = "nextPageToken")]
2205    pub next_page_token: Option<String>,
2206    /// A list of operations that matches the specified filter in the request.
2207    pub operations: Option<Vec<Operation>>,
2208    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
2209    pub unreachable: Option<Vec<String>>,
2210}
2211
2212impl common::ResponseResult for ListOperationsResponse {}
2213
2214/// Response method from the ListScans method.
2215///
2216/// # Activities
2217///
2218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2220///
2221/// * [list scans](ScanListCall) (response)
2222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2223#[serde_with::serde_as]
2224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2225pub struct ListScansResponse {
2226    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
2227    #[serde(rename = "nextPageToken")]
2228    pub next_page_token: Option<String>,
2229    /// Available scans based on the list query parameters.
2230    pub scans: Option<Vec<Scan>>,
2231}
2232
2233impl common::ResponseResult for ListScansResponse {}
2234
2235/// The response for ListSessions.
2236///
2237/// # Activities
2238///
2239/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2240/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2241///
2242/// * [instances databases sessions list projects](ProjectInstanceDatabaseSessionListCall) (response)
2243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2244#[serde_with::serde_as]
2245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2246pub struct ListSessionsResponse {
2247    /// `next_page_token` can be sent in a subsequent ListSessions call to fetch more of the matching sessions.
2248    #[serde(rename = "nextPageToken")]
2249    pub next_page_token: Option<String>,
2250    /// The list of requested sessions.
2251    pub sessions: Option<Vec<Session>>,
2252}
2253
2254impl common::ResponseResult for ListSessionsResponse {}
2255
2256/// A message representing a user-facing string whose value may need to be translated before being displayed.
2257///
2258/// This type is not used in any activity, and only used as *part* of another schema.
2259///
2260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2261#[serde_with::serde_as]
2262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2263pub struct LocalizedString {
2264    /// A map of arguments used when creating the localized message. Keys represent parameter names which may be used by the localized version when substituting dynamic values.
2265    pub args: Option<HashMap<String, String>>,
2266    /// The canonical English version of this message. If no token is provided or the front-end has no message associated with the token, this text will be displayed as-is.
2267    pub message: Option<String>,
2268    /// The token identifying the message, e.g. 'METRIC_READ_CPU'. This should be unique within the service.
2269    pub token: Option<String>,
2270}
2271
2272impl common::Part for LocalizedString {}
2273
2274/// A message representing the actual monitoring data, values for each key bucket over time, of a metric.
2275///
2276/// This type is not used in any activity, and only used as *part* of another schema.
2277///
2278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2279#[serde_with::serde_as]
2280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2281pub struct Metric {
2282    /// The aggregation function used to aggregate each key bucket
2283    pub aggregation: Option<String>,
2284    /// The category of the metric, e.g. "Activity", "Alerts", "Reads", etc.
2285    pub category: Option<LocalizedString>,
2286    /// The references to numerator and denominator metrics for a derived metric.
2287    pub derived: Option<DerivedMetric>,
2288    /// The displayed label of the metric.
2289    #[serde(rename = "displayLabel")]
2290    pub display_label: Option<LocalizedString>,
2291    /// Whether the metric has any non-zero data.
2292    #[serde(rename = "hasNonzeroData")]
2293    pub has_nonzero_data: Option<bool>,
2294    /// The value that is considered hot for the metric. On a per metric basis hotness signals high utilization and something that might potentially be a cause for concern by the end user. hot_value is used to calibrate and scale visual color scales.
2295    #[serde(rename = "hotValue")]
2296    pub hot_value: Option<f32>,
2297    /// The (sparse) mapping from time index to an IndexedHotKey message, representing those time intervals for which there are hot keys.
2298    #[serde(rename = "indexedHotKeys")]
2299    pub indexed_hot_keys: Option<HashMap<String, IndexedHotKey>>,
2300    /// The (sparse) mapping from time interval index to an IndexedKeyRangeInfos message, representing those time intervals for which there are informational messages concerning key ranges.
2301    #[serde(rename = "indexedKeyRangeInfos")]
2302    pub indexed_key_range_infos: Option<HashMap<String, IndexedKeyRangeInfos>>,
2303    /// Information about the metric.
2304    pub info: Option<LocalizedString>,
2305    /// The data for the metric as a matrix.
2306    pub matrix: Option<MetricMatrix>,
2307    /// The unit of the metric.
2308    pub unit: Option<LocalizedString>,
2309    /// Whether the metric is visible to the end user.
2310    pub visible: Option<bool>,
2311}
2312
2313impl common::Part for Metric {}
2314
2315/// A message representing a matrix of floats.
2316///
2317/// This type is not used in any activity, and only used as *part* of another schema.
2318///
2319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2320#[serde_with::serde_as]
2321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2322pub struct MetricMatrix {
2323    /// The rows of the matrix.
2324    pub rows: Option<Vec<MetricMatrixRow>>,
2325}
2326
2327impl common::Part for MetricMatrix {}
2328
2329/// A message representing a row of a matrix of floats.
2330///
2331/// This type is not used in any activity, and only used as *part* of another schema.
2332///
2333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2334#[serde_with::serde_as]
2335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2336pub struct MetricMatrixRow {
2337    /// The columns of the row.
2338    pub cols: Option<Vec<f32>>,
2339}
2340
2341impl common::Part for MetricMatrixRow {}
2342
2343/// The request for MoveInstance.
2344///
2345/// # Activities
2346///
2347/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2348/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2349///
2350/// * [instances move projects](ProjectInstanceMoveCall) (request)
2351#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2352#[serde_with::serde_as]
2353#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2354pub struct MoveInstanceRequest {
2355    /// Required. The target instance configuration where to move the instance. Values are of the form `projects//instanceConfigs/`.
2356    #[serde(rename = "targetConfig")]
2357    pub target_config: Option<String>,
2358    /// Optional. The configuration for each database in the target instance configuration.
2359    #[serde(rename = "targetDatabaseMoveConfigs")]
2360    pub target_database_move_configs: Option<Vec<DatabaseMoveConfig>>,
2361}
2362
2363impl common::RequestValue for MoveInstanceRequest {}
2364
2365/// When a read-write transaction is executed on a multiplexed session, this precommit token is sent back to the client as a part of the Transaction message in the BeginTransaction response and also as a part of the ResultSet and PartialResultSet responses.
2366///
2367/// This type is not used in any activity, and only used as *part* of another schema.
2368///
2369#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2370#[serde_with::serde_as]
2371#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2372pub struct MultiplexedSessionPrecommitToken {
2373    /// Opaque precommit token.
2374    #[serde(rename = "precommitToken")]
2375    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2376    pub precommit_token: Option<Vec<u8>>,
2377    /// An incrementing seq number is generated on every precommit token that is returned. Clients should remember the precommit token with the highest sequence number from the current transaction attempt.
2378    #[serde(rename = "seqNum")]
2379    pub seq_num: Option<i32>,
2380}
2381
2382impl common::Part for MultiplexedSessionPrecommitToken {}
2383
2384/// A modification to one or more Cloud Spanner rows. Mutations can be applied to a Cloud Spanner database by sending them in a Commit call.
2385///
2386/// This type is not used in any activity, and only used as *part* of another schema.
2387///
2388#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2389#[serde_with::serde_as]
2390#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2391pub struct Mutation {
2392    /// Ack a message from a queue.
2393    pub ack: Option<Ack>,
2394    /// Delete rows from a table. Succeeds whether or not the named rows were present.
2395    pub delete: Option<Delete>,
2396    /// Insert new rows in a table. If any of the rows already exist, the write or transaction fails with error `ALREADY_EXISTS`.
2397    pub insert: Option<Write>,
2398    /// Like insert, except that if the row already exists, then its column values are overwritten with the ones provided. Any column values not explicitly written are preserved. When using insert_or_update, just as when using insert, all `NOT NULL` columns in the table must be given a value. This holds true even when the row already exists and will therefore actually be updated.
2399    #[serde(rename = "insertOrUpdate")]
2400    pub insert_or_update: Option<Write>,
2401    /// Like insert, except that if the row already exists, it is deleted, and the column values provided are inserted instead. Unlike insert_or_update, this means any values not explicitly written become `NULL`. In an interleaved table, if you create the child table with the `ON DELETE CASCADE` annotation, then replacing a parent row also deletes the child rows. Otherwise, you must delete the child rows before you replace the parent row.
2402    pub replace: Option<Write>,
2403    /// Send a message to a queue.
2404    pub send: Option<Send>,
2405    /// Update existing rows in a table. If any of the rows does not already exist, the transaction fails with error `NOT_FOUND`.
2406    pub update: Option<Write>,
2407}
2408
2409impl common::Part for Mutation {}
2410
2411/// A group of mutations to be committed together. Related mutations should be placed in a group. For example, two mutations inserting rows with the same primary key prefix in both parent and child tables are related.
2412///
2413/// This type is not used in any activity, and only used as *part* of another schema.
2414///
2415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2416#[serde_with::serde_as]
2417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2418pub struct MutationGroup {
2419    /// Required. The mutations in this group.
2420    pub mutations: Option<Vec<Mutation>>,
2421}
2422
2423impl common::Part for MutationGroup {}
2424
2425/// This resource represents a long-running operation that is the result of a network API call.
2426///
2427/// # Activities
2428///
2429/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2430/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2431///
2432/// * [instance configs operations get projects](ProjectInstanceConfigOperationGetCall) (response)
2433/// * [instance configs ssd caches operations get projects](ProjectInstanceConfigSsdCachOperationGetCall) (response)
2434/// * [instance configs create projects](ProjectInstanceConfigCreateCall) (response)
2435/// * [instance configs patch projects](ProjectInstanceConfigPatchCall) (response)
2436/// * [instances backups operations get projects](ProjectInstanceBackupOperationGetCall) (response)
2437/// * [instances backups copy projects](ProjectInstanceBackupCopyCall) (response)
2438/// * [instances backups create projects](ProjectInstanceBackupCreateCall) (response)
2439/// * [instances databases operations get projects](ProjectInstanceDatabaseOperationGetCall) (response)
2440/// * [instances databases changequorum projects](ProjectInstanceDatabaseChangequorumCall) (response)
2441/// * [instances databases create projects](ProjectInstanceDatabaseCreateCall) (response)
2442/// * [instances databases patch projects](ProjectInstanceDatabasePatchCall) (response)
2443/// * [instances databases restore projects](ProjectInstanceDatabaseRestoreCall) (response)
2444/// * [instances databases update ddl projects](ProjectInstanceDatabaseUpdateDdlCall) (response)
2445/// * [instances instance partitions operations get projects](ProjectInstanceInstancePartitionOperationGetCall) (response)
2446/// * [instances instance partitions create projects](ProjectInstanceInstancePartitionCreateCall) (response)
2447/// * [instances instance partitions patch projects](ProjectInstanceInstancePartitionPatchCall) (response)
2448/// * [instances operations get projects](ProjectInstanceOperationGetCall) (response)
2449/// * [instances create projects](ProjectInstanceCreateCall) (response)
2450/// * [instances move projects](ProjectInstanceMoveCall) (response)
2451/// * [instances patch projects](ProjectInstancePatchCall) (response)
2452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2453#[serde_with::serde_as]
2454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2455pub struct Operation {
2456    /// 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.
2457    pub done: Option<bool>,
2458    /// The error result of the operation in case of failure or cancellation.
2459    pub error: Option<Status>,
2460    /// 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.
2461    pub metadata: Option<HashMap<String, serde_json::Value>>,
2462    /// 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}`.
2463    pub name: Option<String>,
2464    /// 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`.
2465    pub response: Option<HashMap<String, serde_json::Value>>,
2466}
2467
2468impl common::ResponseResult for Operation {}
2469
2470/// Partial results from a streaming read or SQL query. Streaming reads and SQL queries better tolerate large result sets, large rows, and large values, but are a little trickier to consume.
2471///
2472/// # Activities
2473///
2474/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2475/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2476///
2477/// * [instances databases sessions execute streaming sql projects](ProjectInstanceDatabaseSessionExecuteStreamingSqlCall) (response)
2478/// * [instances databases sessions streaming read projects](ProjectInstanceDatabaseSessionStreamingReadCall) (response)
2479#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2480#[serde_with::serde_as]
2481#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2482pub struct PartialResultSet {
2483    /// If true, then the final value in values is chunked, and must be combined with more values from subsequent `PartialResultSet`s to obtain a complete field value.
2484    #[serde(rename = "chunkedValue")]
2485    pub chunked_value: Option<bool>,
2486    /// Optional. Indicates whether this is the last `PartialResultSet` in the stream. The server might optionally set this field. Clients shouldn't rely on this field being set in all cases.
2487    pub last: Option<bool>,
2488    /// Metadata about the result set, such as row type information. Only present in the first response.
2489    pub metadata: Option<ResultSetMetadata>,
2490    /// Optional. A precommit token is included if the read-write transaction has multiplexed sessions enabled. Pass the precommit token with the highest sequence number from this transaction attempt to the Commit request for this transaction.
2491    #[serde(rename = "precommitToken")]
2492    pub precommit_token: Option<MultiplexedSessionPrecommitToken>,
2493    /// Streaming calls might be interrupted for a variety of reasons, such as TCP connection loss. If this occurs, the stream of results can be resumed by re-sending the original request and including `resume_token`. Note that executing any other transaction in the same session invalidates the token.
2494    #[serde(rename = "resumeToken")]
2495    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2496    pub resume_token: Option<Vec<u8>>,
2497    /// Query plan and execution statistics for the statement that produced this streaming result set. These can be requested by setting ExecuteSqlRequest.query_mode and are sent only once with the last response in the stream. This field is also present in the last response for DML statements.
2498    pub stats: Option<ResultSetStats>,
2499    /// A streamed result set consists of a stream of values, which might be split into many `PartialResultSet` messages to accommodate large rows and/or large values. Every N complete values defines a row, where N is equal to the number of entries in metadata.row_type.fields. Most values are encoded based on type as described here. It's possible that the last value in values is "chunked", meaning that the rest of the value is sent in subsequent `PartialResultSet`(s). This is denoted by the chunked_value field. Two or more chunked values can be merged to form a complete value as follows: * `bool/number/null`: can't be chunked * `string`: concatenate the strings * `list`: concatenate the lists. If the last element in a list is a `string`, `list`, or `object`, merge it with the first element in the next list by applying these rules recursively. * `object`: concatenate the (field name, field value) pairs. If a field name is duplicated, then apply these rules recursively to merge the field values. Some examples of merging: Strings are concatenated. "foo", "bar" => "foobar" Lists of non-strings are concatenated. [2, 3], [4] => [2, 3, 4] Lists are concatenated, but the last and first elements are merged because they are strings. ["a", "b"], ["c", "d"] => ["a", "bc", "d"] Lists are concatenated, but the last and first elements are merged because they are lists. Recursively, the last and first elements of the inner lists are merged because they are strings. ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"] Non-overlapping object fields are combined. {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"} Overlapping object fields are merged. {"a": "1"}, {"a": "2"} => {"a": "12"} Examples of merging objects containing lists of strings. {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]} For a more complete example, suppose a streaming SQL query is yielding a result set whose rows contain a single string field. The following `PartialResultSet`s might be yielded: { "metadata": { ... } "values": ["Hello", "W"] "chunked_value": true "resume_token": "Af65..." } { "values": ["orl"] "chunked_value": true } { "values": ["d"] "resume_token": "Zx1B..." } This sequence of `PartialResultSet`s encodes two rows, one containing the field value `"Hello"`, and a second containing the field value `"World" = "W" + "orl" + "d"`. Not all `PartialResultSet`s contain a `resume_token`. Execution can only be resumed from a previously yielded `resume_token`. For the above sequence of `PartialResultSet`s, resuming the query with `"resume_token": "Af65..."` yields results from the `PartialResultSet` with value "orl".
2500    pub values: Option<Vec<serde_json::Value>>,
2501}
2502
2503impl common::ResponseResult for PartialResultSet {}
2504
2505/// Information returned for each partition returned in a PartitionResponse.
2506///
2507/// This type is not used in any activity, and only used as *part* of another schema.
2508///
2509#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2510#[serde_with::serde_as]
2511#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2512pub struct Partition {
2513    /// This token can be passed to `Read`, `StreamingRead`, `ExecuteSql`, or `ExecuteStreamingSql` requests to restrict the results to those identified by this partition token.
2514    #[serde(rename = "partitionToken")]
2515    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2516    pub partition_token: Option<Vec<u8>>,
2517}
2518
2519impl common::Part for Partition {}
2520
2521/// Options for a `PartitionQueryRequest` and `PartitionReadRequest`.
2522///
2523/// This type is not used in any activity, and only used as *part* of another schema.
2524///
2525#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2526#[serde_with::serde_as]
2527#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2528pub struct PartitionOptions {
2529    /// **Note:** This hint is currently ignored by `PartitionQuery` and `PartitionRead` requests. The desired maximum number of partitions to return. For example, this might be set to the number of workers available. The default for this option is currently 10,000. The maximum value is currently 200,000. This is only a hint. The actual number of partitions returned can be smaller or larger than this maximum count request.
2530    #[serde(rename = "maxPartitions")]
2531    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2532    pub max_partitions: Option<i64>,
2533    /// **Note:** This hint is currently ignored by `PartitionQuery` and `PartitionRead` requests. The desired data size for each partition generated. The default for this option is currently 1 GiB. This is only a hint. The actual size of each partition can be smaller or larger than this size request.
2534    #[serde(rename = "partitionSizeBytes")]
2535    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2536    pub partition_size_bytes: Option<i64>,
2537}
2538
2539impl common::Part for PartitionOptions {}
2540
2541/// The request for PartitionQuery
2542///
2543/// # Activities
2544///
2545/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2546/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2547///
2548/// * [instances databases sessions partition query projects](ProjectInstanceDatabaseSessionPartitionQueryCall) (request)
2549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2550#[serde_with::serde_as]
2551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2552pub struct PartitionQueryRequest {
2553    /// It isn't always possible for Cloud Spanner to infer the right SQL type from a JSON value. For example, values of type `BYTES` and values of type `STRING` both appear in params as JSON strings. In these cases, `param_types` can be used to specify the exact SQL type for some or all of the SQL query parameters. See the definition of Type for more information about SQL types.
2554    #[serde(rename = "paramTypes")]
2555    pub param_types: Option<HashMap<String, Type>>,
2556    /// Parameter names and values that bind to placeholders in the SQL string. A parameter placeholder consists of the `@` character followed by the parameter name (for example, `@firstName`). Parameter names can contain letters, numbers, and underscores. Parameters can appear anywhere that a literal value is expected. The same parameter name can be used more than once, for example: `"WHERE id > @msg_id AND id < @msg_id + 100"` It's an error to execute a SQL statement with unbound parameters.
2557    pub params: Option<HashMap<String, serde_json::Value>>,
2558    /// Additional options that affect how many partitions are created.
2559    #[serde(rename = "partitionOptions")]
2560    pub partition_options: Option<PartitionOptions>,
2561    /// Required. The query request to generate partitions for. The request fails if the query isn't root partitionable. For a query to be root partitionable, it needs to satisfy a few conditions. For example, if the query execution plan contains a distributed union operator, then it must be the first operator in the plan. For more information about other conditions, see [Read data in parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel). The query request must not contain DML commands, such as `INSERT`, `UPDATE`, or `DELETE`. Use `ExecuteStreamingSql` with a `PartitionedDml` transaction for large, partition-friendly DML operations.
2562    pub sql: Option<String>,
2563    /// Read-only snapshot transactions are supported, read and write and single-use transactions are not.
2564    pub transaction: Option<TransactionSelector>,
2565}
2566
2567impl common::RequestValue for PartitionQueryRequest {}
2568
2569/// The request for PartitionRead
2570///
2571/// # Activities
2572///
2573/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2574/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2575///
2576/// * [instances databases sessions partition read projects](ProjectInstanceDatabaseSessionPartitionReadCall) (request)
2577#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2578#[serde_with::serde_as]
2579#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2580pub struct PartitionReadRequest {
2581    /// The columns of table to be returned for each row matching this request.
2582    pub columns: Option<Vec<String>>,
2583    /// If non-empty, the name of an index on table. This index is used instead of the table primary key when interpreting key_set and sorting result rows. See key_set for further information.
2584    pub index: Option<String>,
2585    /// Required. `key_set` identifies the rows to be yielded. `key_set` names the primary keys of the rows in table to be yielded, unless index is present. If index is present, then key_set instead names index keys in index. It isn't an error for the `key_set` to name rows that don't exist in the database. Read yields nothing for nonexistent rows.
2586    #[serde(rename = "keySet")]
2587    pub key_set: Option<KeySet>,
2588    /// Additional options that affect how many partitions are created.
2589    #[serde(rename = "partitionOptions")]
2590    pub partition_options: Option<PartitionOptions>,
2591    /// Required. The name of the table in the database to be read.
2592    pub table: Option<String>,
2593    /// Read only snapshot transactions are supported, read/write and single use transactions are not.
2594    pub transaction: Option<TransactionSelector>,
2595}
2596
2597impl common::RequestValue for PartitionReadRequest {}
2598
2599/// The response for PartitionQuery or PartitionRead
2600///
2601/// # Activities
2602///
2603/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2604/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2605///
2606/// * [instances databases sessions partition query projects](ProjectInstanceDatabaseSessionPartitionQueryCall) (response)
2607/// * [instances databases sessions partition read projects](ProjectInstanceDatabaseSessionPartitionReadCall) (response)
2608#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2609#[serde_with::serde_as]
2610#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2611pub struct PartitionResponse {
2612    /// Partitions created by this request.
2613    pub partitions: Option<Vec<Partition>>,
2614    /// Transaction created by this request.
2615    pub transaction: Option<Transaction>,
2616}
2617
2618impl common::ResponseResult for PartitionResponse {}
2619
2620/// Message type to initiate a Partitioned DML transaction.
2621///
2622/// This type is not used in any activity, and only used as *part* of another schema.
2623///
2624#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2625#[serde_with::serde_as]
2626#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2627pub struct PartitionedDml {
2628    _never_set: Option<bool>,
2629}
2630
2631impl common::Part for PartitionedDml {}
2632
2633/// Node information for nodes appearing in a QueryPlan.plan_nodes.
2634///
2635/// This type is not used in any activity, and only used as *part* of another schema.
2636///
2637#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2638#[serde_with::serde_as]
2639#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2640pub struct PlanNode {
2641    /// List of child node `index`es and their relationship to this parent.
2642    #[serde(rename = "childLinks")]
2643    pub child_links: Option<Vec<ChildLink>>,
2644    /// The display name for the node.
2645    #[serde(rename = "displayName")]
2646    pub display_name: Option<String>,
2647    /// The execution statistics associated with the node, contained in a group of key-value pairs. Only present if the plan was returned as a result of a profile query. For example, number of executions, number of rows/time per execution etc.
2648    #[serde(rename = "executionStats")]
2649    pub execution_stats: Option<HashMap<String, serde_json::Value>>,
2650    /// The `PlanNode`'s index in node list.
2651    pub index: Option<i32>,
2652    /// Used to determine the type of node. May be needed for visualizing different kinds of nodes differently. For example, If the node is a SCALAR node, it will have a condensed representation which can be used to directly embed a description of the node in its parent.
2653    pub kind: Option<String>,
2654    /// Attributes relevant to the node contained in a group of key-value pairs. For example, a Parameter Reference node could have the following information in its metadata: { "parameter_reference": "param1", "parameter_type": "array" }
2655    pub metadata: Option<HashMap<String, serde_json::Value>>,
2656    /// Condensed representation for SCALAR nodes.
2657    #[serde(rename = "shortRepresentation")]
2658    pub short_representation: Option<ShortRepresentation>,
2659}
2660
2661impl common::Part for PlanNode {}
2662
2663/// 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/).
2664///
2665/// # Activities
2666///
2667/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2668/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2669///
2670/// * [instances backups get iam policy projects](ProjectInstanceBackupGetIamPolicyCall) (response)
2671/// * [instances backups set iam policy projects](ProjectInstanceBackupSetIamPolicyCall) (response)
2672/// * [instances databases backup schedules get iam policy projects](ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall) (response)
2673/// * [instances databases backup schedules set iam policy projects](ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall) (response)
2674/// * [instances databases get iam policy projects](ProjectInstanceDatabaseGetIamPolicyCall) (response)
2675/// * [instances databases set iam policy projects](ProjectInstanceDatabaseSetIamPolicyCall) (response)
2676/// * [instances get iam policy projects](ProjectInstanceGetIamPolicyCall) (response)
2677/// * [instances set iam policy projects](ProjectInstanceSetIamPolicyCall) (response)
2678#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2679#[serde_with::serde_as]
2680#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2681pub struct Policy {
2682    /// 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`.
2683    pub bindings: Option<Vec<Binding>>,
2684    /// `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.
2685    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2686    pub etag: Option<Vec<u8>>,
2687    /// 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).
2688    pub version: Option<i32>,
2689}
2690
2691impl common::ResponseResult for Policy {}
2692
2693/// A message representing a key prefix node in the key prefix hierarchy. for eg. Bigtable keyspaces are lexicographically ordered mappings of keys to values. Keys often have a shared prefix structure where users use the keys to organize data. Eg ///employee In this case Keysight will possibly use one node for a company and reuse it for all employees that fall under the company. Doing so improves legibility in the UI.
2694///
2695/// This type is not used in any activity, and only used as *part* of another schema.
2696///
2697#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2698#[serde_with::serde_as]
2699#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2700pub struct PrefixNode {
2701    /// Whether this corresponds to a data_source name.
2702    #[serde(rename = "dataSourceNode")]
2703    pub data_source_node: Option<bool>,
2704    /// The depth in the prefix hierarchy.
2705    pub depth: Option<i32>,
2706    /// The index of the end key bucket of the range that this node spans.
2707    #[serde(rename = "endIndex")]
2708    pub end_index: Option<i32>,
2709    /// The index of the start key bucket of the range that this node spans.
2710    #[serde(rename = "startIndex")]
2711    pub start_index: Option<i32>,
2712    /// The string represented by the prefix node.
2713    pub word: Option<String>,
2714}
2715
2716impl common::Part for PrefixNode {}
2717
2718/// Output of query advisor analysis.
2719///
2720/// This type is not used in any activity, and only used as *part* of another schema.
2721///
2722#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2723#[serde_with::serde_as]
2724#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2725pub struct QueryAdvisorResult {
2726    /// Optional. Index Recommendation for a query. This is an optional field and the recommendation will only be available when the recommendation guarantees significant improvement in query performance.
2727    #[serde(rename = "indexAdvice")]
2728    pub index_advice: Option<Vec<IndexAdvice>>,
2729}
2730
2731impl common::Part for QueryAdvisorResult {}
2732
2733/// Query optimizer configuration.
2734///
2735/// This type is not used in any activity, and only used as *part* of another schema.
2736///
2737#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2738#[serde_with::serde_as]
2739#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2740pub struct QueryOptions {
2741    /// An option to control the selection of optimizer statistics package. This parameter allows individual queries to use a different query optimizer statistics package. Specifying `latest` as a value instructs Cloud Spanner to use the latest generated statistics package. If not specified, Cloud Spanner uses the statistics package set at the database level options, or the latest package if the database option isn't set. The statistics package requested by the query has to be exempt from garbage collection. This can be achieved with the following DDL statement: ```sql ALTER STATISTICS SET OPTIONS (allow_gc=false) ``` The list of available statistics packages can be queried from `INFORMATION_SCHEMA.SPANNER_STATISTICS`. Executing a SQL statement with an invalid optimizer statistics package or with a statistics package that allows garbage collection fails with an `INVALID_ARGUMENT` error.
2742    #[serde(rename = "optimizerStatisticsPackage")]
2743    pub optimizer_statistics_package: Option<String>,
2744    /// An option to control the selection of optimizer version. This parameter allows individual queries to pick different query optimizer versions. Specifying `latest` as a value instructs Cloud Spanner to use the latest supported query optimizer version. If not specified, Cloud Spanner uses the optimizer version set at the database level options. Any other positive integer (from the list of supported optimizer versions) overrides the default optimizer version for query execution. The list of supported optimizer versions can be queried from `SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS`. Executing a SQL statement with an invalid optimizer version fails with an `INVALID_ARGUMENT` error. See https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer for more information on managing the query optimizer. The `optimizer_version` statement hint has precedence over this setting.
2745    #[serde(rename = "optimizerVersion")]
2746    pub optimizer_version: Option<String>,
2747}
2748
2749impl common::Part for QueryOptions {}
2750
2751/// Contains an ordered list of nodes appearing in the query plan.
2752///
2753/// This type is not used in any activity, and only used as *part* of another schema.
2754///
2755#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2756#[serde_with::serde_as]
2757#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2758pub struct QueryPlan {
2759    /// The nodes in the query plan. Plan nodes are returned in pre-order starting with the plan root. Each PlanNode's `id` corresponds to its index in `plan_nodes`.
2760    #[serde(rename = "planNodes")]
2761    pub plan_nodes: Option<Vec<PlanNode>>,
2762    /// Optional. The advise/recommendations for a query. Currently this field will be serving index recommendations for a query.
2763    #[serde(rename = "queryAdvice")]
2764    pub query_advice: Option<QueryAdvisorResult>,
2765}
2766
2767impl common::Part for QueryPlan {}
2768
2769/// Information about the dual-region quorum.
2770///
2771/// This type is not used in any activity, and only used as *part* of another schema.
2772///
2773#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2774#[serde_with::serde_as]
2775#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2776pub struct QuorumInfo {
2777    /// Output only. The etag is used for optimistic concurrency control as a way to help prevent simultaneous `ChangeQuorum` requests that might create a race condition.
2778    pub etag: Option<String>,
2779    /// Output only. Whether this `ChangeQuorum` is Google or User initiated.
2780    pub initiator: Option<String>,
2781    /// Output only. The type of this quorum. See QuorumType for more information about quorum type specifications.
2782    #[serde(rename = "quorumType")]
2783    pub quorum_type: Option<QuorumType>,
2784    /// Output only. The timestamp when the request was triggered.
2785    #[serde(rename = "startTime")]
2786    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2787}
2788
2789impl common::Part for QuorumInfo {}
2790
2791/// Information about the database quorum type. This only applies to dual-region instance configs.
2792///
2793/// This type is not used in any activity, and only used as *part* of another schema.
2794///
2795#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2796#[serde_with::serde_as]
2797#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2798pub struct QuorumType {
2799    /// Dual-region quorum type.
2800    #[serde(rename = "dualRegion")]
2801    pub dual_region: Option<DualRegionQuorum>,
2802    /// Single-region quorum type.
2803    #[serde(rename = "singleRegion")]
2804    pub single_region: Option<SingleRegionQuorum>,
2805}
2806
2807impl common::Part for QuorumType {}
2808
2809/// Message type to initiate a read-only transaction.
2810///
2811/// This type is not used in any activity, and only used as *part* of another schema.
2812///
2813#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2814#[serde_with::serde_as]
2815#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2816pub struct ReadOnly {
2817    /// Executes all reads at a timestamp that is `exact_staleness` old. The timestamp is chosen soon after the read is started. Guarantees that all writes that have committed more than the specified number of seconds ago are visible. Because Cloud Spanner chooses the exact timestamp, this mode works even if the client's local clock is substantially skewed from Cloud Spanner commit timestamps. Useful for reading at nearby replicas without the distributed timestamp negotiation overhead of `max_staleness`.
2818    #[serde(rename = "exactStaleness")]
2819    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2820    pub exact_staleness: Option<chrono::Duration>,
2821    /// Read data at a timestamp >= `NOW - max_staleness` seconds. Guarantees that all writes that have committed more than the specified number of seconds ago are visible. Because Cloud Spanner chooses the exact timestamp, this mode works even if the client's local clock is substantially skewed from Cloud Spanner commit timestamps. Useful for reading the freshest data available at a nearby replica, while bounding the possible staleness if the local replica has fallen behind. Note that this option can only be used in single-use transactions.
2822    #[serde(rename = "maxStaleness")]
2823    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2824    pub max_staleness: Option<chrono::Duration>,
2825    /// Executes all reads at a timestamp >= `min_read_timestamp`. This is useful for requesting fresher data than some previous read, or data that is fresh enough to observe the effects of some previously committed transaction whose timestamp is known. Note that this option can only be used in single-use transactions. A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. Example: `"2014-10-02T15:01:23.045123456Z"`.
2826    #[serde(rename = "minReadTimestamp")]
2827    pub min_read_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
2828    /// Executes all reads at the given timestamp. Unlike other modes, reads at a specific timestamp are repeatable; the same read at the same timestamp always returns the same data. If the timestamp is in the future, the read is blocked until the specified timestamp, modulo the read's deadline. Useful for large scale consistent reads such as mapreduces, or for coordinating many reads against a consistent snapshot of the data. A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. Example: `"2014-10-02T15:01:23.045123456Z"`.
2829    #[serde(rename = "readTimestamp")]
2830    pub read_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
2831    /// If true, the Cloud Spanner-selected read timestamp is included in the Transaction message that describes the transaction.
2832    #[serde(rename = "returnReadTimestamp")]
2833    pub return_read_timestamp: Option<bool>,
2834    /// Read at a timestamp where all previously committed transactions are visible.
2835    pub strong: Option<bool>,
2836}
2837
2838impl common::Part for ReadOnly {}
2839
2840/// The request for Read and StreamingRead.
2841///
2842/// # Activities
2843///
2844/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2845/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2846///
2847/// * [instances databases sessions read projects](ProjectInstanceDatabaseSessionReadCall) (request)
2848/// * [instances databases sessions streaming read projects](ProjectInstanceDatabaseSessionStreamingReadCall) (request)
2849#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2850#[serde_with::serde_as]
2851#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2852pub struct ReadRequest {
2853    /// Required. The columns of table to be returned for each row matching this request.
2854    pub columns: Option<Vec<String>>,
2855    /// If this is for a partitioned read and this field is set to `true`, the request is executed with Spanner Data Boost independent compute resources. If the field is set to `true` but the request doesn't set `partition_token`, the API returns an `INVALID_ARGUMENT` error.
2856    #[serde(rename = "dataBoostEnabled")]
2857    pub data_boost_enabled: Option<bool>,
2858    /// Directed read options for this request.
2859    #[serde(rename = "directedReadOptions")]
2860    pub directed_read_options: Option<DirectedReadOptions>,
2861    /// If non-empty, the name of an index on table. This index is used instead of the table primary key when interpreting key_set and sorting result rows. See key_set for further information.
2862    pub index: Option<String>,
2863    /// Required. `key_set` identifies the rows to be yielded. `key_set` names the primary keys of the rows in table to be yielded, unless index is present. If index is present, then key_set instead names index keys in index. If the partition_token field is empty, rows are yielded in table primary key order (if index is empty) or index key order (if index is non-empty). If the partition_token field isn't empty, rows are yielded in an unspecified order. It isn't an error for the `key_set` to name rows that don't exist in the database. Read yields nothing for nonexistent rows.
2864    #[serde(rename = "keySet")]
2865    pub key_set: Option<KeySet>,
2866    /// If greater than zero, only the first `limit` rows are yielded. If `limit` is zero, the default is no limit. A limit can't be specified if `partition_token` is set.
2867    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2868    pub limit: Option<i64>,
2869    /// Optional. Lock Hint for the request, it can only be used with read-write transactions.
2870    #[serde(rename = "lockHint")]
2871    pub lock_hint: Option<String>,
2872    /// Optional. Order for the returned rows. By default, Spanner returns result rows in primary key order except for PartitionRead requests. For applications that don't require rows to be returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval, resulting in lower latencies in certain cases (for example, bulk point lookups).
2873    #[serde(rename = "orderBy")]
2874    pub order_by: Option<String>,
2875    /// If present, results are restricted to the specified partition previously created using `PartitionRead`. There must be an exact match for the values of fields common to this message and the PartitionReadRequest message used to create this partition_token.
2876    #[serde(rename = "partitionToken")]
2877    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2878    pub partition_token: Option<Vec<u8>>,
2879    /// Common options for this request.
2880    #[serde(rename = "requestOptions")]
2881    pub request_options: Option<RequestOptions>,
2882    /// If this request is resuming a previously interrupted read, `resume_token` should be copied from the last PartialResultSet yielded before the interruption. Doing this enables the new read to resume where the last read left off. The rest of the request parameters must exactly match the request that yielded this token.
2883    #[serde(rename = "resumeToken")]
2884    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2885    pub resume_token: Option<Vec<u8>>,
2886    /// Required. The name of the table in the database to be read.
2887    pub table: Option<String>,
2888    /// The transaction to use. If none is provided, the default is a temporary read-only transaction with strong concurrency.
2889    pub transaction: Option<TransactionSelector>,
2890}
2891
2892impl common::RequestValue for ReadRequest {}
2893
2894/// Message type to initiate a read-write transaction. Currently this transaction type has no options.
2895///
2896/// This type is not used in any activity, and only used as *part* of another schema.
2897///
2898#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2899#[serde_with::serde_as]
2900#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2901pub struct ReadWrite {
2902    /// Optional. Clients should pass the transaction ID of the previous transaction attempt that was aborted if this transaction is being executed on a multiplexed session.
2903    #[serde(rename = "multiplexedSessionPreviousTransactionId")]
2904    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2905    pub multiplexed_session_previous_transaction_id: Option<Vec<u8>>,
2906    /// Read lock mode for the transaction.
2907    #[serde(rename = "readLockMode")]
2908    pub read_lock_mode: Option<String>,
2909}
2910
2911impl common::Part for ReadWrite {}
2912
2913/// ReplicaComputeCapacity describes the amount of server resources that are allocated to each replica identified by the replica selection.
2914///
2915/// This type is not used in any activity, and only used as *part* of another schema.
2916///
2917#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2918#[serde_with::serde_as]
2919#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2920pub struct ReplicaComputeCapacity {
2921    /// The number of nodes allocated to each replica. This may be zero in API responses for instances that are not yet in state `READY`.
2922    #[serde(rename = "nodeCount")]
2923    pub node_count: Option<i32>,
2924    /// The number of processing units allocated to each replica. This may be zero in API responses for instances that are not yet in state `READY`.
2925    #[serde(rename = "processingUnits")]
2926    pub processing_units: Option<i32>,
2927    /// Required. Identifies replicas by specified properties. All replicas in the selection have the same amount of compute capacity.
2928    #[serde(rename = "replicaSelection")]
2929    pub replica_selection: Option<InstanceReplicaSelection>,
2930}
2931
2932impl common::Part for ReplicaComputeCapacity {}
2933
2934/// There is no detailed description.
2935///
2936/// This type is not used in any activity, and only used as *part* of another schema.
2937///
2938#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2939#[serde_with::serde_as]
2940#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2941pub struct ReplicaInfo {
2942    /// If true, this location is designated as the default leader location where leader replicas are placed. See the [region types documentation](https://cloud.google.com/spanner/docs/instances#region_types) for more details.
2943    #[serde(rename = "defaultLeaderLocation")]
2944    pub default_leader_location: Option<bool>,
2945    /// The location of the serving resources, e.g., "us-central1".
2946    pub location: Option<String>,
2947    /// The type of replica.
2948    #[serde(rename = "type")]
2949    pub type_: Option<String>,
2950}
2951
2952impl common::Part for ReplicaInfo {}
2953
2954/// The directed read replica selector. Callers must provide one or more of the following fields for replica selection: * `location` - The location must be one of the regions within the multi-region configuration of your database. * `type` - The type of the replica. Some examples of using replica_selectors are: * `location:us-east1` --> The "us-east1" replica(s) of any available type is used to process the request. * `type:READ_ONLY` --> The "READ_ONLY" type replica(s) in the nearest available location are used to process the request. * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s) in location "us-east1" is used to process the request.
2955///
2956/// This type is not used in any activity, and only used as *part* of another schema.
2957///
2958#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2959#[serde_with::serde_as]
2960#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2961pub struct ReplicaSelection {
2962    /// The location or region of the serving requests, for example, "us-east1".
2963    pub location: Option<String>,
2964    /// The type of replica.
2965    #[serde(rename = "type")]
2966    pub type_: Option<String>,
2967}
2968
2969impl common::Part for ReplicaSelection {}
2970
2971/// Common request options for various APIs.
2972///
2973/// This type is not used in any activity, and only used as *part* of another schema.
2974///
2975#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2976#[serde_with::serde_as]
2977#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2978pub struct RequestOptions {
2979    /// Priority for the request.
2980    pub priority: Option<String>,
2981    /// A per-request tag which can be applied to queries or reads, used for statistics collection. Both `request_tag` and `transaction_tag` can be specified for a read or query that belongs to a transaction. This field is ignored for requests where it's not applicable (for example, `CommitRequest`). Legal characters for `request_tag` values are all printable characters (ASCII 32 - 126) and the length of a request_tag is limited to 50 characters. Values that exceed this limit are truncated. Any leading underscore (_) characters are removed from the string.
2982    #[serde(rename = "requestTag")]
2983    pub request_tag: Option<String>,
2984    /// A tag used for statistics collection about this transaction. Both `request_tag` and `transaction_tag` can be specified for a read or query that belongs to a transaction. The value of transaction_tag should be the same for all requests belonging to the same transaction. If this request doesn't belong to any transaction, `transaction_tag` is ignored. Legal characters for `transaction_tag` values are all printable characters (ASCII 32 - 126) and the length of a `transaction_tag` is limited to 50 characters. Values that exceed this limit are truncated. Any leading underscore (_) characters are removed from the string.
2985    #[serde(rename = "transactionTag")]
2986    pub transaction_tag: Option<String>,
2987}
2988
2989impl common::Part for RequestOptions {}
2990
2991/// Encryption configuration for the restored database.
2992///
2993/// This type is not used in any activity, and only used as *part* of another schema.
2994///
2995#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2996#[serde_with::serde_as]
2997#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2998pub struct RestoreDatabaseEncryptionConfig {
2999    /// Required. The encryption type of the restored database.
3000    #[serde(rename = "encryptionType")]
3001    pub encryption_type: Option<String>,
3002    /// Optional. This field is maintained for backwards compatibility. For new callers, we recommend using `kms_key_names` to specify the KMS key. Only use `kms_key_name` if the location of the KMS key matches the database instance's configuration (location) exactly. For example, if the KMS location is in `us-central1` or `nam3`, then the database instance must also be in `us-central1` or `nam3`. The Cloud KMS key that is used to encrypt and decrypt the restored database. Set this field only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
3003    #[serde(rename = "kmsKeyName")]
3004    pub kms_key_name: Option<String>,
3005    /// Optional. Specifies the KMS configuration for one or more keys used to encrypt the database. Values have the form `projects//locations//keyRings//cryptoKeys/`. The keys referenced by `kms_key_names` must fully cover all regions of the database's instance configuration. Some examples: * For regional (single-region) instance configurations, specify a regional location KMS key. * For multi-region instance configurations of type `GOOGLE_MANAGED`, either specify a multi-region location KMS key or multiple regional location KMS keys that cover all regions in the instance configuration. * For an instance configuration of type `USER_MANAGED`, specify only regional location KMS keys to cover each region in the instance configuration. Multi-region location KMS keys aren't supported for `USER_MANAGED` type instance configurations.
3006    #[serde(rename = "kmsKeyNames")]
3007    pub kms_key_names: Option<Vec<String>>,
3008}
3009
3010impl common::Part for RestoreDatabaseEncryptionConfig {}
3011
3012/// The request for RestoreDatabase.
3013///
3014/// # Activities
3015///
3016/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3017/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3018///
3019/// * [instances databases restore projects](ProjectInstanceDatabaseRestoreCall) (request)
3020#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3021#[serde_with::serde_as]
3022#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3023pub struct RestoreDatabaseRequest {
3024    /// Name of the backup from which to restore. Values are of the form `projects//instances//backups/`.
3025    pub backup: Option<String>,
3026    /// Required. The id of the database to create and restore to. This database must not already exist. The `database_id` appended to `parent` forms the full database name of the form `projects//instances//databases/`.
3027    #[serde(rename = "databaseId")]
3028    pub database_id: Option<String>,
3029    /// Optional. An encryption configuration describing the encryption type and key resources in Cloud KMS used to encrypt/decrypt the database to restore to. If this field is not specified, the restored database will use the same encryption configuration as the backup by default, namely encryption_type = `USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION`.
3030    #[serde(rename = "encryptionConfig")]
3031    pub encryption_config: Option<RestoreDatabaseEncryptionConfig>,
3032}
3033
3034impl common::RequestValue for RestoreDatabaseRequest {}
3035
3036/// Information about the database restore.
3037///
3038/// This type is not used in any activity, and only used as *part* of another schema.
3039///
3040#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3041#[serde_with::serde_as]
3042#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3043pub struct RestoreInfo {
3044    /// Information about the backup used to restore the database. The backup may no longer exist.
3045    #[serde(rename = "backupInfo")]
3046    pub backup_info: Option<BackupInfo>,
3047    /// The type of the restore source.
3048    #[serde(rename = "sourceType")]
3049    pub source_type: Option<String>,
3050}
3051
3052impl common::Part for RestoreInfo {}
3053
3054/// Results from Read or ExecuteSql.
3055///
3056/// # Activities
3057///
3058/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3059/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3060///
3061/// * [instances databases sessions execute sql projects](ProjectInstanceDatabaseSessionExecuteSqlCall) (response)
3062/// * [instances databases sessions read projects](ProjectInstanceDatabaseSessionReadCall) (response)
3063#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3064#[serde_with::serde_as]
3065#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3066pub struct ResultSet {
3067    /// Metadata about the result set, such as row type information.
3068    pub metadata: Option<ResultSetMetadata>,
3069    /// Optional. A precommit token is included if the read-write transaction is on a multiplexed session. Pass the precommit token with the highest sequence number from this transaction attempt to the Commit request for this transaction.
3070    #[serde(rename = "precommitToken")]
3071    pub precommit_token: Option<MultiplexedSessionPrecommitToken>,
3072    /// Each element in `rows` is a row whose format is defined by metadata.row_type. The ith element in each row matches the ith field in metadata.row_type. Elements are encoded based on type as described here.
3073    pub rows: Option<Vec<Vec<serde_json::Value>>>,
3074    /// Query plan and execution statistics for the SQL statement that produced this result set. These can be requested by setting ExecuteSqlRequest.query_mode. DML statements always produce stats containing the number of rows modified, unless executed using the ExecuteSqlRequest.QueryMode.PLAN ExecuteSqlRequest.query_mode. Other fields might or might not be populated, based on the ExecuteSqlRequest.query_mode.
3075    pub stats: Option<ResultSetStats>,
3076}
3077
3078impl common::ResponseResult for ResultSet {}
3079
3080/// Metadata about a ResultSet or PartialResultSet.
3081///
3082/// This type is not used in any activity, and only used as *part* of another schema.
3083///
3084#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3085#[serde_with::serde_as]
3086#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3087pub struct ResultSetMetadata {
3088    /// Indicates the field names and types for the rows in the result set. For example, a SQL query like `"SELECT UserId, UserName FROM Users"` could return a `row_type` value like: "fields": [ { "name": "UserId", "type": { "code": "INT64" } }, { "name": "UserName", "type": { "code": "STRING" } }, ]
3089    #[serde(rename = "rowType")]
3090    pub row_type: Option<StructType>,
3091    /// If the read or SQL query began a transaction as a side-effect, the information about the new transaction is yielded here.
3092    pub transaction: Option<Transaction>,
3093    /// A SQL query can be parameterized. In PLAN mode, these parameters can be undeclared. This indicates the field names and types for those undeclared parameters in the SQL query. For example, a SQL query like `"SELECT * FROM Users where UserId = @userId and UserName = @userName "` could return a `undeclared_parameters` value like: "fields": [ { "name": "UserId", "type": { "code": "INT64" } }, { "name": "UserName", "type": { "code": "STRING" } }, ]
3094    #[serde(rename = "undeclaredParameters")]
3095    pub undeclared_parameters: Option<StructType>,
3096}
3097
3098impl common::Part for ResultSetMetadata {}
3099
3100/// Additional statistics about a ResultSet or PartialResultSet.
3101///
3102/// This type is not used in any activity, and only used as *part* of another schema.
3103///
3104#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3105#[serde_with::serde_as]
3106#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3107pub struct ResultSetStats {
3108    /// QueryPlan for the query associated with this result.
3109    #[serde(rename = "queryPlan")]
3110    pub query_plan: Option<QueryPlan>,
3111    /// Aggregated statistics from the execution of the query. Only present when the query is profiled. For example, a query could return the statistics as follows: { "rows_returned": "3", "elapsed_time": "1.22 secs", "cpu_time": "1.19 secs" }
3112    #[serde(rename = "queryStats")]
3113    pub query_stats: Option<HashMap<String, serde_json::Value>>,
3114    /// Standard DML returns an exact count of rows that were modified.
3115    #[serde(rename = "rowCountExact")]
3116    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3117    pub row_count_exact: Option<i64>,
3118    /// Partitioned DML doesn't offer exactly-once semantics, so it returns a lower bound of the rows modified.
3119    #[serde(rename = "rowCountLowerBound")]
3120    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3121    pub row_count_lower_bound: Option<i64>,
3122}
3123
3124impl common::Part for ResultSetStats {}
3125
3126/// The request for Rollback.
3127///
3128/// # Activities
3129///
3130/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3131/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3132///
3133/// * [instances databases sessions rollback projects](ProjectInstanceDatabaseSessionRollbackCall) (request)
3134#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3135#[serde_with::serde_as]
3136#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3137pub struct RollbackRequest {
3138    /// Required. The transaction to roll back.
3139    #[serde(rename = "transactionId")]
3140    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
3141    pub transaction_id: Option<Vec<u8>>,
3142}
3143
3144impl common::RequestValue for RollbackRequest {}
3145
3146/// Scan is a structure which describes Cloud Key Visualizer scan information.
3147///
3148/// # Activities
3149///
3150/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3151/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3152///
3153/// * [instances databases get scans projects](ProjectInstanceDatabaseGetScanCall) (response)
3154/// * [list scans](ScanListCall) (none)
3155#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3156#[serde_with::serde_as]
3157#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3158pub struct Scan {
3159    /// Additional information provided by the implementer.
3160    pub details: Option<HashMap<String, serde_json::Value>>,
3161    /// The upper bound for when the scan is defined.
3162    #[serde(rename = "endTime")]
3163    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3164    /// The unique name of the scan, specific to the Database service implementing this interface.
3165    pub name: Option<String>,
3166    /// Output only. Cloud Key Visualizer scan data. Note, this field is not available to the ListScans method.
3167    #[serde(rename = "scanData")]
3168    pub scan_data: Option<ScanData>,
3169    /// A range of time (inclusive) for when the scan is defined. The lower bound for when the scan is defined.
3170    #[serde(rename = "startTime")]
3171    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3172}
3173
3174impl common::Resource for Scan {}
3175impl common::ResponseResult for Scan {}
3176
3177/// ScanData contains Cloud Key Visualizer scan data used by the caller to construct a visualization.
3178///
3179/// This type is not used in any activity, and only used as *part* of another schema.
3180///
3181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3182#[serde_with::serde_as]
3183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3184pub struct ScanData {
3185    /// Cloud Key Visualizer scan data. The range of time this information covers is captured via the above time range fields. Note, this field is not available to the ListScans method.
3186    pub data: Option<VisualizationData>,
3187    /// The upper bound for when the contained data is defined.
3188    #[serde(rename = "endTime")]
3189    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3190    /// A range of time (inclusive) for when the contained data is defined. The lower bound for when the contained data is defined.
3191    #[serde(rename = "startTime")]
3192    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3193}
3194
3195impl common::Part for ScanData {}
3196
3197/// Arguments to send operations.
3198///
3199/// This type is not used in any activity, and only used as *part* of another schema.
3200///
3201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3202#[serde_with::serde_as]
3203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3204pub struct Send {
3205    /// The time at which Spanner will begin attempting to deliver the message. If `deliver_time` is not set, Spanner will deliver the message immediately. If `deliver_time` is in the past, Spanner will replace it with a value closer to the current time.
3206    #[serde(rename = "deliverTime")]
3207    pub deliver_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3208    /// Required. The primary key of the message to be sent.
3209    pub key: Option<Vec<serde_json::Value>>,
3210    /// The payload of the message.
3211    pub payload: Option<serde_json::Value>,
3212    /// Required. The queue to which the message will be sent.
3213    pub queue: Option<String>,
3214}
3215
3216impl common::Part for Send {}
3217
3218/// A session in the Cloud Spanner API.
3219///
3220/// # Activities
3221///
3222/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3223/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3224///
3225/// * [instances databases sessions create projects](ProjectInstanceDatabaseSessionCreateCall) (response)
3226/// * [instances databases sessions get projects](ProjectInstanceDatabaseSessionGetCall) (response)
3227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3228#[serde_with::serde_as]
3229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3230pub struct Session {
3231    /// Output only. The approximate timestamp when the session is last used. It's typically earlier than the actual last use time.
3232    #[serde(rename = "approximateLastUseTime")]
3233    pub approximate_last_use_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3234    /// Output only. The timestamp when the session is created.
3235    #[serde(rename = "createTime")]
3236    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3237    /// The database role which created this session.
3238    #[serde(rename = "creatorRole")]
3239    pub creator_role: Option<String>,
3240    /// The labels for the session. * Label keys must be between 1 and 63 characters long and must conform to the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. * Label values must be between 0 and 63 characters long and must conform to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. * No more than 64 labels can be associated with a given session. See https://goo.gl/xmQnxf for more information on and examples of labels.
3241    pub labels: Option<HashMap<String, String>>,
3242    /// Optional. If `true`, specifies a multiplexed session. Use a multiplexed session for multiple, concurrent operations including any combination of read-only and read-write transactions. Use `sessions.create` to create multiplexed sessions. Don't use BatchCreateSessions to create a multiplexed session. You can't delete or list multiplexed sessions.
3243    pub multiplexed: Option<bool>,
3244    /// Output only. The name of the session. This is always system-assigned.
3245    pub name: Option<String>,
3246}
3247
3248impl common::ResponseResult for Session {}
3249
3250/// Request message for `SetIamPolicy` method.
3251///
3252/// # Activities
3253///
3254/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3255/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3256///
3257/// * [instances backups set iam policy projects](ProjectInstanceBackupSetIamPolicyCall) (request)
3258/// * [instances databases backup schedules set iam policy projects](ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall) (request)
3259/// * [instances databases set iam policy projects](ProjectInstanceDatabaseSetIamPolicyCall) (request)
3260/// * [instances set iam policy projects](ProjectInstanceSetIamPolicyCall) (request)
3261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3262#[serde_with::serde_as]
3263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3264pub struct SetIamPolicyRequest {
3265    /// 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.
3266    pub policy: Option<Policy>,
3267}
3268
3269impl common::RequestValue for SetIamPolicyRequest {}
3270
3271/// Condensed representation of a node and its subtree. Only present for `SCALAR` PlanNode(s).
3272///
3273/// This type is not used in any activity, and only used as *part* of another schema.
3274///
3275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3276#[serde_with::serde_as]
3277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3278pub struct ShortRepresentation {
3279    /// A string representation of the expression subtree rooted at this node.
3280    pub description: Option<String>,
3281    /// A mapping of (subquery variable name) -> (subquery node id) for cases where the `description` string of this node references a `SCALAR` subquery contained in the expression subtree rooted at this node. The referenced `SCALAR` subquery may not necessarily be a direct child of this node.
3282    pub subqueries: Option<HashMap<String, i32>>,
3283}
3284
3285impl common::Part for ShortRepresentation {}
3286
3287/// Message type for a single-region quorum.
3288///
3289/// This type is not used in any activity, and only used as *part* of another schema.
3290///
3291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3292#[serde_with::serde_as]
3293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3294pub struct SingleRegionQuorum {
3295    /// Required. The location of the serving region, for example, "us-central1". The location must be one of the regions within the dual-region instance configuration of your database. The list of valid locations is available using the GetInstanceConfig API. This should only be used if you plan to change quorum to the single-region quorum type.
3296    #[serde(rename = "servingLocation")]
3297    pub serving_location: Option<String>,
3298}
3299
3300impl common::Part for SingleRegionQuorum {}
3301
3302/// The split points of a table or an index.
3303///
3304/// This type is not used in any activity, and only used as *part* of another schema.
3305///
3306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3307#[serde_with::serde_as]
3308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3309pub struct SplitPoints {
3310    /// Optional. The expiration timestamp of the split points. A timestamp in the past means immediate expiration. The maximum value can be 30 days in the future. Defaults to 10 days in the future if not specified.
3311    #[serde(rename = "expireTime")]
3312    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3313    /// The index to split. If specified, the `table` field must refer to the index's base table.
3314    pub index: Option<String>,
3315    /// Required. The list of split keys. In essence, the split boundaries.
3316    pub keys: Option<Vec<Key>>,
3317    /// The table to split.
3318    pub table: Option<String>,
3319}
3320
3321impl common::Part for SplitPoints {}
3322
3323/// A single DML statement.
3324///
3325/// This type is not used in any activity, and only used as *part* of another schema.
3326///
3327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3328#[serde_with::serde_as]
3329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3330pub struct Statement {
3331    /// It isn't always possible for Cloud Spanner to infer the right SQL type from a JSON value. For example, values of type `BYTES` and values of type `STRING` both appear in params as JSON strings. In these cases, `param_types` can be used to specify the exact SQL type for some or all of the SQL statement parameters. See the definition of Type for more information about SQL types.
3332    #[serde(rename = "paramTypes")]
3333    pub param_types: Option<HashMap<String, Type>>,
3334    /// Parameter names and values that bind to placeholders in the DML string. A parameter placeholder consists of the `@` character followed by the parameter name (for example, `@firstName`). Parameter names can contain letters, numbers, and underscores. Parameters can appear anywhere that a literal value is expected. The same parameter name can be used more than once, for example: `"WHERE id > @msg_id AND id < @msg_id + 100"` It's an error to execute a SQL statement with unbound parameters.
3335    pub params: Option<HashMap<String, serde_json::Value>>,
3336    /// Required. The DML string.
3337    pub sql: Option<String>,
3338}
3339
3340impl common::Part for Statement {}
3341
3342/// 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).
3343///
3344/// This type is not used in any activity, and only used as *part* of another schema.
3345///
3346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3347#[serde_with::serde_as]
3348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3349pub struct Status {
3350    /// The status code, which should be an enum value of google.rpc.Code.
3351    pub code: Option<i32>,
3352    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
3353    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
3354    /// 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.
3355    pub message: Option<String>,
3356}
3357
3358impl common::Part for Status {}
3359
3360/// `StructType` defines the fields of a STRUCT type.
3361///
3362/// This type is not used in any activity, and only used as *part* of another schema.
3363///
3364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3365#[serde_with::serde_as]
3366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3367pub struct StructType {
3368    /// The list of fields that make up this struct. Order is significant, because values of this struct type are represented as lists, where the order of field values matches the order of fields in the StructType. In turn, the order of fields matches the order of columns in a read request, or the order of fields in the `SELECT` clause of a query.
3369    pub fields: Option<Vec<Field>>,
3370}
3371
3372impl common::Part for StructType {}
3373
3374/// Request message for `TestIamPermissions` method.
3375///
3376/// # Activities
3377///
3378/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3379/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3380///
3381/// * [instances backups test iam permissions projects](ProjectInstanceBackupTestIamPermissionCall) (request)
3382/// * [instances databases backup schedules test iam permissions projects](ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall) (request)
3383/// * [instances databases database roles test iam permissions projects](ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall) (request)
3384/// * [instances databases test iam permissions projects](ProjectInstanceDatabaseTestIamPermissionCall) (request)
3385/// * [instances test iam permissions projects](ProjectInstanceTestIamPermissionCall) (request)
3386#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3387#[serde_with::serde_as]
3388#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3389pub struct TestIamPermissionsRequest {
3390    /// REQUIRED: The set of permissions to check for 'resource'. Permissions with wildcards (such as '*', 'spanner.*', 'spanner.instances.*') are not allowed.
3391    pub permissions: Option<Vec<String>>,
3392}
3393
3394impl common::RequestValue for TestIamPermissionsRequest {}
3395
3396/// Response message for `TestIamPermissions` method.
3397///
3398/// # Activities
3399///
3400/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3401/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3402///
3403/// * [instances backups test iam permissions projects](ProjectInstanceBackupTestIamPermissionCall) (response)
3404/// * [instances databases backup schedules test iam permissions projects](ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall) (response)
3405/// * [instances databases database roles test iam permissions projects](ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall) (response)
3406/// * [instances databases test iam permissions projects](ProjectInstanceDatabaseTestIamPermissionCall) (response)
3407/// * [instances test iam permissions projects](ProjectInstanceTestIamPermissionCall) (response)
3408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3409#[serde_with::serde_as]
3410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3411pub struct TestIamPermissionsResponse {
3412    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
3413    pub permissions: Option<Vec<String>>,
3414}
3415
3416impl common::ResponseResult for TestIamPermissionsResponse {}
3417
3418/// A transaction.
3419///
3420/// # Activities
3421///
3422/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3423/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3424///
3425/// * [instances databases sessions begin transaction projects](ProjectInstanceDatabaseSessionBeginTransactionCall) (response)
3426#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3427#[serde_with::serde_as]
3428#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3429pub struct Transaction {
3430    /// `id` may be used to identify the transaction in subsequent Read, ExecuteSql, Commit, or Rollback calls. Single-use read-only transactions do not have IDs, because single-use transactions do not support multiple requests.
3431    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
3432    pub id: Option<Vec<u8>>,
3433    /// A precommit token is included in the response of a BeginTransaction request if the read-write transaction is on a multiplexed session and a mutation_key was specified in the BeginTransaction. The precommit token with the highest sequence number from this transaction attempt should be passed to the Commit request for this transaction.
3434    #[serde(rename = "precommitToken")]
3435    pub precommit_token: Option<MultiplexedSessionPrecommitToken>,
3436    /// For snapshot read-only transactions, the read timestamp chosen for the transaction. Not returned by default: see TransactionOptions.ReadOnly.return_read_timestamp. A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. Example: `"2014-10-02T15:01:23.045123456Z"`.
3437    #[serde(rename = "readTimestamp")]
3438    pub read_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
3439}
3440
3441impl common::ResponseResult for Transaction {}
3442
3443/// Options to use for transactions.
3444///
3445/// This type is not used in any activity, and only used as *part* of another schema.
3446///
3447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3448#[serde_with::serde_as]
3449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3450pub struct TransactionOptions {
3451    /// When `exclude_txn_from_change_streams` is set to `true`, it prevents read or write transactions from being tracked in change streams. * If the DDL option `allow_txn_exclusion` is set to `true`, then the updates made within this transaction aren't recorded in the change stream. * If you don't set the DDL option `allow_txn_exclusion` or if it's set to `false`, then the updates made within this transaction are recorded in the change stream. When `exclude_txn_from_change_streams` is set to `false` or not set, modifications from this transaction are recorded in all change streams that are tracking columns modified by these transactions. The `exclude_txn_from_change_streams` option can only be specified for read-write or partitioned DML transactions, otherwise the API returns an `INVALID_ARGUMENT` error.
3452    #[serde(rename = "excludeTxnFromChangeStreams")]
3453    pub exclude_txn_from_change_streams: Option<bool>,
3454    /// Isolation level for the transaction.
3455    #[serde(rename = "isolationLevel")]
3456    pub isolation_level: Option<String>,
3457    /// Partitioned DML transaction. Authorization to begin a Partitioned DML transaction requires `spanner.databases.beginPartitionedDmlTransaction` permission on the `session` resource.
3458    #[serde(rename = "partitionedDml")]
3459    pub partitioned_dml: Option<PartitionedDml>,
3460    /// Transaction does not write. Authorization to begin a read-only transaction requires `spanner.databases.beginReadOnlyTransaction` permission on the `session` resource.
3461    #[serde(rename = "readOnly")]
3462    pub read_only: Option<ReadOnly>,
3463    /// Transaction may write. Authorization to begin a read-write transaction requires `spanner.databases.beginOrRollbackReadWriteTransaction` permission on the `session` resource.
3464    #[serde(rename = "readWrite")]
3465    pub read_write: Option<ReadWrite>,
3466}
3467
3468impl common::Part for TransactionOptions {}
3469
3470/// This message is used to select the transaction in which a Read or ExecuteSql call runs. See TransactionOptions for more information about transactions.
3471///
3472/// This type is not used in any activity, and only used as *part* of another schema.
3473///
3474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3475#[serde_with::serde_as]
3476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3477pub struct TransactionSelector {
3478    /// Begin a new transaction and execute this read or SQL query in it. The transaction ID of the new transaction is returned in ResultSetMetadata.transaction, which is a Transaction.
3479    pub begin: Option<TransactionOptions>,
3480    /// Execute the read or SQL query in a previously-started transaction.
3481    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
3482    pub id: Option<Vec<u8>>,
3483    /// Execute the read or SQL query in a temporary transaction. This is the most efficient way to execute a transaction that consists of a single SQL query.
3484    #[serde(rename = "singleUse")]
3485    pub single_use: Option<TransactionOptions>,
3486}
3487
3488impl common::Part for TransactionSelector {}
3489
3490/// `Type` indicates the type of a Cloud Spanner value, as might be stored in a table cell or returned from an SQL query.
3491///
3492/// This type is not used in any activity, and only used as *part* of another schema.
3493///
3494#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3495#[serde_with::serde_as]
3496#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3497pub struct Type {
3498    /// If code == ARRAY, then `array_element_type` is the type of the array elements.
3499    #[serde(rename = "arrayElementType")]
3500    pub array_element_type: Option<Option<Box<Type>>>,
3501    /// Required. The TypeCode for this type.
3502    pub code: Option<String>,
3503    /// If code == PROTO or code == ENUM, then `proto_type_fqn` is the fully qualified name of the proto type representing the proto/enum definition.
3504    #[serde(rename = "protoTypeFqn")]
3505    pub proto_type_fqn: Option<String>,
3506    /// If code == STRUCT, then `struct_type` provides type information for the struct's fields.
3507    #[serde(rename = "structType")]
3508    pub struct_type: Option<StructType>,
3509    /// The TypeAnnotationCode that disambiguates SQL type that Spanner will use to represent values of this type during query processing. This is necessary for some type codes because a single TypeCode can be mapped to different SQL types depending on the SQL dialect. type_annotation typically is not needed to process the content of a value (it doesn't affect serialization) and clients can ignore it on the read path.
3510    #[serde(rename = "typeAnnotation")]
3511    pub type_annotation: Option<String>,
3512}
3513
3514impl common::Part for Type {}
3515
3516/// Enqueues the given DDL statements to be applied, in order but not necessarily all at once, to the database schema at some point (or points) in the future. The server checks that the statements are executable (syntactically valid, name tables that exist, etc.) before enqueueing them, but they may still fail upon later execution (for example, if a statement from another batch of statements is applied first and it conflicts in some way, or if there is some data-related problem like a `NULL` value in a column to which `NOT NULL` would be added). If a statement fails, all subsequent statements in the batch are automatically cancelled. Each batch of statements is assigned a name which can be used with the Operations API to monitor progress. See the operation_id field for more details.
3517///
3518/// # Activities
3519///
3520/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3521/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3522///
3523/// * [instances databases update ddl projects](ProjectInstanceDatabaseUpdateDdlCall) (request)
3524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3525#[serde_with::serde_as]
3526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3527pub struct UpdateDatabaseDdlRequest {
3528    /// If empty, the new update request is assigned an automatically-generated operation ID. Otherwise, `operation_id` is used to construct the name of the resulting Operation. Specifying an explicit operation ID simplifies determining whether the statements were executed in the event that the UpdateDatabaseDdl call is replayed, or the return value is otherwise lost: the database and `operation_id` fields can be combined to form the `name` of the resulting longrunning.Operation: `/operations/`. `operation_id` should be unique within the database, and must be a valid identifier: `a-z*`. Note that automatically-generated operation IDs always begin with an underscore. If the named operation already exists, UpdateDatabaseDdl returns `ALREADY_EXISTS`.
3529    #[serde(rename = "operationId")]
3530    pub operation_id: Option<String>,
3531    /// Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements. Contains a protobuf-serialized [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto). To generate it, [install](https://grpc.io/docs/protoc-installation/) and run `protoc` with --include_imports and --descriptor_set_out. For example, to generate for moon/shot/app.proto, run ``` $protoc --proto_path=/app_path --proto_path=/lib_path \ --include_imports \ --descriptor_set_out=descriptors.data \ moon/shot/app.proto ``` For more details, see protobuffer [self description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
3532    #[serde(rename = "protoDescriptors")]
3533    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
3534    pub proto_descriptors: Option<Vec<u8>>,
3535    /// Required. DDL statements to be applied to the database.
3536    pub statements: Option<Vec<String>>,
3537}
3538
3539impl common::RequestValue for UpdateDatabaseDdlRequest {}
3540
3541/// The request for UpdateInstanceConfig.
3542///
3543/// # Activities
3544///
3545/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3546/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3547///
3548/// * [instance configs patch projects](ProjectInstanceConfigPatchCall) (request)
3549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3550#[serde_with::serde_as]
3551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3552pub struct UpdateInstanceConfigRequest {
3553    /// Required. The user instance configuration to update, which must always include the instance configuration name. Otherwise, only fields mentioned in update_mask need be included. To prevent conflicts of concurrent updates, etag can be used.
3554    #[serde(rename = "instanceConfig")]
3555    pub instance_config: Option<InstanceConfig>,
3556    /// Required. A mask specifying which fields in InstanceConfig should be updated. The field mask must always be specified; this prevents any future fields in InstanceConfig from being erased accidentally by clients that do not know about them. Only display_name and labels can be updated.
3557    #[serde(rename = "updateMask")]
3558    pub update_mask: Option<common::FieldMask>,
3559    /// An option to validate, but not actually execute, a request, and provide the same response.
3560    #[serde(rename = "validateOnly")]
3561    pub validate_only: Option<bool>,
3562}
3563
3564impl common::RequestValue for UpdateInstanceConfigRequest {}
3565
3566/// The request for UpdateInstancePartition.
3567///
3568/// # Activities
3569///
3570/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3571/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3572///
3573/// * [instances instance partitions patch projects](ProjectInstanceInstancePartitionPatchCall) (request)
3574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3575#[serde_with::serde_as]
3576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3577pub struct UpdateInstancePartitionRequest {
3578    /// Required. A mask specifying which fields in InstancePartition should be updated. The field mask must always be specified; this prevents any future fields in InstancePartition from being erased accidentally by clients that do not know about them.
3579    #[serde(rename = "fieldMask")]
3580    pub field_mask: Option<common::FieldMask>,
3581    /// Required. The instance partition to update, which must always include the instance partition name. Otherwise, only fields mentioned in field_mask need be included.
3582    #[serde(rename = "instancePartition")]
3583    pub instance_partition: Option<InstancePartition>,
3584}
3585
3586impl common::RequestValue for UpdateInstancePartitionRequest {}
3587
3588/// The request for UpdateInstance.
3589///
3590/// # Activities
3591///
3592/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3593/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3594///
3595/// * [instances patch projects](ProjectInstancePatchCall) (request)
3596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3597#[serde_with::serde_as]
3598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3599pub struct UpdateInstanceRequest {
3600    /// Required. A mask specifying which fields in Instance should be updated. The field mask must always be specified; this prevents any future fields in Instance from being erased accidentally by clients that do not know about them.
3601    #[serde(rename = "fieldMask")]
3602    pub field_mask: Option<common::FieldMask>,
3603    /// Required. The instance to update, which must always include the instance name. Otherwise, only fields mentioned in field_mask need be included.
3604    pub instance: Option<Instance>,
3605}
3606
3607impl common::RequestValue for UpdateInstanceRequest {}
3608
3609/// There is no detailed description.
3610///
3611/// This type is not used in any activity, and only used as *part* of another schema.
3612///
3613#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3614#[serde_with::serde_as]
3615#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3616pub struct VisualizationData {
3617    /// The token signifying the end of a data_source.
3618    #[serde(rename = "dataSourceEndToken")]
3619    pub data_source_end_token: Option<String>,
3620    /// The token delimiting a datasource name from the rest of a key in a data_source.
3621    #[serde(rename = "dataSourceSeparatorToken")]
3622    pub data_source_separator_token: Option<String>,
3623    /// The list of messages (info, alerts, ...)
3624    #[serde(rename = "diagnosticMessages")]
3625    pub diagnostic_messages: Option<Vec<DiagnosticMessage>>,
3626    /// We discretize the entire keyspace into buckets. Assuming each bucket has an inclusive keyrange and covers keys from k(i) ... k(n). In this case k(n) would be an end key for a given range. end_key_string is the collection of all such end keys
3627    #[serde(rename = "endKeyStrings")]
3628    pub end_key_strings: Option<Vec<String>>,
3629    /// Whether this scan contains PII.
3630    #[serde(rename = "hasPii")]
3631    pub has_pii: Option<bool>,
3632    /// Keys of key ranges that contribute significantly to a given metric Can be thought of as heavy hitters.
3633    #[serde(rename = "indexedKeys")]
3634    pub indexed_keys: Option<Vec<String>>,
3635    /// The token delimiting the key prefixes.
3636    #[serde(rename = "keySeparator")]
3637    pub key_separator: Option<String>,
3638    /// The unit for the key: e.g. 'key' or 'chunk'.
3639    #[serde(rename = "keyUnit")]
3640    pub key_unit: Option<String>,
3641    /// The list of data objects for each metric.
3642    pub metrics: Option<Vec<Metric>>,
3643    /// The list of extracted key prefix nodes used in the key prefix hierarchy.
3644    #[serde(rename = "prefixNodes")]
3645    pub prefix_nodes: Option<Vec<PrefixNode>>,
3646}
3647
3648impl common::Part for VisualizationData {}
3649
3650/// Arguments to insert, update, insert_or_update, and replace operations.
3651///
3652/// This type is not used in any activity, and only used as *part* of another schema.
3653///
3654#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3655#[serde_with::serde_as]
3656#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3657pub struct Write {
3658    /// The names of the columns in table to be written. The list of columns must contain enough columns to allow Cloud Spanner to derive values for all primary key columns in the row(s) to be modified.
3659    pub columns: Option<Vec<String>>,
3660    /// Required. The table whose rows will be written.
3661    pub table: Option<String>,
3662    /// The values to be written. `values` can contain more than one list of values. If it does, then multiple rows are written, one for each entry in `values`. Each list in `values` must have exactly as many entries as there are entries in columns above. Sending multiple lists is equivalent to sending multiple `Mutation`s, each containing one `values` entry and repeating table and columns. Individual values in each list are encoded as described here.
3663    pub values: Option<Vec<Vec<serde_json::Value>>>,
3664}
3665
3666impl common::Part for Write {}
3667
3668// ###################
3669// MethodBuilders ###
3670// #################
3671
3672/// A builder providing access to all methods supported on *project* resources.
3673/// It is not used directly, but through the [`Spanner`] hub.
3674///
3675/// # Example
3676///
3677/// Instantiate a resource builder
3678///
3679/// ```test_harness,no_run
3680/// extern crate hyper;
3681/// extern crate hyper_rustls;
3682/// extern crate google_spanner1 as spanner1;
3683///
3684/// # async fn dox() {
3685/// use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3686///
3687/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3688/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3689///     .with_native_roots()
3690///     .unwrap()
3691///     .https_only()
3692///     .enable_http2()
3693///     .build();
3694///
3695/// let executor = hyper_util::rt::TokioExecutor::new();
3696/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3697///     secret,
3698///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3699///     yup_oauth2::client::CustomHyperClientBuilder::from(
3700///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3701///     ),
3702/// ).build().await.unwrap();
3703///
3704/// let client = hyper_util::client::legacy::Client::builder(
3705///     hyper_util::rt::TokioExecutor::new()
3706/// )
3707/// .build(
3708///     hyper_rustls::HttpsConnectorBuilder::new()
3709///         .with_native_roots()
3710///         .unwrap()
3711///         .https_or_http()
3712///         .enable_http2()
3713///         .build()
3714/// );
3715/// let mut hub = Spanner::new(client, auth);
3716/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3717/// // like `instance_config_operations_list(...)`, `instance_configs_create(...)`, `instance_configs_delete(...)`, `instance_configs_get(...)`, `instance_configs_list(...)`, `instance_configs_operations_cancel(...)`, `instance_configs_operations_delete(...)`, `instance_configs_operations_get(...)`, `instance_configs_operations_list(...)`, `instance_configs_patch(...)`, `instance_configs_ssd_caches_operations_cancel(...)`, `instance_configs_ssd_caches_operations_delete(...)`, `instance_configs_ssd_caches_operations_get(...)`, `instance_configs_ssd_caches_operations_list(...)`, `instances_backup_operations_list(...)`, `instances_backups_copy(...)`, `instances_backups_create(...)`, `instances_backups_delete(...)`, `instances_backups_get(...)`, `instances_backups_get_iam_policy(...)`, `instances_backups_list(...)`, `instances_backups_operations_cancel(...)`, `instances_backups_operations_delete(...)`, `instances_backups_operations_get(...)`, `instances_backups_operations_list(...)`, `instances_backups_patch(...)`, `instances_backups_set_iam_policy(...)`, `instances_backups_test_iam_permissions(...)`, `instances_create(...)`, `instances_database_operations_list(...)`, `instances_databases_add_split_points(...)`, `instances_databases_backup_schedules_create(...)`, `instances_databases_backup_schedules_delete(...)`, `instances_databases_backup_schedules_get(...)`, `instances_databases_backup_schedules_get_iam_policy(...)`, `instances_databases_backup_schedules_list(...)`, `instances_databases_backup_schedules_patch(...)`, `instances_databases_backup_schedules_set_iam_policy(...)`, `instances_databases_backup_schedules_test_iam_permissions(...)`, `instances_databases_changequorum(...)`, `instances_databases_create(...)`, `instances_databases_database_roles_list(...)`, `instances_databases_database_roles_test_iam_permissions(...)`, `instances_databases_drop_database(...)`, `instances_databases_get(...)`, `instances_databases_get_ddl(...)`, `instances_databases_get_iam_policy(...)`, `instances_databases_get_scans(...)`, `instances_databases_list(...)`, `instances_databases_operations_cancel(...)`, `instances_databases_operations_delete(...)`, `instances_databases_operations_get(...)`, `instances_databases_operations_list(...)`, `instances_databases_patch(...)`, `instances_databases_restore(...)`, `instances_databases_sessions_adapt_message(...)`, `instances_databases_sessions_adapter(...)`, `instances_databases_sessions_batch_create(...)`, `instances_databases_sessions_batch_write(...)`, `instances_databases_sessions_begin_transaction(...)`, `instances_databases_sessions_commit(...)`, `instances_databases_sessions_create(...)`, `instances_databases_sessions_delete(...)`, `instances_databases_sessions_execute_batch_dml(...)`, `instances_databases_sessions_execute_sql(...)`, `instances_databases_sessions_execute_streaming_sql(...)`, `instances_databases_sessions_get(...)`, `instances_databases_sessions_list(...)`, `instances_databases_sessions_partition_query(...)`, `instances_databases_sessions_partition_read(...)`, `instances_databases_sessions_read(...)`, `instances_databases_sessions_rollback(...)`, `instances_databases_sessions_streaming_read(...)`, `instances_databases_set_iam_policy(...)`, `instances_databases_test_iam_permissions(...)`, `instances_databases_update_ddl(...)`, `instances_delete(...)`, `instances_get(...)`, `instances_get_iam_policy(...)`, `instances_instance_partition_operations_list(...)`, `instances_instance_partitions_create(...)`, `instances_instance_partitions_delete(...)`, `instances_instance_partitions_get(...)`, `instances_instance_partitions_list(...)`, `instances_instance_partitions_operations_cancel(...)`, `instances_instance_partitions_operations_delete(...)`, `instances_instance_partitions_operations_get(...)`, `instances_instance_partitions_operations_list(...)`, `instances_instance_partitions_patch(...)`, `instances_list(...)`, `instances_move(...)`, `instances_operations_cancel(...)`, `instances_operations_delete(...)`, `instances_operations_get(...)`, `instances_operations_list(...)`, `instances_patch(...)`, `instances_set_iam_policy(...)` and `instances_test_iam_permissions(...)`
3718/// // to build up your call.
3719/// let rb = hub.projects();
3720/// # }
3721/// ```
3722pub struct ProjectMethods<'a, C>
3723where
3724    C: 'a,
3725{
3726    hub: &'a Spanner<C>,
3727}
3728
3729impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3730
3731impl<'a, C> ProjectMethods<'a, C> {
3732    /// Create a builder to help you perform the following task:
3733    ///
3734    /// Lists the user-managed instance configuration long-running operations in the given project. An instance configuration operation has a name of the form `projects//instanceConfigs//operations/`. The long-running operation metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by `operation.metadata.value.start_time` in descending order starting from the most recently started operation.
3735    ///
3736    /// # Arguments
3737    ///
3738    /// * `parent` - Required. The project of the instance configuration operations. Values are of the form `projects/`.
3739    pub fn instance_config_operations_list(
3740        &self,
3741        parent: &str,
3742    ) -> ProjectInstanceConfigOperationListCall<'a, C> {
3743        ProjectInstanceConfigOperationListCall {
3744            hub: self.hub,
3745            _parent: parent.to_string(),
3746            _page_token: Default::default(),
3747            _page_size: Default::default(),
3748            _filter: Default::default(),
3749            _delegate: Default::default(),
3750            _additional_params: Default::default(),
3751            _scopes: Default::default(),
3752        }
3753    }
3754
3755    /// Create a builder to help you perform the following task:
3756    ///
3757    /// 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`.
3758    ///
3759    /// # Arguments
3760    ///
3761    /// * `name` - The name of the operation resource to be cancelled.
3762    pub fn instance_configs_operations_cancel(
3763        &self,
3764        name: &str,
3765    ) -> ProjectInstanceConfigOperationCancelCall<'a, C> {
3766        ProjectInstanceConfigOperationCancelCall {
3767            hub: self.hub,
3768            _name: name.to_string(),
3769            _delegate: Default::default(),
3770            _additional_params: Default::default(),
3771            _scopes: Default::default(),
3772        }
3773    }
3774
3775    /// Create a builder to help you perform the following task:
3776    ///
3777    /// 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`.
3778    ///
3779    /// # Arguments
3780    ///
3781    /// * `name` - The name of the operation resource to be deleted.
3782    pub fn instance_configs_operations_delete(
3783        &self,
3784        name: &str,
3785    ) -> ProjectInstanceConfigOperationDeleteCall<'a, C> {
3786        ProjectInstanceConfigOperationDeleteCall {
3787            hub: self.hub,
3788            _name: name.to_string(),
3789            _delegate: Default::default(),
3790            _additional_params: Default::default(),
3791            _scopes: Default::default(),
3792        }
3793    }
3794
3795    /// Create a builder to help you perform the following task:
3796    ///
3797    /// 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.
3798    ///
3799    /// # Arguments
3800    ///
3801    /// * `name` - The name of the operation resource.
3802    pub fn instance_configs_operations_get(
3803        &self,
3804        name: &str,
3805    ) -> ProjectInstanceConfigOperationGetCall<'a, C> {
3806        ProjectInstanceConfigOperationGetCall {
3807            hub: self.hub,
3808            _name: name.to_string(),
3809            _delegate: Default::default(),
3810            _additional_params: Default::default(),
3811            _scopes: Default::default(),
3812        }
3813    }
3814
3815    /// Create a builder to help you perform the following task:
3816    ///
3817    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3818    ///
3819    /// # Arguments
3820    ///
3821    /// * `name` - The name of the operation's parent resource.
3822    pub fn instance_configs_operations_list(
3823        &self,
3824        name: &str,
3825    ) -> ProjectInstanceConfigOperationListCall1<'a, C> {
3826        ProjectInstanceConfigOperationListCall1 {
3827            hub: self.hub,
3828            _name: name.to_string(),
3829            _return_partial_success: Default::default(),
3830            _page_token: Default::default(),
3831            _page_size: Default::default(),
3832            _filter: Default::default(),
3833            _delegate: Default::default(),
3834            _additional_params: Default::default(),
3835            _scopes: Default::default(),
3836        }
3837    }
3838
3839    /// Create a builder to help you perform the following task:
3840    ///
3841    /// 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`.
3842    ///
3843    /// # Arguments
3844    ///
3845    /// * `name` - The name of the operation resource to be cancelled.
3846    pub fn instance_configs_ssd_caches_operations_cancel(
3847        &self,
3848        name: &str,
3849    ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {
3850        ProjectInstanceConfigSsdCachOperationCancelCall {
3851            hub: self.hub,
3852            _name: name.to_string(),
3853            _delegate: Default::default(),
3854            _additional_params: Default::default(),
3855            _scopes: Default::default(),
3856        }
3857    }
3858
3859    /// Create a builder to help you perform the following task:
3860    ///
3861    /// 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`.
3862    ///
3863    /// # Arguments
3864    ///
3865    /// * `name` - The name of the operation resource to be deleted.
3866    pub fn instance_configs_ssd_caches_operations_delete(
3867        &self,
3868        name: &str,
3869    ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {
3870        ProjectInstanceConfigSsdCachOperationDeleteCall {
3871            hub: self.hub,
3872            _name: name.to_string(),
3873            _delegate: Default::default(),
3874            _additional_params: Default::default(),
3875            _scopes: Default::default(),
3876        }
3877    }
3878
3879    /// Create a builder to help you perform the following task:
3880    ///
3881    /// 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.
3882    ///
3883    /// # Arguments
3884    ///
3885    /// * `name` - The name of the operation resource.
3886    pub fn instance_configs_ssd_caches_operations_get(
3887        &self,
3888        name: &str,
3889    ) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {
3890        ProjectInstanceConfigSsdCachOperationGetCall {
3891            hub: self.hub,
3892            _name: name.to_string(),
3893            _delegate: Default::default(),
3894            _additional_params: Default::default(),
3895            _scopes: Default::default(),
3896        }
3897    }
3898
3899    /// Create a builder to help you perform the following task:
3900    ///
3901    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3902    ///
3903    /// # Arguments
3904    ///
3905    /// * `name` - The name of the operation's parent resource.
3906    pub fn instance_configs_ssd_caches_operations_list(
3907        &self,
3908        name: &str,
3909    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
3910        ProjectInstanceConfigSsdCachOperationListCall {
3911            hub: self.hub,
3912            _name: name.to_string(),
3913            _return_partial_success: Default::default(),
3914            _page_token: Default::default(),
3915            _page_size: Default::default(),
3916            _filter: Default::default(),
3917            _delegate: Default::default(),
3918            _additional_params: Default::default(),
3919            _scopes: Default::default(),
3920        }
3921    }
3922
3923    /// Create a builder to help you perform the following task:
3924    ///
3925    /// Creates an instance configuration and begins preparing it to be used. The returned long-running operation can be used to track the progress of preparing the new instance configuration. The instance configuration name is assigned by the caller. If the named instance configuration already exists, `CreateInstanceConfig` returns `ALREADY_EXISTS`. Immediately after the request returns: * The instance configuration is readable via the API, with all requested attributes. The instance configuration's reconciling field is set to true. Its state is `CREATING`. While the operation is pending: * Cancelling the operation renders the instance configuration immediately unreadable via the API. * Except for deleting the creating resource, all other attempts to modify the instance configuration are rejected. Upon completion of the returned operation: * Instances can be created using the instance configuration. * The instance configuration's reconciling field becomes false. Its state becomes `READY`. The returned long-running operation will have a name of the format `/operations/` and can be used to track creation of the instance configuration. The metadata field type is CreateInstanceConfigMetadata. The response field type is InstanceConfig, if successful. Authorization requires `spanner.instanceConfigs.create` permission on the resource parent.
3926    ///
3927    /// # Arguments
3928    ///
3929    /// * `request` - No description provided.
3930    /// * `parent` - Required. The name of the project in which to create the instance configuration. Values are of the form `projects/`.
3931    pub fn instance_configs_create(
3932        &self,
3933        request: CreateInstanceConfigRequest,
3934        parent: &str,
3935    ) -> ProjectInstanceConfigCreateCall<'a, C> {
3936        ProjectInstanceConfigCreateCall {
3937            hub: self.hub,
3938            _request: request,
3939            _parent: parent.to_string(),
3940            _delegate: Default::default(),
3941            _additional_params: Default::default(),
3942            _scopes: Default::default(),
3943        }
3944    }
3945
3946    /// Create a builder to help you perform the following task:
3947    ///
3948    /// Deletes the instance configuration. Deletion is only allowed when no instances are using the configuration. If any instances are using the configuration, returns `FAILED_PRECONDITION`. Only user-managed configurations can be deleted. Authorization requires `spanner.instanceConfigs.delete` permission on the resource name.
3949    ///
3950    /// # Arguments
3951    ///
3952    /// * `name` - Required. The name of the instance configuration to be deleted. Values are of the form `projects//instanceConfigs/`
3953    pub fn instance_configs_delete(&self, name: &str) -> ProjectInstanceConfigDeleteCall<'a, C> {
3954        ProjectInstanceConfigDeleteCall {
3955            hub: self.hub,
3956            _name: name.to_string(),
3957            _validate_only: Default::default(),
3958            _etag: Default::default(),
3959            _delegate: Default::default(),
3960            _additional_params: Default::default(),
3961            _scopes: Default::default(),
3962        }
3963    }
3964
3965    /// Create a builder to help you perform the following task:
3966    ///
3967    /// Gets information about a particular instance configuration.
3968    ///
3969    /// # Arguments
3970    ///
3971    /// * `name` - Required. The name of the requested instance configuration. Values are of the form `projects//instanceConfigs/`.
3972    pub fn instance_configs_get(&self, name: &str) -> ProjectInstanceConfigGetCall<'a, C> {
3973        ProjectInstanceConfigGetCall {
3974            hub: self.hub,
3975            _name: name.to_string(),
3976            _delegate: Default::default(),
3977            _additional_params: Default::default(),
3978            _scopes: Default::default(),
3979        }
3980    }
3981
3982    /// Create a builder to help you perform the following task:
3983    ///
3984    /// Lists the supported instance configurations for a given project. Returns both Google-managed configurations and user-managed configurations.
3985    ///
3986    /// # Arguments
3987    ///
3988    /// * `parent` - Required. The name of the project for which a list of supported instance configurations is requested. Values are of the form `projects/`.
3989    pub fn instance_configs_list(&self, parent: &str) -> ProjectInstanceConfigListCall<'a, C> {
3990        ProjectInstanceConfigListCall {
3991            hub: self.hub,
3992            _parent: parent.to_string(),
3993            _page_token: Default::default(),
3994            _page_size: Default::default(),
3995            _delegate: Default::default(),
3996            _additional_params: Default::default(),
3997            _scopes: Default::default(),
3998        }
3999    }
4000
4001    /// Create a builder to help you perform the following task:
4002    ///
4003    /// Updates an instance configuration. The returned long-running operation can be used to track the progress of updating the instance. If the named instance configuration does not exist, returns `NOT_FOUND`. Only user-managed configurations can be updated. Immediately after the request returns: * The instance configuration's reconciling field is set to true. While the operation is pending: * Cancelling the operation sets its metadata's cancel_time. The operation is guaranteed to succeed at undoing all changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance configuration are rejected. * Reading the instance configuration via the API continues to give the pre-request values. Upon completion of the returned operation: * Creating instances using the instance configuration uses the new values. * The new values of the instance configuration are readable via the API. * The instance configuration's reconciling field becomes false. The returned long-running operation will have a name of the format `/operations/` and can be used to track the instance configuration modification. The metadata field type is UpdateInstanceConfigMetadata. The response field type is InstanceConfig, if successful. Authorization requires `spanner.instanceConfigs.update` permission on the resource name.
4004    ///
4005    /// # Arguments
4006    ///
4007    /// * `request` - No description provided.
4008    /// * `name` - A unique identifier for the instance configuration. Values are of the form `projects//instanceConfigs/a-z*`. User instance configuration must start with `custom-`.
4009    pub fn instance_configs_patch(
4010        &self,
4011        request: UpdateInstanceConfigRequest,
4012        name: &str,
4013    ) -> ProjectInstanceConfigPatchCall<'a, C> {
4014        ProjectInstanceConfigPatchCall {
4015            hub: self.hub,
4016            _request: request,
4017            _name: name.to_string(),
4018            _delegate: Default::default(),
4019            _additional_params: Default::default(),
4020            _scopes: Default::default(),
4021        }
4022    }
4023
4024    /// Create a builder to help you perform the following task:
4025    ///
4026    /// Lists the backup long-running operations in the given instance. A backup operation has a name of the form `projects//instances//backups//operations/`. The long-running operation metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by `operation.metadata.value.progress.start_time` in descending order starting from the most recently started operation.
4027    ///
4028    /// # Arguments
4029    ///
4030    /// * `parent` - Required. The instance of the backup operations. Values are of the form `projects//instances/`.
4031    pub fn instances_backup_operations_list(
4032        &self,
4033        parent: &str,
4034    ) -> ProjectInstanceBackupOperationListCall<'a, C> {
4035        ProjectInstanceBackupOperationListCall {
4036            hub: self.hub,
4037            _parent: parent.to_string(),
4038            _page_token: Default::default(),
4039            _page_size: Default::default(),
4040            _filter: Default::default(),
4041            _delegate: Default::default(),
4042            _additional_params: Default::default(),
4043            _scopes: Default::default(),
4044        }
4045    }
4046
4047    /// Create a builder to help you perform the following task:
4048    ///
4049    /// 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`.
4050    ///
4051    /// # Arguments
4052    ///
4053    /// * `name` - The name of the operation resource to be cancelled.
4054    pub fn instances_backups_operations_cancel(
4055        &self,
4056        name: &str,
4057    ) -> ProjectInstanceBackupOperationCancelCall<'a, C> {
4058        ProjectInstanceBackupOperationCancelCall {
4059            hub: self.hub,
4060            _name: name.to_string(),
4061            _delegate: Default::default(),
4062            _additional_params: Default::default(),
4063            _scopes: Default::default(),
4064        }
4065    }
4066
4067    /// Create a builder to help you perform the following task:
4068    ///
4069    /// 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`.
4070    ///
4071    /// # Arguments
4072    ///
4073    /// * `name` - The name of the operation resource to be deleted.
4074    pub fn instances_backups_operations_delete(
4075        &self,
4076        name: &str,
4077    ) -> ProjectInstanceBackupOperationDeleteCall<'a, C> {
4078        ProjectInstanceBackupOperationDeleteCall {
4079            hub: self.hub,
4080            _name: name.to_string(),
4081            _delegate: Default::default(),
4082            _additional_params: Default::default(),
4083            _scopes: Default::default(),
4084        }
4085    }
4086
4087    /// Create a builder to help you perform the following task:
4088    ///
4089    /// 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.
4090    ///
4091    /// # Arguments
4092    ///
4093    /// * `name` - The name of the operation resource.
4094    pub fn instances_backups_operations_get(
4095        &self,
4096        name: &str,
4097    ) -> ProjectInstanceBackupOperationGetCall<'a, C> {
4098        ProjectInstanceBackupOperationGetCall {
4099            hub: self.hub,
4100            _name: name.to_string(),
4101            _delegate: Default::default(),
4102            _additional_params: Default::default(),
4103            _scopes: Default::default(),
4104        }
4105    }
4106
4107    /// Create a builder to help you perform the following task:
4108    ///
4109    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4110    ///
4111    /// # Arguments
4112    ///
4113    /// * `name` - The name of the operation's parent resource.
4114    pub fn instances_backups_operations_list(
4115        &self,
4116        name: &str,
4117    ) -> ProjectInstanceBackupOperationListCall1<'a, C> {
4118        ProjectInstanceBackupOperationListCall1 {
4119            hub: self.hub,
4120            _name: name.to_string(),
4121            _return_partial_success: Default::default(),
4122            _page_token: Default::default(),
4123            _page_size: Default::default(),
4124            _filter: Default::default(),
4125            _delegate: Default::default(),
4126            _additional_params: Default::default(),
4127            _scopes: Default::default(),
4128        }
4129    }
4130
4131    /// Create a builder to help you perform the following task:
4132    ///
4133    /// Starts copying a Cloud Spanner Backup. The returned backup long-running operation will have a name of the format `projects//instances//backups//operations/` and can be used to track copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the destination backup. Concurrent CopyBackup requests can run on the same source backup.
4134    ///
4135    /// # Arguments
4136    ///
4137    /// * `request` - No description provided.
4138    /// * `parent` - Required. The name of the destination instance that will contain the backup copy. Values are of the form: `projects//instances/`.
4139    pub fn instances_backups_copy(
4140        &self,
4141        request: CopyBackupRequest,
4142        parent: &str,
4143    ) -> ProjectInstanceBackupCopyCall<'a, C> {
4144        ProjectInstanceBackupCopyCall {
4145            hub: self.hub,
4146            _request: request,
4147            _parent: parent.to_string(),
4148            _delegate: Default::default(),
4149            _additional_params: Default::default(),
4150            _scopes: Default::default(),
4151        }
4152    }
4153
4154    /// Create a builder to help you perform the following task:
4155    ///
4156    /// Starts creating a new Cloud Spanner Backup. The returned backup long-running operation will have a name of the format `projects//instances//backups//operations/` and can be used to track creation of the backup. The metadata field type is CreateBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the creation and delete the backup. There can be only one pending backup creation per database. Backup creation of different databases can run concurrently.
4157    ///
4158    /// # Arguments
4159    ///
4160    /// * `request` - No description provided.
4161    /// * `parent` - Required. The name of the instance in which the backup is created. This must be the same instance that contains the database the backup is created from. The backup will be stored in the locations specified in the instance configuration of this instance. Values are of the form `projects//instances/`.
4162    pub fn instances_backups_create(
4163        &self,
4164        request: Backup,
4165        parent: &str,
4166    ) -> ProjectInstanceBackupCreateCall<'a, C> {
4167        ProjectInstanceBackupCreateCall {
4168            hub: self.hub,
4169            _request: request,
4170            _parent: parent.to_string(),
4171            _encryption_config_kms_key_names: Default::default(),
4172            _encryption_config_kms_key_name: Default::default(),
4173            _encryption_config_encryption_type: Default::default(),
4174            _backup_id: Default::default(),
4175            _delegate: Default::default(),
4176            _additional_params: Default::default(),
4177            _scopes: Default::default(),
4178        }
4179    }
4180
4181    /// Create a builder to help you perform the following task:
4182    ///
4183    /// Deletes a pending or completed Backup.
4184    ///
4185    /// # Arguments
4186    ///
4187    /// * `name` - Required. Name of the backup to delete. Values are of the form `projects//instances//backups/`.
4188    pub fn instances_backups_delete(&self, name: &str) -> ProjectInstanceBackupDeleteCall<'a, C> {
4189        ProjectInstanceBackupDeleteCall {
4190            hub: self.hub,
4191            _name: name.to_string(),
4192            _delegate: Default::default(),
4193            _additional_params: Default::default(),
4194            _scopes: Default::default(),
4195        }
4196    }
4197
4198    /// Create a builder to help you perform the following task:
4199    ///
4200    /// Gets metadata on a pending or completed Backup.
4201    ///
4202    /// # Arguments
4203    ///
4204    /// * `name` - Required. Name of the backup. Values are of the form `projects//instances//backups/`.
4205    pub fn instances_backups_get(&self, name: &str) -> ProjectInstanceBackupGetCall<'a, C> {
4206        ProjectInstanceBackupGetCall {
4207            hub: self.hub,
4208            _name: name.to_string(),
4209            _delegate: Default::default(),
4210            _additional_params: Default::default(),
4211            _scopes: Default::default(),
4212        }
4213    }
4214
4215    /// Create a builder to help you perform the following task:
4216    ///
4217    /// Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set. Authorization requires `spanner.databases.getIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.getIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.getIamPolicy` permission on resource.
4218    ///
4219    /// # Arguments
4220    ///
4221    /// * `request` - No description provided.
4222    /// * `resource` - REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
4223    pub fn instances_backups_get_iam_policy(
4224        &self,
4225        request: GetIamPolicyRequest,
4226        resource: &str,
4227    ) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
4228        ProjectInstanceBackupGetIamPolicyCall {
4229            hub: self.hub,
4230            _request: request,
4231            _resource: resource.to_string(),
4232            _delegate: Default::default(),
4233            _additional_params: Default::default(),
4234            _scopes: Default::default(),
4235        }
4236    }
4237
4238    /// Create a builder to help you perform the following task:
4239    ///
4240    /// Lists completed and pending backups. Backups returned are ordered by `create_time` in descending order, starting from the most recent `create_time`.
4241    ///
4242    /// # Arguments
4243    ///
4244    /// * `parent` - Required. The instance to list backups from. Values are of the form `projects//instances/`.
4245    pub fn instances_backups_list(&self, parent: &str) -> ProjectInstanceBackupListCall<'a, C> {
4246        ProjectInstanceBackupListCall {
4247            hub: self.hub,
4248            _parent: parent.to_string(),
4249            _page_token: Default::default(),
4250            _page_size: Default::default(),
4251            _filter: Default::default(),
4252            _delegate: Default::default(),
4253            _additional_params: Default::default(),
4254            _scopes: Default::default(),
4255        }
4256    }
4257
4258    /// Create a builder to help you perform the following task:
4259    ///
4260    /// Updates a pending or completed Backup.
4261    ///
4262    /// # Arguments
4263    ///
4264    /// * `request` - No description provided.
4265    /// * `name` - Output only for the CreateBackup operation. Required for the UpdateBackup operation. A globally unique identifier for the backup which cannot be changed. Values are of the form `projects//instances//backups/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length. The backup is stored in the location(s) specified in the instance configuration of the instance containing the backup, identified by the prefix of the backup name of the form `projects//instances/`.
4266    pub fn instances_backups_patch(
4267        &self,
4268        request: Backup,
4269        name: &str,
4270    ) -> ProjectInstanceBackupPatchCall<'a, C> {
4271        ProjectInstanceBackupPatchCall {
4272            hub: self.hub,
4273            _request: request,
4274            _name: name.to_string(),
4275            _update_mask: Default::default(),
4276            _delegate: Default::default(),
4277            _additional_params: Default::default(),
4278            _scopes: Default::default(),
4279        }
4280    }
4281
4282    /// Create a builder to help you perform the following task:
4283    ///
4284    /// Sets the access control policy on a database or backup resource. Replaces any existing policy. Authorization requires `spanner.databases.setIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.setIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.setIamPolicy` permission on resource.
4285    ///
4286    /// # Arguments
4287    ///
4288    /// * `request` - No description provided.
4289    /// * `resource` - REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for databases resources.
4290    pub fn instances_backups_set_iam_policy(
4291        &self,
4292        request: SetIamPolicyRequest,
4293        resource: &str,
4294    ) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
4295        ProjectInstanceBackupSetIamPolicyCall {
4296            hub: self.hub,
4297            _request: request,
4298            _resource: resource.to_string(),
4299            _delegate: Default::default(),
4300            _additional_params: Default::default(),
4301            _scopes: Default::default(),
4302        }
4303    }
4304
4305    /// Create a builder to help you perform the following task:
4306    ///
4307    /// Returns permissions that the caller has on the specified database or backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance. Calling this method on a backup schedule that does not exist will result in a NOT_FOUND error if the user has `spanner.backupSchedules.list` permission on the containing database.
4308    ///
4309    /// # Arguments
4310    ///
4311    /// * `request` - No description provided.
4312    /// * `resource` - REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
4313    pub fn instances_backups_test_iam_permissions(
4314        &self,
4315        request: TestIamPermissionsRequest,
4316        resource: &str,
4317    ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
4318        ProjectInstanceBackupTestIamPermissionCall {
4319            hub: self.hub,
4320            _request: request,
4321            _resource: resource.to_string(),
4322            _delegate: Default::default(),
4323            _additional_params: Default::default(),
4324            _scopes: Default::default(),
4325        }
4326    }
4327
4328    /// Create a builder to help you perform the following task:
4329    ///
4330    /// Lists database longrunning-operations. A database operation has a name of the form `projects//instances//databases//operations/`. The long-running operation metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations.
4331    ///
4332    /// # Arguments
4333    ///
4334    /// * `parent` - Required. The instance of the database operations. Values are of the form `projects//instances/`.
4335    pub fn instances_database_operations_list(
4336        &self,
4337        parent: &str,
4338    ) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
4339        ProjectInstanceDatabaseOperationListCall {
4340            hub: self.hub,
4341            _parent: parent.to_string(),
4342            _page_token: Default::default(),
4343            _page_size: Default::default(),
4344            _filter: Default::default(),
4345            _delegate: Default::default(),
4346            _additional_params: Default::default(),
4347            _scopes: Default::default(),
4348        }
4349    }
4350
4351    /// Create a builder to help you perform the following task:
4352    ///
4353    /// Creates a new backup schedule.
4354    ///
4355    /// # Arguments
4356    ///
4357    /// * `request` - No description provided.
4358    /// * `parent` - Required. The name of the database that this backup schedule applies to.
4359    pub fn instances_databases_backup_schedules_create(
4360        &self,
4361        request: BackupSchedule,
4362        parent: &str,
4363    ) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C> {
4364        ProjectInstanceDatabaseBackupScheduleCreateCall {
4365            hub: self.hub,
4366            _request: request,
4367            _parent: parent.to_string(),
4368            _backup_schedule_id: Default::default(),
4369            _delegate: Default::default(),
4370            _additional_params: Default::default(),
4371            _scopes: Default::default(),
4372        }
4373    }
4374
4375    /// Create a builder to help you perform the following task:
4376    ///
4377    /// Deletes a backup schedule.
4378    ///
4379    /// # Arguments
4380    ///
4381    /// * `name` - Required. The name of the schedule to delete. Values are of the form `projects//instances//databases//backupSchedules/`.
4382    pub fn instances_databases_backup_schedules_delete(
4383        &self,
4384        name: &str,
4385    ) -> ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C> {
4386        ProjectInstanceDatabaseBackupScheduleDeleteCall {
4387            hub: self.hub,
4388            _name: name.to_string(),
4389            _delegate: Default::default(),
4390            _additional_params: Default::default(),
4391            _scopes: Default::default(),
4392        }
4393    }
4394
4395    /// Create a builder to help you perform the following task:
4396    ///
4397    /// Gets backup schedule for the input schedule name.
4398    ///
4399    /// # Arguments
4400    ///
4401    /// * `name` - Required. The name of the schedule to retrieve. Values are of the form `projects//instances//databases//backupSchedules/`.
4402    pub fn instances_databases_backup_schedules_get(
4403        &self,
4404        name: &str,
4405    ) -> ProjectInstanceDatabaseBackupScheduleGetCall<'a, C> {
4406        ProjectInstanceDatabaseBackupScheduleGetCall {
4407            hub: self.hub,
4408            _name: name.to_string(),
4409            _delegate: Default::default(),
4410            _additional_params: Default::default(),
4411            _scopes: Default::default(),
4412        }
4413    }
4414
4415    /// Create a builder to help you perform the following task:
4416    ///
4417    /// Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set. Authorization requires `spanner.databases.getIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.getIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.getIamPolicy` permission on resource.
4418    ///
4419    /// # Arguments
4420    ///
4421    /// * `request` - No description provided.
4422    /// * `resource` - REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
4423    pub fn instances_databases_backup_schedules_get_iam_policy(
4424        &self,
4425        request: GetIamPolicyRequest,
4426        resource: &str,
4427    ) -> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C> {
4428        ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall {
4429            hub: self.hub,
4430            _request: request,
4431            _resource: resource.to_string(),
4432            _delegate: Default::default(),
4433            _additional_params: Default::default(),
4434            _scopes: Default::default(),
4435        }
4436    }
4437
4438    /// Create a builder to help you perform the following task:
4439    ///
4440    /// Lists all the backup schedules for the database.
4441    ///
4442    /// # Arguments
4443    ///
4444    /// * `parent` - Required. Database is the parent resource whose backup schedules should be listed. Values are of the form projects//instances//databases/
4445    pub fn instances_databases_backup_schedules_list(
4446        &self,
4447        parent: &str,
4448    ) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C> {
4449        ProjectInstanceDatabaseBackupScheduleListCall {
4450            hub: self.hub,
4451            _parent: parent.to_string(),
4452            _page_token: Default::default(),
4453            _page_size: Default::default(),
4454            _delegate: Default::default(),
4455            _additional_params: Default::default(),
4456            _scopes: Default::default(),
4457        }
4458    }
4459
4460    /// Create a builder to help you perform the following task:
4461    ///
4462    /// Updates a backup schedule.
4463    ///
4464    /// # Arguments
4465    ///
4466    /// * `request` - No description provided.
4467    /// * `name` - Identifier. Output only for the CreateBackupSchedule operation. Required for the UpdateBackupSchedule operation. A globally unique identifier for the backup schedule which cannot be changed. Values are of the form `projects//instances//databases//backupSchedules/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length.
4468    pub fn instances_databases_backup_schedules_patch(
4469        &self,
4470        request: BackupSchedule,
4471        name: &str,
4472    ) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C> {
4473        ProjectInstanceDatabaseBackupSchedulePatchCall {
4474            hub: self.hub,
4475            _request: request,
4476            _name: name.to_string(),
4477            _update_mask: Default::default(),
4478            _delegate: Default::default(),
4479            _additional_params: Default::default(),
4480            _scopes: Default::default(),
4481        }
4482    }
4483
4484    /// Create a builder to help you perform the following task:
4485    ///
4486    /// Sets the access control policy on a database or backup resource. Replaces any existing policy. Authorization requires `spanner.databases.setIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.setIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.setIamPolicy` permission on resource.
4487    ///
4488    /// # Arguments
4489    ///
4490    /// * `request` - No description provided.
4491    /// * `resource` - REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for databases resources.
4492    pub fn instances_databases_backup_schedules_set_iam_policy(
4493        &self,
4494        request: SetIamPolicyRequest,
4495        resource: &str,
4496    ) -> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C> {
4497        ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall {
4498            hub: self.hub,
4499            _request: request,
4500            _resource: resource.to_string(),
4501            _delegate: Default::default(),
4502            _additional_params: Default::default(),
4503            _scopes: Default::default(),
4504        }
4505    }
4506
4507    /// Create a builder to help you perform the following task:
4508    ///
4509    /// Returns permissions that the caller has on the specified database or backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance. Calling this method on a backup schedule that does not exist will result in a NOT_FOUND error if the user has `spanner.backupSchedules.list` permission on the containing database.
4510    ///
4511    /// # Arguments
4512    ///
4513    /// * `request` - No description provided.
4514    /// * `resource` - REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
4515    pub fn instances_databases_backup_schedules_test_iam_permissions(
4516        &self,
4517        request: TestIamPermissionsRequest,
4518        resource: &str,
4519    ) -> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C> {
4520        ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall {
4521            hub: self.hub,
4522            _request: request,
4523            _resource: resource.to_string(),
4524            _delegate: Default::default(),
4525            _additional_params: Default::default(),
4526            _scopes: Default::default(),
4527        }
4528    }
4529
4530    /// Create a builder to help you perform the following task:
4531    ///
4532    /// Lists Cloud Spanner database roles.
4533    ///
4534    /// # Arguments
4535    ///
4536    /// * `parent` - Required. The database whose roles should be listed. Values are of the form `projects//instances//databases/`.
4537    pub fn instances_databases_database_roles_list(
4538        &self,
4539        parent: &str,
4540    ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
4541        ProjectInstanceDatabaseDatabaseRoleListCall {
4542            hub: self.hub,
4543            _parent: parent.to_string(),
4544            _page_token: Default::default(),
4545            _page_size: Default::default(),
4546            _delegate: Default::default(),
4547            _additional_params: Default::default(),
4548            _scopes: Default::default(),
4549        }
4550    }
4551
4552    /// Create a builder to help you perform the following task:
4553    ///
4554    /// Returns permissions that the caller has on the specified database or backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance. Calling this method on a backup schedule that does not exist will result in a NOT_FOUND error if the user has `spanner.backupSchedules.list` permission on the containing database.
4555    ///
4556    /// # Arguments
4557    ///
4558    /// * `request` - No description provided.
4559    /// * `resource` - REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
4560    pub fn instances_databases_database_roles_test_iam_permissions(
4561        &self,
4562        request: TestIamPermissionsRequest,
4563        resource: &str,
4564    ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
4565        ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall {
4566            hub: self.hub,
4567            _request: request,
4568            _resource: resource.to_string(),
4569            _delegate: Default::default(),
4570            _additional_params: Default::default(),
4571            _scopes: Default::default(),
4572        }
4573    }
4574
4575    /// Create a builder to help you perform the following task:
4576    ///
4577    /// 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`.
4578    ///
4579    /// # Arguments
4580    ///
4581    /// * `name` - The name of the operation resource to be cancelled.
4582    pub fn instances_databases_operations_cancel(
4583        &self,
4584        name: &str,
4585    ) -> ProjectInstanceDatabaseOperationCancelCall<'a, C> {
4586        ProjectInstanceDatabaseOperationCancelCall {
4587            hub: self.hub,
4588            _name: name.to_string(),
4589            _delegate: Default::default(),
4590            _additional_params: Default::default(),
4591            _scopes: Default::default(),
4592        }
4593    }
4594
4595    /// Create a builder to help you perform the following task:
4596    ///
4597    /// 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`.
4598    ///
4599    /// # Arguments
4600    ///
4601    /// * `name` - The name of the operation resource to be deleted.
4602    pub fn instances_databases_operations_delete(
4603        &self,
4604        name: &str,
4605    ) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C> {
4606        ProjectInstanceDatabaseOperationDeleteCall {
4607            hub: self.hub,
4608            _name: name.to_string(),
4609            _delegate: Default::default(),
4610            _additional_params: Default::default(),
4611            _scopes: Default::default(),
4612        }
4613    }
4614
4615    /// Create a builder to help you perform the following task:
4616    ///
4617    /// 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.
4618    ///
4619    /// # Arguments
4620    ///
4621    /// * `name` - The name of the operation resource.
4622    pub fn instances_databases_operations_get(
4623        &self,
4624        name: &str,
4625    ) -> ProjectInstanceDatabaseOperationGetCall<'a, C> {
4626        ProjectInstanceDatabaseOperationGetCall {
4627            hub: self.hub,
4628            _name: name.to_string(),
4629            _delegate: Default::default(),
4630            _additional_params: Default::default(),
4631            _scopes: Default::default(),
4632        }
4633    }
4634
4635    /// Create a builder to help you perform the following task:
4636    ///
4637    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4638    ///
4639    /// # Arguments
4640    ///
4641    /// * `name` - The name of the operation's parent resource.
4642    pub fn instances_databases_operations_list(
4643        &self,
4644        name: &str,
4645    ) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
4646        ProjectInstanceDatabaseOperationListCall1 {
4647            hub: self.hub,
4648            _name: name.to_string(),
4649            _return_partial_success: Default::default(),
4650            _page_token: Default::default(),
4651            _page_size: Default::default(),
4652            _filter: Default::default(),
4653            _delegate: Default::default(),
4654            _additional_params: Default::default(),
4655            _scopes: Default::default(),
4656        }
4657    }
4658
4659    /// Create a builder to help you perform the following task:
4660    ///
4661    /// Handles a single message from the client and returns the result as a stream. The server will interpret the message frame and respond with message frames to the client.
4662    ///
4663    /// # Arguments
4664    ///
4665    /// * `request` - No description provided.
4666    /// * `name` - Required. The database session in which the adapter request is processed.
4667    pub fn instances_databases_sessions_adapt_message(
4668        &self,
4669        request: AdaptMessageRequest,
4670        name: &str,
4671    ) -> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C> {
4672        ProjectInstanceDatabaseSessionAdaptMessageCall {
4673            hub: self.hub,
4674            _request: request,
4675            _name: name.to_string(),
4676            _delegate: Default::default(),
4677            _additional_params: Default::default(),
4678            _scopes: Default::default(),
4679        }
4680    }
4681
4682    /// Create a builder to help you perform the following task:
4683    ///
4684    /// Creates a new session to be used for requests made by the adapter. A session identifies a specific incarnation of a database resource and is meant to be reused across many `AdaptMessage` calls.
4685    ///
4686    /// # Arguments
4687    ///
4688    /// * `request` - No description provided.
4689    /// * `parent` - Required. The database in which the new session is created.
4690    pub fn instances_databases_sessions_adapter(
4691        &self,
4692        request: AdapterSession,
4693        parent: &str,
4694    ) -> ProjectInstanceDatabaseSessionAdapterCall<'a, C> {
4695        ProjectInstanceDatabaseSessionAdapterCall {
4696            hub: self.hub,
4697            _request: request,
4698            _parent: parent.to_string(),
4699            _delegate: Default::default(),
4700            _additional_params: Default::default(),
4701            _scopes: Default::default(),
4702        }
4703    }
4704
4705    /// Create a builder to help you perform the following task:
4706    ///
4707    /// Creates multiple new sessions. This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.
4708    ///
4709    /// # Arguments
4710    ///
4711    /// * `request` - No description provided.
4712    /// * `database` - Required. The database in which the new sessions are created.
4713    pub fn instances_databases_sessions_batch_create(
4714        &self,
4715        request: BatchCreateSessionsRequest,
4716        database: &str,
4717    ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
4718        ProjectInstanceDatabaseSessionBatchCreateCall {
4719            hub: self.hub,
4720            _request: request,
4721            _database: database.to_string(),
4722            _delegate: Default::default(),
4723            _additional_params: Default::default(),
4724            _scopes: Default::default(),
4725        }
4726    }
4727
4728    /// Create a builder to help you perform the following task:
4729    ///
4730    /// Batches the supplied mutation groups in a collection of efficient transactions. All mutations in a group are committed atomically. However, mutations across groups can be committed non-atomically in an unspecified order and thus, they must be independent of each other. Partial failure is possible, that is, some groups might have been committed successfully, while some might have failed. The results of individual batches are streamed into the response as the batches are applied. `BatchWrite` requests are not replay protected, meaning that each mutation group can be applied more than once. Replays of non-idempotent mutations can have undesirable effects. For example, replays of an insert mutation can produce an already exists error or if you use generated or commit timestamp-based keys, it can result in additional rows being added to the mutation's table. We recommend structuring your mutation groups to be idempotent to avoid this issue.
4731    ///
4732    /// # Arguments
4733    ///
4734    /// * `request` - No description provided.
4735    /// * `session` - Required. The session in which the batch request is to be run.
4736    pub fn instances_databases_sessions_batch_write(
4737        &self,
4738        request: BatchWriteRequest,
4739        session: &str,
4740    ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
4741        ProjectInstanceDatabaseSessionBatchWriteCall {
4742            hub: self.hub,
4743            _request: request,
4744            _session: session.to_string(),
4745            _delegate: Default::default(),
4746            _additional_params: Default::default(),
4747            _scopes: Default::default(),
4748        }
4749    }
4750
4751    /// Create a builder to help you perform the following task:
4752    ///
4753    /// Begins a new transaction. This step can often be skipped: Read, ExecuteSql and Commit can begin a new transaction as a side-effect.
4754    ///
4755    /// # Arguments
4756    ///
4757    /// * `request` - No description provided.
4758    /// * `session` - Required. The session in which the transaction runs.
4759    pub fn instances_databases_sessions_begin_transaction(
4760        &self,
4761        request: BeginTransactionRequest,
4762        session: &str,
4763    ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
4764        ProjectInstanceDatabaseSessionBeginTransactionCall {
4765            hub: self.hub,
4766            _request: request,
4767            _session: session.to_string(),
4768            _delegate: Default::default(),
4769            _additional_params: Default::default(),
4770            _scopes: Default::default(),
4771        }
4772    }
4773
4774    /// Create a builder to help you perform the following task:
4775    ///
4776    /// Commits a transaction. The request includes the mutations to be applied to rows in the database. `Commit` might return an `ABORTED` error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If `Commit` returns `ABORTED`, the caller should retry the transaction from the beginning, reusing the same session. On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.
4777    ///
4778    /// # Arguments
4779    ///
4780    /// * `request` - No description provided.
4781    /// * `session` - Required. The session in which the transaction to be committed is running.
4782    pub fn instances_databases_sessions_commit(
4783        &self,
4784        request: CommitRequest,
4785        session: &str,
4786    ) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
4787        ProjectInstanceDatabaseSessionCommitCall {
4788            hub: self.hub,
4789            _request: request,
4790            _session: session.to_string(),
4791            _delegate: Default::default(),
4792            _additional_params: Default::default(),
4793            _scopes: Default::default(),
4794        }
4795    }
4796
4797    /// Create a builder to help you perform the following task:
4798    ///
4799    /// Creates a new session. A session can be used to perform transactions that read and/or modify data in a Cloud Spanner database. Sessions are meant to be reused for many consecutive transactions. Sessions can only execute one transaction at a time. To execute multiple concurrent read-write/write-only transactions, create multiple sessions. Note that standalone reads and queries use a transaction internally, and count toward the one transaction limit. Active sessions use additional server resources, so it's a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner can delete sessions when no operations are sent for more than an hour. If a session is deleted, requests to it return `NOT_FOUND`. Idle sessions can be kept alive by sending a trivial SQL query periodically, for example, `"SELECT 1"`.
4800    ///
4801    /// # Arguments
4802    ///
4803    /// * `request` - No description provided.
4804    /// * `database` - Required. The database in which the new session is created.
4805    pub fn instances_databases_sessions_create(
4806        &self,
4807        request: CreateSessionRequest,
4808        database: &str,
4809    ) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
4810        ProjectInstanceDatabaseSessionCreateCall {
4811            hub: self.hub,
4812            _request: request,
4813            _database: database.to_string(),
4814            _delegate: Default::default(),
4815            _additional_params: Default::default(),
4816            _scopes: Default::default(),
4817        }
4818    }
4819
4820    /// Create a builder to help you perform the following task:
4821    ///
4822    /// Ends a session, releasing server resources associated with it. This asynchronously triggers the cancellation of any operations that are running with this session.
4823    ///
4824    /// # Arguments
4825    ///
4826    /// * `name` - Required. The name of the session to delete.
4827    pub fn instances_databases_sessions_delete(
4828        &self,
4829        name: &str,
4830    ) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C> {
4831        ProjectInstanceDatabaseSessionDeleteCall {
4832            hub: self.hub,
4833            _name: name.to_string(),
4834            _delegate: Default::default(),
4835            _additional_params: Default::default(),
4836            _scopes: Default::default(),
4837        }
4838    }
4839
4840    /// Create a builder to help you perform the following task:
4841    ///
4842    /// Executes a batch of SQL DML statements. This method allows many statements to be run with lower latency than submitting them sequentially with ExecuteSql. Statements are executed in sequential order. A request can succeed even if a statement fails. The ExecuteBatchDmlResponse.status field in the response provides information about the statement that failed. Clients must inspect this field to determine whether an error occurred. Execution stops after the first failed statement; the remaining statements are not executed.
4843    ///
4844    /// # Arguments
4845    ///
4846    /// * `request` - No description provided.
4847    /// * `session` - Required. The session in which the DML statements should be performed.
4848    pub fn instances_databases_sessions_execute_batch_dml(
4849        &self,
4850        request: ExecuteBatchDmlRequest,
4851        session: &str,
4852    ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
4853        ProjectInstanceDatabaseSessionExecuteBatchDmlCall {
4854            hub: self.hub,
4855            _request: request,
4856            _session: session.to_string(),
4857            _delegate: Default::default(),
4858            _additional_params: Default::default(),
4859            _scopes: Default::default(),
4860        }
4861    }
4862
4863    /// Create a builder to help you perform the following task:
4864    ///
4865    /// Executes an SQL statement, returning all results in a single reply. This method can't be used to return a result set larger than 10 MiB; if the query yields more data than that, the query fails with a `FAILED_PRECONDITION` error. Operations inside read-write transactions might return `ABORTED`. If this occurs, the application should restart the transaction from the beginning. See Transaction for more details. Larger result sets can be fetched in streaming fashion by calling ExecuteStreamingSql instead. The query string can be SQL or [Graph Query Language (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro).
4866    ///
4867    /// # Arguments
4868    ///
4869    /// * `request` - No description provided.
4870    /// * `session` - Required. The session in which the SQL query should be performed.
4871    pub fn instances_databases_sessions_execute_sql(
4872        &self,
4873        request: ExecuteSqlRequest,
4874        session: &str,
4875    ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
4876        ProjectInstanceDatabaseSessionExecuteSqlCall {
4877            hub: self.hub,
4878            _request: request,
4879            _session: session.to_string(),
4880            _delegate: Default::default(),
4881            _additional_params: Default::default(),
4882            _scopes: Default::default(),
4883        }
4884    }
4885
4886    /// Create a builder to help you perform the following task:
4887    ///
4888    /// Like ExecuteSql, except returns the result set as a stream. Unlike ExecuteSql, there is no limit on the size of the returned result set. However, no individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB. The query string can be SQL or [Graph Query Language (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro).
4889    ///
4890    /// # Arguments
4891    ///
4892    /// * `request` - No description provided.
4893    /// * `session` - Required. The session in which the SQL query should be performed.
4894    pub fn instances_databases_sessions_execute_streaming_sql(
4895        &self,
4896        request: ExecuteSqlRequest,
4897        session: &str,
4898    ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
4899        ProjectInstanceDatabaseSessionExecuteStreamingSqlCall {
4900            hub: self.hub,
4901            _request: request,
4902            _session: session.to_string(),
4903            _delegate: Default::default(),
4904            _additional_params: Default::default(),
4905            _scopes: Default::default(),
4906        }
4907    }
4908
4909    /// Create a builder to help you perform the following task:
4910    ///
4911    /// Gets a session. Returns `NOT_FOUND` if the session doesn't exist. This is mainly useful for determining whether a session is still alive.
4912    ///
4913    /// # Arguments
4914    ///
4915    /// * `name` - Required. The name of the session to retrieve.
4916    pub fn instances_databases_sessions_get(
4917        &self,
4918        name: &str,
4919    ) -> ProjectInstanceDatabaseSessionGetCall<'a, C> {
4920        ProjectInstanceDatabaseSessionGetCall {
4921            hub: self.hub,
4922            _name: name.to_string(),
4923            _delegate: Default::default(),
4924            _additional_params: Default::default(),
4925            _scopes: Default::default(),
4926        }
4927    }
4928
4929    /// Create a builder to help you perform the following task:
4930    ///
4931    /// Lists all sessions in a given database.
4932    ///
4933    /// # Arguments
4934    ///
4935    /// * `database` - Required. The database in which to list sessions.
4936    pub fn instances_databases_sessions_list(
4937        &self,
4938        database: &str,
4939    ) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
4940        ProjectInstanceDatabaseSessionListCall {
4941            hub: self.hub,
4942            _database: database.to_string(),
4943            _page_token: Default::default(),
4944            _page_size: Default::default(),
4945            _filter: Default::default(),
4946            _delegate: Default::default(),
4947            _additional_params: Default::default(),
4948            _scopes: Default::default(),
4949        }
4950    }
4951
4952    /// Create a builder to help you perform the following task:
4953    ///
4954    /// Creates a set of partition tokens that can be used to execute a query operation in parallel. Each of the returned partition tokens can be used by ExecuteStreamingSql to specify a subset of the query result to read. The same session and read-only transaction must be used by the `PartitionQueryRequest` used to create the partition tokens and the `ExecuteSqlRequests` that use the partition tokens. Partition tokens become invalid when the session used to create them is deleted, is idle for too long, begins a new transaction, or becomes too old. When any of these happen, it isn't possible to resume the query, and the whole operation must be restarted from the beginning.
4955    ///
4956    /// # Arguments
4957    ///
4958    /// * `request` - No description provided.
4959    /// * `session` - Required. The session used to create the partitions.
4960    pub fn instances_databases_sessions_partition_query(
4961        &self,
4962        request: PartitionQueryRequest,
4963        session: &str,
4964    ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
4965        ProjectInstanceDatabaseSessionPartitionQueryCall {
4966            hub: self.hub,
4967            _request: request,
4968            _session: session.to_string(),
4969            _delegate: Default::default(),
4970            _additional_params: Default::default(),
4971            _scopes: Default::default(),
4972        }
4973    }
4974
4975    /// Create a builder to help you perform the following task:
4976    ///
4977    /// Creates a set of partition tokens that can be used to execute a read operation in parallel. Each of the returned partition tokens can be used by StreamingRead to specify a subset of the read result to read. The same session and read-only transaction must be used by the `PartitionReadRequest` used to create the partition tokens and the `ReadRequests` that use the partition tokens. There are no ordering guarantees on rows returned among the returned partition tokens, or even within each individual `StreamingRead` call issued with a `partition_token`. Partition tokens become invalid when the session used to create them is deleted, is idle for too long, begins a new transaction, or becomes too old. When any of these happen, it isn't possible to resume the read, and the whole operation must be restarted from the beginning.
4978    ///
4979    /// # Arguments
4980    ///
4981    /// * `request` - No description provided.
4982    /// * `session` - Required. The session used to create the partitions.
4983    pub fn instances_databases_sessions_partition_read(
4984        &self,
4985        request: PartitionReadRequest,
4986        session: &str,
4987    ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
4988        ProjectInstanceDatabaseSessionPartitionReadCall {
4989            hub: self.hub,
4990            _request: request,
4991            _session: session.to_string(),
4992            _delegate: Default::default(),
4993            _additional_params: Default::default(),
4994            _scopes: Default::default(),
4995        }
4996    }
4997
4998    /// Create a builder to help you perform the following task:
4999    ///
5000    /// Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteSql. This method can't be used to return a result set larger than 10 MiB; if the read matches more data than that, the read fails with a `FAILED_PRECONDITION` error. Reads inside read-write transactions might return `ABORTED`. If this occurs, the application should restart the transaction from the beginning. See Transaction for more details. Larger result sets can be yielded in streaming fashion by calling StreamingRead instead.
5001    ///
5002    /// # Arguments
5003    ///
5004    /// * `request` - No description provided.
5005    /// * `session` - Required. The session in which the read should be performed.
5006    pub fn instances_databases_sessions_read(
5007        &self,
5008        request: ReadRequest,
5009        session: &str,
5010    ) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
5011        ProjectInstanceDatabaseSessionReadCall {
5012            hub: self.hub,
5013            _request: request,
5014            _session: session.to_string(),
5015            _delegate: Default::default(),
5016            _additional_params: Default::default(),
5017            _scopes: Default::default(),
5018        }
5019    }
5020
5021    /// Create a builder to help you perform the following task:
5022    ///
5023    /// Rolls back a transaction, releasing any locks it holds. It's a good idea to call this for any transaction that includes one or more Read or ExecuteSql requests and ultimately decides not to commit. `Rollback` returns `OK` if it successfully aborts the transaction, the transaction was already aborted, or the transaction isn't found. `Rollback` never returns `ABORTED`.
5024    ///
5025    /// # Arguments
5026    ///
5027    /// * `request` - No description provided.
5028    /// * `session` - Required. The session in which the transaction to roll back is running.
5029    pub fn instances_databases_sessions_rollback(
5030        &self,
5031        request: RollbackRequest,
5032        session: &str,
5033    ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
5034        ProjectInstanceDatabaseSessionRollbackCall {
5035            hub: self.hub,
5036            _request: request,
5037            _session: session.to_string(),
5038            _delegate: Default::default(),
5039            _additional_params: Default::default(),
5040            _scopes: Default::default(),
5041        }
5042    }
5043
5044    /// Create a builder to help you perform the following task:
5045    ///
5046    /// Like Read, except returns the result set as a stream. Unlike Read, there is no limit on the size of the returned result set. However, no individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB.
5047    ///
5048    /// # Arguments
5049    ///
5050    /// * `request` - No description provided.
5051    /// * `session` - Required. The session in which the read should be performed.
5052    pub fn instances_databases_sessions_streaming_read(
5053        &self,
5054        request: ReadRequest,
5055        session: &str,
5056    ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
5057        ProjectInstanceDatabaseSessionStreamingReadCall {
5058            hub: self.hub,
5059            _request: request,
5060            _session: session.to_string(),
5061            _delegate: Default::default(),
5062            _additional_params: Default::default(),
5063            _scopes: Default::default(),
5064        }
5065    }
5066
5067    /// Create a builder to help you perform the following task:
5068    ///
5069    /// Adds split points to specified tables and indexes of a database.
5070    ///
5071    /// # Arguments
5072    ///
5073    /// * `request` - No description provided.
5074    /// * `database` - Required. The database on whose tables or indexes the split points are to be added. Values are of the form `projects//instances//databases/`.
5075    pub fn instances_databases_add_split_points(
5076        &self,
5077        request: AddSplitPointsRequest,
5078        database: &str,
5079    ) -> ProjectInstanceDatabaseAddSplitPointCall<'a, C> {
5080        ProjectInstanceDatabaseAddSplitPointCall {
5081            hub: self.hub,
5082            _request: request,
5083            _database: database.to_string(),
5084            _delegate: Default::default(),
5085            _additional_params: Default::default(),
5086            _scopes: Default::default(),
5087        }
5088    }
5089
5090    /// Create a builder to help you perform the following task:
5091    ///
5092    /// `ChangeQuorum` is strictly restricted to databases that use dual-region instance configurations. Initiates a background operation to change the quorum of a database from dual-region mode to single-region mode or vice versa. The returned long-running operation has a name of the format `projects//instances//databases//operations/` and can be used to track execution of the `ChangeQuorum`. The metadata field type is ChangeQuorumMetadata. Authorization requires `spanner.databases.changequorum` permission on the resource database.
5093    ///
5094    /// # Arguments
5095    ///
5096    /// * `request` - No description provided.
5097    /// * `name` - Required. Name of the database in which to apply `ChangeQuorum`. Values are of the form `projects//instances//databases/`.
5098    pub fn instances_databases_changequorum(
5099        &self,
5100        request: ChangeQuorumRequest,
5101        name: &str,
5102    ) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
5103        ProjectInstanceDatabaseChangequorumCall {
5104            hub: self.hub,
5105            _request: request,
5106            _name: name.to_string(),
5107            _delegate: Default::default(),
5108            _additional_params: Default::default(),
5109            _scopes: Default::default(),
5110        }
5111    }
5112
5113    /// Create a builder to help you perform the following task:
5114    ///
5115    /// Creates a new Spanner database and starts to prepare it for serving. The returned long-running operation will have a name of the format `/operations/` and can be used to track preparation of the database. The metadata field type is CreateDatabaseMetadata. The response field type is Database, if successful.
5116    ///
5117    /// # Arguments
5118    ///
5119    /// * `request` - No description provided.
5120    /// * `parent` - Required. The name of the instance that will serve the new database. Values are of the form `projects//instances/`.
5121    pub fn instances_databases_create(
5122        &self,
5123        request: CreateDatabaseRequest,
5124        parent: &str,
5125    ) -> ProjectInstanceDatabaseCreateCall<'a, C> {
5126        ProjectInstanceDatabaseCreateCall {
5127            hub: self.hub,
5128            _request: request,
5129            _parent: parent.to_string(),
5130            _delegate: Default::default(),
5131            _additional_params: Default::default(),
5132            _scopes: Default::default(),
5133        }
5134    }
5135
5136    /// Create a builder to help you perform the following task:
5137    ///
5138    /// Drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be retained according to their `expire_time`. Note: Cloud Spanner might continue to accept requests for a few seconds after the database has been deleted.
5139    ///
5140    /// # Arguments
5141    ///
5142    /// * `database` - Required. The database to be dropped.
5143    pub fn instances_databases_drop_database(
5144        &self,
5145        database: &str,
5146    ) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C> {
5147        ProjectInstanceDatabaseDropDatabaseCall {
5148            hub: self.hub,
5149            _database: database.to_string(),
5150            _delegate: Default::default(),
5151            _additional_params: Default::default(),
5152            _scopes: Default::default(),
5153        }
5154    }
5155
5156    /// Create a builder to help you perform the following task:
5157    ///
5158    /// Gets the state of a Cloud Spanner database.
5159    ///
5160    /// # Arguments
5161    ///
5162    /// * `name` - Required. The name of the requested database. Values are of the form `projects//instances//databases/`.
5163    pub fn instances_databases_get(&self, name: &str) -> ProjectInstanceDatabaseGetCall<'a, C> {
5164        ProjectInstanceDatabaseGetCall {
5165            hub: self.hub,
5166            _name: name.to_string(),
5167            _delegate: Default::default(),
5168            _additional_params: Default::default(),
5169            _scopes: Default::default(),
5170        }
5171    }
5172
5173    /// Create a builder to help you perform the following task:
5174    ///
5175    /// Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.
5176    ///
5177    /// # Arguments
5178    ///
5179    /// * `database` - Required. The database whose schema we wish to get. Values are of the form `projects//instances//databases/`
5180    pub fn instances_databases_get_ddl(
5181        &self,
5182        database: &str,
5183    ) -> ProjectInstanceDatabaseGetDdlCall<'a, C> {
5184        ProjectInstanceDatabaseGetDdlCall {
5185            hub: self.hub,
5186            _database: database.to_string(),
5187            _delegate: Default::default(),
5188            _additional_params: Default::default(),
5189            _scopes: Default::default(),
5190        }
5191    }
5192
5193    /// Create a builder to help you perform the following task:
5194    ///
5195    /// Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set. Authorization requires `spanner.databases.getIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.getIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.getIamPolicy` permission on resource.
5196    ///
5197    /// # Arguments
5198    ///
5199    /// * `request` - No description provided.
5200    /// * `resource` - REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
5201    pub fn instances_databases_get_iam_policy(
5202        &self,
5203        request: GetIamPolicyRequest,
5204        resource: &str,
5205    ) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
5206        ProjectInstanceDatabaseGetIamPolicyCall {
5207            hub: self.hub,
5208            _request: request,
5209            _resource: resource.to_string(),
5210            _delegate: Default::default(),
5211            _additional_params: Default::default(),
5212            _scopes: Default::default(),
5213        }
5214    }
5215
5216    /// Create a builder to help you perform the following task:
5217    ///
5218    /// Request a specific scan with Database-specific data for Cloud Key Visualizer.
5219    ///
5220    /// # Arguments
5221    ///
5222    /// * `name` - Required. The unique name of the scan containing the requested information, specific to the Database service implementing this interface.
5223    pub fn instances_databases_get_scans(
5224        &self,
5225        name: &str,
5226    ) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
5227        ProjectInstanceDatabaseGetScanCall {
5228            hub: self.hub,
5229            _name: name.to_string(),
5230            _view: Default::default(),
5231            _start_time: Default::default(),
5232            _end_time: Default::default(),
5233            _delegate: Default::default(),
5234            _additional_params: Default::default(),
5235            _scopes: Default::default(),
5236        }
5237    }
5238
5239    /// Create a builder to help you perform the following task:
5240    ///
5241    /// Lists Cloud Spanner databases.
5242    ///
5243    /// # Arguments
5244    ///
5245    /// * `parent` - Required. The instance whose databases should be listed. Values are of the form `projects//instances/`.
5246    pub fn instances_databases_list(&self, parent: &str) -> ProjectInstanceDatabaseListCall<'a, C> {
5247        ProjectInstanceDatabaseListCall {
5248            hub: self.hub,
5249            _parent: parent.to_string(),
5250            _page_token: Default::default(),
5251            _page_size: Default::default(),
5252            _delegate: Default::default(),
5253            _additional_params: Default::default(),
5254            _scopes: Default::default(),
5255        }
5256    }
5257
5258    /// Create a builder to help you perform the following task:
5259    ///
5260    /// Updates a Cloud Spanner database. The returned long-running operation can be used to track the progress of updating the database. If the named database does not exist, returns `NOT_FOUND`. While the operation is pending: * The database's reconciling field is set to true. * Cancelling the operation is best-effort. If the cancellation succeeds, the operation metadata's cancel_time is set, the updates are reverted, and the operation terminates with a `CANCELLED` status. * New UpdateDatabase requests will return a `FAILED_PRECONDITION` error until the pending operation is done (returns successfully or with error). * Reading the database via the API continues to give the pre-request values. Upon completion of the returned operation: * The new values are in effect and readable via the API. * The database's reconciling field becomes false. The returned long-running operation will have a name of the format `projects//instances//databases//operations/` and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.
5261    ///
5262    /// # Arguments
5263    ///
5264    /// * `request` - No description provided.
5265    /// * `name` - Required. The name of the database. Values are of the form `projects//instances//databases/`, where `` is as specified in the `CREATE DATABASE` statement. This name can be passed to other API methods to identify the database.
5266    pub fn instances_databases_patch(
5267        &self,
5268        request: Database,
5269        name: &str,
5270    ) -> ProjectInstanceDatabasePatchCall<'a, C> {
5271        ProjectInstanceDatabasePatchCall {
5272            hub: self.hub,
5273            _request: request,
5274            _name: name.to_string(),
5275            _update_mask: Default::default(),
5276            _delegate: Default::default(),
5277            _additional_params: Default::default(),
5278            _scopes: Default::default(),
5279        }
5280    }
5281
5282    /// Create a builder to help you perform the following task:
5283    ///
5284    /// Create a new database by restoring from a completed backup. The new database must be in the same project and in an instance with the same instance configuration as the instance containing the backup. The returned database long-running operation has a name of the format `projects//instances//databases//operations/`, and can be used to track the progress of the operation, and to cancel it. The metadata field type is RestoreDatabaseMetadata. The response type is Database, if successful. Cancelling the returned operation will stop the restore and delete the database. There can be only one database being restored into an instance at a time. Once the restore operation completes, a new restore operation can be initiated, without waiting for the optimize operation associated with the first restore to complete.
5285    ///
5286    /// # Arguments
5287    ///
5288    /// * `request` - No description provided.
5289    /// * `parent` - Required. The name of the instance in which to create the restored database. This instance must be in the same project and have the same instance configuration as the instance containing the source backup. Values are of the form `projects//instances/`.
5290    pub fn instances_databases_restore(
5291        &self,
5292        request: RestoreDatabaseRequest,
5293        parent: &str,
5294    ) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
5295        ProjectInstanceDatabaseRestoreCall {
5296            hub: self.hub,
5297            _request: request,
5298            _parent: parent.to_string(),
5299            _delegate: Default::default(),
5300            _additional_params: Default::default(),
5301            _scopes: Default::default(),
5302        }
5303    }
5304
5305    /// Create a builder to help you perform the following task:
5306    ///
5307    /// Sets the access control policy on a database or backup resource. Replaces any existing policy. Authorization requires `spanner.databases.setIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.setIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.setIamPolicy` permission on resource.
5308    ///
5309    /// # Arguments
5310    ///
5311    /// * `request` - No description provided.
5312    /// * `resource` - REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for databases resources.
5313    pub fn instances_databases_set_iam_policy(
5314        &self,
5315        request: SetIamPolicyRequest,
5316        resource: &str,
5317    ) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
5318        ProjectInstanceDatabaseSetIamPolicyCall {
5319            hub: self.hub,
5320            _request: request,
5321            _resource: resource.to_string(),
5322            _delegate: Default::default(),
5323            _additional_params: Default::default(),
5324            _scopes: Default::default(),
5325        }
5326    }
5327
5328    /// Create a builder to help you perform the following task:
5329    ///
5330    /// Returns permissions that the caller has on the specified database or backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance. Calling this method on a backup schedule that does not exist will result in a NOT_FOUND error if the user has `spanner.backupSchedules.list` permission on the containing database.
5331    ///
5332    /// # Arguments
5333    ///
5334    /// * `request` - No description provided.
5335    /// * `resource` - REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
5336    pub fn instances_databases_test_iam_permissions(
5337        &self,
5338        request: TestIamPermissionsRequest,
5339        resource: &str,
5340    ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
5341        ProjectInstanceDatabaseTestIamPermissionCall {
5342            hub: self.hub,
5343            _request: request,
5344            _resource: resource.to_string(),
5345            _delegate: Default::default(),
5346            _additional_params: Default::default(),
5347            _scopes: Default::default(),
5348        }
5349    }
5350
5351    /// Create a builder to help you perform the following task:
5352    ///
5353    /// Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns, indexes, etc. The returned long-running operation will have a name of the format `/operations/` and can be used to track execution of the schema changes. The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response.
5354    ///
5355    /// # Arguments
5356    ///
5357    /// * `request` - No description provided.
5358    /// * `database` - Required. The database to update.
5359    pub fn instances_databases_update_ddl(
5360        &self,
5361        request: UpdateDatabaseDdlRequest,
5362        database: &str,
5363    ) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
5364        ProjectInstanceDatabaseUpdateDdlCall {
5365            hub: self.hub,
5366            _request: request,
5367            _database: database.to_string(),
5368            _delegate: Default::default(),
5369            _additional_params: Default::default(),
5370            _scopes: Default::default(),
5371        }
5372    }
5373
5374    /// Create a builder to help you perform the following task:
5375    ///
5376    /// Lists instance partition long-running operations in the given instance. An instance partition operation has a name of the form `projects//instances//instancePartitions//operations/`. The long-running operation metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by `operation.metadata.value.start_time` in descending order starting from the most recently started operation. Authorization requires `spanner.instancePartitionOperations.list` permission on the resource parent.
5377    ///
5378    /// # Arguments
5379    ///
5380    /// * `parent` - Required. The parent instance of the instance partition operations. Values are of the form `projects//instances/`.
5381    pub fn instances_instance_partition_operations_list(
5382        &self,
5383        parent: &str,
5384    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
5385        ProjectInstanceInstancePartitionOperationListCall {
5386            hub: self.hub,
5387            _parent: parent.to_string(),
5388            _page_token: Default::default(),
5389            _page_size: Default::default(),
5390            _instance_partition_deadline: Default::default(),
5391            _filter: Default::default(),
5392            _delegate: Default::default(),
5393            _additional_params: Default::default(),
5394            _scopes: Default::default(),
5395        }
5396    }
5397
5398    /// Create a builder to help you perform the following task:
5399    ///
5400    /// 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`.
5401    ///
5402    /// # Arguments
5403    ///
5404    /// * `name` - The name of the operation resource to be cancelled.
5405    pub fn instances_instance_partitions_operations_cancel(
5406        &self,
5407        name: &str,
5408    ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {
5409        ProjectInstanceInstancePartitionOperationCancelCall {
5410            hub: self.hub,
5411            _name: name.to_string(),
5412            _delegate: Default::default(),
5413            _additional_params: Default::default(),
5414            _scopes: Default::default(),
5415        }
5416    }
5417
5418    /// Create a builder to help you perform the following task:
5419    ///
5420    /// 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`.
5421    ///
5422    /// # Arguments
5423    ///
5424    /// * `name` - The name of the operation resource to be deleted.
5425    pub fn instances_instance_partitions_operations_delete(
5426        &self,
5427        name: &str,
5428    ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {
5429        ProjectInstanceInstancePartitionOperationDeleteCall {
5430            hub: self.hub,
5431            _name: name.to_string(),
5432            _delegate: Default::default(),
5433            _additional_params: Default::default(),
5434            _scopes: Default::default(),
5435        }
5436    }
5437
5438    /// Create a builder to help you perform the following task:
5439    ///
5440    /// 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.
5441    ///
5442    /// # Arguments
5443    ///
5444    /// * `name` - The name of the operation resource.
5445    pub fn instances_instance_partitions_operations_get(
5446        &self,
5447        name: &str,
5448    ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C> {
5449        ProjectInstanceInstancePartitionOperationGetCall {
5450            hub: self.hub,
5451            _name: name.to_string(),
5452            _delegate: Default::default(),
5453            _additional_params: Default::default(),
5454            _scopes: Default::default(),
5455        }
5456    }
5457
5458    /// Create a builder to help you perform the following task:
5459    ///
5460    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
5461    ///
5462    /// # Arguments
5463    ///
5464    /// * `name` - The name of the operation's parent resource.
5465    pub fn instances_instance_partitions_operations_list(
5466        &self,
5467        name: &str,
5468    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
5469        ProjectInstanceInstancePartitionOperationListCall1 {
5470            hub: self.hub,
5471            _name: name.to_string(),
5472            _return_partial_success: Default::default(),
5473            _page_token: Default::default(),
5474            _page_size: Default::default(),
5475            _filter: Default::default(),
5476            _delegate: Default::default(),
5477            _additional_params: Default::default(),
5478            _scopes: Default::default(),
5479        }
5480    }
5481
5482    /// Create a builder to help you perform the following task:
5483    ///
5484    /// Creates an instance partition and begins preparing it to be used. The returned long-running operation can be used to track the progress of preparing the new instance partition. The instance partition name is assigned by the caller. If the named instance partition already exists, `CreateInstancePartition` returns `ALREADY_EXISTS`. Immediately upon completion of this request: * The instance partition is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`. Until completion of the returned operation: * Cancelling the operation renders the instance partition immediately unreadable via the API. * The instance partition can be deleted. * All other attempts to modify the instance partition are rejected. Upon completion of the returned operation: * Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can start using this instance partition. * The instance partition's allocated resource levels are readable via the API. * The instance partition's state becomes `READY`. The returned long-running operation will have a name of the format `/operations/` and can be used to track creation of the instance partition. The metadata field type is CreateInstancePartitionMetadata. The response field type is InstancePartition, if successful.
5485    ///
5486    /// # Arguments
5487    ///
5488    /// * `request` - No description provided.
5489    /// * `parent` - Required. The name of the instance in which to create the instance partition. Values are of the form `projects//instances/`.
5490    pub fn instances_instance_partitions_create(
5491        &self,
5492        request: CreateInstancePartitionRequest,
5493        parent: &str,
5494    ) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
5495        ProjectInstanceInstancePartitionCreateCall {
5496            hub: self.hub,
5497            _request: request,
5498            _parent: parent.to_string(),
5499            _delegate: Default::default(),
5500            _additional_params: Default::default(),
5501            _scopes: Default::default(),
5502        }
5503    }
5504
5505    /// Create a builder to help you perform the following task:
5506    ///
5507    /// Deletes an existing instance partition. Requires that the instance partition is not used by any database or backup and is not the default instance partition of an instance. Authorization requires `spanner.instancePartitions.delete` permission on the resource name.
5508    ///
5509    /// # Arguments
5510    ///
5511    /// * `name` - Required. The name of the instance partition to be deleted. Values are of the form `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`
5512    pub fn instances_instance_partitions_delete(
5513        &self,
5514        name: &str,
5515    ) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
5516        ProjectInstanceInstancePartitionDeleteCall {
5517            hub: self.hub,
5518            _name: name.to_string(),
5519            _etag: Default::default(),
5520            _delegate: Default::default(),
5521            _additional_params: Default::default(),
5522            _scopes: Default::default(),
5523        }
5524    }
5525
5526    /// Create a builder to help you perform the following task:
5527    ///
5528    /// Gets information about a particular instance partition.
5529    ///
5530    /// # Arguments
5531    ///
5532    /// * `name` - Required. The name of the requested instance partition. Values are of the form `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`.
5533    pub fn instances_instance_partitions_get(
5534        &self,
5535        name: &str,
5536    ) -> ProjectInstanceInstancePartitionGetCall<'a, C> {
5537        ProjectInstanceInstancePartitionGetCall {
5538            hub: self.hub,
5539            _name: name.to_string(),
5540            _delegate: Default::default(),
5541            _additional_params: Default::default(),
5542            _scopes: Default::default(),
5543        }
5544    }
5545
5546    /// Create a builder to help you perform the following task:
5547    ///
5548    /// Lists all instance partitions for the given instance.
5549    ///
5550    /// # Arguments
5551    ///
5552    /// * `parent` - Required. The instance whose instance partitions should be listed. Values are of the form `projects//instances/`. Use `{instance} = '-'` to list instance partitions for all Instances in a project, e.g., `projects/myproject/instances/-`.
5553    pub fn instances_instance_partitions_list(
5554        &self,
5555        parent: &str,
5556    ) -> ProjectInstanceInstancePartitionListCall<'a, C> {
5557        ProjectInstanceInstancePartitionListCall {
5558            hub: self.hub,
5559            _parent: parent.to_string(),
5560            _page_token: Default::default(),
5561            _page_size: Default::default(),
5562            _instance_partition_deadline: Default::default(),
5563            _delegate: Default::default(),
5564            _additional_params: Default::default(),
5565            _scopes: Default::default(),
5566        }
5567    }
5568
5569    /// Create a builder to help you perform the following task:
5570    ///
5571    /// Updates an instance partition, and begins allocating or releasing resources as requested. The returned long-running operation can be used to track the progress of updating the instance partition. If the named instance partition does not exist, returns `NOT_FOUND`. Immediately upon completion of this request: * For resource types for which a decrease in the instance partition's allocation has been requested, billing is based on the newly-requested level. Until completion of the returned operation: * Cancelling the operation sets its metadata's cancel_time, and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance partition are rejected. * Reading the instance partition via the API continues to give the pre-request resource levels. Upon completion of the returned operation: * Billing begins for all successfully-allocated resources (some types may have lower than the requested levels). * All newly-reserved resources are available for serving the instance partition's tables. * The instance partition's new resource levels are readable via the API. The returned long-running operation will have a name of the format `/operations/` and can be used to track the instance partition modification. The metadata field type is UpdateInstancePartitionMetadata. The response field type is InstancePartition, if successful. Authorization requires `spanner.instancePartitions.update` permission on the resource name.
5572    ///
5573    /// # Arguments
5574    ///
5575    /// * `request` - No description provided.
5576    /// * `name` - Required. A unique identifier for the instance partition. Values are of the form `projects//instances//instancePartitions/a-z*[a-z0-9]`. The final segment of the name must be between 2 and 64 characters in length. An instance partition's name cannot be changed after the instance partition is created.
5577    pub fn instances_instance_partitions_patch(
5578        &self,
5579        request: UpdateInstancePartitionRequest,
5580        name: &str,
5581    ) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
5582        ProjectInstanceInstancePartitionPatchCall {
5583            hub: self.hub,
5584            _request: request,
5585            _name: name.to_string(),
5586            _delegate: Default::default(),
5587            _additional_params: Default::default(),
5588            _scopes: Default::default(),
5589        }
5590    }
5591
5592    /// Create a builder to help you perform the following task:
5593    ///
5594    /// 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`.
5595    ///
5596    /// # Arguments
5597    ///
5598    /// * `name` - The name of the operation resource to be cancelled.
5599    pub fn instances_operations_cancel(
5600        &self,
5601        name: &str,
5602    ) -> ProjectInstanceOperationCancelCall<'a, C> {
5603        ProjectInstanceOperationCancelCall {
5604            hub: self.hub,
5605            _name: name.to_string(),
5606            _delegate: Default::default(),
5607            _additional_params: Default::default(),
5608            _scopes: Default::default(),
5609        }
5610    }
5611
5612    /// Create a builder to help you perform the following task:
5613    ///
5614    /// 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`.
5615    ///
5616    /// # Arguments
5617    ///
5618    /// * `name` - The name of the operation resource to be deleted.
5619    pub fn instances_operations_delete(
5620        &self,
5621        name: &str,
5622    ) -> ProjectInstanceOperationDeleteCall<'a, C> {
5623        ProjectInstanceOperationDeleteCall {
5624            hub: self.hub,
5625            _name: name.to_string(),
5626            _delegate: Default::default(),
5627            _additional_params: Default::default(),
5628            _scopes: Default::default(),
5629        }
5630    }
5631
5632    /// Create a builder to help you perform the following task:
5633    ///
5634    /// 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.
5635    ///
5636    /// # Arguments
5637    ///
5638    /// * `name` - The name of the operation resource.
5639    pub fn instances_operations_get(&self, name: &str) -> ProjectInstanceOperationGetCall<'a, C> {
5640        ProjectInstanceOperationGetCall {
5641            hub: self.hub,
5642            _name: name.to_string(),
5643            _delegate: Default::default(),
5644            _additional_params: Default::default(),
5645            _scopes: Default::default(),
5646        }
5647    }
5648
5649    /// Create a builder to help you perform the following task:
5650    ///
5651    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
5652    ///
5653    /// # Arguments
5654    ///
5655    /// * `name` - The name of the operation's parent resource.
5656    pub fn instances_operations_list(&self, name: &str) -> ProjectInstanceOperationListCall<'a, C> {
5657        ProjectInstanceOperationListCall {
5658            hub: self.hub,
5659            _name: name.to_string(),
5660            _return_partial_success: Default::default(),
5661            _page_token: Default::default(),
5662            _page_size: Default::default(),
5663            _filter: Default::default(),
5664            _delegate: Default::default(),
5665            _additional_params: Default::default(),
5666            _scopes: Default::default(),
5667        }
5668    }
5669
5670    /// Create a builder to help you perform the following task:
5671    ///
5672    /// Creates an instance and begins preparing it to begin serving. The returned long-running operation can be used to track the progress of preparing the new instance. The instance name is assigned by the caller. If the named instance already exists, `CreateInstance` returns `ALREADY_EXISTS`. Immediately upon completion of this request: * The instance is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`. Until completion of the returned operation: * Cancelling the operation renders the instance immediately unreadable via the API. * The instance can be deleted. * All other attempts to modify the instance are rejected. Upon completion of the returned operation: * Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can be created in the instance. * The instance's allocated resource levels are readable via the API. * The instance's state becomes `READY`. The returned long-running operation will have a name of the format `/operations/` and can be used to track creation of the instance. The metadata field type is CreateInstanceMetadata. The response field type is Instance, if successful.
5673    ///
5674    /// # Arguments
5675    ///
5676    /// * `request` - No description provided.
5677    /// * `parent` - Required. The name of the project in which to create the instance. Values are of the form `projects/`.
5678    pub fn instances_create(
5679        &self,
5680        request: CreateInstanceRequest,
5681        parent: &str,
5682    ) -> ProjectInstanceCreateCall<'a, C> {
5683        ProjectInstanceCreateCall {
5684            hub: self.hub,
5685            _request: request,
5686            _parent: parent.to_string(),
5687            _delegate: Default::default(),
5688            _additional_params: Default::default(),
5689            _scopes: Default::default(),
5690        }
5691    }
5692
5693    /// Create a builder to help you perform the following task:
5694    ///
5695    /// Deletes an instance. Immediately upon completion of the request: * Billing ceases for all of the instance's reserved resources. Soon afterward: * The instance and *all of its databases* immediately and irrevocably disappear from the API. All data in the databases is permanently deleted.
5696    ///
5697    /// # Arguments
5698    ///
5699    /// * `name` - Required. The name of the instance to be deleted. Values are of the form `projects//instances/`
5700    pub fn instances_delete(&self, name: &str) -> ProjectInstanceDeleteCall<'a, C> {
5701        ProjectInstanceDeleteCall {
5702            hub: self.hub,
5703            _name: name.to_string(),
5704            _delegate: Default::default(),
5705            _additional_params: Default::default(),
5706            _scopes: Default::default(),
5707        }
5708    }
5709
5710    /// Create a builder to help you perform the following task:
5711    ///
5712    /// Gets information about a particular instance.
5713    ///
5714    /// # Arguments
5715    ///
5716    /// * `name` - Required. The name of the requested instance. Values are of the form `projects//instances/`.
5717    pub fn instances_get(&self, name: &str) -> ProjectInstanceGetCall<'a, C> {
5718        ProjectInstanceGetCall {
5719            hub: self.hub,
5720            _name: name.to_string(),
5721            _field_mask: Default::default(),
5722            _delegate: Default::default(),
5723            _additional_params: Default::default(),
5724            _scopes: Default::default(),
5725        }
5726    }
5727
5728    /// Create a builder to help you perform the following task:
5729    ///
5730    /// Gets the access control policy for an instance resource. Returns an empty policy if an instance exists but does not have a policy set. Authorization requires `spanner.instances.getIamPolicy` on resource.
5731    ///
5732    /// # Arguments
5733    ///
5734    /// * `request` - No description provided.
5735    /// * `resource` - REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
5736    pub fn instances_get_iam_policy(
5737        &self,
5738        request: GetIamPolicyRequest,
5739        resource: &str,
5740    ) -> ProjectInstanceGetIamPolicyCall<'a, C> {
5741        ProjectInstanceGetIamPolicyCall {
5742            hub: self.hub,
5743            _request: request,
5744            _resource: resource.to_string(),
5745            _delegate: Default::default(),
5746            _additional_params: Default::default(),
5747            _scopes: Default::default(),
5748        }
5749    }
5750
5751    /// Create a builder to help you perform the following task:
5752    ///
5753    /// Lists all instances in the given project.
5754    ///
5755    /// # Arguments
5756    ///
5757    /// * `parent` - Required. The name of the project for which a list of instances is requested. Values are of the form `projects/`.
5758    pub fn instances_list(&self, parent: &str) -> ProjectInstanceListCall<'a, C> {
5759        ProjectInstanceListCall {
5760            hub: self.hub,
5761            _parent: parent.to_string(),
5762            _page_token: Default::default(),
5763            _page_size: Default::default(),
5764            _instance_deadline: Default::default(),
5765            _filter: Default::default(),
5766            _delegate: Default::default(),
5767            _additional_params: Default::default(),
5768            _scopes: Default::default(),
5769        }
5770    }
5771
5772    /// Create a builder to help you perform the following task:
5773    ///
5774    /// Moves an instance to the target instance configuration. You can use the returned long-running operation to track the progress of moving the instance. `MoveInstance` returns `FAILED_PRECONDITION` if the instance meets any of the following criteria: * Is undergoing a move to a different instance configuration * Has backups * Has an ongoing update * Contains any CMEK-enabled databases * Is a free trial instance While the operation is pending: * All other attempts to modify the instance, including changes to its compute capacity, are rejected. * The following database and backup admin operations are rejected: * `DatabaseAdmin.CreateDatabase` * `DatabaseAdmin.UpdateDatabaseDdl` (disabled if default_leader is specified in the request.) * `DatabaseAdmin.RestoreDatabase` * `DatabaseAdmin.CreateBackup` * `DatabaseAdmin.CopyBackup` * Both the source and target instance configurations are subject to hourly compute and storage charges. * The instance might experience higher read-write latencies and a higher transaction abort rate. However, moving an instance doesn't cause any downtime. The returned long-running operation has a name of the format `/operations/` and can be used to track the move instance operation. The metadata field type is MoveInstanceMetadata. The response field type is Instance, if successful. Cancelling the operation sets its metadata's cancel_time. Cancellation is not immediate because it involves moving any data previously moved to the target instance configuration back to the original instance configuration. You can use this operation to track the progress of the cancellation. Upon successful completion of the cancellation, the operation terminates with `CANCELLED` status. If not cancelled, upon completion of the returned operation: * The instance successfully moves to the target instance configuration. * You are billed for compute and storage in target instance configuration. Authorization requires the `spanner.instances.update` permission on the resource instance. For more details, see [Move an instance](https://cloud.google.com/spanner/docs/move-instance).
5775    ///
5776    /// # Arguments
5777    ///
5778    /// * `request` - No description provided.
5779    /// * `name` - Required. The instance to move. Values are of the form `projects//instances/`.
5780    pub fn instances_move(
5781        &self,
5782        request: MoveInstanceRequest,
5783        name: &str,
5784    ) -> ProjectInstanceMoveCall<'a, C> {
5785        ProjectInstanceMoveCall {
5786            hub: self.hub,
5787            _request: request,
5788            _name: name.to_string(),
5789            _delegate: Default::default(),
5790            _additional_params: Default::default(),
5791            _scopes: Default::default(),
5792        }
5793    }
5794
5795    /// Create a builder to help you perform the following task:
5796    ///
5797    /// Updates an instance, and begins allocating or releasing resources as requested. The returned long-running operation can be used to track the progress of updating the instance. If the named instance does not exist, returns `NOT_FOUND`. Immediately upon completion of this request: * For resource types for which a decrease in the instance's allocation has been requested, billing is based on the newly-requested level. Until completion of the returned operation: * Cancelling the operation sets its metadata's cancel_time, and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance are rejected. * Reading the instance via the API continues to give the pre-request resource levels. Upon completion of the returned operation: * Billing begins for all successfully-allocated resources (some types may have lower than the requested levels). * All newly-reserved resources are available for serving the instance's tables. * The instance's new resource levels are readable via the API. The returned long-running operation will have a name of the format `/operations/` and can be used to track the instance modification. The metadata field type is UpdateInstanceMetadata. The response field type is Instance, if successful. Authorization requires `spanner.instances.update` permission on the resource name.
5798    ///
5799    /// # Arguments
5800    ///
5801    /// * `request` - No description provided.
5802    /// * `name` - Required. A unique identifier for the instance, which cannot be changed after the instance is created. Values are of the form `projects//instances/a-z*[a-z0-9]`. The final segment of the name must be between 2 and 64 characters in length.
5803    pub fn instances_patch(
5804        &self,
5805        request: UpdateInstanceRequest,
5806        name: &str,
5807    ) -> ProjectInstancePatchCall<'a, C> {
5808        ProjectInstancePatchCall {
5809            hub: self.hub,
5810            _request: request,
5811            _name: name.to_string(),
5812            _delegate: Default::default(),
5813            _additional_params: Default::default(),
5814            _scopes: Default::default(),
5815        }
5816    }
5817
5818    /// Create a builder to help you perform the following task:
5819    ///
5820    /// Sets the access control policy on an instance resource. Replaces any existing policy. Authorization requires `spanner.instances.setIamPolicy` on resource.
5821    ///
5822    /// # Arguments
5823    ///
5824    /// * `request` - No description provided.
5825    /// * `resource` - REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for databases resources.
5826    pub fn instances_set_iam_policy(
5827        &self,
5828        request: SetIamPolicyRequest,
5829        resource: &str,
5830    ) -> ProjectInstanceSetIamPolicyCall<'a, C> {
5831        ProjectInstanceSetIamPolicyCall {
5832            hub: self.hub,
5833            _request: request,
5834            _resource: resource.to_string(),
5835            _delegate: Default::default(),
5836            _additional_params: Default::default(),
5837            _scopes: Default::default(),
5838        }
5839    }
5840
5841    /// Create a builder to help you perform the following task:
5842    ///
5843    /// Returns permissions that the caller has on the specified instance resource. Attempting this RPC on a non-existent Cloud Spanner instance resource will result in a NOT_FOUND error if the user has `spanner.instances.list` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions.
5844    ///
5845    /// # Arguments
5846    ///
5847    /// * `request` - No description provided.
5848    /// * `resource` - REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
5849    pub fn instances_test_iam_permissions(
5850        &self,
5851        request: TestIamPermissionsRequest,
5852        resource: &str,
5853    ) -> ProjectInstanceTestIamPermissionCall<'a, C> {
5854        ProjectInstanceTestIamPermissionCall {
5855            hub: self.hub,
5856            _request: request,
5857            _resource: resource.to_string(),
5858            _delegate: Default::default(),
5859            _additional_params: Default::default(),
5860            _scopes: Default::default(),
5861        }
5862    }
5863}
5864
5865/// A builder providing access to all methods supported on *scan* resources.
5866/// It is not used directly, but through the [`Spanner`] hub.
5867///
5868/// # Example
5869///
5870/// Instantiate a resource builder
5871///
5872/// ```test_harness,no_run
5873/// extern crate hyper;
5874/// extern crate hyper_rustls;
5875/// extern crate google_spanner1 as spanner1;
5876///
5877/// # async fn dox() {
5878/// use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5879///
5880/// let secret: yup_oauth2::ApplicationSecret = Default::default();
5881/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
5882///     .with_native_roots()
5883///     .unwrap()
5884///     .https_only()
5885///     .enable_http2()
5886///     .build();
5887///
5888/// let executor = hyper_util::rt::TokioExecutor::new();
5889/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5890///     secret,
5891///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5892///     yup_oauth2::client::CustomHyperClientBuilder::from(
5893///         hyper_util::client::legacy::Client::builder(executor).build(connector),
5894///     ),
5895/// ).build().await.unwrap();
5896///
5897/// let client = hyper_util::client::legacy::Client::builder(
5898///     hyper_util::rt::TokioExecutor::new()
5899/// )
5900/// .build(
5901///     hyper_rustls::HttpsConnectorBuilder::new()
5902///         .with_native_roots()
5903///         .unwrap()
5904///         .https_or_http()
5905///         .enable_http2()
5906///         .build()
5907/// );
5908/// let mut hub = Spanner::new(client, auth);
5909/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
5910/// // like `list(...)`
5911/// // to build up your call.
5912/// let rb = hub.scans();
5913/// # }
5914/// ```
5915pub struct ScanMethods<'a, C>
5916where
5917    C: 'a,
5918{
5919    hub: &'a Spanner<C>,
5920}
5921
5922impl<'a, C> common::MethodsBuilder for ScanMethods<'a, C> {}
5923
5924impl<'a, C> ScanMethods<'a, C> {
5925    /// Create a builder to help you perform the following task:
5926    ///
5927    /// Return available scans given a Database-specific resource name.
5928    ///
5929    /// # Arguments
5930    ///
5931    /// * `parent` - Required. The unique name of the parent resource, specific to the Database service implementing this interface.
5932    pub fn list(&self, parent: &str) -> ScanListCall<'a, C> {
5933        ScanListCall {
5934            hub: self.hub,
5935            _parent: parent.to_string(),
5936            _view: Default::default(),
5937            _page_token: Default::default(),
5938            _page_size: Default::default(),
5939            _filter: Default::default(),
5940            _delegate: Default::default(),
5941            _additional_params: Default::default(),
5942            _scopes: Default::default(),
5943        }
5944    }
5945}
5946
5947// ###################
5948// CallBuilders   ###
5949// #################
5950
5951/// Lists the user-managed instance configuration long-running operations in the given project. An instance configuration operation has a name of the form `projects//instanceConfigs//operations/`. The long-running operation metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by `operation.metadata.value.start_time` in descending order starting from the most recently started operation.
5952///
5953/// A builder for the *instanceConfigOperations.list* method supported by a *project* resource.
5954/// It is not used directly, but through a [`ProjectMethods`] instance.
5955///
5956/// # Example
5957///
5958/// Instantiate a resource method builder
5959///
5960/// ```test_harness,no_run
5961/// # extern crate hyper;
5962/// # extern crate hyper_rustls;
5963/// # extern crate google_spanner1 as spanner1;
5964/// # async fn dox() {
5965/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5966///
5967/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5968/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5969/// #     .with_native_roots()
5970/// #     .unwrap()
5971/// #     .https_only()
5972/// #     .enable_http2()
5973/// #     .build();
5974///
5975/// # let executor = hyper_util::rt::TokioExecutor::new();
5976/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5977/// #     secret,
5978/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5979/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5980/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5981/// #     ),
5982/// # ).build().await.unwrap();
5983///
5984/// # let client = hyper_util::client::legacy::Client::builder(
5985/// #     hyper_util::rt::TokioExecutor::new()
5986/// # )
5987/// # .build(
5988/// #     hyper_rustls::HttpsConnectorBuilder::new()
5989/// #         .with_native_roots()
5990/// #         .unwrap()
5991/// #         .https_or_http()
5992/// #         .enable_http2()
5993/// #         .build()
5994/// # );
5995/// # let mut hub = Spanner::new(client, auth);
5996/// // You can configure optional parameters by calling the respective setters at will, and
5997/// // execute the final call using `doit()`.
5998/// // Values shown here are possibly random and not representative !
5999/// let result = hub.projects().instance_config_operations_list("parent")
6000///              .page_token("eos")
6001///              .page_size(-4)
6002///              .filter("ea")
6003///              .doit().await;
6004/// # }
6005/// ```
6006pub struct ProjectInstanceConfigOperationListCall<'a, C>
6007where
6008    C: 'a,
6009{
6010    hub: &'a Spanner<C>,
6011    _parent: String,
6012    _page_token: Option<String>,
6013    _page_size: Option<i32>,
6014    _filter: Option<String>,
6015    _delegate: Option<&'a mut dyn common::Delegate>,
6016    _additional_params: HashMap<String, String>,
6017    _scopes: BTreeSet<String>,
6018}
6019
6020impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationListCall<'a, C> {}
6021
6022impl<'a, C> ProjectInstanceConfigOperationListCall<'a, C>
6023where
6024    C: common::Connector,
6025{
6026    /// Perform the operation you have build so far.
6027    pub async fn doit(
6028        mut self,
6029    ) -> common::Result<(common::Response, ListInstanceConfigOperationsResponse)> {
6030        use std::borrow::Cow;
6031        use std::io::{Read, Seek};
6032
6033        use common::{url::Params, ToParts};
6034        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6035
6036        let mut dd = common::DefaultDelegate;
6037        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6038        dlg.begin(common::MethodInfo {
6039            id: "spanner.projects.instanceConfigOperations.list",
6040            http_method: hyper::Method::GET,
6041        });
6042
6043        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
6044            if self._additional_params.contains_key(field) {
6045                dlg.finished(false);
6046                return Err(common::Error::FieldClash(field));
6047            }
6048        }
6049
6050        let mut params = Params::with_capacity(6 + self._additional_params.len());
6051        params.push("parent", self._parent);
6052        if let Some(value) = self._page_token.as_ref() {
6053            params.push("pageToken", value);
6054        }
6055        if let Some(value) = self._page_size.as_ref() {
6056            params.push("pageSize", value.to_string());
6057        }
6058        if let Some(value) = self._filter.as_ref() {
6059            params.push("filter", value);
6060        }
6061
6062        params.extend(self._additional_params.iter());
6063
6064        params.push("alt", "json");
6065        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instanceConfigOperations";
6066        if self._scopes.is_empty() {
6067            self._scopes
6068                .insert(Scope::CloudPlatform.as_ref().to_string());
6069        }
6070
6071        #[allow(clippy::single_element_loop)]
6072        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6073            url = params.uri_replacement(url, param_name, find_this, true);
6074        }
6075        {
6076            let to_remove = ["parent"];
6077            params.remove_params(&to_remove);
6078        }
6079
6080        let url = params.parse_with_url(&url);
6081
6082        loop {
6083            let token = match self
6084                .hub
6085                .auth
6086                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6087                .await
6088            {
6089                Ok(token) => token,
6090                Err(e) => match dlg.token(e) {
6091                    Ok(token) => token,
6092                    Err(e) => {
6093                        dlg.finished(false);
6094                        return Err(common::Error::MissingToken(e));
6095                    }
6096                },
6097            };
6098            let mut req_result = {
6099                let client = &self.hub.client;
6100                dlg.pre_request();
6101                let mut req_builder = hyper::Request::builder()
6102                    .method(hyper::Method::GET)
6103                    .uri(url.as_str())
6104                    .header(USER_AGENT, self.hub._user_agent.clone());
6105
6106                if let Some(token) = token.as_ref() {
6107                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6108                }
6109
6110                let request = req_builder
6111                    .header(CONTENT_LENGTH, 0_u64)
6112                    .body(common::to_body::<String>(None));
6113
6114                client.request(request.unwrap()).await
6115            };
6116
6117            match req_result {
6118                Err(err) => {
6119                    if let common::Retry::After(d) = dlg.http_error(&err) {
6120                        sleep(d).await;
6121                        continue;
6122                    }
6123                    dlg.finished(false);
6124                    return Err(common::Error::HttpError(err));
6125                }
6126                Ok(res) => {
6127                    let (mut parts, body) = res.into_parts();
6128                    let mut body = common::Body::new(body);
6129                    if !parts.status.is_success() {
6130                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6131                        let error = serde_json::from_str(&common::to_string(&bytes));
6132                        let response = common::to_response(parts, bytes.into());
6133
6134                        if let common::Retry::After(d) =
6135                            dlg.http_failure(&response, error.as_ref().ok())
6136                        {
6137                            sleep(d).await;
6138                            continue;
6139                        }
6140
6141                        dlg.finished(false);
6142
6143                        return Err(match error {
6144                            Ok(value) => common::Error::BadRequest(value),
6145                            _ => common::Error::Failure(response),
6146                        });
6147                    }
6148                    let response = {
6149                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6150                        let encoded = common::to_string(&bytes);
6151                        match serde_json::from_str(&encoded) {
6152                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6153                            Err(error) => {
6154                                dlg.response_json_decode_error(&encoded, &error);
6155                                return Err(common::Error::JsonDecodeError(
6156                                    encoded.to_string(),
6157                                    error,
6158                                ));
6159                            }
6160                        }
6161                    };
6162
6163                    dlg.finished(true);
6164                    return Ok(response);
6165                }
6166            }
6167        }
6168    }
6169
6170    /// Required. The project of the instance configuration operations. Values are of the form `projects/`.
6171    ///
6172    /// Sets the *parent* path property to the given value.
6173    ///
6174    /// Even though the property as already been set when instantiating this call,
6175    /// we provide this method for API completeness.
6176    pub fn parent(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall<'a, C> {
6177        self._parent = new_value.to_string();
6178        self
6179    }
6180    /// If non-empty, `page_token` should contain a next_page_token from a previous ListInstanceConfigOperationsResponse to the same `parent` and with the same `filter`.
6181    ///
6182    /// Sets the *page token* query property to the given value.
6183    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall<'a, C> {
6184        self._page_token = Some(new_value.to_string());
6185        self
6186    }
6187    /// Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
6188    ///
6189    /// Sets the *page size* query property to the given value.
6190    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceConfigOperationListCall<'a, C> {
6191        self._page_size = Some(new_value);
6192        self
6193    }
6194    /// An expression that filters the list of returned operations. A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. Colon `:` is the contains operator. Filter rules are not case sensitive. The following fields in the Operation are eligible for filtering: * `name` - The name of the long-running operation * `done` - False if the operation is in progress, else true. * `metadata.@type` - the type of metadata. For example, the type string for CreateInstanceConfigMetadata is `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata`. * `metadata.` - any field in metadata.value. `metadata.@type` must be specified first, if filtering on metadata fields. * `error` - Error associated with the long-running operation. * `response.@type` - the type of response. * `response.` - any field in response.value. You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly. Here are a few examples: * `done:true` - The operation is complete. * `(metadata.@type=` \ `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) AND` \ `(metadata.instance_config.name:custom-config) AND` \ `(metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND` \ `(error:*)` - Return operations where: * The operation's metadata type is CreateInstanceConfigMetadata. * The instance configuration name contains "custom-config". * The operation started before 2021-03-28T14:50:00Z. * The operation resulted in an error.
6195    ///
6196    /// Sets the *filter* query property to the given value.
6197    pub fn filter(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall<'a, C> {
6198        self._filter = Some(new_value.to_string());
6199        self
6200    }
6201    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6202    /// while executing the actual API request.
6203    ///
6204    /// ````text
6205    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6206    /// ````
6207    ///
6208    /// Sets the *delegate* property to the given value.
6209    pub fn delegate(
6210        mut self,
6211        new_value: &'a mut dyn common::Delegate,
6212    ) -> ProjectInstanceConfigOperationListCall<'a, C> {
6213        self._delegate = Some(new_value);
6214        self
6215    }
6216
6217    /// Set any additional parameter of the query string used in the request.
6218    /// It should be used to set parameters which are not yet available through their own
6219    /// setters.
6220    ///
6221    /// Please note that this method must not be used to set any of the known parameters
6222    /// which have their own setter method. If done anyway, the request will fail.
6223    ///
6224    /// # Additional Parameters
6225    ///
6226    /// * *$.xgafv* (query-string) - V1 error format.
6227    /// * *access_token* (query-string) - OAuth access token.
6228    /// * *alt* (query-string) - Data format for response.
6229    /// * *callback* (query-string) - JSONP
6230    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6231    /// * *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.
6232    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6233    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6234    /// * *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.
6235    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6236    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6237    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationListCall<'a, C>
6238    where
6239        T: AsRef<str>,
6240    {
6241        self._additional_params
6242            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6243        self
6244    }
6245
6246    /// Identifies the authorization scope for the method you are building.
6247    ///
6248    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6249    /// [`Scope::CloudPlatform`].
6250    ///
6251    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6252    /// tokens for more than one scope.
6253    ///
6254    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6255    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6256    /// sufficient, a read-write scope will do as well.
6257    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationListCall<'a, C>
6258    where
6259        St: AsRef<str>,
6260    {
6261        self._scopes.insert(String::from(scope.as_ref()));
6262        self
6263    }
6264    /// Identifies the authorization scope(s) for the method you are building.
6265    ///
6266    /// See [`Self::add_scope()`] for details.
6267    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationListCall<'a, C>
6268    where
6269        I: IntoIterator<Item = St>,
6270        St: AsRef<str>,
6271    {
6272        self._scopes
6273            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6274        self
6275    }
6276
6277    /// Removes all scopes, and no default scope will be used either.
6278    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6279    /// for details).
6280    pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationListCall<'a, C> {
6281        self._scopes.clear();
6282        self
6283    }
6284}
6285
6286/// 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`.
6287///
6288/// A builder for the *instanceConfigs.operations.cancel* method supported by a *project* resource.
6289/// It is not used directly, but through a [`ProjectMethods`] instance.
6290///
6291/// # Example
6292///
6293/// Instantiate a resource method builder
6294///
6295/// ```test_harness,no_run
6296/// # extern crate hyper;
6297/// # extern crate hyper_rustls;
6298/// # extern crate google_spanner1 as spanner1;
6299/// # async fn dox() {
6300/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6301///
6302/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6303/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6304/// #     .with_native_roots()
6305/// #     .unwrap()
6306/// #     .https_only()
6307/// #     .enable_http2()
6308/// #     .build();
6309///
6310/// # let executor = hyper_util::rt::TokioExecutor::new();
6311/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6312/// #     secret,
6313/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6314/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6315/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6316/// #     ),
6317/// # ).build().await.unwrap();
6318///
6319/// # let client = hyper_util::client::legacy::Client::builder(
6320/// #     hyper_util::rt::TokioExecutor::new()
6321/// # )
6322/// # .build(
6323/// #     hyper_rustls::HttpsConnectorBuilder::new()
6324/// #         .with_native_roots()
6325/// #         .unwrap()
6326/// #         .https_or_http()
6327/// #         .enable_http2()
6328/// #         .build()
6329/// # );
6330/// # let mut hub = Spanner::new(client, auth);
6331/// // You can configure optional parameters by calling the respective setters at will, and
6332/// // execute the final call using `doit()`.
6333/// // Values shown here are possibly random and not representative !
6334/// let result = hub.projects().instance_configs_operations_cancel("name")
6335///              .doit().await;
6336/// # }
6337/// ```
6338pub struct ProjectInstanceConfigOperationCancelCall<'a, C>
6339where
6340    C: 'a,
6341{
6342    hub: &'a Spanner<C>,
6343    _name: String,
6344    _delegate: Option<&'a mut dyn common::Delegate>,
6345    _additional_params: HashMap<String, String>,
6346    _scopes: BTreeSet<String>,
6347}
6348
6349impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationCancelCall<'a, C> {}
6350
6351impl<'a, C> ProjectInstanceConfigOperationCancelCall<'a, C>
6352where
6353    C: common::Connector,
6354{
6355    /// Perform the operation you have build so far.
6356    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6357        use std::borrow::Cow;
6358        use std::io::{Read, Seek};
6359
6360        use common::{url::Params, ToParts};
6361        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6362
6363        let mut dd = common::DefaultDelegate;
6364        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6365        dlg.begin(common::MethodInfo {
6366            id: "spanner.projects.instanceConfigs.operations.cancel",
6367            http_method: hyper::Method::POST,
6368        });
6369
6370        for &field in ["alt", "name"].iter() {
6371            if self._additional_params.contains_key(field) {
6372                dlg.finished(false);
6373                return Err(common::Error::FieldClash(field));
6374            }
6375        }
6376
6377        let mut params = Params::with_capacity(3 + self._additional_params.len());
6378        params.push("name", self._name);
6379
6380        params.extend(self._additional_params.iter());
6381
6382        params.push("alt", "json");
6383        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
6384        if self._scopes.is_empty() {
6385            self._scopes
6386                .insert(Scope::CloudPlatform.as_ref().to_string());
6387        }
6388
6389        #[allow(clippy::single_element_loop)]
6390        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6391            url = params.uri_replacement(url, param_name, find_this, true);
6392        }
6393        {
6394            let to_remove = ["name"];
6395            params.remove_params(&to_remove);
6396        }
6397
6398        let url = params.parse_with_url(&url);
6399
6400        loop {
6401            let token = match self
6402                .hub
6403                .auth
6404                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6405                .await
6406            {
6407                Ok(token) => token,
6408                Err(e) => match dlg.token(e) {
6409                    Ok(token) => token,
6410                    Err(e) => {
6411                        dlg.finished(false);
6412                        return Err(common::Error::MissingToken(e));
6413                    }
6414                },
6415            };
6416            let mut req_result = {
6417                let client = &self.hub.client;
6418                dlg.pre_request();
6419                let mut req_builder = hyper::Request::builder()
6420                    .method(hyper::Method::POST)
6421                    .uri(url.as_str())
6422                    .header(USER_AGENT, self.hub._user_agent.clone());
6423
6424                if let Some(token) = token.as_ref() {
6425                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6426                }
6427
6428                let request = req_builder
6429                    .header(CONTENT_LENGTH, 0_u64)
6430                    .body(common::to_body::<String>(None));
6431
6432                client.request(request.unwrap()).await
6433            };
6434
6435            match req_result {
6436                Err(err) => {
6437                    if let common::Retry::After(d) = dlg.http_error(&err) {
6438                        sleep(d).await;
6439                        continue;
6440                    }
6441                    dlg.finished(false);
6442                    return Err(common::Error::HttpError(err));
6443                }
6444                Ok(res) => {
6445                    let (mut parts, body) = res.into_parts();
6446                    let mut body = common::Body::new(body);
6447                    if !parts.status.is_success() {
6448                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6449                        let error = serde_json::from_str(&common::to_string(&bytes));
6450                        let response = common::to_response(parts, bytes.into());
6451
6452                        if let common::Retry::After(d) =
6453                            dlg.http_failure(&response, error.as_ref().ok())
6454                        {
6455                            sleep(d).await;
6456                            continue;
6457                        }
6458
6459                        dlg.finished(false);
6460
6461                        return Err(match error {
6462                            Ok(value) => common::Error::BadRequest(value),
6463                            _ => common::Error::Failure(response),
6464                        });
6465                    }
6466                    let response = {
6467                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6468                        let encoded = common::to_string(&bytes);
6469                        match serde_json::from_str(&encoded) {
6470                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6471                            Err(error) => {
6472                                dlg.response_json_decode_error(&encoded, &error);
6473                                return Err(common::Error::JsonDecodeError(
6474                                    encoded.to_string(),
6475                                    error,
6476                                ));
6477                            }
6478                        }
6479                    };
6480
6481                    dlg.finished(true);
6482                    return Ok(response);
6483                }
6484            }
6485        }
6486    }
6487
6488    /// The name of the operation resource to be cancelled.
6489    ///
6490    /// Sets the *name* path property to the given value.
6491    ///
6492    /// Even though the property as already been set when instantiating this call,
6493    /// we provide this method for API completeness.
6494    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigOperationCancelCall<'a, C> {
6495        self._name = new_value.to_string();
6496        self
6497    }
6498    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6499    /// while executing the actual API request.
6500    ///
6501    /// ````text
6502    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6503    /// ````
6504    ///
6505    /// Sets the *delegate* property to the given value.
6506    pub fn delegate(
6507        mut self,
6508        new_value: &'a mut dyn common::Delegate,
6509    ) -> ProjectInstanceConfigOperationCancelCall<'a, C> {
6510        self._delegate = Some(new_value);
6511        self
6512    }
6513
6514    /// Set any additional parameter of the query string used in the request.
6515    /// It should be used to set parameters which are not yet available through their own
6516    /// setters.
6517    ///
6518    /// Please note that this method must not be used to set any of the known parameters
6519    /// which have their own setter method. If done anyway, the request will fail.
6520    ///
6521    /// # Additional Parameters
6522    ///
6523    /// * *$.xgafv* (query-string) - V1 error format.
6524    /// * *access_token* (query-string) - OAuth access token.
6525    /// * *alt* (query-string) - Data format for response.
6526    /// * *callback* (query-string) - JSONP
6527    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6528    /// * *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.
6529    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6530    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6531    /// * *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.
6532    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6533    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6534    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationCancelCall<'a, C>
6535    where
6536        T: AsRef<str>,
6537    {
6538        self._additional_params
6539            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6540        self
6541    }
6542
6543    /// Identifies the authorization scope for the method you are building.
6544    ///
6545    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6546    /// [`Scope::CloudPlatform`].
6547    ///
6548    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6549    /// tokens for more than one scope.
6550    ///
6551    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6552    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6553    /// sufficient, a read-write scope will do as well.
6554    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationCancelCall<'a, C>
6555    where
6556        St: AsRef<str>,
6557    {
6558        self._scopes.insert(String::from(scope.as_ref()));
6559        self
6560    }
6561    /// Identifies the authorization scope(s) for the method you are building.
6562    ///
6563    /// See [`Self::add_scope()`] for details.
6564    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationCancelCall<'a, C>
6565    where
6566        I: IntoIterator<Item = St>,
6567        St: AsRef<str>,
6568    {
6569        self._scopes
6570            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6571        self
6572    }
6573
6574    /// Removes all scopes, and no default scope will be used either.
6575    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6576    /// for details).
6577    pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationCancelCall<'a, C> {
6578        self._scopes.clear();
6579        self
6580    }
6581}
6582
6583/// 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`.
6584///
6585/// A builder for the *instanceConfigs.operations.delete* method supported by a *project* resource.
6586/// It is not used directly, but through a [`ProjectMethods`] instance.
6587///
6588/// # Example
6589///
6590/// Instantiate a resource method builder
6591///
6592/// ```test_harness,no_run
6593/// # extern crate hyper;
6594/// # extern crate hyper_rustls;
6595/// # extern crate google_spanner1 as spanner1;
6596/// # async fn dox() {
6597/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6598///
6599/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6600/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6601/// #     .with_native_roots()
6602/// #     .unwrap()
6603/// #     .https_only()
6604/// #     .enable_http2()
6605/// #     .build();
6606///
6607/// # let executor = hyper_util::rt::TokioExecutor::new();
6608/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6609/// #     secret,
6610/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6611/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6612/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6613/// #     ),
6614/// # ).build().await.unwrap();
6615///
6616/// # let client = hyper_util::client::legacy::Client::builder(
6617/// #     hyper_util::rt::TokioExecutor::new()
6618/// # )
6619/// # .build(
6620/// #     hyper_rustls::HttpsConnectorBuilder::new()
6621/// #         .with_native_roots()
6622/// #         .unwrap()
6623/// #         .https_or_http()
6624/// #         .enable_http2()
6625/// #         .build()
6626/// # );
6627/// # let mut hub = Spanner::new(client, auth);
6628/// // You can configure optional parameters by calling the respective setters at will, and
6629/// // execute the final call using `doit()`.
6630/// // Values shown here are possibly random and not representative !
6631/// let result = hub.projects().instance_configs_operations_delete("name")
6632///              .doit().await;
6633/// # }
6634/// ```
6635pub struct ProjectInstanceConfigOperationDeleteCall<'a, C>
6636where
6637    C: 'a,
6638{
6639    hub: &'a Spanner<C>,
6640    _name: String,
6641    _delegate: Option<&'a mut dyn common::Delegate>,
6642    _additional_params: HashMap<String, String>,
6643    _scopes: BTreeSet<String>,
6644}
6645
6646impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationDeleteCall<'a, C> {}
6647
6648impl<'a, C> ProjectInstanceConfigOperationDeleteCall<'a, C>
6649where
6650    C: common::Connector,
6651{
6652    /// Perform the operation you have build so far.
6653    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6654        use std::borrow::Cow;
6655        use std::io::{Read, Seek};
6656
6657        use common::{url::Params, ToParts};
6658        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6659
6660        let mut dd = common::DefaultDelegate;
6661        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6662        dlg.begin(common::MethodInfo {
6663            id: "spanner.projects.instanceConfigs.operations.delete",
6664            http_method: hyper::Method::DELETE,
6665        });
6666
6667        for &field in ["alt", "name"].iter() {
6668            if self._additional_params.contains_key(field) {
6669                dlg.finished(false);
6670                return Err(common::Error::FieldClash(field));
6671            }
6672        }
6673
6674        let mut params = Params::with_capacity(3 + self._additional_params.len());
6675        params.push("name", self._name);
6676
6677        params.extend(self._additional_params.iter());
6678
6679        params.push("alt", "json");
6680        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6681        if self._scopes.is_empty() {
6682            self._scopes
6683                .insert(Scope::CloudPlatform.as_ref().to_string());
6684        }
6685
6686        #[allow(clippy::single_element_loop)]
6687        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6688            url = params.uri_replacement(url, param_name, find_this, true);
6689        }
6690        {
6691            let to_remove = ["name"];
6692            params.remove_params(&to_remove);
6693        }
6694
6695        let url = params.parse_with_url(&url);
6696
6697        loop {
6698            let token = match self
6699                .hub
6700                .auth
6701                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6702                .await
6703            {
6704                Ok(token) => token,
6705                Err(e) => match dlg.token(e) {
6706                    Ok(token) => token,
6707                    Err(e) => {
6708                        dlg.finished(false);
6709                        return Err(common::Error::MissingToken(e));
6710                    }
6711                },
6712            };
6713            let mut req_result = {
6714                let client = &self.hub.client;
6715                dlg.pre_request();
6716                let mut req_builder = hyper::Request::builder()
6717                    .method(hyper::Method::DELETE)
6718                    .uri(url.as_str())
6719                    .header(USER_AGENT, self.hub._user_agent.clone());
6720
6721                if let Some(token) = token.as_ref() {
6722                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6723                }
6724
6725                let request = req_builder
6726                    .header(CONTENT_LENGTH, 0_u64)
6727                    .body(common::to_body::<String>(None));
6728
6729                client.request(request.unwrap()).await
6730            };
6731
6732            match req_result {
6733                Err(err) => {
6734                    if let common::Retry::After(d) = dlg.http_error(&err) {
6735                        sleep(d).await;
6736                        continue;
6737                    }
6738                    dlg.finished(false);
6739                    return Err(common::Error::HttpError(err));
6740                }
6741                Ok(res) => {
6742                    let (mut parts, body) = res.into_parts();
6743                    let mut body = common::Body::new(body);
6744                    if !parts.status.is_success() {
6745                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6746                        let error = serde_json::from_str(&common::to_string(&bytes));
6747                        let response = common::to_response(parts, bytes.into());
6748
6749                        if let common::Retry::After(d) =
6750                            dlg.http_failure(&response, error.as_ref().ok())
6751                        {
6752                            sleep(d).await;
6753                            continue;
6754                        }
6755
6756                        dlg.finished(false);
6757
6758                        return Err(match error {
6759                            Ok(value) => common::Error::BadRequest(value),
6760                            _ => common::Error::Failure(response),
6761                        });
6762                    }
6763                    let response = {
6764                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6765                        let encoded = common::to_string(&bytes);
6766                        match serde_json::from_str(&encoded) {
6767                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6768                            Err(error) => {
6769                                dlg.response_json_decode_error(&encoded, &error);
6770                                return Err(common::Error::JsonDecodeError(
6771                                    encoded.to_string(),
6772                                    error,
6773                                ));
6774                            }
6775                        }
6776                    };
6777
6778                    dlg.finished(true);
6779                    return Ok(response);
6780                }
6781            }
6782        }
6783    }
6784
6785    /// The name of the operation resource to be deleted.
6786    ///
6787    /// Sets the *name* path property to the given value.
6788    ///
6789    /// Even though the property as already been set when instantiating this call,
6790    /// we provide this method for API completeness.
6791    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigOperationDeleteCall<'a, C> {
6792        self._name = new_value.to_string();
6793        self
6794    }
6795    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6796    /// while executing the actual API request.
6797    ///
6798    /// ````text
6799    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6800    /// ````
6801    ///
6802    /// Sets the *delegate* property to the given value.
6803    pub fn delegate(
6804        mut self,
6805        new_value: &'a mut dyn common::Delegate,
6806    ) -> ProjectInstanceConfigOperationDeleteCall<'a, C> {
6807        self._delegate = Some(new_value);
6808        self
6809    }
6810
6811    /// Set any additional parameter of the query string used in the request.
6812    /// It should be used to set parameters which are not yet available through their own
6813    /// setters.
6814    ///
6815    /// Please note that this method must not be used to set any of the known parameters
6816    /// which have their own setter method. If done anyway, the request will fail.
6817    ///
6818    /// # Additional Parameters
6819    ///
6820    /// * *$.xgafv* (query-string) - V1 error format.
6821    /// * *access_token* (query-string) - OAuth access token.
6822    /// * *alt* (query-string) - Data format for response.
6823    /// * *callback* (query-string) - JSONP
6824    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6825    /// * *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.
6826    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6827    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6828    /// * *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.
6829    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6830    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6831    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationDeleteCall<'a, C>
6832    where
6833        T: AsRef<str>,
6834    {
6835        self._additional_params
6836            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6837        self
6838    }
6839
6840    /// Identifies the authorization scope for the method you are building.
6841    ///
6842    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6843    /// [`Scope::CloudPlatform`].
6844    ///
6845    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6846    /// tokens for more than one scope.
6847    ///
6848    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6849    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6850    /// sufficient, a read-write scope will do as well.
6851    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationDeleteCall<'a, C>
6852    where
6853        St: AsRef<str>,
6854    {
6855        self._scopes.insert(String::from(scope.as_ref()));
6856        self
6857    }
6858    /// Identifies the authorization scope(s) for the method you are building.
6859    ///
6860    /// See [`Self::add_scope()`] for details.
6861    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationDeleteCall<'a, C>
6862    where
6863        I: IntoIterator<Item = St>,
6864        St: AsRef<str>,
6865    {
6866        self._scopes
6867            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6868        self
6869    }
6870
6871    /// Removes all scopes, and no default scope will be used either.
6872    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6873    /// for details).
6874    pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationDeleteCall<'a, C> {
6875        self._scopes.clear();
6876        self
6877    }
6878}
6879
6880/// 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.
6881///
6882/// A builder for the *instanceConfigs.operations.get* method supported by a *project* resource.
6883/// It is not used directly, but through a [`ProjectMethods`] instance.
6884///
6885/// # Example
6886///
6887/// Instantiate a resource method builder
6888///
6889/// ```test_harness,no_run
6890/// # extern crate hyper;
6891/// # extern crate hyper_rustls;
6892/// # extern crate google_spanner1 as spanner1;
6893/// # async fn dox() {
6894/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6895///
6896/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6897/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6898/// #     .with_native_roots()
6899/// #     .unwrap()
6900/// #     .https_only()
6901/// #     .enable_http2()
6902/// #     .build();
6903///
6904/// # let executor = hyper_util::rt::TokioExecutor::new();
6905/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6906/// #     secret,
6907/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6908/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6909/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6910/// #     ),
6911/// # ).build().await.unwrap();
6912///
6913/// # let client = hyper_util::client::legacy::Client::builder(
6914/// #     hyper_util::rt::TokioExecutor::new()
6915/// # )
6916/// # .build(
6917/// #     hyper_rustls::HttpsConnectorBuilder::new()
6918/// #         .with_native_roots()
6919/// #         .unwrap()
6920/// #         .https_or_http()
6921/// #         .enable_http2()
6922/// #         .build()
6923/// # );
6924/// # let mut hub = Spanner::new(client, auth);
6925/// // You can configure optional parameters by calling the respective setters at will, and
6926/// // execute the final call using `doit()`.
6927/// // Values shown here are possibly random and not representative !
6928/// let result = hub.projects().instance_configs_operations_get("name")
6929///              .doit().await;
6930/// # }
6931/// ```
6932pub struct ProjectInstanceConfigOperationGetCall<'a, C>
6933where
6934    C: 'a,
6935{
6936    hub: &'a Spanner<C>,
6937    _name: String,
6938    _delegate: Option<&'a mut dyn common::Delegate>,
6939    _additional_params: HashMap<String, String>,
6940    _scopes: BTreeSet<String>,
6941}
6942
6943impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationGetCall<'a, C> {}
6944
6945impl<'a, C> ProjectInstanceConfigOperationGetCall<'a, C>
6946where
6947    C: common::Connector,
6948{
6949    /// Perform the operation you have build so far.
6950    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6951        use std::borrow::Cow;
6952        use std::io::{Read, Seek};
6953
6954        use common::{url::Params, ToParts};
6955        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6956
6957        let mut dd = common::DefaultDelegate;
6958        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6959        dlg.begin(common::MethodInfo {
6960            id: "spanner.projects.instanceConfigs.operations.get",
6961            http_method: hyper::Method::GET,
6962        });
6963
6964        for &field in ["alt", "name"].iter() {
6965            if self._additional_params.contains_key(field) {
6966                dlg.finished(false);
6967                return Err(common::Error::FieldClash(field));
6968            }
6969        }
6970
6971        let mut params = Params::with_capacity(3 + self._additional_params.len());
6972        params.push("name", self._name);
6973
6974        params.extend(self._additional_params.iter());
6975
6976        params.push("alt", "json");
6977        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6978        if self._scopes.is_empty() {
6979            self._scopes
6980                .insert(Scope::CloudPlatform.as_ref().to_string());
6981        }
6982
6983        #[allow(clippy::single_element_loop)]
6984        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6985            url = params.uri_replacement(url, param_name, find_this, true);
6986        }
6987        {
6988            let to_remove = ["name"];
6989            params.remove_params(&to_remove);
6990        }
6991
6992        let url = params.parse_with_url(&url);
6993
6994        loop {
6995            let token = match self
6996                .hub
6997                .auth
6998                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6999                .await
7000            {
7001                Ok(token) => token,
7002                Err(e) => match dlg.token(e) {
7003                    Ok(token) => token,
7004                    Err(e) => {
7005                        dlg.finished(false);
7006                        return Err(common::Error::MissingToken(e));
7007                    }
7008                },
7009            };
7010            let mut req_result = {
7011                let client = &self.hub.client;
7012                dlg.pre_request();
7013                let mut req_builder = hyper::Request::builder()
7014                    .method(hyper::Method::GET)
7015                    .uri(url.as_str())
7016                    .header(USER_AGENT, self.hub._user_agent.clone());
7017
7018                if let Some(token) = token.as_ref() {
7019                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7020                }
7021
7022                let request = req_builder
7023                    .header(CONTENT_LENGTH, 0_u64)
7024                    .body(common::to_body::<String>(None));
7025
7026                client.request(request.unwrap()).await
7027            };
7028
7029            match req_result {
7030                Err(err) => {
7031                    if let common::Retry::After(d) = dlg.http_error(&err) {
7032                        sleep(d).await;
7033                        continue;
7034                    }
7035                    dlg.finished(false);
7036                    return Err(common::Error::HttpError(err));
7037                }
7038                Ok(res) => {
7039                    let (mut parts, body) = res.into_parts();
7040                    let mut body = common::Body::new(body);
7041                    if !parts.status.is_success() {
7042                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7043                        let error = serde_json::from_str(&common::to_string(&bytes));
7044                        let response = common::to_response(parts, bytes.into());
7045
7046                        if let common::Retry::After(d) =
7047                            dlg.http_failure(&response, error.as_ref().ok())
7048                        {
7049                            sleep(d).await;
7050                            continue;
7051                        }
7052
7053                        dlg.finished(false);
7054
7055                        return Err(match error {
7056                            Ok(value) => common::Error::BadRequest(value),
7057                            _ => common::Error::Failure(response),
7058                        });
7059                    }
7060                    let response = {
7061                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7062                        let encoded = common::to_string(&bytes);
7063                        match serde_json::from_str(&encoded) {
7064                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7065                            Err(error) => {
7066                                dlg.response_json_decode_error(&encoded, &error);
7067                                return Err(common::Error::JsonDecodeError(
7068                                    encoded.to_string(),
7069                                    error,
7070                                ));
7071                            }
7072                        }
7073                    };
7074
7075                    dlg.finished(true);
7076                    return Ok(response);
7077                }
7078            }
7079        }
7080    }
7081
7082    /// The name of the operation resource.
7083    ///
7084    /// Sets the *name* path property to the given value.
7085    ///
7086    /// Even though the property as already been set when instantiating this call,
7087    /// we provide this method for API completeness.
7088    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigOperationGetCall<'a, C> {
7089        self._name = new_value.to_string();
7090        self
7091    }
7092    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7093    /// while executing the actual API request.
7094    ///
7095    /// ````text
7096    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7097    /// ````
7098    ///
7099    /// Sets the *delegate* property to the given value.
7100    pub fn delegate(
7101        mut self,
7102        new_value: &'a mut dyn common::Delegate,
7103    ) -> ProjectInstanceConfigOperationGetCall<'a, C> {
7104        self._delegate = Some(new_value);
7105        self
7106    }
7107
7108    /// Set any additional parameter of the query string used in the request.
7109    /// It should be used to set parameters which are not yet available through their own
7110    /// setters.
7111    ///
7112    /// Please note that this method must not be used to set any of the known parameters
7113    /// which have their own setter method. If done anyway, the request will fail.
7114    ///
7115    /// # Additional Parameters
7116    ///
7117    /// * *$.xgafv* (query-string) - V1 error format.
7118    /// * *access_token* (query-string) - OAuth access token.
7119    /// * *alt* (query-string) - Data format for response.
7120    /// * *callback* (query-string) - JSONP
7121    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7122    /// * *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.
7123    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7124    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7125    /// * *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.
7126    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7127    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7128    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationGetCall<'a, C>
7129    where
7130        T: AsRef<str>,
7131    {
7132        self._additional_params
7133            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7134        self
7135    }
7136
7137    /// Identifies the authorization scope for the method you are building.
7138    ///
7139    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7140    /// [`Scope::CloudPlatform`].
7141    ///
7142    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7143    /// tokens for more than one scope.
7144    ///
7145    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7146    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7147    /// sufficient, a read-write scope will do as well.
7148    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationGetCall<'a, C>
7149    where
7150        St: AsRef<str>,
7151    {
7152        self._scopes.insert(String::from(scope.as_ref()));
7153        self
7154    }
7155    /// Identifies the authorization scope(s) for the method you are building.
7156    ///
7157    /// See [`Self::add_scope()`] for details.
7158    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationGetCall<'a, C>
7159    where
7160        I: IntoIterator<Item = St>,
7161        St: AsRef<str>,
7162    {
7163        self._scopes
7164            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7165        self
7166    }
7167
7168    /// Removes all scopes, and no default scope will be used either.
7169    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7170    /// for details).
7171    pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationGetCall<'a, C> {
7172        self._scopes.clear();
7173        self
7174    }
7175}
7176
7177/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
7178///
7179/// A builder for the *instanceConfigs.operations.list* method supported by a *project* resource.
7180/// It is not used directly, but through a [`ProjectMethods`] instance.
7181///
7182/// # Example
7183///
7184/// Instantiate a resource method builder
7185///
7186/// ```test_harness,no_run
7187/// # extern crate hyper;
7188/// # extern crate hyper_rustls;
7189/// # extern crate google_spanner1 as spanner1;
7190/// # async fn dox() {
7191/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7192///
7193/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7194/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7195/// #     .with_native_roots()
7196/// #     .unwrap()
7197/// #     .https_only()
7198/// #     .enable_http2()
7199/// #     .build();
7200///
7201/// # let executor = hyper_util::rt::TokioExecutor::new();
7202/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7203/// #     secret,
7204/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7205/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7206/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7207/// #     ),
7208/// # ).build().await.unwrap();
7209///
7210/// # let client = hyper_util::client::legacy::Client::builder(
7211/// #     hyper_util::rt::TokioExecutor::new()
7212/// # )
7213/// # .build(
7214/// #     hyper_rustls::HttpsConnectorBuilder::new()
7215/// #         .with_native_roots()
7216/// #         .unwrap()
7217/// #         .https_or_http()
7218/// #         .enable_http2()
7219/// #         .build()
7220/// # );
7221/// # let mut hub = Spanner::new(client, auth);
7222/// // You can configure optional parameters by calling the respective setters at will, and
7223/// // execute the final call using `doit()`.
7224/// // Values shown here are possibly random and not representative !
7225/// let result = hub.projects().instance_configs_operations_list("name")
7226///              .return_partial_success(true)
7227///              .page_token("sed")
7228///              .page_size(-37)
7229///              .filter("gubergren")
7230///              .doit().await;
7231/// # }
7232/// ```
7233pub struct ProjectInstanceConfigOperationListCall1<'a, C>
7234where
7235    C: 'a,
7236{
7237    hub: &'a Spanner<C>,
7238    _name: String,
7239    _return_partial_success: Option<bool>,
7240    _page_token: Option<String>,
7241    _page_size: Option<i32>,
7242    _filter: Option<String>,
7243    _delegate: Option<&'a mut dyn common::Delegate>,
7244    _additional_params: HashMap<String, String>,
7245    _scopes: BTreeSet<String>,
7246}
7247
7248impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationListCall1<'a, C> {}
7249
7250impl<'a, C> ProjectInstanceConfigOperationListCall1<'a, C>
7251where
7252    C: common::Connector,
7253{
7254    /// Perform the operation you have build so far.
7255    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
7256        use std::borrow::Cow;
7257        use std::io::{Read, Seek};
7258
7259        use common::{url::Params, ToParts};
7260        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7261
7262        let mut dd = common::DefaultDelegate;
7263        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7264        dlg.begin(common::MethodInfo {
7265            id: "spanner.projects.instanceConfigs.operations.list",
7266            http_method: hyper::Method::GET,
7267        });
7268
7269        for &field in [
7270            "alt",
7271            "name",
7272            "returnPartialSuccess",
7273            "pageToken",
7274            "pageSize",
7275            "filter",
7276        ]
7277        .iter()
7278        {
7279            if self._additional_params.contains_key(field) {
7280                dlg.finished(false);
7281                return Err(common::Error::FieldClash(field));
7282            }
7283        }
7284
7285        let mut params = Params::with_capacity(7 + self._additional_params.len());
7286        params.push("name", self._name);
7287        if let Some(value) = self._return_partial_success.as_ref() {
7288            params.push("returnPartialSuccess", value.to_string());
7289        }
7290        if let Some(value) = self._page_token.as_ref() {
7291            params.push("pageToken", value);
7292        }
7293        if let Some(value) = self._page_size.as_ref() {
7294            params.push("pageSize", value.to_string());
7295        }
7296        if let Some(value) = self._filter.as_ref() {
7297            params.push("filter", value);
7298        }
7299
7300        params.extend(self._additional_params.iter());
7301
7302        params.push("alt", "json");
7303        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7304        if self._scopes.is_empty() {
7305            self._scopes
7306                .insert(Scope::CloudPlatform.as_ref().to_string());
7307        }
7308
7309        #[allow(clippy::single_element_loop)]
7310        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7311            url = params.uri_replacement(url, param_name, find_this, true);
7312        }
7313        {
7314            let to_remove = ["name"];
7315            params.remove_params(&to_remove);
7316        }
7317
7318        let url = params.parse_with_url(&url);
7319
7320        loop {
7321            let token = match self
7322                .hub
7323                .auth
7324                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7325                .await
7326            {
7327                Ok(token) => token,
7328                Err(e) => match dlg.token(e) {
7329                    Ok(token) => token,
7330                    Err(e) => {
7331                        dlg.finished(false);
7332                        return Err(common::Error::MissingToken(e));
7333                    }
7334                },
7335            };
7336            let mut req_result = {
7337                let client = &self.hub.client;
7338                dlg.pre_request();
7339                let mut req_builder = hyper::Request::builder()
7340                    .method(hyper::Method::GET)
7341                    .uri(url.as_str())
7342                    .header(USER_AGENT, self.hub._user_agent.clone());
7343
7344                if let Some(token) = token.as_ref() {
7345                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7346                }
7347
7348                let request = req_builder
7349                    .header(CONTENT_LENGTH, 0_u64)
7350                    .body(common::to_body::<String>(None));
7351
7352                client.request(request.unwrap()).await
7353            };
7354
7355            match req_result {
7356                Err(err) => {
7357                    if let common::Retry::After(d) = dlg.http_error(&err) {
7358                        sleep(d).await;
7359                        continue;
7360                    }
7361                    dlg.finished(false);
7362                    return Err(common::Error::HttpError(err));
7363                }
7364                Ok(res) => {
7365                    let (mut parts, body) = res.into_parts();
7366                    let mut body = common::Body::new(body);
7367                    if !parts.status.is_success() {
7368                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7369                        let error = serde_json::from_str(&common::to_string(&bytes));
7370                        let response = common::to_response(parts, bytes.into());
7371
7372                        if let common::Retry::After(d) =
7373                            dlg.http_failure(&response, error.as_ref().ok())
7374                        {
7375                            sleep(d).await;
7376                            continue;
7377                        }
7378
7379                        dlg.finished(false);
7380
7381                        return Err(match error {
7382                            Ok(value) => common::Error::BadRequest(value),
7383                            _ => common::Error::Failure(response),
7384                        });
7385                    }
7386                    let response = {
7387                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7388                        let encoded = common::to_string(&bytes);
7389                        match serde_json::from_str(&encoded) {
7390                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7391                            Err(error) => {
7392                                dlg.response_json_decode_error(&encoded, &error);
7393                                return Err(common::Error::JsonDecodeError(
7394                                    encoded.to_string(),
7395                                    error,
7396                                ));
7397                            }
7398                        }
7399                    };
7400
7401                    dlg.finished(true);
7402                    return Ok(response);
7403                }
7404            }
7405        }
7406    }
7407
7408    /// The name of the operation's parent resource.
7409    ///
7410    /// Sets the *name* path property to the given value.
7411    ///
7412    /// Even though the property as already been set when instantiating this call,
7413    /// we provide this method for API completeness.
7414    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall1<'a, C> {
7415        self._name = new_value.to_string();
7416        self
7417    }
7418    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
7419    ///
7420    /// Sets the *return partial success* query property to the given value.
7421    pub fn return_partial_success(
7422        mut self,
7423        new_value: bool,
7424    ) -> ProjectInstanceConfigOperationListCall1<'a, C> {
7425        self._return_partial_success = Some(new_value);
7426        self
7427    }
7428    /// The standard list page token.
7429    ///
7430    /// Sets the *page token* query property to the given value.
7431    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall1<'a, C> {
7432        self._page_token = Some(new_value.to_string());
7433        self
7434    }
7435    /// The standard list page size.
7436    ///
7437    /// Sets the *page size* query property to the given value.
7438    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceConfigOperationListCall1<'a, C> {
7439        self._page_size = Some(new_value);
7440        self
7441    }
7442    /// The standard list filter.
7443    ///
7444    /// Sets the *filter* query property to the given value.
7445    pub fn filter(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall1<'a, C> {
7446        self._filter = Some(new_value.to_string());
7447        self
7448    }
7449    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7450    /// while executing the actual API request.
7451    ///
7452    /// ````text
7453    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7454    /// ````
7455    ///
7456    /// Sets the *delegate* property to the given value.
7457    pub fn delegate(
7458        mut self,
7459        new_value: &'a mut dyn common::Delegate,
7460    ) -> ProjectInstanceConfigOperationListCall1<'a, C> {
7461        self._delegate = Some(new_value);
7462        self
7463    }
7464
7465    /// Set any additional parameter of the query string used in the request.
7466    /// It should be used to set parameters which are not yet available through their own
7467    /// setters.
7468    ///
7469    /// Please note that this method must not be used to set any of the known parameters
7470    /// which have their own setter method. If done anyway, the request will fail.
7471    ///
7472    /// # Additional Parameters
7473    ///
7474    /// * *$.xgafv* (query-string) - V1 error format.
7475    /// * *access_token* (query-string) - OAuth access token.
7476    /// * *alt* (query-string) - Data format for response.
7477    /// * *callback* (query-string) - JSONP
7478    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7479    /// * *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.
7480    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7481    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7482    /// * *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.
7483    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7484    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7485    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationListCall1<'a, C>
7486    where
7487        T: AsRef<str>,
7488    {
7489        self._additional_params
7490            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7491        self
7492    }
7493
7494    /// Identifies the authorization scope for the method you are building.
7495    ///
7496    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7497    /// [`Scope::CloudPlatform`].
7498    ///
7499    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7500    /// tokens for more than one scope.
7501    ///
7502    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7503    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7504    /// sufficient, a read-write scope will do as well.
7505    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationListCall1<'a, C>
7506    where
7507        St: AsRef<str>,
7508    {
7509        self._scopes.insert(String::from(scope.as_ref()));
7510        self
7511    }
7512    /// Identifies the authorization scope(s) for the method you are building.
7513    ///
7514    /// See [`Self::add_scope()`] for details.
7515    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationListCall1<'a, C>
7516    where
7517        I: IntoIterator<Item = St>,
7518        St: AsRef<str>,
7519    {
7520        self._scopes
7521            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7522        self
7523    }
7524
7525    /// Removes all scopes, and no default scope will be used either.
7526    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7527    /// for details).
7528    pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationListCall1<'a, C> {
7529        self._scopes.clear();
7530        self
7531    }
7532}
7533
7534/// 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`.
7535///
7536/// A builder for the *instanceConfigs.ssdCaches.operations.cancel* method supported by a *project* resource.
7537/// It is not used directly, but through a [`ProjectMethods`] instance.
7538///
7539/// # Example
7540///
7541/// Instantiate a resource method builder
7542///
7543/// ```test_harness,no_run
7544/// # extern crate hyper;
7545/// # extern crate hyper_rustls;
7546/// # extern crate google_spanner1 as spanner1;
7547/// # async fn dox() {
7548/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7549///
7550/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7551/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7552/// #     .with_native_roots()
7553/// #     .unwrap()
7554/// #     .https_only()
7555/// #     .enable_http2()
7556/// #     .build();
7557///
7558/// # let executor = hyper_util::rt::TokioExecutor::new();
7559/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7560/// #     secret,
7561/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7562/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7563/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7564/// #     ),
7565/// # ).build().await.unwrap();
7566///
7567/// # let client = hyper_util::client::legacy::Client::builder(
7568/// #     hyper_util::rt::TokioExecutor::new()
7569/// # )
7570/// # .build(
7571/// #     hyper_rustls::HttpsConnectorBuilder::new()
7572/// #         .with_native_roots()
7573/// #         .unwrap()
7574/// #         .https_or_http()
7575/// #         .enable_http2()
7576/// #         .build()
7577/// # );
7578/// # let mut hub = Spanner::new(client, auth);
7579/// // You can configure optional parameters by calling the respective setters at will, and
7580/// // execute the final call using `doit()`.
7581/// // Values shown here are possibly random and not representative !
7582/// let result = hub.projects().instance_configs_ssd_caches_operations_cancel("name")
7583///              .doit().await;
7584/// # }
7585/// ```
7586pub struct ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
7587where
7588    C: 'a,
7589{
7590    hub: &'a Spanner<C>,
7591    _name: String,
7592    _delegate: Option<&'a mut dyn common::Delegate>,
7593    _additional_params: HashMap<String, String>,
7594    _scopes: BTreeSet<String>,
7595}
7596
7597impl<'a, C> common::CallBuilder for ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {}
7598
7599impl<'a, C> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
7600where
7601    C: common::Connector,
7602{
7603    /// Perform the operation you have build so far.
7604    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7605        use std::borrow::Cow;
7606        use std::io::{Read, Seek};
7607
7608        use common::{url::Params, ToParts};
7609        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7610
7611        let mut dd = common::DefaultDelegate;
7612        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7613        dlg.begin(common::MethodInfo {
7614            id: "spanner.projects.instanceConfigs.ssdCaches.operations.cancel",
7615            http_method: hyper::Method::POST,
7616        });
7617
7618        for &field in ["alt", "name"].iter() {
7619            if self._additional_params.contains_key(field) {
7620                dlg.finished(false);
7621                return Err(common::Error::FieldClash(field));
7622            }
7623        }
7624
7625        let mut params = Params::with_capacity(3 + self._additional_params.len());
7626        params.push("name", self._name);
7627
7628        params.extend(self._additional_params.iter());
7629
7630        params.push("alt", "json");
7631        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
7632        if self._scopes.is_empty() {
7633            self._scopes
7634                .insert(Scope::CloudPlatform.as_ref().to_string());
7635        }
7636
7637        #[allow(clippy::single_element_loop)]
7638        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7639            url = params.uri_replacement(url, param_name, find_this, true);
7640        }
7641        {
7642            let to_remove = ["name"];
7643            params.remove_params(&to_remove);
7644        }
7645
7646        let url = params.parse_with_url(&url);
7647
7648        loop {
7649            let token = match self
7650                .hub
7651                .auth
7652                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7653                .await
7654            {
7655                Ok(token) => token,
7656                Err(e) => match dlg.token(e) {
7657                    Ok(token) => token,
7658                    Err(e) => {
7659                        dlg.finished(false);
7660                        return Err(common::Error::MissingToken(e));
7661                    }
7662                },
7663            };
7664            let mut req_result = {
7665                let client = &self.hub.client;
7666                dlg.pre_request();
7667                let mut req_builder = hyper::Request::builder()
7668                    .method(hyper::Method::POST)
7669                    .uri(url.as_str())
7670                    .header(USER_AGENT, self.hub._user_agent.clone());
7671
7672                if let Some(token) = token.as_ref() {
7673                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7674                }
7675
7676                let request = req_builder
7677                    .header(CONTENT_LENGTH, 0_u64)
7678                    .body(common::to_body::<String>(None));
7679
7680                client.request(request.unwrap()).await
7681            };
7682
7683            match req_result {
7684                Err(err) => {
7685                    if let common::Retry::After(d) = dlg.http_error(&err) {
7686                        sleep(d).await;
7687                        continue;
7688                    }
7689                    dlg.finished(false);
7690                    return Err(common::Error::HttpError(err));
7691                }
7692                Ok(res) => {
7693                    let (mut parts, body) = res.into_parts();
7694                    let mut body = common::Body::new(body);
7695                    if !parts.status.is_success() {
7696                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7697                        let error = serde_json::from_str(&common::to_string(&bytes));
7698                        let response = common::to_response(parts, bytes.into());
7699
7700                        if let common::Retry::After(d) =
7701                            dlg.http_failure(&response, error.as_ref().ok())
7702                        {
7703                            sleep(d).await;
7704                            continue;
7705                        }
7706
7707                        dlg.finished(false);
7708
7709                        return Err(match error {
7710                            Ok(value) => common::Error::BadRequest(value),
7711                            _ => common::Error::Failure(response),
7712                        });
7713                    }
7714                    let response = {
7715                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7716                        let encoded = common::to_string(&bytes);
7717                        match serde_json::from_str(&encoded) {
7718                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7719                            Err(error) => {
7720                                dlg.response_json_decode_error(&encoded, &error);
7721                                return Err(common::Error::JsonDecodeError(
7722                                    encoded.to_string(),
7723                                    error,
7724                                ));
7725                            }
7726                        }
7727                    };
7728
7729                    dlg.finished(true);
7730                    return Ok(response);
7731                }
7732            }
7733        }
7734    }
7735
7736    /// The name of the operation resource to be cancelled.
7737    ///
7738    /// Sets the *name* path property to the given value.
7739    ///
7740    /// Even though the property as already been set when instantiating this call,
7741    /// we provide this method for API completeness.
7742    pub fn name(
7743        mut self,
7744        new_value: &str,
7745    ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {
7746        self._name = new_value.to_string();
7747        self
7748    }
7749    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7750    /// while executing the actual API request.
7751    ///
7752    /// ````text
7753    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7754    /// ````
7755    ///
7756    /// Sets the *delegate* property to the given value.
7757    pub fn delegate(
7758        mut self,
7759        new_value: &'a mut dyn common::Delegate,
7760    ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {
7761        self._delegate = Some(new_value);
7762        self
7763    }
7764
7765    /// Set any additional parameter of the query string used in the request.
7766    /// It should be used to set parameters which are not yet available through their own
7767    /// setters.
7768    ///
7769    /// Please note that this method must not be used to set any of the known parameters
7770    /// which have their own setter method. If done anyway, the request will fail.
7771    ///
7772    /// # Additional Parameters
7773    ///
7774    /// * *$.xgafv* (query-string) - V1 error format.
7775    /// * *access_token* (query-string) - OAuth access token.
7776    /// * *alt* (query-string) - Data format for response.
7777    /// * *callback* (query-string) - JSONP
7778    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7779    /// * *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.
7780    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7781    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7782    /// * *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.
7783    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7784    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7785    pub fn param<T>(
7786        mut self,
7787        name: T,
7788        value: T,
7789    ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
7790    where
7791        T: AsRef<str>,
7792    {
7793        self._additional_params
7794            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7795        self
7796    }
7797
7798    /// Identifies the authorization scope for the method you are building.
7799    ///
7800    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7801    /// [`Scope::CloudPlatform`].
7802    ///
7803    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7804    /// tokens for more than one scope.
7805    ///
7806    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7807    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7808    /// sufficient, a read-write scope will do as well.
7809    pub fn add_scope<St>(
7810        mut self,
7811        scope: St,
7812    ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
7813    where
7814        St: AsRef<str>,
7815    {
7816        self._scopes.insert(String::from(scope.as_ref()));
7817        self
7818    }
7819    /// Identifies the authorization scope(s) for the method you are building.
7820    ///
7821    /// See [`Self::add_scope()`] for details.
7822    pub fn add_scopes<I, St>(
7823        mut self,
7824        scopes: I,
7825    ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
7826    where
7827        I: IntoIterator<Item = St>,
7828        St: AsRef<str>,
7829    {
7830        self._scopes
7831            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7832        self
7833    }
7834
7835    /// Removes all scopes, and no default scope will be used either.
7836    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7837    /// for details).
7838    pub fn clear_scopes(mut self) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {
7839        self._scopes.clear();
7840        self
7841    }
7842}
7843
7844/// 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`.
7845///
7846/// A builder for the *instanceConfigs.ssdCaches.operations.delete* method supported by a *project* resource.
7847/// It is not used directly, but through a [`ProjectMethods`] instance.
7848///
7849/// # Example
7850///
7851/// Instantiate a resource method builder
7852///
7853/// ```test_harness,no_run
7854/// # extern crate hyper;
7855/// # extern crate hyper_rustls;
7856/// # extern crate google_spanner1 as spanner1;
7857/// # async fn dox() {
7858/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7859///
7860/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7861/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7862/// #     .with_native_roots()
7863/// #     .unwrap()
7864/// #     .https_only()
7865/// #     .enable_http2()
7866/// #     .build();
7867///
7868/// # let executor = hyper_util::rt::TokioExecutor::new();
7869/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7870/// #     secret,
7871/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7872/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7873/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7874/// #     ),
7875/// # ).build().await.unwrap();
7876///
7877/// # let client = hyper_util::client::legacy::Client::builder(
7878/// #     hyper_util::rt::TokioExecutor::new()
7879/// # )
7880/// # .build(
7881/// #     hyper_rustls::HttpsConnectorBuilder::new()
7882/// #         .with_native_roots()
7883/// #         .unwrap()
7884/// #         .https_or_http()
7885/// #         .enable_http2()
7886/// #         .build()
7887/// # );
7888/// # let mut hub = Spanner::new(client, auth);
7889/// // You can configure optional parameters by calling the respective setters at will, and
7890/// // execute the final call using `doit()`.
7891/// // Values shown here are possibly random and not representative !
7892/// let result = hub.projects().instance_configs_ssd_caches_operations_delete("name")
7893///              .doit().await;
7894/// # }
7895/// ```
7896pub struct ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
7897where
7898    C: 'a,
7899{
7900    hub: &'a Spanner<C>,
7901    _name: String,
7902    _delegate: Option<&'a mut dyn common::Delegate>,
7903    _additional_params: HashMap<String, String>,
7904    _scopes: BTreeSet<String>,
7905}
7906
7907impl<'a, C> common::CallBuilder for ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {}
7908
7909impl<'a, C> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
7910where
7911    C: common::Connector,
7912{
7913    /// Perform the operation you have build so far.
7914    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7915        use std::borrow::Cow;
7916        use std::io::{Read, Seek};
7917
7918        use common::{url::Params, ToParts};
7919        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7920
7921        let mut dd = common::DefaultDelegate;
7922        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7923        dlg.begin(common::MethodInfo {
7924            id: "spanner.projects.instanceConfigs.ssdCaches.operations.delete",
7925            http_method: hyper::Method::DELETE,
7926        });
7927
7928        for &field in ["alt", "name"].iter() {
7929            if self._additional_params.contains_key(field) {
7930                dlg.finished(false);
7931                return Err(common::Error::FieldClash(field));
7932            }
7933        }
7934
7935        let mut params = Params::with_capacity(3 + self._additional_params.len());
7936        params.push("name", self._name);
7937
7938        params.extend(self._additional_params.iter());
7939
7940        params.push("alt", "json");
7941        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7942        if self._scopes.is_empty() {
7943            self._scopes
7944                .insert(Scope::CloudPlatform.as_ref().to_string());
7945        }
7946
7947        #[allow(clippy::single_element_loop)]
7948        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7949            url = params.uri_replacement(url, param_name, find_this, true);
7950        }
7951        {
7952            let to_remove = ["name"];
7953            params.remove_params(&to_remove);
7954        }
7955
7956        let url = params.parse_with_url(&url);
7957
7958        loop {
7959            let token = match self
7960                .hub
7961                .auth
7962                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7963                .await
7964            {
7965                Ok(token) => token,
7966                Err(e) => match dlg.token(e) {
7967                    Ok(token) => token,
7968                    Err(e) => {
7969                        dlg.finished(false);
7970                        return Err(common::Error::MissingToken(e));
7971                    }
7972                },
7973            };
7974            let mut req_result = {
7975                let client = &self.hub.client;
7976                dlg.pre_request();
7977                let mut req_builder = hyper::Request::builder()
7978                    .method(hyper::Method::DELETE)
7979                    .uri(url.as_str())
7980                    .header(USER_AGENT, self.hub._user_agent.clone());
7981
7982                if let Some(token) = token.as_ref() {
7983                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7984                }
7985
7986                let request = req_builder
7987                    .header(CONTENT_LENGTH, 0_u64)
7988                    .body(common::to_body::<String>(None));
7989
7990                client.request(request.unwrap()).await
7991            };
7992
7993            match req_result {
7994                Err(err) => {
7995                    if let common::Retry::After(d) = dlg.http_error(&err) {
7996                        sleep(d).await;
7997                        continue;
7998                    }
7999                    dlg.finished(false);
8000                    return Err(common::Error::HttpError(err));
8001                }
8002                Ok(res) => {
8003                    let (mut parts, body) = res.into_parts();
8004                    let mut body = common::Body::new(body);
8005                    if !parts.status.is_success() {
8006                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8007                        let error = serde_json::from_str(&common::to_string(&bytes));
8008                        let response = common::to_response(parts, bytes.into());
8009
8010                        if let common::Retry::After(d) =
8011                            dlg.http_failure(&response, error.as_ref().ok())
8012                        {
8013                            sleep(d).await;
8014                            continue;
8015                        }
8016
8017                        dlg.finished(false);
8018
8019                        return Err(match error {
8020                            Ok(value) => common::Error::BadRequest(value),
8021                            _ => common::Error::Failure(response),
8022                        });
8023                    }
8024                    let response = {
8025                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8026                        let encoded = common::to_string(&bytes);
8027                        match serde_json::from_str(&encoded) {
8028                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8029                            Err(error) => {
8030                                dlg.response_json_decode_error(&encoded, &error);
8031                                return Err(common::Error::JsonDecodeError(
8032                                    encoded.to_string(),
8033                                    error,
8034                                ));
8035                            }
8036                        }
8037                    };
8038
8039                    dlg.finished(true);
8040                    return Ok(response);
8041                }
8042            }
8043        }
8044    }
8045
8046    /// The name of the operation resource to be deleted.
8047    ///
8048    /// Sets the *name* path property to the given value.
8049    ///
8050    /// Even though the property as already been set when instantiating this call,
8051    /// we provide this method for API completeness.
8052    pub fn name(
8053        mut self,
8054        new_value: &str,
8055    ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {
8056        self._name = new_value.to_string();
8057        self
8058    }
8059    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8060    /// while executing the actual API request.
8061    ///
8062    /// ````text
8063    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8064    /// ````
8065    ///
8066    /// Sets the *delegate* property to the given value.
8067    pub fn delegate(
8068        mut self,
8069        new_value: &'a mut dyn common::Delegate,
8070    ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {
8071        self._delegate = Some(new_value);
8072        self
8073    }
8074
8075    /// Set any additional parameter of the query string used in the request.
8076    /// It should be used to set parameters which are not yet available through their own
8077    /// setters.
8078    ///
8079    /// Please note that this method must not be used to set any of the known parameters
8080    /// which have their own setter method. If done anyway, the request will fail.
8081    ///
8082    /// # Additional Parameters
8083    ///
8084    /// * *$.xgafv* (query-string) - V1 error format.
8085    /// * *access_token* (query-string) - OAuth access token.
8086    /// * *alt* (query-string) - Data format for response.
8087    /// * *callback* (query-string) - JSONP
8088    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8089    /// * *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.
8090    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8091    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8092    /// * *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.
8093    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8094    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8095    pub fn param<T>(
8096        mut self,
8097        name: T,
8098        value: T,
8099    ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
8100    where
8101        T: AsRef<str>,
8102    {
8103        self._additional_params
8104            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8105        self
8106    }
8107
8108    /// Identifies the authorization scope for the method you are building.
8109    ///
8110    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8111    /// [`Scope::CloudPlatform`].
8112    ///
8113    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8114    /// tokens for more than one scope.
8115    ///
8116    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8117    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8118    /// sufficient, a read-write scope will do as well.
8119    pub fn add_scope<St>(
8120        mut self,
8121        scope: St,
8122    ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
8123    where
8124        St: AsRef<str>,
8125    {
8126        self._scopes.insert(String::from(scope.as_ref()));
8127        self
8128    }
8129    /// Identifies the authorization scope(s) for the method you are building.
8130    ///
8131    /// See [`Self::add_scope()`] for details.
8132    pub fn add_scopes<I, St>(
8133        mut self,
8134        scopes: I,
8135    ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
8136    where
8137        I: IntoIterator<Item = St>,
8138        St: AsRef<str>,
8139    {
8140        self._scopes
8141            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8142        self
8143    }
8144
8145    /// Removes all scopes, and no default scope will be used either.
8146    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8147    /// for details).
8148    pub fn clear_scopes(mut self) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {
8149        self._scopes.clear();
8150        self
8151    }
8152}
8153
8154/// 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.
8155///
8156/// A builder for the *instanceConfigs.ssdCaches.operations.get* method supported by a *project* resource.
8157/// It is not used directly, but through a [`ProjectMethods`] instance.
8158///
8159/// # Example
8160///
8161/// Instantiate a resource method builder
8162///
8163/// ```test_harness,no_run
8164/// # extern crate hyper;
8165/// # extern crate hyper_rustls;
8166/// # extern crate google_spanner1 as spanner1;
8167/// # async fn dox() {
8168/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8169///
8170/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8171/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8172/// #     .with_native_roots()
8173/// #     .unwrap()
8174/// #     .https_only()
8175/// #     .enable_http2()
8176/// #     .build();
8177///
8178/// # let executor = hyper_util::rt::TokioExecutor::new();
8179/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8180/// #     secret,
8181/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8182/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8183/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8184/// #     ),
8185/// # ).build().await.unwrap();
8186///
8187/// # let client = hyper_util::client::legacy::Client::builder(
8188/// #     hyper_util::rt::TokioExecutor::new()
8189/// # )
8190/// # .build(
8191/// #     hyper_rustls::HttpsConnectorBuilder::new()
8192/// #         .with_native_roots()
8193/// #         .unwrap()
8194/// #         .https_or_http()
8195/// #         .enable_http2()
8196/// #         .build()
8197/// # );
8198/// # let mut hub = Spanner::new(client, auth);
8199/// // You can configure optional parameters by calling the respective setters at will, and
8200/// // execute the final call using `doit()`.
8201/// // Values shown here are possibly random and not representative !
8202/// let result = hub.projects().instance_configs_ssd_caches_operations_get("name")
8203///              .doit().await;
8204/// # }
8205/// ```
8206pub struct ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
8207where
8208    C: 'a,
8209{
8210    hub: &'a Spanner<C>,
8211    _name: String,
8212    _delegate: Option<&'a mut dyn common::Delegate>,
8213    _additional_params: HashMap<String, String>,
8214    _scopes: BTreeSet<String>,
8215}
8216
8217impl<'a, C> common::CallBuilder for ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {}
8218
8219impl<'a, C> ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
8220where
8221    C: common::Connector,
8222{
8223    /// Perform the operation you have build so far.
8224    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8225        use std::borrow::Cow;
8226        use std::io::{Read, Seek};
8227
8228        use common::{url::Params, ToParts};
8229        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8230
8231        let mut dd = common::DefaultDelegate;
8232        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8233        dlg.begin(common::MethodInfo {
8234            id: "spanner.projects.instanceConfigs.ssdCaches.operations.get",
8235            http_method: hyper::Method::GET,
8236        });
8237
8238        for &field in ["alt", "name"].iter() {
8239            if self._additional_params.contains_key(field) {
8240                dlg.finished(false);
8241                return Err(common::Error::FieldClash(field));
8242            }
8243        }
8244
8245        let mut params = Params::with_capacity(3 + self._additional_params.len());
8246        params.push("name", self._name);
8247
8248        params.extend(self._additional_params.iter());
8249
8250        params.push("alt", "json");
8251        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8252        if self._scopes.is_empty() {
8253            self._scopes
8254                .insert(Scope::CloudPlatform.as_ref().to_string());
8255        }
8256
8257        #[allow(clippy::single_element_loop)]
8258        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8259            url = params.uri_replacement(url, param_name, find_this, true);
8260        }
8261        {
8262            let to_remove = ["name"];
8263            params.remove_params(&to_remove);
8264        }
8265
8266        let url = params.parse_with_url(&url);
8267
8268        loop {
8269            let token = match self
8270                .hub
8271                .auth
8272                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8273                .await
8274            {
8275                Ok(token) => token,
8276                Err(e) => match dlg.token(e) {
8277                    Ok(token) => token,
8278                    Err(e) => {
8279                        dlg.finished(false);
8280                        return Err(common::Error::MissingToken(e));
8281                    }
8282                },
8283            };
8284            let mut req_result = {
8285                let client = &self.hub.client;
8286                dlg.pre_request();
8287                let mut req_builder = hyper::Request::builder()
8288                    .method(hyper::Method::GET)
8289                    .uri(url.as_str())
8290                    .header(USER_AGENT, self.hub._user_agent.clone());
8291
8292                if let Some(token) = token.as_ref() {
8293                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8294                }
8295
8296                let request = req_builder
8297                    .header(CONTENT_LENGTH, 0_u64)
8298                    .body(common::to_body::<String>(None));
8299
8300                client.request(request.unwrap()).await
8301            };
8302
8303            match req_result {
8304                Err(err) => {
8305                    if let common::Retry::After(d) = dlg.http_error(&err) {
8306                        sleep(d).await;
8307                        continue;
8308                    }
8309                    dlg.finished(false);
8310                    return Err(common::Error::HttpError(err));
8311                }
8312                Ok(res) => {
8313                    let (mut parts, body) = res.into_parts();
8314                    let mut body = common::Body::new(body);
8315                    if !parts.status.is_success() {
8316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8317                        let error = serde_json::from_str(&common::to_string(&bytes));
8318                        let response = common::to_response(parts, bytes.into());
8319
8320                        if let common::Retry::After(d) =
8321                            dlg.http_failure(&response, error.as_ref().ok())
8322                        {
8323                            sleep(d).await;
8324                            continue;
8325                        }
8326
8327                        dlg.finished(false);
8328
8329                        return Err(match error {
8330                            Ok(value) => common::Error::BadRequest(value),
8331                            _ => common::Error::Failure(response),
8332                        });
8333                    }
8334                    let response = {
8335                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8336                        let encoded = common::to_string(&bytes);
8337                        match serde_json::from_str(&encoded) {
8338                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8339                            Err(error) => {
8340                                dlg.response_json_decode_error(&encoded, &error);
8341                                return Err(common::Error::JsonDecodeError(
8342                                    encoded.to_string(),
8343                                    error,
8344                                ));
8345                            }
8346                        }
8347                    };
8348
8349                    dlg.finished(true);
8350                    return Ok(response);
8351                }
8352            }
8353        }
8354    }
8355
8356    /// The name of the operation resource.
8357    ///
8358    /// Sets the *name* path property to the given value.
8359    ///
8360    /// Even though the property as already been set when instantiating this call,
8361    /// we provide this method for API completeness.
8362    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {
8363        self._name = new_value.to_string();
8364        self
8365    }
8366    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8367    /// while executing the actual API request.
8368    ///
8369    /// ````text
8370    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8371    /// ````
8372    ///
8373    /// Sets the *delegate* property to the given value.
8374    pub fn delegate(
8375        mut self,
8376        new_value: &'a mut dyn common::Delegate,
8377    ) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {
8378        self._delegate = Some(new_value);
8379        self
8380    }
8381
8382    /// Set any additional parameter of the query string used in the request.
8383    /// It should be used to set parameters which are not yet available through their own
8384    /// setters.
8385    ///
8386    /// Please note that this method must not be used to set any of the known parameters
8387    /// which have their own setter method. If done anyway, the request will fail.
8388    ///
8389    /// # Additional Parameters
8390    ///
8391    /// * *$.xgafv* (query-string) - V1 error format.
8392    /// * *access_token* (query-string) - OAuth access token.
8393    /// * *alt* (query-string) - Data format for response.
8394    /// * *callback* (query-string) - JSONP
8395    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8396    /// * *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.
8397    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8398    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8399    /// * *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.
8400    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8401    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8402    pub fn param<T>(
8403        mut self,
8404        name: T,
8405        value: T,
8406    ) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
8407    where
8408        T: AsRef<str>,
8409    {
8410        self._additional_params
8411            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8412        self
8413    }
8414
8415    /// Identifies the authorization scope for the method you are building.
8416    ///
8417    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8418    /// [`Scope::CloudPlatform`].
8419    ///
8420    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8421    /// tokens for more than one scope.
8422    ///
8423    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8424    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8425    /// sufficient, a read-write scope will do as well.
8426    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
8427    where
8428        St: AsRef<str>,
8429    {
8430        self._scopes.insert(String::from(scope.as_ref()));
8431        self
8432    }
8433    /// Identifies the authorization scope(s) for the method you are building.
8434    ///
8435    /// See [`Self::add_scope()`] for details.
8436    pub fn add_scopes<I, St>(
8437        mut self,
8438        scopes: I,
8439    ) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
8440    where
8441        I: IntoIterator<Item = St>,
8442        St: AsRef<str>,
8443    {
8444        self._scopes
8445            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8446        self
8447    }
8448
8449    /// Removes all scopes, and no default scope will be used either.
8450    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8451    /// for details).
8452    pub fn clear_scopes(mut self) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {
8453        self._scopes.clear();
8454        self
8455    }
8456}
8457
8458/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
8459///
8460/// A builder for the *instanceConfigs.ssdCaches.operations.list* method supported by a *project* resource.
8461/// It is not used directly, but through a [`ProjectMethods`] instance.
8462///
8463/// # Example
8464///
8465/// Instantiate a resource method builder
8466///
8467/// ```test_harness,no_run
8468/// # extern crate hyper;
8469/// # extern crate hyper_rustls;
8470/// # extern crate google_spanner1 as spanner1;
8471/// # async fn dox() {
8472/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8473///
8474/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8475/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8476/// #     .with_native_roots()
8477/// #     .unwrap()
8478/// #     .https_only()
8479/// #     .enable_http2()
8480/// #     .build();
8481///
8482/// # let executor = hyper_util::rt::TokioExecutor::new();
8483/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8484/// #     secret,
8485/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8486/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8487/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8488/// #     ),
8489/// # ).build().await.unwrap();
8490///
8491/// # let client = hyper_util::client::legacy::Client::builder(
8492/// #     hyper_util::rt::TokioExecutor::new()
8493/// # )
8494/// # .build(
8495/// #     hyper_rustls::HttpsConnectorBuilder::new()
8496/// #         .with_native_roots()
8497/// #         .unwrap()
8498/// #         .https_or_http()
8499/// #         .enable_http2()
8500/// #         .build()
8501/// # );
8502/// # let mut hub = Spanner::new(client, auth);
8503/// // You can configure optional parameters by calling the respective setters at will, and
8504/// // execute the final call using `doit()`.
8505/// // Values shown here are possibly random and not representative !
8506/// let result = hub.projects().instance_configs_ssd_caches_operations_list("name")
8507///              .return_partial_success(true)
8508///              .page_token("ea")
8509///              .page_size(-99)
8510///              .filter("Lorem")
8511///              .doit().await;
8512/// # }
8513/// ```
8514pub struct ProjectInstanceConfigSsdCachOperationListCall<'a, C>
8515where
8516    C: 'a,
8517{
8518    hub: &'a Spanner<C>,
8519    _name: String,
8520    _return_partial_success: Option<bool>,
8521    _page_token: Option<String>,
8522    _page_size: Option<i32>,
8523    _filter: Option<String>,
8524    _delegate: Option<&'a mut dyn common::Delegate>,
8525    _additional_params: HashMap<String, String>,
8526    _scopes: BTreeSet<String>,
8527}
8528
8529impl<'a, C> common::CallBuilder for ProjectInstanceConfigSsdCachOperationListCall<'a, C> {}
8530
8531impl<'a, C> ProjectInstanceConfigSsdCachOperationListCall<'a, C>
8532where
8533    C: common::Connector,
8534{
8535    /// Perform the operation you have build so far.
8536    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
8537        use std::borrow::Cow;
8538        use std::io::{Read, Seek};
8539
8540        use common::{url::Params, ToParts};
8541        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8542
8543        let mut dd = common::DefaultDelegate;
8544        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8545        dlg.begin(common::MethodInfo {
8546            id: "spanner.projects.instanceConfigs.ssdCaches.operations.list",
8547            http_method: hyper::Method::GET,
8548        });
8549
8550        for &field in [
8551            "alt",
8552            "name",
8553            "returnPartialSuccess",
8554            "pageToken",
8555            "pageSize",
8556            "filter",
8557        ]
8558        .iter()
8559        {
8560            if self._additional_params.contains_key(field) {
8561                dlg.finished(false);
8562                return Err(common::Error::FieldClash(field));
8563            }
8564        }
8565
8566        let mut params = Params::with_capacity(7 + self._additional_params.len());
8567        params.push("name", self._name);
8568        if let Some(value) = self._return_partial_success.as_ref() {
8569            params.push("returnPartialSuccess", value.to_string());
8570        }
8571        if let Some(value) = self._page_token.as_ref() {
8572            params.push("pageToken", value);
8573        }
8574        if let Some(value) = self._page_size.as_ref() {
8575            params.push("pageSize", value.to_string());
8576        }
8577        if let Some(value) = self._filter.as_ref() {
8578            params.push("filter", value);
8579        }
8580
8581        params.extend(self._additional_params.iter());
8582
8583        params.push("alt", "json");
8584        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8585        if self._scopes.is_empty() {
8586            self._scopes
8587                .insert(Scope::CloudPlatform.as_ref().to_string());
8588        }
8589
8590        #[allow(clippy::single_element_loop)]
8591        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8592            url = params.uri_replacement(url, param_name, find_this, true);
8593        }
8594        {
8595            let to_remove = ["name"];
8596            params.remove_params(&to_remove);
8597        }
8598
8599        let url = params.parse_with_url(&url);
8600
8601        loop {
8602            let token = match self
8603                .hub
8604                .auth
8605                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8606                .await
8607            {
8608                Ok(token) => token,
8609                Err(e) => match dlg.token(e) {
8610                    Ok(token) => token,
8611                    Err(e) => {
8612                        dlg.finished(false);
8613                        return Err(common::Error::MissingToken(e));
8614                    }
8615                },
8616            };
8617            let mut req_result = {
8618                let client = &self.hub.client;
8619                dlg.pre_request();
8620                let mut req_builder = hyper::Request::builder()
8621                    .method(hyper::Method::GET)
8622                    .uri(url.as_str())
8623                    .header(USER_AGENT, self.hub._user_agent.clone());
8624
8625                if let Some(token) = token.as_ref() {
8626                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8627                }
8628
8629                let request = req_builder
8630                    .header(CONTENT_LENGTH, 0_u64)
8631                    .body(common::to_body::<String>(None));
8632
8633                client.request(request.unwrap()).await
8634            };
8635
8636            match req_result {
8637                Err(err) => {
8638                    if let common::Retry::After(d) = dlg.http_error(&err) {
8639                        sleep(d).await;
8640                        continue;
8641                    }
8642                    dlg.finished(false);
8643                    return Err(common::Error::HttpError(err));
8644                }
8645                Ok(res) => {
8646                    let (mut parts, body) = res.into_parts();
8647                    let mut body = common::Body::new(body);
8648                    if !parts.status.is_success() {
8649                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8650                        let error = serde_json::from_str(&common::to_string(&bytes));
8651                        let response = common::to_response(parts, bytes.into());
8652
8653                        if let common::Retry::After(d) =
8654                            dlg.http_failure(&response, error.as_ref().ok())
8655                        {
8656                            sleep(d).await;
8657                            continue;
8658                        }
8659
8660                        dlg.finished(false);
8661
8662                        return Err(match error {
8663                            Ok(value) => common::Error::BadRequest(value),
8664                            _ => common::Error::Failure(response),
8665                        });
8666                    }
8667                    let response = {
8668                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8669                        let encoded = common::to_string(&bytes);
8670                        match serde_json::from_str(&encoded) {
8671                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8672                            Err(error) => {
8673                                dlg.response_json_decode_error(&encoded, &error);
8674                                return Err(common::Error::JsonDecodeError(
8675                                    encoded.to_string(),
8676                                    error,
8677                                ));
8678                            }
8679                        }
8680                    };
8681
8682                    dlg.finished(true);
8683                    return Ok(response);
8684                }
8685            }
8686        }
8687    }
8688
8689    /// The name of the operation's parent resource.
8690    ///
8691    /// Sets the *name* path property to the given value.
8692    ///
8693    /// Even though the property as already been set when instantiating this call,
8694    /// we provide this method for API completeness.
8695    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
8696        self._name = new_value.to_string();
8697        self
8698    }
8699    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
8700    ///
8701    /// Sets the *return partial success* query property to the given value.
8702    pub fn return_partial_success(
8703        mut self,
8704        new_value: bool,
8705    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
8706        self._return_partial_success = Some(new_value);
8707        self
8708    }
8709    /// The standard list page token.
8710    ///
8711    /// Sets the *page token* query property to the given value.
8712    pub fn page_token(
8713        mut self,
8714        new_value: &str,
8715    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
8716        self._page_token = Some(new_value.to_string());
8717        self
8718    }
8719    /// The standard list page size.
8720    ///
8721    /// Sets the *page size* query property to the given value.
8722    pub fn page_size(
8723        mut self,
8724        new_value: i32,
8725    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
8726        self._page_size = Some(new_value);
8727        self
8728    }
8729    /// The standard list filter.
8730    ///
8731    /// Sets the *filter* query property to the given value.
8732    pub fn filter(
8733        mut self,
8734        new_value: &str,
8735    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
8736        self._filter = Some(new_value.to_string());
8737        self
8738    }
8739    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8740    /// while executing the actual API request.
8741    ///
8742    /// ````text
8743    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8744    /// ````
8745    ///
8746    /// Sets the *delegate* property to the given value.
8747    pub fn delegate(
8748        mut self,
8749        new_value: &'a mut dyn common::Delegate,
8750    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
8751        self._delegate = Some(new_value);
8752        self
8753    }
8754
8755    /// Set any additional parameter of the query string used in the request.
8756    /// It should be used to set parameters which are not yet available through their own
8757    /// setters.
8758    ///
8759    /// Please note that this method must not be used to set any of the known parameters
8760    /// which have their own setter method. If done anyway, the request will fail.
8761    ///
8762    /// # Additional Parameters
8763    ///
8764    /// * *$.xgafv* (query-string) - V1 error format.
8765    /// * *access_token* (query-string) - OAuth access token.
8766    /// * *alt* (query-string) - Data format for response.
8767    /// * *callback* (query-string) - JSONP
8768    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8769    /// * *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.
8770    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8771    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8772    /// * *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.
8773    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8774    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8775    pub fn param<T>(
8776        mut self,
8777        name: T,
8778        value: T,
8779    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C>
8780    where
8781        T: AsRef<str>,
8782    {
8783        self._additional_params
8784            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8785        self
8786    }
8787
8788    /// Identifies the authorization scope for the method you are building.
8789    ///
8790    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8791    /// [`Scope::CloudPlatform`].
8792    ///
8793    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8794    /// tokens for more than one scope.
8795    ///
8796    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8797    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8798    /// sufficient, a read-write scope will do as well.
8799    pub fn add_scope<St>(
8800        mut self,
8801        scope: St,
8802    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C>
8803    where
8804        St: AsRef<str>,
8805    {
8806        self._scopes.insert(String::from(scope.as_ref()));
8807        self
8808    }
8809    /// Identifies the authorization scope(s) for the method you are building.
8810    ///
8811    /// See [`Self::add_scope()`] for details.
8812    pub fn add_scopes<I, St>(
8813        mut self,
8814        scopes: I,
8815    ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C>
8816    where
8817        I: IntoIterator<Item = St>,
8818        St: AsRef<str>,
8819    {
8820        self._scopes
8821            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8822        self
8823    }
8824
8825    /// Removes all scopes, and no default scope will be used either.
8826    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8827    /// for details).
8828    pub fn clear_scopes(mut self) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
8829        self._scopes.clear();
8830        self
8831    }
8832}
8833
8834/// Creates an instance configuration and begins preparing it to be used. The returned long-running operation can be used to track the progress of preparing the new instance configuration. The instance configuration name is assigned by the caller. If the named instance configuration already exists, `CreateInstanceConfig` returns `ALREADY_EXISTS`. Immediately after the request returns: * The instance configuration is readable via the API, with all requested attributes. The instance configuration's reconciling field is set to true. Its state is `CREATING`. While the operation is pending: * Cancelling the operation renders the instance configuration immediately unreadable via the API. * Except for deleting the creating resource, all other attempts to modify the instance configuration are rejected. Upon completion of the returned operation: * Instances can be created using the instance configuration. * The instance configuration's reconciling field becomes false. Its state becomes `READY`. The returned long-running operation will have a name of the format `/operations/` and can be used to track creation of the instance configuration. The metadata field type is CreateInstanceConfigMetadata. The response field type is InstanceConfig, if successful. Authorization requires `spanner.instanceConfigs.create` permission on the resource parent.
8835///
8836/// A builder for the *instanceConfigs.create* method supported by a *project* resource.
8837/// It is not used directly, but through a [`ProjectMethods`] instance.
8838///
8839/// # Example
8840///
8841/// Instantiate a resource method builder
8842///
8843/// ```test_harness,no_run
8844/// # extern crate hyper;
8845/// # extern crate hyper_rustls;
8846/// # extern crate google_spanner1 as spanner1;
8847/// use spanner1::api::CreateInstanceConfigRequest;
8848/// # async fn dox() {
8849/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8850///
8851/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8852/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8853/// #     .with_native_roots()
8854/// #     .unwrap()
8855/// #     .https_only()
8856/// #     .enable_http2()
8857/// #     .build();
8858///
8859/// # let executor = hyper_util::rt::TokioExecutor::new();
8860/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8861/// #     secret,
8862/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8863/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8864/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8865/// #     ),
8866/// # ).build().await.unwrap();
8867///
8868/// # let client = hyper_util::client::legacy::Client::builder(
8869/// #     hyper_util::rt::TokioExecutor::new()
8870/// # )
8871/// # .build(
8872/// #     hyper_rustls::HttpsConnectorBuilder::new()
8873/// #         .with_native_roots()
8874/// #         .unwrap()
8875/// #         .https_or_http()
8876/// #         .enable_http2()
8877/// #         .build()
8878/// # );
8879/// # let mut hub = Spanner::new(client, auth);
8880/// // As the method needs a request, you would usually fill it with the desired information
8881/// // into the respective structure. Some of the parts shown here might not be applicable !
8882/// // Values shown here are possibly random and not representative !
8883/// let mut req = CreateInstanceConfigRequest::default();
8884///
8885/// // You can configure optional parameters by calling the respective setters at will, and
8886/// // execute the final call using `doit()`.
8887/// // Values shown here are possibly random and not representative !
8888/// let result = hub.projects().instance_configs_create(req, "parent")
8889///              .doit().await;
8890/// # }
8891/// ```
8892pub struct ProjectInstanceConfigCreateCall<'a, C>
8893where
8894    C: 'a,
8895{
8896    hub: &'a Spanner<C>,
8897    _request: CreateInstanceConfigRequest,
8898    _parent: String,
8899    _delegate: Option<&'a mut dyn common::Delegate>,
8900    _additional_params: HashMap<String, String>,
8901    _scopes: BTreeSet<String>,
8902}
8903
8904impl<'a, C> common::CallBuilder for ProjectInstanceConfigCreateCall<'a, C> {}
8905
8906impl<'a, C> ProjectInstanceConfigCreateCall<'a, C>
8907where
8908    C: common::Connector,
8909{
8910    /// Perform the operation you have build so far.
8911    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8912        use std::borrow::Cow;
8913        use std::io::{Read, Seek};
8914
8915        use common::{url::Params, ToParts};
8916        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8917
8918        let mut dd = common::DefaultDelegate;
8919        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8920        dlg.begin(common::MethodInfo {
8921            id: "spanner.projects.instanceConfigs.create",
8922            http_method: hyper::Method::POST,
8923        });
8924
8925        for &field in ["alt", "parent"].iter() {
8926            if self._additional_params.contains_key(field) {
8927                dlg.finished(false);
8928                return Err(common::Error::FieldClash(field));
8929            }
8930        }
8931
8932        let mut params = Params::with_capacity(4 + self._additional_params.len());
8933        params.push("parent", self._parent);
8934
8935        params.extend(self._additional_params.iter());
8936
8937        params.push("alt", "json");
8938        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instanceConfigs";
8939        if self._scopes.is_empty() {
8940            self._scopes
8941                .insert(Scope::CloudPlatform.as_ref().to_string());
8942        }
8943
8944        #[allow(clippy::single_element_loop)]
8945        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8946            url = params.uri_replacement(url, param_name, find_this, true);
8947        }
8948        {
8949            let to_remove = ["parent"];
8950            params.remove_params(&to_remove);
8951        }
8952
8953        let url = params.parse_with_url(&url);
8954
8955        let mut json_mime_type = mime::APPLICATION_JSON;
8956        let mut request_value_reader = {
8957            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8958            common::remove_json_null_values(&mut value);
8959            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8960            serde_json::to_writer(&mut dst, &value).unwrap();
8961            dst
8962        };
8963        let request_size = request_value_reader
8964            .seek(std::io::SeekFrom::End(0))
8965            .unwrap();
8966        request_value_reader
8967            .seek(std::io::SeekFrom::Start(0))
8968            .unwrap();
8969
8970        loop {
8971            let token = match self
8972                .hub
8973                .auth
8974                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8975                .await
8976            {
8977                Ok(token) => token,
8978                Err(e) => match dlg.token(e) {
8979                    Ok(token) => token,
8980                    Err(e) => {
8981                        dlg.finished(false);
8982                        return Err(common::Error::MissingToken(e));
8983                    }
8984                },
8985            };
8986            request_value_reader
8987                .seek(std::io::SeekFrom::Start(0))
8988                .unwrap();
8989            let mut req_result = {
8990                let client = &self.hub.client;
8991                dlg.pre_request();
8992                let mut req_builder = hyper::Request::builder()
8993                    .method(hyper::Method::POST)
8994                    .uri(url.as_str())
8995                    .header(USER_AGENT, self.hub._user_agent.clone());
8996
8997                if let Some(token) = token.as_ref() {
8998                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8999                }
9000
9001                let request = req_builder
9002                    .header(CONTENT_TYPE, json_mime_type.to_string())
9003                    .header(CONTENT_LENGTH, request_size as u64)
9004                    .body(common::to_body(
9005                        request_value_reader.get_ref().clone().into(),
9006                    ));
9007
9008                client.request(request.unwrap()).await
9009            };
9010
9011            match req_result {
9012                Err(err) => {
9013                    if let common::Retry::After(d) = dlg.http_error(&err) {
9014                        sleep(d).await;
9015                        continue;
9016                    }
9017                    dlg.finished(false);
9018                    return Err(common::Error::HttpError(err));
9019                }
9020                Ok(res) => {
9021                    let (mut parts, body) = res.into_parts();
9022                    let mut body = common::Body::new(body);
9023                    if !parts.status.is_success() {
9024                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9025                        let error = serde_json::from_str(&common::to_string(&bytes));
9026                        let response = common::to_response(parts, bytes.into());
9027
9028                        if let common::Retry::After(d) =
9029                            dlg.http_failure(&response, error.as_ref().ok())
9030                        {
9031                            sleep(d).await;
9032                            continue;
9033                        }
9034
9035                        dlg.finished(false);
9036
9037                        return Err(match error {
9038                            Ok(value) => common::Error::BadRequest(value),
9039                            _ => common::Error::Failure(response),
9040                        });
9041                    }
9042                    let response = {
9043                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9044                        let encoded = common::to_string(&bytes);
9045                        match serde_json::from_str(&encoded) {
9046                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9047                            Err(error) => {
9048                                dlg.response_json_decode_error(&encoded, &error);
9049                                return Err(common::Error::JsonDecodeError(
9050                                    encoded.to_string(),
9051                                    error,
9052                                ));
9053                            }
9054                        }
9055                    };
9056
9057                    dlg.finished(true);
9058                    return Ok(response);
9059                }
9060            }
9061        }
9062    }
9063
9064    ///
9065    /// Sets the *request* property to the given value.
9066    ///
9067    /// Even though the property as already been set when instantiating this call,
9068    /// we provide this method for API completeness.
9069    pub fn request(
9070        mut self,
9071        new_value: CreateInstanceConfigRequest,
9072    ) -> ProjectInstanceConfigCreateCall<'a, C> {
9073        self._request = new_value;
9074        self
9075    }
9076    /// Required. The name of the project in which to create the instance configuration. Values are of the form `projects/`.
9077    ///
9078    /// Sets the *parent* path property to the given value.
9079    ///
9080    /// Even though the property as already been set when instantiating this call,
9081    /// we provide this method for API completeness.
9082    pub fn parent(mut self, new_value: &str) -> ProjectInstanceConfigCreateCall<'a, C> {
9083        self._parent = new_value.to_string();
9084        self
9085    }
9086    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9087    /// while executing the actual API request.
9088    ///
9089    /// ````text
9090    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9091    /// ````
9092    ///
9093    /// Sets the *delegate* property to the given value.
9094    pub fn delegate(
9095        mut self,
9096        new_value: &'a mut dyn common::Delegate,
9097    ) -> ProjectInstanceConfigCreateCall<'a, C> {
9098        self._delegate = Some(new_value);
9099        self
9100    }
9101
9102    /// Set any additional parameter of the query string used in the request.
9103    /// It should be used to set parameters which are not yet available through their own
9104    /// setters.
9105    ///
9106    /// Please note that this method must not be used to set any of the known parameters
9107    /// which have their own setter method. If done anyway, the request will fail.
9108    ///
9109    /// # Additional Parameters
9110    ///
9111    /// * *$.xgafv* (query-string) - V1 error format.
9112    /// * *access_token* (query-string) - OAuth access token.
9113    /// * *alt* (query-string) - Data format for response.
9114    /// * *callback* (query-string) - JSONP
9115    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9116    /// * *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.
9117    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9118    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9119    /// * *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.
9120    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9121    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9122    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigCreateCall<'a, C>
9123    where
9124        T: AsRef<str>,
9125    {
9126        self._additional_params
9127            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9128        self
9129    }
9130
9131    /// Identifies the authorization scope for the method you are building.
9132    ///
9133    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9134    /// [`Scope::CloudPlatform`].
9135    ///
9136    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9137    /// tokens for more than one scope.
9138    ///
9139    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9140    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9141    /// sufficient, a read-write scope will do as well.
9142    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigCreateCall<'a, C>
9143    where
9144        St: AsRef<str>,
9145    {
9146        self._scopes.insert(String::from(scope.as_ref()));
9147        self
9148    }
9149    /// Identifies the authorization scope(s) for the method you are building.
9150    ///
9151    /// See [`Self::add_scope()`] for details.
9152    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigCreateCall<'a, C>
9153    where
9154        I: IntoIterator<Item = St>,
9155        St: AsRef<str>,
9156    {
9157        self._scopes
9158            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9159        self
9160    }
9161
9162    /// Removes all scopes, and no default scope will be used either.
9163    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9164    /// for details).
9165    pub fn clear_scopes(mut self) -> ProjectInstanceConfigCreateCall<'a, C> {
9166        self._scopes.clear();
9167        self
9168    }
9169}
9170
9171/// Deletes the instance configuration. Deletion is only allowed when no instances are using the configuration. If any instances are using the configuration, returns `FAILED_PRECONDITION`. Only user-managed configurations can be deleted. Authorization requires `spanner.instanceConfigs.delete` permission on the resource name.
9172///
9173/// A builder for the *instanceConfigs.delete* method supported by a *project* resource.
9174/// It is not used directly, but through a [`ProjectMethods`] instance.
9175///
9176/// # Example
9177///
9178/// Instantiate a resource method builder
9179///
9180/// ```test_harness,no_run
9181/// # extern crate hyper;
9182/// # extern crate hyper_rustls;
9183/// # extern crate google_spanner1 as spanner1;
9184/// # async fn dox() {
9185/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9186///
9187/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9188/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9189/// #     .with_native_roots()
9190/// #     .unwrap()
9191/// #     .https_only()
9192/// #     .enable_http2()
9193/// #     .build();
9194///
9195/// # let executor = hyper_util::rt::TokioExecutor::new();
9196/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9197/// #     secret,
9198/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9199/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9200/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9201/// #     ),
9202/// # ).build().await.unwrap();
9203///
9204/// # let client = hyper_util::client::legacy::Client::builder(
9205/// #     hyper_util::rt::TokioExecutor::new()
9206/// # )
9207/// # .build(
9208/// #     hyper_rustls::HttpsConnectorBuilder::new()
9209/// #         .with_native_roots()
9210/// #         .unwrap()
9211/// #         .https_or_http()
9212/// #         .enable_http2()
9213/// #         .build()
9214/// # );
9215/// # let mut hub = Spanner::new(client, auth);
9216/// // You can configure optional parameters by calling the respective setters at will, and
9217/// // execute the final call using `doit()`.
9218/// // Values shown here are possibly random and not representative !
9219/// let result = hub.projects().instance_configs_delete("name")
9220///              .validate_only(true)
9221///              .etag("duo")
9222///              .doit().await;
9223/// # }
9224/// ```
9225pub struct ProjectInstanceConfigDeleteCall<'a, C>
9226where
9227    C: 'a,
9228{
9229    hub: &'a Spanner<C>,
9230    _name: String,
9231    _validate_only: Option<bool>,
9232    _etag: Option<String>,
9233    _delegate: Option<&'a mut dyn common::Delegate>,
9234    _additional_params: HashMap<String, String>,
9235    _scopes: BTreeSet<String>,
9236}
9237
9238impl<'a, C> common::CallBuilder for ProjectInstanceConfigDeleteCall<'a, C> {}
9239
9240impl<'a, C> ProjectInstanceConfigDeleteCall<'a, C>
9241where
9242    C: common::Connector,
9243{
9244    /// Perform the operation you have build so far.
9245    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9246        use std::borrow::Cow;
9247        use std::io::{Read, Seek};
9248
9249        use common::{url::Params, ToParts};
9250        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9251
9252        let mut dd = common::DefaultDelegate;
9253        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9254        dlg.begin(common::MethodInfo {
9255            id: "spanner.projects.instanceConfigs.delete",
9256            http_method: hyper::Method::DELETE,
9257        });
9258
9259        for &field in ["alt", "name", "validateOnly", "etag"].iter() {
9260            if self._additional_params.contains_key(field) {
9261                dlg.finished(false);
9262                return Err(common::Error::FieldClash(field));
9263            }
9264        }
9265
9266        let mut params = Params::with_capacity(5 + self._additional_params.len());
9267        params.push("name", self._name);
9268        if let Some(value) = self._validate_only.as_ref() {
9269            params.push("validateOnly", value.to_string());
9270        }
9271        if let Some(value) = self._etag.as_ref() {
9272            params.push("etag", value);
9273        }
9274
9275        params.extend(self._additional_params.iter());
9276
9277        params.push("alt", "json");
9278        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9279        if self._scopes.is_empty() {
9280            self._scopes
9281                .insert(Scope::CloudPlatform.as_ref().to_string());
9282        }
9283
9284        #[allow(clippy::single_element_loop)]
9285        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9286            url = params.uri_replacement(url, param_name, find_this, true);
9287        }
9288        {
9289            let to_remove = ["name"];
9290            params.remove_params(&to_remove);
9291        }
9292
9293        let url = params.parse_with_url(&url);
9294
9295        loop {
9296            let token = match self
9297                .hub
9298                .auth
9299                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9300                .await
9301            {
9302                Ok(token) => token,
9303                Err(e) => match dlg.token(e) {
9304                    Ok(token) => token,
9305                    Err(e) => {
9306                        dlg.finished(false);
9307                        return Err(common::Error::MissingToken(e));
9308                    }
9309                },
9310            };
9311            let mut req_result = {
9312                let client = &self.hub.client;
9313                dlg.pre_request();
9314                let mut req_builder = hyper::Request::builder()
9315                    .method(hyper::Method::DELETE)
9316                    .uri(url.as_str())
9317                    .header(USER_AGENT, self.hub._user_agent.clone());
9318
9319                if let Some(token) = token.as_ref() {
9320                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9321                }
9322
9323                let request = req_builder
9324                    .header(CONTENT_LENGTH, 0_u64)
9325                    .body(common::to_body::<String>(None));
9326
9327                client.request(request.unwrap()).await
9328            };
9329
9330            match req_result {
9331                Err(err) => {
9332                    if let common::Retry::After(d) = dlg.http_error(&err) {
9333                        sleep(d).await;
9334                        continue;
9335                    }
9336                    dlg.finished(false);
9337                    return Err(common::Error::HttpError(err));
9338                }
9339                Ok(res) => {
9340                    let (mut parts, body) = res.into_parts();
9341                    let mut body = common::Body::new(body);
9342                    if !parts.status.is_success() {
9343                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9344                        let error = serde_json::from_str(&common::to_string(&bytes));
9345                        let response = common::to_response(parts, bytes.into());
9346
9347                        if let common::Retry::After(d) =
9348                            dlg.http_failure(&response, error.as_ref().ok())
9349                        {
9350                            sleep(d).await;
9351                            continue;
9352                        }
9353
9354                        dlg.finished(false);
9355
9356                        return Err(match error {
9357                            Ok(value) => common::Error::BadRequest(value),
9358                            _ => common::Error::Failure(response),
9359                        });
9360                    }
9361                    let response = {
9362                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9363                        let encoded = common::to_string(&bytes);
9364                        match serde_json::from_str(&encoded) {
9365                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9366                            Err(error) => {
9367                                dlg.response_json_decode_error(&encoded, &error);
9368                                return Err(common::Error::JsonDecodeError(
9369                                    encoded.to_string(),
9370                                    error,
9371                                ));
9372                            }
9373                        }
9374                    };
9375
9376                    dlg.finished(true);
9377                    return Ok(response);
9378                }
9379            }
9380        }
9381    }
9382
9383    /// Required. The name of the instance configuration to be deleted. Values are of the form `projects//instanceConfigs/`
9384    ///
9385    /// Sets the *name* path property to the given value.
9386    ///
9387    /// Even though the property as already been set when instantiating this call,
9388    /// we provide this method for API completeness.
9389    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigDeleteCall<'a, C> {
9390        self._name = new_value.to_string();
9391        self
9392    }
9393    /// An option to validate, but not actually execute, a request, and provide the same response.
9394    ///
9395    /// Sets the *validate only* query property to the given value.
9396    pub fn validate_only(mut self, new_value: bool) -> ProjectInstanceConfigDeleteCall<'a, C> {
9397        self._validate_only = Some(new_value);
9398        self
9399    }
9400    /// Used for optimistic concurrency control as a way to help prevent simultaneous deletes of an instance configuration from overwriting each other. If not empty, the API only deletes the instance configuration when the etag provided matches the current status of the requested instance configuration. Otherwise, deletes the instance configuration without checking the current status of the requested instance configuration.
9401    ///
9402    /// Sets the *etag* query property to the given value.
9403    pub fn etag(mut self, new_value: &str) -> ProjectInstanceConfigDeleteCall<'a, C> {
9404        self._etag = Some(new_value.to_string());
9405        self
9406    }
9407    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9408    /// while executing the actual API request.
9409    ///
9410    /// ````text
9411    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9412    /// ````
9413    ///
9414    /// Sets the *delegate* property to the given value.
9415    pub fn delegate(
9416        mut self,
9417        new_value: &'a mut dyn common::Delegate,
9418    ) -> ProjectInstanceConfigDeleteCall<'a, C> {
9419        self._delegate = Some(new_value);
9420        self
9421    }
9422
9423    /// Set any additional parameter of the query string used in the request.
9424    /// It should be used to set parameters which are not yet available through their own
9425    /// setters.
9426    ///
9427    /// Please note that this method must not be used to set any of the known parameters
9428    /// which have their own setter method. If done anyway, the request will fail.
9429    ///
9430    /// # Additional Parameters
9431    ///
9432    /// * *$.xgafv* (query-string) - V1 error format.
9433    /// * *access_token* (query-string) - OAuth access token.
9434    /// * *alt* (query-string) - Data format for response.
9435    /// * *callback* (query-string) - JSONP
9436    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9437    /// * *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.
9438    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9439    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9440    /// * *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.
9441    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9442    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9443    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigDeleteCall<'a, C>
9444    where
9445        T: AsRef<str>,
9446    {
9447        self._additional_params
9448            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9449        self
9450    }
9451
9452    /// Identifies the authorization scope for the method you are building.
9453    ///
9454    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9455    /// [`Scope::CloudPlatform`].
9456    ///
9457    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9458    /// tokens for more than one scope.
9459    ///
9460    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9461    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9462    /// sufficient, a read-write scope will do as well.
9463    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigDeleteCall<'a, C>
9464    where
9465        St: AsRef<str>,
9466    {
9467        self._scopes.insert(String::from(scope.as_ref()));
9468        self
9469    }
9470    /// Identifies the authorization scope(s) for the method you are building.
9471    ///
9472    /// See [`Self::add_scope()`] for details.
9473    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigDeleteCall<'a, C>
9474    where
9475        I: IntoIterator<Item = St>,
9476        St: AsRef<str>,
9477    {
9478        self._scopes
9479            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9480        self
9481    }
9482
9483    /// Removes all scopes, and no default scope will be used either.
9484    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9485    /// for details).
9486    pub fn clear_scopes(mut self) -> ProjectInstanceConfigDeleteCall<'a, C> {
9487        self._scopes.clear();
9488        self
9489    }
9490}
9491
9492/// Gets information about a particular instance configuration.
9493///
9494/// A builder for the *instanceConfigs.get* method supported by a *project* resource.
9495/// It is not used directly, but through a [`ProjectMethods`] instance.
9496///
9497/// # Example
9498///
9499/// Instantiate a resource method builder
9500///
9501/// ```test_harness,no_run
9502/// # extern crate hyper;
9503/// # extern crate hyper_rustls;
9504/// # extern crate google_spanner1 as spanner1;
9505/// # async fn dox() {
9506/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9507///
9508/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9509/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9510/// #     .with_native_roots()
9511/// #     .unwrap()
9512/// #     .https_only()
9513/// #     .enable_http2()
9514/// #     .build();
9515///
9516/// # let executor = hyper_util::rt::TokioExecutor::new();
9517/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9518/// #     secret,
9519/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9520/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9521/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9522/// #     ),
9523/// # ).build().await.unwrap();
9524///
9525/// # let client = hyper_util::client::legacy::Client::builder(
9526/// #     hyper_util::rt::TokioExecutor::new()
9527/// # )
9528/// # .build(
9529/// #     hyper_rustls::HttpsConnectorBuilder::new()
9530/// #         .with_native_roots()
9531/// #         .unwrap()
9532/// #         .https_or_http()
9533/// #         .enable_http2()
9534/// #         .build()
9535/// # );
9536/// # let mut hub = Spanner::new(client, auth);
9537/// // You can configure optional parameters by calling the respective setters at will, and
9538/// // execute the final call using `doit()`.
9539/// // Values shown here are possibly random and not representative !
9540/// let result = hub.projects().instance_configs_get("name")
9541///              .doit().await;
9542/// # }
9543/// ```
9544pub struct ProjectInstanceConfigGetCall<'a, C>
9545where
9546    C: 'a,
9547{
9548    hub: &'a Spanner<C>,
9549    _name: String,
9550    _delegate: Option<&'a mut dyn common::Delegate>,
9551    _additional_params: HashMap<String, String>,
9552    _scopes: BTreeSet<String>,
9553}
9554
9555impl<'a, C> common::CallBuilder for ProjectInstanceConfigGetCall<'a, C> {}
9556
9557impl<'a, C> ProjectInstanceConfigGetCall<'a, C>
9558where
9559    C: common::Connector,
9560{
9561    /// Perform the operation you have build so far.
9562    pub async fn doit(mut self) -> common::Result<(common::Response, InstanceConfig)> {
9563        use std::borrow::Cow;
9564        use std::io::{Read, Seek};
9565
9566        use common::{url::Params, ToParts};
9567        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9568
9569        let mut dd = common::DefaultDelegate;
9570        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9571        dlg.begin(common::MethodInfo {
9572            id: "spanner.projects.instanceConfigs.get",
9573            http_method: hyper::Method::GET,
9574        });
9575
9576        for &field in ["alt", "name"].iter() {
9577            if self._additional_params.contains_key(field) {
9578                dlg.finished(false);
9579                return Err(common::Error::FieldClash(field));
9580            }
9581        }
9582
9583        let mut params = Params::with_capacity(3 + self._additional_params.len());
9584        params.push("name", self._name);
9585
9586        params.extend(self._additional_params.iter());
9587
9588        params.push("alt", "json");
9589        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9590        if self._scopes.is_empty() {
9591            self._scopes
9592                .insert(Scope::CloudPlatform.as_ref().to_string());
9593        }
9594
9595        #[allow(clippy::single_element_loop)]
9596        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9597            url = params.uri_replacement(url, param_name, find_this, true);
9598        }
9599        {
9600            let to_remove = ["name"];
9601            params.remove_params(&to_remove);
9602        }
9603
9604        let url = params.parse_with_url(&url);
9605
9606        loop {
9607            let token = match self
9608                .hub
9609                .auth
9610                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9611                .await
9612            {
9613                Ok(token) => token,
9614                Err(e) => match dlg.token(e) {
9615                    Ok(token) => token,
9616                    Err(e) => {
9617                        dlg.finished(false);
9618                        return Err(common::Error::MissingToken(e));
9619                    }
9620                },
9621            };
9622            let mut req_result = {
9623                let client = &self.hub.client;
9624                dlg.pre_request();
9625                let mut req_builder = hyper::Request::builder()
9626                    .method(hyper::Method::GET)
9627                    .uri(url.as_str())
9628                    .header(USER_AGENT, self.hub._user_agent.clone());
9629
9630                if let Some(token) = token.as_ref() {
9631                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9632                }
9633
9634                let request = req_builder
9635                    .header(CONTENT_LENGTH, 0_u64)
9636                    .body(common::to_body::<String>(None));
9637
9638                client.request(request.unwrap()).await
9639            };
9640
9641            match req_result {
9642                Err(err) => {
9643                    if let common::Retry::After(d) = dlg.http_error(&err) {
9644                        sleep(d).await;
9645                        continue;
9646                    }
9647                    dlg.finished(false);
9648                    return Err(common::Error::HttpError(err));
9649                }
9650                Ok(res) => {
9651                    let (mut parts, body) = res.into_parts();
9652                    let mut body = common::Body::new(body);
9653                    if !parts.status.is_success() {
9654                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9655                        let error = serde_json::from_str(&common::to_string(&bytes));
9656                        let response = common::to_response(parts, bytes.into());
9657
9658                        if let common::Retry::After(d) =
9659                            dlg.http_failure(&response, error.as_ref().ok())
9660                        {
9661                            sleep(d).await;
9662                            continue;
9663                        }
9664
9665                        dlg.finished(false);
9666
9667                        return Err(match error {
9668                            Ok(value) => common::Error::BadRequest(value),
9669                            _ => common::Error::Failure(response),
9670                        });
9671                    }
9672                    let response = {
9673                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9674                        let encoded = common::to_string(&bytes);
9675                        match serde_json::from_str(&encoded) {
9676                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9677                            Err(error) => {
9678                                dlg.response_json_decode_error(&encoded, &error);
9679                                return Err(common::Error::JsonDecodeError(
9680                                    encoded.to_string(),
9681                                    error,
9682                                ));
9683                            }
9684                        }
9685                    };
9686
9687                    dlg.finished(true);
9688                    return Ok(response);
9689                }
9690            }
9691        }
9692    }
9693
9694    /// Required. The name of the requested instance configuration. Values are of the form `projects//instanceConfigs/`.
9695    ///
9696    /// Sets the *name* path property to the given value.
9697    ///
9698    /// Even though the property as already been set when instantiating this call,
9699    /// we provide this method for API completeness.
9700    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigGetCall<'a, C> {
9701        self._name = new_value.to_string();
9702        self
9703    }
9704    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9705    /// while executing the actual API request.
9706    ///
9707    /// ````text
9708    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9709    /// ````
9710    ///
9711    /// Sets the *delegate* property to the given value.
9712    pub fn delegate(
9713        mut self,
9714        new_value: &'a mut dyn common::Delegate,
9715    ) -> ProjectInstanceConfigGetCall<'a, C> {
9716        self._delegate = Some(new_value);
9717        self
9718    }
9719
9720    /// Set any additional parameter of the query string used in the request.
9721    /// It should be used to set parameters which are not yet available through their own
9722    /// setters.
9723    ///
9724    /// Please note that this method must not be used to set any of the known parameters
9725    /// which have their own setter method. If done anyway, the request will fail.
9726    ///
9727    /// # Additional Parameters
9728    ///
9729    /// * *$.xgafv* (query-string) - V1 error format.
9730    /// * *access_token* (query-string) - OAuth access token.
9731    /// * *alt* (query-string) - Data format for response.
9732    /// * *callback* (query-string) - JSONP
9733    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9734    /// * *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.
9735    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9736    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9737    /// * *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.
9738    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9739    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9740    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigGetCall<'a, C>
9741    where
9742        T: AsRef<str>,
9743    {
9744        self._additional_params
9745            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9746        self
9747    }
9748
9749    /// Identifies the authorization scope for the method you are building.
9750    ///
9751    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9752    /// [`Scope::CloudPlatform`].
9753    ///
9754    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9755    /// tokens for more than one scope.
9756    ///
9757    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9758    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9759    /// sufficient, a read-write scope will do as well.
9760    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigGetCall<'a, C>
9761    where
9762        St: AsRef<str>,
9763    {
9764        self._scopes.insert(String::from(scope.as_ref()));
9765        self
9766    }
9767    /// Identifies the authorization scope(s) for the method you are building.
9768    ///
9769    /// See [`Self::add_scope()`] for details.
9770    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigGetCall<'a, C>
9771    where
9772        I: IntoIterator<Item = St>,
9773        St: AsRef<str>,
9774    {
9775        self._scopes
9776            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9777        self
9778    }
9779
9780    /// Removes all scopes, and no default scope will be used either.
9781    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9782    /// for details).
9783    pub fn clear_scopes(mut self) -> ProjectInstanceConfigGetCall<'a, C> {
9784        self._scopes.clear();
9785        self
9786    }
9787}
9788
9789/// Lists the supported instance configurations for a given project. Returns both Google-managed configurations and user-managed configurations.
9790///
9791/// A builder for the *instanceConfigs.list* method supported by a *project* resource.
9792/// It is not used directly, but through a [`ProjectMethods`] instance.
9793///
9794/// # Example
9795///
9796/// Instantiate a resource method builder
9797///
9798/// ```test_harness,no_run
9799/// # extern crate hyper;
9800/// # extern crate hyper_rustls;
9801/// # extern crate google_spanner1 as spanner1;
9802/// # async fn dox() {
9803/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9804///
9805/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9806/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9807/// #     .with_native_roots()
9808/// #     .unwrap()
9809/// #     .https_only()
9810/// #     .enable_http2()
9811/// #     .build();
9812///
9813/// # let executor = hyper_util::rt::TokioExecutor::new();
9814/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9815/// #     secret,
9816/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9817/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9818/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9819/// #     ),
9820/// # ).build().await.unwrap();
9821///
9822/// # let client = hyper_util::client::legacy::Client::builder(
9823/// #     hyper_util::rt::TokioExecutor::new()
9824/// # )
9825/// # .build(
9826/// #     hyper_rustls::HttpsConnectorBuilder::new()
9827/// #         .with_native_roots()
9828/// #         .unwrap()
9829/// #         .https_or_http()
9830/// #         .enable_http2()
9831/// #         .build()
9832/// # );
9833/// # let mut hub = Spanner::new(client, auth);
9834/// // You can configure optional parameters by calling the respective setters at will, and
9835/// // execute the final call using `doit()`.
9836/// // Values shown here are possibly random and not representative !
9837/// let result = hub.projects().instance_configs_list("parent")
9838///              .page_token("Stet")
9839///              .page_size(-13)
9840///              .doit().await;
9841/// # }
9842/// ```
9843pub struct ProjectInstanceConfigListCall<'a, C>
9844where
9845    C: 'a,
9846{
9847    hub: &'a Spanner<C>,
9848    _parent: String,
9849    _page_token: Option<String>,
9850    _page_size: Option<i32>,
9851    _delegate: Option<&'a mut dyn common::Delegate>,
9852    _additional_params: HashMap<String, String>,
9853    _scopes: BTreeSet<String>,
9854}
9855
9856impl<'a, C> common::CallBuilder for ProjectInstanceConfigListCall<'a, C> {}
9857
9858impl<'a, C> ProjectInstanceConfigListCall<'a, C>
9859where
9860    C: common::Connector,
9861{
9862    /// Perform the operation you have build so far.
9863    pub async fn doit(mut self) -> common::Result<(common::Response, ListInstanceConfigsResponse)> {
9864        use std::borrow::Cow;
9865        use std::io::{Read, Seek};
9866
9867        use common::{url::Params, ToParts};
9868        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9869
9870        let mut dd = common::DefaultDelegate;
9871        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9872        dlg.begin(common::MethodInfo {
9873            id: "spanner.projects.instanceConfigs.list",
9874            http_method: hyper::Method::GET,
9875        });
9876
9877        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9878            if self._additional_params.contains_key(field) {
9879                dlg.finished(false);
9880                return Err(common::Error::FieldClash(field));
9881            }
9882        }
9883
9884        let mut params = Params::with_capacity(5 + self._additional_params.len());
9885        params.push("parent", self._parent);
9886        if let Some(value) = self._page_token.as_ref() {
9887            params.push("pageToken", value);
9888        }
9889        if let Some(value) = self._page_size.as_ref() {
9890            params.push("pageSize", value.to_string());
9891        }
9892
9893        params.extend(self._additional_params.iter());
9894
9895        params.push("alt", "json");
9896        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instanceConfigs";
9897        if self._scopes.is_empty() {
9898            self._scopes
9899                .insert(Scope::CloudPlatform.as_ref().to_string());
9900        }
9901
9902        #[allow(clippy::single_element_loop)]
9903        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9904            url = params.uri_replacement(url, param_name, find_this, true);
9905        }
9906        {
9907            let to_remove = ["parent"];
9908            params.remove_params(&to_remove);
9909        }
9910
9911        let url = params.parse_with_url(&url);
9912
9913        loop {
9914            let token = match self
9915                .hub
9916                .auth
9917                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9918                .await
9919            {
9920                Ok(token) => token,
9921                Err(e) => match dlg.token(e) {
9922                    Ok(token) => token,
9923                    Err(e) => {
9924                        dlg.finished(false);
9925                        return Err(common::Error::MissingToken(e));
9926                    }
9927                },
9928            };
9929            let mut req_result = {
9930                let client = &self.hub.client;
9931                dlg.pre_request();
9932                let mut req_builder = hyper::Request::builder()
9933                    .method(hyper::Method::GET)
9934                    .uri(url.as_str())
9935                    .header(USER_AGENT, self.hub._user_agent.clone());
9936
9937                if let Some(token) = token.as_ref() {
9938                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9939                }
9940
9941                let request = req_builder
9942                    .header(CONTENT_LENGTH, 0_u64)
9943                    .body(common::to_body::<String>(None));
9944
9945                client.request(request.unwrap()).await
9946            };
9947
9948            match req_result {
9949                Err(err) => {
9950                    if let common::Retry::After(d) = dlg.http_error(&err) {
9951                        sleep(d).await;
9952                        continue;
9953                    }
9954                    dlg.finished(false);
9955                    return Err(common::Error::HttpError(err));
9956                }
9957                Ok(res) => {
9958                    let (mut parts, body) = res.into_parts();
9959                    let mut body = common::Body::new(body);
9960                    if !parts.status.is_success() {
9961                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9962                        let error = serde_json::from_str(&common::to_string(&bytes));
9963                        let response = common::to_response(parts, bytes.into());
9964
9965                        if let common::Retry::After(d) =
9966                            dlg.http_failure(&response, error.as_ref().ok())
9967                        {
9968                            sleep(d).await;
9969                            continue;
9970                        }
9971
9972                        dlg.finished(false);
9973
9974                        return Err(match error {
9975                            Ok(value) => common::Error::BadRequest(value),
9976                            _ => common::Error::Failure(response),
9977                        });
9978                    }
9979                    let response = {
9980                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9981                        let encoded = common::to_string(&bytes);
9982                        match serde_json::from_str(&encoded) {
9983                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9984                            Err(error) => {
9985                                dlg.response_json_decode_error(&encoded, &error);
9986                                return Err(common::Error::JsonDecodeError(
9987                                    encoded.to_string(),
9988                                    error,
9989                                ));
9990                            }
9991                        }
9992                    };
9993
9994                    dlg.finished(true);
9995                    return Ok(response);
9996                }
9997            }
9998        }
9999    }
10000
10001    /// Required. The name of the project for which a list of supported instance configurations is requested. Values are of the form `projects/`.
10002    ///
10003    /// Sets the *parent* path property to the given value.
10004    ///
10005    /// Even though the property as already been set when instantiating this call,
10006    /// we provide this method for API completeness.
10007    pub fn parent(mut self, new_value: &str) -> ProjectInstanceConfigListCall<'a, C> {
10008        self._parent = new_value.to_string();
10009        self
10010    }
10011    /// If non-empty, `page_token` should contain a next_page_token from a previous ListInstanceConfigsResponse.
10012    ///
10013    /// Sets the *page token* query property to the given value.
10014    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceConfigListCall<'a, C> {
10015        self._page_token = Some(new_value.to_string());
10016        self
10017    }
10018    /// Number of instance configurations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
10019    ///
10020    /// Sets the *page size* query property to the given value.
10021    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceConfigListCall<'a, C> {
10022        self._page_size = Some(new_value);
10023        self
10024    }
10025    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10026    /// while executing the actual API request.
10027    ///
10028    /// ````text
10029    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10030    /// ````
10031    ///
10032    /// Sets the *delegate* property to the given value.
10033    pub fn delegate(
10034        mut self,
10035        new_value: &'a mut dyn common::Delegate,
10036    ) -> ProjectInstanceConfigListCall<'a, C> {
10037        self._delegate = Some(new_value);
10038        self
10039    }
10040
10041    /// Set any additional parameter of the query string used in the request.
10042    /// It should be used to set parameters which are not yet available through their own
10043    /// setters.
10044    ///
10045    /// Please note that this method must not be used to set any of the known parameters
10046    /// which have their own setter method. If done anyway, the request will fail.
10047    ///
10048    /// # Additional Parameters
10049    ///
10050    /// * *$.xgafv* (query-string) - V1 error format.
10051    /// * *access_token* (query-string) - OAuth access token.
10052    /// * *alt* (query-string) - Data format for response.
10053    /// * *callback* (query-string) - JSONP
10054    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10055    /// * *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.
10056    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10057    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10058    /// * *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.
10059    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10060    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10061    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigListCall<'a, C>
10062    where
10063        T: AsRef<str>,
10064    {
10065        self._additional_params
10066            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10067        self
10068    }
10069
10070    /// Identifies the authorization scope for the method you are building.
10071    ///
10072    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10073    /// [`Scope::CloudPlatform`].
10074    ///
10075    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10076    /// tokens for more than one scope.
10077    ///
10078    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10079    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10080    /// sufficient, a read-write scope will do as well.
10081    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigListCall<'a, C>
10082    where
10083        St: AsRef<str>,
10084    {
10085        self._scopes.insert(String::from(scope.as_ref()));
10086        self
10087    }
10088    /// Identifies the authorization scope(s) for the method you are building.
10089    ///
10090    /// See [`Self::add_scope()`] for details.
10091    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigListCall<'a, C>
10092    where
10093        I: IntoIterator<Item = St>,
10094        St: AsRef<str>,
10095    {
10096        self._scopes
10097            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10098        self
10099    }
10100
10101    /// Removes all scopes, and no default scope will be used either.
10102    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10103    /// for details).
10104    pub fn clear_scopes(mut self) -> ProjectInstanceConfigListCall<'a, C> {
10105        self._scopes.clear();
10106        self
10107    }
10108}
10109
10110/// Updates an instance configuration. The returned long-running operation can be used to track the progress of updating the instance. If the named instance configuration does not exist, returns `NOT_FOUND`. Only user-managed configurations can be updated. Immediately after the request returns: * The instance configuration's reconciling field is set to true. While the operation is pending: * Cancelling the operation sets its metadata's cancel_time. The operation is guaranteed to succeed at undoing all changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance configuration are rejected. * Reading the instance configuration via the API continues to give the pre-request values. Upon completion of the returned operation: * Creating instances using the instance configuration uses the new values. * The new values of the instance configuration are readable via the API. * The instance configuration's reconciling field becomes false. The returned long-running operation will have a name of the format `/operations/` and can be used to track the instance configuration modification. The metadata field type is UpdateInstanceConfigMetadata. The response field type is InstanceConfig, if successful. Authorization requires `spanner.instanceConfigs.update` permission on the resource name.
10111///
10112/// A builder for the *instanceConfigs.patch* method supported by a *project* resource.
10113/// It is not used directly, but through a [`ProjectMethods`] instance.
10114///
10115/// # Example
10116///
10117/// Instantiate a resource method builder
10118///
10119/// ```test_harness,no_run
10120/// # extern crate hyper;
10121/// # extern crate hyper_rustls;
10122/// # extern crate google_spanner1 as spanner1;
10123/// use spanner1::api::UpdateInstanceConfigRequest;
10124/// # async fn dox() {
10125/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10126///
10127/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10128/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10129/// #     .with_native_roots()
10130/// #     .unwrap()
10131/// #     .https_only()
10132/// #     .enable_http2()
10133/// #     .build();
10134///
10135/// # let executor = hyper_util::rt::TokioExecutor::new();
10136/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10137/// #     secret,
10138/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10139/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10140/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10141/// #     ),
10142/// # ).build().await.unwrap();
10143///
10144/// # let client = hyper_util::client::legacy::Client::builder(
10145/// #     hyper_util::rt::TokioExecutor::new()
10146/// # )
10147/// # .build(
10148/// #     hyper_rustls::HttpsConnectorBuilder::new()
10149/// #         .with_native_roots()
10150/// #         .unwrap()
10151/// #         .https_or_http()
10152/// #         .enable_http2()
10153/// #         .build()
10154/// # );
10155/// # let mut hub = Spanner::new(client, auth);
10156/// // As the method needs a request, you would usually fill it with the desired information
10157/// // into the respective structure. Some of the parts shown here might not be applicable !
10158/// // Values shown here are possibly random and not representative !
10159/// let mut req = UpdateInstanceConfigRequest::default();
10160///
10161/// // You can configure optional parameters by calling the respective setters at will, and
10162/// // execute the final call using `doit()`.
10163/// // Values shown here are possibly random and not representative !
10164/// let result = hub.projects().instance_configs_patch(req, "name")
10165///              .doit().await;
10166/// # }
10167/// ```
10168pub struct ProjectInstanceConfigPatchCall<'a, C>
10169where
10170    C: 'a,
10171{
10172    hub: &'a Spanner<C>,
10173    _request: UpdateInstanceConfigRequest,
10174    _name: String,
10175    _delegate: Option<&'a mut dyn common::Delegate>,
10176    _additional_params: HashMap<String, String>,
10177    _scopes: BTreeSet<String>,
10178}
10179
10180impl<'a, C> common::CallBuilder for ProjectInstanceConfigPatchCall<'a, C> {}
10181
10182impl<'a, C> ProjectInstanceConfigPatchCall<'a, C>
10183where
10184    C: common::Connector,
10185{
10186    /// Perform the operation you have build so far.
10187    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10188        use std::borrow::Cow;
10189        use std::io::{Read, Seek};
10190
10191        use common::{url::Params, ToParts};
10192        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10193
10194        let mut dd = common::DefaultDelegate;
10195        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10196        dlg.begin(common::MethodInfo {
10197            id: "spanner.projects.instanceConfigs.patch",
10198            http_method: hyper::Method::PATCH,
10199        });
10200
10201        for &field in ["alt", "name"].iter() {
10202            if self._additional_params.contains_key(field) {
10203                dlg.finished(false);
10204                return Err(common::Error::FieldClash(field));
10205            }
10206        }
10207
10208        let mut params = Params::with_capacity(4 + self._additional_params.len());
10209        params.push("name", self._name);
10210
10211        params.extend(self._additional_params.iter());
10212
10213        params.push("alt", "json");
10214        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10215        if self._scopes.is_empty() {
10216            self._scopes
10217                .insert(Scope::CloudPlatform.as_ref().to_string());
10218        }
10219
10220        #[allow(clippy::single_element_loop)]
10221        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10222            url = params.uri_replacement(url, param_name, find_this, true);
10223        }
10224        {
10225            let to_remove = ["name"];
10226            params.remove_params(&to_remove);
10227        }
10228
10229        let url = params.parse_with_url(&url);
10230
10231        let mut json_mime_type = mime::APPLICATION_JSON;
10232        let mut request_value_reader = {
10233            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10234            common::remove_json_null_values(&mut value);
10235            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10236            serde_json::to_writer(&mut dst, &value).unwrap();
10237            dst
10238        };
10239        let request_size = request_value_reader
10240            .seek(std::io::SeekFrom::End(0))
10241            .unwrap();
10242        request_value_reader
10243            .seek(std::io::SeekFrom::Start(0))
10244            .unwrap();
10245
10246        loop {
10247            let token = match self
10248                .hub
10249                .auth
10250                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10251                .await
10252            {
10253                Ok(token) => token,
10254                Err(e) => match dlg.token(e) {
10255                    Ok(token) => token,
10256                    Err(e) => {
10257                        dlg.finished(false);
10258                        return Err(common::Error::MissingToken(e));
10259                    }
10260                },
10261            };
10262            request_value_reader
10263                .seek(std::io::SeekFrom::Start(0))
10264                .unwrap();
10265            let mut req_result = {
10266                let client = &self.hub.client;
10267                dlg.pre_request();
10268                let mut req_builder = hyper::Request::builder()
10269                    .method(hyper::Method::PATCH)
10270                    .uri(url.as_str())
10271                    .header(USER_AGENT, self.hub._user_agent.clone());
10272
10273                if let Some(token) = token.as_ref() {
10274                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10275                }
10276
10277                let request = req_builder
10278                    .header(CONTENT_TYPE, json_mime_type.to_string())
10279                    .header(CONTENT_LENGTH, request_size as u64)
10280                    .body(common::to_body(
10281                        request_value_reader.get_ref().clone().into(),
10282                    ));
10283
10284                client.request(request.unwrap()).await
10285            };
10286
10287            match req_result {
10288                Err(err) => {
10289                    if let common::Retry::After(d) = dlg.http_error(&err) {
10290                        sleep(d).await;
10291                        continue;
10292                    }
10293                    dlg.finished(false);
10294                    return Err(common::Error::HttpError(err));
10295                }
10296                Ok(res) => {
10297                    let (mut parts, body) = res.into_parts();
10298                    let mut body = common::Body::new(body);
10299                    if !parts.status.is_success() {
10300                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10301                        let error = serde_json::from_str(&common::to_string(&bytes));
10302                        let response = common::to_response(parts, bytes.into());
10303
10304                        if let common::Retry::After(d) =
10305                            dlg.http_failure(&response, error.as_ref().ok())
10306                        {
10307                            sleep(d).await;
10308                            continue;
10309                        }
10310
10311                        dlg.finished(false);
10312
10313                        return Err(match error {
10314                            Ok(value) => common::Error::BadRequest(value),
10315                            _ => common::Error::Failure(response),
10316                        });
10317                    }
10318                    let response = {
10319                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10320                        let encoded = common::to_string(&bytes);
10321                        match serde_json::from_str(&encoded) {
10322                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10323                            Err(error) => {
10324                                dlg.response_json_decode_error(&encoded, &error);
10325                                return Err(common::Error::JsonDecodeError(
10326                                    encoded.to_string(),
10327                                    error,
10328                                ));
10329                            }
10330                        }
10331                    };
10332
10333                    dlg.finished(true);
10334                    return Ok(response);
10335                }
10336            }
10337        }
10338    }
10339
10340    ///
10341    /// Sets the *request* property to the given value.
10342    ///
10343    /// Even though the property as already been set when instantiating this call,
10344    /// we provide this method for API completeness.
10345    pub fn request(
10346        mut self,
10347        new_value: UpdateInstanceConfigRequest,
10348    ) -> ProjectInstanceConfigPatchCall<'a, C> {
10349        self._request = new_value;
10350        self
10351    }
10352    /// A unique identifier for the instance configuration. Values are of the form `projects//instanceConfigs/a-z*`. User instance configuration must start with `custom-`.
10353    ///
10354    /// Sets the *name* path property to the given value.
10355    ///
10356    /// Even though the property as already been set when instantiating this call,
10357    /// we provide this method for API completeness.
10358    pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigPatchCall<'a, C> {
10359        self._name = new_value.to_string();
10360        self
10361    }
10362    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10363    /// while executing the actual API request.
10364    ///
10365    /// ````text
10366    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10367    /// ````
10368    ///
10369    /// Sets the *delegate* property to the given value.
10370    pub fn delegate(
10371        mut self,
10372        new_value: &'a mut dyn common::Delegate,
10373    ) -> ProjectInstanceConfigPatchCall<'a, C> {
10374        self._delegate = Some(new_value);
10375        self
10376    }
10377
10378    /// Set any additional parameter of the query string used in the request.
10379    /// It should be used to set parameters which are not yet available through their own
10380    /// setters.
10381    ///
10382    /// Please note that this method must not be used to set any of the known parameters
10383    /// which have their own setter method. If done anyway, the request will fail.
10384    ///
10385    /// # Additional Parameters
10386    ///
10387    /// * *$.xgafv* (query-string) - V1 error format.
10388    /// * *access_token* (query-string) - OAuth access token.
10389    /// * *alt* (query-string) - Data format for response.
10390    /// * *callback* (query-string) - JSONP
10391    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10392    /// * *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.
10393    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10394    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10395    /// * *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.
10396    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10397    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10398    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigPatchCall<'a, C>
10399    where
10400        T: AsRef<str>,
10401    {
10402        self._additional_params
10403            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10404        self
10405    }
10406
10407    /// Identifies the authorization scope for the method you are building.
10408    ///
10409    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10410    /// [`Scope::CloudPlatform`].
10411    ///
10412    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10413    /// tokens for more than one scope.
10414    ///
10415    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10416    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10417    /// sufficient, a read-write scope will do as well.
10418    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigPatchCall<'a, C>
10419    where
10420        St: AsRef<str>,
10421    {
10422        self._scopes.insert(String::from(scope.as_ref()));
10423        self
10424    }
10425    /// Identifies the authorization scope(s) for the method you are building.
10426    ///
10427    /// See [`Self::add_scope()`] for details.
10428    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigPatchCall<'a, C>
10429    where
10430        I: IntoIterator<Item = St>,
10431        St: AsRef<str>,
10432    {
10433        self._scopes
10434            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10435        self
10436    }
10437
10438    /// Removes all scopes, and no default scope will be used either.
10439    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10440    /// for details).
10441    pub fn clear_scopes(mut self) -> ProjectInstanceConfigPatchCall<'a, C> {
10442        self._scopes.clear();
10443        self
10444    }
10445}
10446
10447/// Lists the backup long-running operations in the given instance. A backup operation has a name of the form `projects//instances//backups//operations/`. The long-running operation metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by `operation.metadata.value.progress.start_time` in descending order starting from the most recently started operation.
10448///
10449/// A builder for the *instances.backupOperations.list* method supported by a *project* resource.
10450/// It is not used directly, but through a [`ProjectMethods`] instance.
10451///
10452/// # Example
10453///
10454/// Instantiate a resource method builder
10455///
10456/// ```test_harness,no_run
10457/// # extern crate hyper;
10458/// # extern crate hyper_rustls;
10459/// # extern crate google_spanner1 as spanner1;
10460/// # async fn dox() {
10461/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10462///
10463/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10464/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10465/// #     .with_native_roots()
10466/// #     .unwrap()
10467/// #     .https_only()
10468/// #     .enable_http2()
10469/// #     .build();
10470///
10471/// # let executor = hyper_util::rt::TokioExecutor::new();
10472/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10473/// #     secret,
10474/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10475/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10476/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10477/// #     ),
10478/// # ).build().await.unwrap();
10479///
10480/// # let client = hyper_util::client::legacy::Client::builder(
10481/// #     hyper_util::rt::TokioExecutor::new()
10482/// # )
10483/// # .build(
10484/// #     hyper_rustls::HttpsConnectorBuilder::new()
10485/// #         .with_native_roots()
10486/// #         .unwrap()
10487/// #         .https_or_http()
10488/// #         .enable_http2()
10489/// #         .build()
10490/// # );
10491/// # let mut hub = Spanner::new(client, auth);
10492/// // You can configure optional parameters by calling the respective setters at will, and
10493/// // execute the final call using `doit()`.
10494/// // Values shown here are possibly random and not representative !
10495/// let result = hub.projects().instances_backup_operations_list("parent")
10496///              .page_token("et")
10497///              .page_size(-68)
10498///              .filter("vero")
10499///              .doit().await;
10500/// # }
10501/// ```
10502pub struct ProjectInstanceBackupOperationListCall<'a, C>
10503where
10504    C: 'a,
10505{
10506    hub: &'a Spanner<C>,
10507    _parent: String,
10508    _page_token: Option<String>,
10509    _page_size: Option<i32>,
10510    _filter: Option<String>,
10511    _delegate: Option<&'a mut dyn common::Delegate>,
10512    _additional_params: HashMap<String, String>,
10513    _scopes: BTreeSet<String>,
10514}
10515
10516impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationListCall<'a, C> {}
10517
10518impl<'a, C> ProjectInstanceBackupOperationListCall<'a, C>
10519where
10520    C: common::Connector,
10521{
10522    /// Perform the operation you have build so far.
10523    pub async fn doit(
10524        mut self,
10525    ) -> common::Result<(common::Response, ListBackupOperationsResponse)> {
10526        use std::borrow::Cow;
10527        use std::io::{Read, Seek};
10528
10529        use common::{url::Params, ToParts};
10530        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10531
10532        let mut dd = common::DefaultDelegate;
10533        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10534        dlg.begin(common::MethodInfo {
10535            id: "spanner.projects.instances.backupOperations.list",
10536            http_method: hyper::Method::GET,
10537        });
10538
10539        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
10540            if self._additional_params.contains_key(field) {
10541                dlg.finished(false);
10542                return Err(common::Error::FieldClash(field));
10543            }
10544        }
10545
10546        let mut params = Params::with_capacity(6 + self._additional_params.len());
10547        params.push("parent", self._parent);
10548        if let Some(value) = self._page_token.as_ref() {
10549            params.push("pageToken", value);
10550        }
10551        if let Some(value) = self._page_size.as_ref() {
10552            params.push("pageSize", value.to_string());
10553        }
10554        if let Some(value) = self._filter.as_ref() {
10555            params.push("filter", value);
10556        }
10557
10558        params.extend(self._additional_params.iter());
10559
10560        params.push("alt", "json");
10561        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backupOperations";
10562        if self._scopes.is_empty() {
10563            self._scopes
10564                .insert(Scope::CloudPlatform.as_ref().to_string());
10565        }
10566
10567        #[allow(clippy::single_element_loop)]
10568        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10569            url = params.uri_replacement(url, param_name, find_this, true);
10570        }
10571        {
10572            let to_remove = ["parent"];
10573            params.remove_params(&to_remove);
10574        }
10575
10576        let url = params.parse_with_url(&url);
10577
10578        loop {
10579            let token = match self
10580                .hub
10581                .auth
10582                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10583                .await
10584            {
10585                Ok(token) => token,
10586                Err(e) => match dlg.token(e) {
10587                    Ok(token) => token,
10588                    Err(e) => {
10589                        dlg.finished(false);
10590                        return Err(common::Error::MissingToken(e));
10591                    }
10592                },
10593            };
10594            let mut req_result = {
10595                let client = &self.hub.client;
10596                dlg.pre_request();
10597                let mut req_builder = hyper::Request::builder()
10598                    .method(hyper::Method::GET)
10599                    .uri(url.as_str())
10600                    .header(USER_AGENT, self.hub._user_agent.clone());
10601
10602                if let Some(token) = token.as_ref() {
10603                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10604                }
10605
10606                let request = req_builder
10607                    .header(CONTENT_LENGTH, 0_u64)
10608                    .body(common::to_body::<String>(None));
10609
10610                client.request(request.unwrap()).await
10611            };
10612
10613            match req_result {
10614                Err(err) => {
10615                    if let common::Retry::After(d) = dlg.http_error(&err) {
10616                        sleep(d).await;
10617                        continue;
10618                    }
10619                    dlg.finished(false);
10620                    return Err(common::Error::HttpError(err));
10621                }
10622                Ok(res) => {
10623                    let (mut parts, body) = res.into_parts();
10624                    let mut body = common::Body::new(body);
10625                    if !parts.status.is_success() {
10626                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10627                        let error = serde_json::from_str(&common::to_string(&bytes));
10628                        let response = common::to_response(parts, bytes.into());
10629
10630                        if let common::Retry::After(d) =
10631                            dlg.http_failure(&response, error.as_ref().ok())
10632                        {
10633                            sleep(d).await;
10634                            continue;
10635                        }
10636
10637                        dlg.finished(false);
10638
10639                        return Err(match error {
10640                            Ok(value) => common::Error::BadRequest(value),
10641                            _ => common::Error::Failure(response),
10642                        });
10643                    }
10644                    let response = {
10645                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10646                        let encoded = common::to_string(&bytes);
10647                        match serde_json::from_str(&encoded) {
10648                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10649                            Err(error) => {
10650                                dlg.response_json_decode_error(&encoded, &error);
10651                                return Err(common::Error::JsonDecodeError(
10652                                    encoded.to_string(),
10653                                    error,
10654                                ));
10655                            }
10656                        }
10657                    };
10658
10659                    dlg.finished(true);
10660                    return Ok(response);
10661                }
10662            }
10663        }
10664    }
10665
10666    /// Required. The instance of the backup operations. Values are of the form `projects//instances/`.
10667    ///
10668    /// Sets the *parent* path property to the given value.
10669    ///
10670    /// Even though the property as already been set when instantiating this call,
10671    /// we provide this method for API completeness.
10672    pub fn parent(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall<'a, C> {
10673        self._parent = new_value.to_string();
10674        self
10675    }
10676    /// If non-empty, `page_token` should contain a next_page_token from a previous ListBackupOperationsResponse to the same `parent` and with the same `filter`.
10677    ///
10678    /// Sets the *page token* query property to the given value.
10679    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall<'a, C> {
10680        self._page_token = Some(new_value.to_string());
10681        self
10682    }
10683    /// Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
10684    ///
10685    /// Sets the *page size* query property to the given value.
10686    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceBackupOperationListCall<'a, C> {
10687        self._page_size = Some(new_value);
10688        self
10689    }
10690    /// An expression that filters the list of returned backup operations. A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. Colon `:` is the contains operator. Filter rules are not case sensitive. The following fields in the operation are eligible for filtering: * `name` - The name of the long-running operation * `done` - False if the operation is in progress, else true. * `metadata.@type` - the type of metadata. For example, the type string for CreateBackupMetadata is `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`. * `metadata.` - any field in metadata.value. `metadata.@type` must be specified first if filtering on metadata fields. * `error` - Error associated with the long-running operation. * `response.@type` - the type of response. * `response.` - any field in response.value. You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly. Here are a few examples: * `done:true` - The operation is complete. * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ `metadata.database:prod` - Returns operations where: * The operation's metadata type is CreateBackupMetadata. * The source database name of backup contains the string "prod". * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ `(metadata.name:howl) AND` \ `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ `(error:*)` - Returns operations where: * The operation's metadata type is CreateBackupMetadata. * The backup name contains the string "howl". * The operation started before 2018-03-28T14:50:00Z. * The operation resulted in an error. * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ `(metadata.source_backup:test) AND` \ `(metadata.progress.start_time < \"2022-01-18T14:50:00Z\") AND` \ `(error:*)` - Returns operations where: * The operation's metadata type is CopyBackupMetadata. * The source backup name contains the string "test". * The operation started before 2022-01-18T14:50:00Z. * The operation resulted in an error. * `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` \ `(metadata.database:test_db)) OR` \ `((metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CopyBackupMetadata) AND` \ `(metadata.source_backup:test_bkp)) AND` \ `(error:*)` - Returns operations where: * The operation's metadata matches either of criteria: * The operation's metadata type is CreateBackupMetadata AND the source database name of the backup contains the string "test_db" * The operation's metadata type is CopyBackupMetadata AND the source backup name contains the string "test_bkp" * The operation resulted in an error.
10691    ///
10692    /// Sets the *filter* query property to the given value.
10693    pub fn filter(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall<'a, C> {
10694        self._filter = Some(new_value.to_string());
10695        self
10696    }
10697    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10698    /// while executing the actual API request.
10699    ///
10700    /// ````text
10701    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10702    /// ````
10703    ///
10704    /// Sets the *delegate* property to the given value.
10705    pub fn delegate(
10706        mut self,
10707        new_value: &'a mut dyn common::Delegate,
10708    ) -> ProjectInstanceBackupOperationListCall<'a, C> {
10709        self._delegate = Some(new_value);
10710        self
10711    }
10712
10713    /// Set any additional parameter of the query string used in the request.
10714    /// It should be used to set parameters which are not yet available through their own
10715    /// setters.
10716    ///
10717    /// Please note that this method must not be used to set any of the known parameters
10718    /// which have their own setter method. If done anyway, the request will fail.
10719    ///
10720    /// # Additional Parameters
10721    ///
10722    /// * *$.xgafv* (query-string) - V1 error format.
10723    /// * *access_token* (query-string) - OAuth access token.
10724    /// * *alt* (query-string) - Data format for response.
10725    /// * *callback* (query-string) - JSONP
10726    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10727    /// * *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.
10728    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10729    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10730    /// * *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.
10731    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10732    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10733    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationListCall<'a, C>
10734    where
10735        T: AsRef<str>,
10736    {
10737        self._additional_params
10738            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10739        self
10740    }
10741
10742    /// Identifies the authorization scope for the method you are building.
10743    ///
10744    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10745    /// [`Scope::CloudPlatform`].
10746    ///
10747    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10748    /// tokens for more than one scope.
10749    ///
10750    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10751    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10752    /// sufficient, a read-write scope will do as well.
10753    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationListCall<'a, C>
10754    where
10755        St: AsRef<str>,
10756    {
10757        self._scopes.insert(String::from(scope.as_ref()));
10758        self
10759    }
10760    /// Identifies the authorization scope(s) for the method you are building.
10761    ///
10762    /// See [`Self::add_scope()`] for details.
10763    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationListCall<'a, C>
10764    where
10765        I: IntoIterator<Item = St>,
10766        St: AsRef<str>,
10767    {
10768        self._scopes
10769            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10770        self
10771    }
10772
10773    /// Removes all scopes, and no default scope will be used either.
10774    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10775    /// for details).
10776    pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationListCall<'a, C> {
10777        self._scopes.clear();
10778        self
10779    }
10780}
10781
10782/// 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`.
10783///
10784/// A builder for the *instances.backups.operations.cancel* method supported by a *project* resource.
10785/// It is not used directly, but through a [`ProjectMethods`] instance.
10786///
10787/// # Example
10788///
10789/// Instantiate a resource method builder
10790///
10791/// ```test_harness,no_run
10792/// # extern crate hyper;
10793/// # extern crate hyper_rustls;
10794/// # extern crate google_spanner1 as spanner1;
10795/// # async fn dox() {
10796/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10797///
10798/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10799/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10800/// #     .with_native_roots()
10801/// #     .unwrap()
10802/// #     .https_only()
10803/// #     .enable_http2()
10804/// #     .build();
10805///
10806/// # let executor = hyper_util::rt::TokioExecutor::new();
10807/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10808/// #     secret,
10809/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10810/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10811/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10812/// #     ),
10813/// # ).build().await.unwrap();
10814///
10815/// # let client = hyper_util::client::legacy::Client::builder(
10816/// #     hyper_util::rt::TokioExecutor::new()
10817/// # )
10818/// # .build(
10819/// #     hyper_rustls::HttpsConnectorBuilder::new()
10820/// #         .with_native_roots()
10821/// #         .unwrap()
10822/// #         .https_or_http()
10823/// #         .enable_http2()
10824/// #         .build()
10825/// # );
10826/// # let mut hub = Spanner::new(client, auth);
10827/// // You can configure optional parameters by calling the respective setters at will, and
10828/// // execute the final call using `doit()`.
10829/// // Values shown here are possibly random and not representative !
10830/// let result = hub.projects().instances_backups_operations_cancel("name")
10831///              .doit().await;
10832/// # }
10833/// ```
10834pub struct ProjectInstanceBackupOperationCancelCall<'a, C>
10835where
10836    C: 'a,
10837{
10838    hub: &'a Spanner<C>,
10839    _name: String,
10840    _delegate: Option<&'a mut dyn common::Delegate>,
10841    _additional_params: HashMap<String, String>,
10842    _scopes: BTreeSet<String>,
10843}
10844
10845impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationCancelCall<'a, C> {}
10846
10847impl<'a, C> ProjectInstanceBackupOperationCancelCall<'a, C>
10848where
10849    C: common::Connector,
10850{
10851    /// Perform the operation you have build so far.
10852    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
10853        use std::borrow::Cow;
10854        use std::io::{Read, Seek};
10855
10856        use common::{url::Params, ToParts};
10857        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10858
10859        let mut dd = common::DefaultDelegate;
10860        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10861        dlg.begin(common::MethodInfo {
10862            id: "spanner.projects.instances.backups.operations.cancel",
10863            http_method: hyper::Method::POST,
10864        });
10865
10866        for &field in ["alt", "name"].iter() {
10867            if self._additional_params.contains_key(field) {
10868                dlg.finished(false);
10869                return Err(common::Error::FieldClash(field));
10870            }
10871        }
10872
10873        let mut params = Params::with_capacity(3 + self._additional_params.len());
10874        params.push("name", self._name);
10875
10876        params.extend(self._additional_params.iter());
10877
10878        params.push("alt", "json");
10879        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
10880        if self._scopes.is_empty() {
10881            self._scopes
10882                .insert(Scope::CloudPlatform.as_ref().to_string());
10883        }
10884
10885        #[allow(clippy::single_element_loop)]
10886        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10887            url = params.uri_replacement(url, param_name, find_this, true);
10888        }
10889        {
10890            let to_remove = ["name"];
10891            params.remove_params(&to_remove);
10892        }
10893
10894        let url = params.parse_with_url(&url);
10895
10896        loop {
10897            let token = match self
10898                .hub
10899                .auth
10900                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10901                .await
10902            {
10903                Ok(token) => token,
10904                Err(e) => match dlg.token(e) {
10905                    Ok(token) => token,
10906                    Err(e) => {
10907                        dlg.finished(false);
10908                        return Err(common::Error::MissingToken(e));
10909                    }
10910                },
10911            };
10912            let mut req_result = {
10913                let client = &self.hub.client;
10914                dlg.pre_request();
10915                let mut req_builder = hyper::Request::builder()
10916                    .method(hyper::Method::POST)
10917                    .uri(url.as_str())
10918                    .header(USER_AGENT, self.hub._user_agent.clone());
10919
10920                if let Some(token) = token.as_ref() {
10921                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10922                }
10923
10924                let request = req_builder
10925                    .header(CONTENT_LENGTH, 0_u64)
10926                    .body(common::to_body::<String>(None));
10927
10928                client.request(request.unwrap()).await
10929            };
10930
10931            match req_result {
10932                Err(err) => {
10933                    if let common::Retry::After(d) = dlg.http_error(&err) {
10934                        sleep(d).await;
10935                        continue;
10936                    }
10937                    dlg.finished(false);
10938                    return Err(common::Error::HttpError(err));
10939                }
10940                Ok(res) => {
10941                    let (mut parts, body) = res.into_parts();
10942                    let mut body = common::Body::new(body);
10943                    if !parts.status.is_success() {
10944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10945                        let error = serde_json::from_str(&common::to_string(&bytes));
10946                        let response = common::to_response(parts, bytes.into());
10947
10948                        if let common::Retry::After(d) =
10949                            dlg.http_failure(&response, error.as_ref().ok())
10950                        {
10951                            sleep(d).await;
10952                            continue;
10953                        }
10954
10955                        dlg.finished(false);
10956
10957                        return Err(match error {
10958                            Ok(value) => common::Error::BadRequest(value),
10959                            _ => common::Error::Failure(response),
10960                        });
10961                    }
10962                    let response = {
10963                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10964                        let encoded = common::to_string(&bytes);
10965                        match serde_json::from_str(&encoded) {
10966                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10967                            Err(error) => {
10968                                dlg.response_json_decode_error(&encoded, &error);
10969                                return Err(common::Error::JsonDecodeError(
10970                                    encoded.to_string(),
10971                                    error,
10972                                ));
10973                            }
10974                        }
10975                    };
10976
10977                    dlg.finished(true);
10978                    return Ok(response);
10979                }
10980            }
10981        }
10982    }
10983
10984    /// The name of the operation resource to be cancelled.
10985    ///
10986    /// Sets the *name* path property to the given value.
10987    ///
10988    /// Even though the property as already been set when instantiating this call,
10989    /// we provide this method for API completeness.
10990    pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupOperationCancelCall<'a, C> {
10991        self._name = new_value.to_string();
10992        self
10993    }
10994    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10995    /// while executing the actual API request.
10996    ///
10997    /// ````text
10998    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10999    /// ````
11000    ///
11001    /// Sets the *delegate* property to the given value.
11002    pub fn delegate(
11003        mut self,
11004        new_value: &'a mut dyn common::Delegate,
11005    ) -> ProjectInstanceBackupOperationCancelCall<'a, C> {
11006        self._delegate = Some(new_value);
11007        self
11008    }
11009
11010    /// Set any additional parameter of the query string used in the request.
11011    /// It should be used to set parameters which are not yet available through their own
11012    /// setters.
11013    ///
11014    /// Please note that this method must not be used to set any of the known parameters
11015    /// which have their own setter method. If done anyway, the request will fail.
11016    ///
11017    /// # Additional Parameters
11018    ///
11019    /// * *$.xgafv* (query-string) - V1 error format.
11020    /// * *access_token* (query-string) - OAuth access token.
11021    /// * *alt* (query-string) - Data format for response.
11022    /// * *callback* (query-string) - JSONP
11023    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11024    /// * *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.
11025    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11026    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11027    /// * *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.
11028    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11029    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11030    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationCancelCall<'a, C>
11031    where
11032        T: AsRef<str>,
11033    {
11034        self._additional_params
11035            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11036        self
11037    }
11038
11039    /// Identifies the authorization scope for the method you are building.
11040    ///
11041    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11042    /// [`Scope::CloudPlatform`].
11043    ///
11044    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11045    /// tokens for more than one scope.
11046    ///
11047    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11048    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11049    /// sufficient, a read-write scope will do as well.
11050    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationCancelCall<'a, C>
11051    where
11052        St: AsRef<str>,
11053    {
11054        self._scopes.insert(String::from(scope.as_ref()));
11055        self
11056    }
11057    /// Identifies the authorization scope(s) for the method you are building.
11058    ///
11059    /// See [`Self::add_scope()`] for details.
11060    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationCancelCall<'a, C>
11061    where
11062        I: IntoIterator<Item = St>,
11063        St: AsRef<str>,
11064    {
11065        self._scopes
11066            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11067        self
11068    }
11069
11070    /// Removes all scopes, and no default scope will be used either.
11071    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11072    /// for details).
11073    pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationCancelCall<'a, C> {
11074        self._scopes.clear();
11075        self
11076    }
11077}
11078
11079/// 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`.
11080///
11081/// A builder for the *instances.backups.operations.delete* method supported by a *project* resource.
11082/// It is not used directly, but through a [`ProjectMethods`] instance.
11083///
11084/// # Example
11085///
11086/// Instantiate a resource method builder
11087///
11088/// ```test_harness,no_run
11089/// # extern crate hyper;
11090/// # extern crate hyper_rustls;
11091/// # extern crate google_spanner1 as spanner1;
11092/// # async fn dox() {
11093/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11094///
11095/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11096/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11097/// #     .with_native_roots()
11098/// #     .unwrap()
11099/// #     .https_only()
11100/// #     .enable_http2()
11101/// #     .build();
11102///
11103/// # let executor = hyper_util::rt::TokioExecutor::new();
11104/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11105/// #     secret,
11106/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11107/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11108/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11109/// #     ),
11110/// # ).build().await.unwrap();
11111///
11112/// # let client = hyper_util::client::legacy::Client::builder(
11113/// #     hyper_util::rt::TokioExecutor::new()
11114/// # )
11115/// # .build(
11116/// #     hyper_rustls::HttpsConnectorBuilder::new()
11117/// #         .with_native_roots()
11118/// #         .unwrap()
11119/// #         .https_or_http()
11120/// #         .enable_http2()
11121/// #         .build()
11122/// # );
11123/// # let mut hub = Spanner::new(client, auth);
11124/// // You can configure optional parameters by calling the respective setters at will, and
11125/// // execute the final call using `doit()`.
11126/// // Values shown here are possibly random and not representative !
11127/// let result = hub.projects().instances_backups_operations_delete("name")
11128///              .doit().await;
11129/// # }
11130/// ```
11131pub struct ProjectInstanceBackupOperationDeleteCall<'a, C>
11132where
11133    C: 'a,
11134{
11135    hub: &'a Spanner<C>,
11136    _name: String,
11137    _delegate: Option<&'a mut dyn common::Delegate>,
11138    _additional_params: HashMap<String, String>,
11139    _scopes: BTreeSet<String>,
11140}
11141
11142impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationDeleteCall<'a, C> {}
11143
11144impl<'a, C> ProjectInstanceBackupOperationDeleteCall<'a, C>
11145where
11146    C: common::Connector,
11147{
11148    /// Perform the operation you have build so far.
11149    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11150        use std::borrow::Cow;
11151        use std::io::{Read, Seek};
11152
11153        use common::{url::Params, ToParts};
11154        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11155
11156        let mut dd = common::DefaultDelegate;
11157        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11158        dlg.begin(common::MethodInfo {
11159            id: "spanner.projects.instances.backups.operations.delete",
11160            http_method: hyper::Method::DELETE,
11161        });
11162
11163        for &field in ["alt", "name"].iter() {
11164            if self._additional_params.contains_key(field) {
11165                dlg.finished(false);
11166                return Err(common::Error::FieldClash(field));
11167            }
11168        }
11169
11170        let mut params = Params::with_capacity(3 + self._additional_params.len());
11171        params.push("name", self._name);
11172
11173        params.extend(self._additional_params.iter());
11174
11175        params.push("alt", "json");
11176        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11177        if self._scopes.is_empty() {
11178            self._scopes
11179                .insert(Scope::CloudPlatform.as_ref().to_string());
11180        }
11181
11182        #[allow(clippy::single_element_loop)]
11183        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11184            url = params.uri_replacement(url, param_name, find_this, true);
11185        }
11186        {
11187            let to_remove = ["name"];
11188            params.remove_params(&to_remove);
11189        }
11190
11191        let url = params.parse_with_url(&url);
11192
11193        loop {
11194            let token = match self
11195                .hub
11196                .auth
11197                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11198                .await
11199            {
11200                Ok(token) => token,
11201                Err(e) => match dlg.token(e) {
11202                    Ok(token) => token,
11203                    Err(e) => {
11204                        dlg.finished(false);
11205                        return Err(common::Error::MissingToken(e));
11206                    }
11207                },
11208            };
11209            let mut req_result = {
11210                let client = &self.hub.client;
11211                dlg.pre_request();
11212                let mut req_builder = hyper::Request::builder()
11213                    .method(hyper::Method::DELETE)
11214                    .uri(url.as_str())
11215                    .header(USER_AGENT, self.hub._user_agent.clone());
11216
11217                if let Some(token) = token.as_ref() {
11218                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11219                }
11220
11221                let request = req_builder
11222                    .header(CONTENT_LENGTH, 0_u64)
11223                    .body(common::to_body::<String>(None));
11224
11225                client.request(request.unwrap()).await
11226            };
11227
11228            match req_result {
11229                Err(err) => {
11230                    if let common::Retry::After(d) = dlg.http_error(&err) {
11231                        sleep(d).await;
11232                        continue;
11233                    }
11234                    dlg.finished(false);
11235                    return Err(common::Error::HttpError(err));
11236                }
11237                Ok(res) => {
11238                    let (mut parts, body) = res.into_parts();
11239                    let mut body = common::Body::new(body);
11240                    if !parts.status.is_success() {
11241                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11242                        let error = serde_json::from_str(&common::to_string(&bytes));
11243                        let response = common::to_response(parts, bytes.into());
11244
11245                        if let common::Retry::After(d) =
11246                            dlg.http_failure(&response, error.as_ref().ok())
11247                        {
11248                            sleep(d).await;
11249                            continue;
11250                        }
11251
11252                        dlg.finished(false);
11253
11254                        return Err(match error {
11255                            Ok(value) => common::Error::BadRequest(value),
11256                            _ => common::Error::Failure(response),
11257                        });
11258                    }
11259                    let response = {
11260                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11261                        let encoded = common::to_string(&bytes);
11262                        match serde_json::from_str(&encoded) {
11263                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11264                            Err(error) => {
11265                                dlg.response_json_decode_error(&encoded, &error);
11266                                return Err(common::Error::JsonDecodeError(
11267                                    encoded.to_string(),
11268                                    error,
11269                                ));
11270                            }
11271                        }
11272                    };
11273
11274                    dlg.finished(true);
11275                    return Ok(response);
11276                }
11277            }
11278        }
11279    }
11280
11281    /// The name of the operation resource to be deleted.
11282    ///
11283    /// Sets the *name* path property to the given value.
11284    ///
11285    /// Even though the property as already been set when instantiating this call,
11286    /// we provide this method for API completeness.
11287    pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupOperationDeleteCall<'a, C> {
11288        self._name = new_value.to_string();
11289        self
11290    }
11291    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11292    /// while executing the actual API request.
11293    ///
11294    /// ````text
11295    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11296    /// ````
11297    ///
11298    /// Sets the *delegate* property to the given value.
11299    pub fn delegate(
11300        mut self,
11301        new_value: &'a mut dyn common::Delegate,
11302    ) -> ProjectInstanceBackupOperationDeleteCall<'a, C> {
11303        self._delegate = Some(new_value);
11304        self
11305    }
11306
11307    /// Set any additional parameter of the query string used in the request.
11308    /// It should be used to set parameters which are not yet available through their own
11309    /// setters.
11310    ///
11311    /// Please note that this method must not be used to set any of the known parameters
11312    /// which have their own setter method. If done anyway, the request will fail.
11313    ///
11314    /// # Additional Parameters
11315    ///
11316    /// * *$.xgafv* (query-string) - V1 error format.
11317    /// * *access_token* (query-string) - OAuth access token.
11318    /// * *alt* (query-string) - Data format for response.
11319    /// * *callback* (query-string) - JSONP
11320    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11321    /// * *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.
11322    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11323    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11324    /// * *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.
11325    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11326    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11327    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationDeleteCall<'a, C>
11328    where
11329        T: AsRef<str>,
11330    {
11331        self._additional_params
11332            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11333        self
11334    }
11335
11336    /// Identifies the authorization scope for the method you are building.
11337    ///
11338    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11339    /// [`Scope::CloudPlatform`].
11340    ///
11341    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11342    /// tokens for more than one scope.
11343    ///
11344    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11345    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11346    /// sufficient, a read-write scope will do as well.
11347    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationDeleteCall<'a, C>
11348    where
11349        St: AsRef<str>,
11350    {
11351        self._scopes.insert(String::from(scope.as_ref()));
11352        self
11353    }
11354    /// Identifies the authorization scope(s) for the method you are building.
11355    ///
11356    /// See [`Self::add_scope()`] for details.
11357    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationDeleteCall<'a, C>
11358    where
11359        I: IntoIterator<Item = St>,
11360        St: AsRef<str>,
11361    {
11362        self._scopes
11363            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11364        self
11365    }
11366
11367    /// Removes all scopes, and no default scope will be used either.
11368    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11369    /// for details).
11370    pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationDeleteCall<'a, C> {
11371        self._scopes.clear();
11372        self
11373    }
11374}
11375
11376/// 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.
11377///
11378/// A builder for the *instances.backups.operations.get* method supported by a *project* resource.
11379/// It is not used directly, but through a [`ProjectMethods`] instance.
11380///
11381/// # Example
11382///
11383/// Instantiate a resource method builder
11384///
11385/// ```test_harness,no_run
11386/// # extern crate hyper;
11387/// # extern crate hyper_rustls;
11388/// # extern crate google_spanner1 as spanner1;
11389/// # async fn dox() {
11390/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11391///
11392/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11393/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11394/// #     .with_native_roots()
11395/// #     .unwrap()
11396/// #     .https_only()
11397/// #     .enable_http2()
11398/// #     .build();
11399///
11400/// # let executor = hyper_util::rt::TokioExecutor::new();
11401/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11402/// #     secret,
11403/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11404/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11405/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11406/// #     ),
11407/// # ).build().await.unwrap();
11408///
11409/// # let client = hyper_util::client::legacy::Client::builder(
11410/// #     hyper_util::rt::TokioExecutor::new()
11411/// # )
11412/// # .build(
11413/// #     hyper_rustls::HttpsConnectorBuilder::new()
11414/// #         .with_native_roots()
11415/// #         .unwrap()
11416/// #         .https_or_http()
11417/// #         .enable_http2()
11418/// #         .build()
11419/// # );
11420/// # let mut hub = Spanner::new(client, auth);
11421/// // You can configure optional parameters by calling the respective setters at will, and
11422/// // execute the final call using `doit()`.
11423/// // Values shown here are possibly random and not representative !
11424/// let result = hub.projects().instances_backups_operations_get("name")
11425///              .doit().await;
11426/// # }
11427/// ```
11428pub struct ProjectInstanceBackupOperationGetCall<'a, C>
11429where
11430    C: 'a,
11431{
11432    hub: &'a Spanner<C>,
11433    _name: String,
11434    _delegate: Option<&'a mut dyn common::Delegate>,
11435    _additional_params: HashMap<String, String>,
11436    _scopes: BTreeSet<String>,
11437}
11438
11439impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationGetCall<'a, C> {}
11440
11441impl<'a, C> ProjectInstanceBackupOperationGetCall<'a, C>
11442where
11443    C: common::Connector,
11444{
11445    /// Perform the operation you have build so far.
11446    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11447        use std::borrow::Cow;
11448        use std::io::{Read, Seek};
11449
11450        use common::{url::Params, ToParts};
11451        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11452
11453        let mut dd = common::DefaultDelegate;
11454        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11455        dlg.begin(common::MethodInfo {
11456            id: "spanner.projects.instances.backups.operations.get",
11457            http_method: hyper::Method::GET,
11458        });
11459
11460        for &field in ["alt", "name"].iter() {
11461            if self._additional_params.contains_key(field) {
11462                dlg.finished(false);
11463                return Err(common::Error::FieldClash(field));
11464            }
11465        }
11466
11467        let mut params = Params::with_capacity(3 + self._additional_params.len());
11468        params.push("name", self._name);
11469
11470        params.extend(self._additional_params.iter());
11471
11472        params.push("alt", "json");
11473        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11474        if self._scopes.is_empty() {
11475            self._scopes
11476                .insert(Scope::CloudPlatform.as_ref().to_string());
11477        }
11478
11479        #[allow(clippy::single_element_loop)]
11480        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11481            url = params.uri_replacement(url, param_name, find_this, true);
11482        }
11483        {
11484            let to_remove = ["name"];
11485            params.remove_params(&to_remove);
11486        }
11487
11488        let url = params.parse_with_url(&url);
11489
11490        loop {
11491            let token = match self
11492                .hub
11493                .auth
11494                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11495                .await
11496            {
11497                Ok(token) => token,
11498                Err(e) => match dlg.token(e) {
11499                    Ok(token) => token,
11500                    Err(e) => {
11501                        dlg.finished(false);
11502                        return Err(common::Error::MissingToken(e));
11503                    }
11504                },
11505            };
11506            let mut req_result = {
11507                let client = &self.hub.client;
11508                dlg.pre_request();
11509                let mut req_builder = hyper::Request::builder()
11510                    .method(hyper::Method::GET)
11511                    .uri(url.as_str())
11512                    .header(USER_AGENT, self.hub._user_agent.clone());
11513
11514                if let Some(token) = token.as_ref() {
11515                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11516                }
11517
11518                let request = req_builder
11519                    .header(CONTENT_LENGTH, 0_u64)
11520                    .body(common::to_body::<String>(None));
11521
11522                client.request(request.unwrap()).await
11523            };
11524
11525            match req_result {
11526                Err(err) => {
11527                    if let common::Retry::After(d) = dlg.http_error(&err) {
11528                        sleep(d).await;
11529                        continue;
11530                    }
11531                    dlg.finished(false);
11532                    return Err(common::Error::HttpError(err));
11533                }
11534                Ok(res) => {
11535                    let (mut parts, body) = res.into_parts();
11536                    let mut body = common::Body::new(body);
11537                    if !parts.status.is_success() {
11538                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11539                        let error = serde_json::from_str(&common::to_string(&bytes));
11540                        let response = common::to_response(parts, bytes.into());
11541
11542                        if let common::Retry::After(d) =
11543                            dlg.http_failure(&response, error.as_ref().ok())
11544                        {
11545                            sleep(d).await;
11546                            continue;
11547                        }
11548
11549                        dlg.finished(false);
11550
11551                        return Err(match error {
11552                            Ok(value) => common::Error::BadRequest(value),
11553                            _ => common::Error::Failure(response),
11554                        });
11555                    }
11556                    let response = {
11557                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11558                        let encoded = common::to_string(&bytes);
11559                        match serde_json::from_str(&encoded) {
11560                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11561                            Err(error) => {
11562                                dlg.response_json_decode_error(&encoded, &error);
11563                                return Err(common::Error::JsonDecodeError(
11564                                    encoded.to_string(),
11565                                    error,
11566                                ));
11567                            }
11568                        }
11569                    };
11570
11571                    dlg.finished(true);
11572                    return Ok(response);
11573                }
11574            }
11575        }
11576    }
11577
11578    /// The name of the operation resource.
11579    ///
11580    /// Sets the *name* path property to the given value.
11581    ///
11582    /// Even though the property as already been set when instantiating this call,
11583    /// we provide this method for API completeness.
11584    pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupOperationGetCall<'a, C> {
11585        self._name = new_value.to_string();
11586        self
11587    }
11588    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11589    /// while executing the actual API request.
11590    ///
11591    /// ````text
11592    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11593    /// ````
11594    ///
11595    /// Sets the *delegate* property to the given value.
11596    pub fn delegate(
11597        mut self,
11598        new_value: &'a mut dyn common::Delegate,
11599    ) -> ProjectInstanceBackupOperationGetCall<'a, C> {
11600        self._delegate = Some(new_value);
11601        self
11602    }
11603
11604    /// Set any additional parameter of the query string used in the request.
11605    /// It should be used to set parameters which are not yet available through their own
11606    /// setters.
11607    ///
11608    /// Please note that this method must not be used to set any of the known parameters
11609    /// which have their own setter method. If done anyway, the request will fail.
11610    ///
11611    /// # Additional Parameters
11612    ///
11613    /// * *$.xgafv* (query-string) - V1 error format.
11614    /// * *access_token* (query-string) - OAuth access token.
11615    /// * *alt* (query-string) - Data format for response.
11616    /// * *callback* (query-string) - JSONP
11617    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11618    /// * *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.
11619    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11620    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11621    /// * *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.
11622    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11623    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11624    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationGetCall<'a, C>
11625    where
11626        T: AsRef<str>,
11627    {
11628        self._additional_params
11629            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11630        self
11631    }
11632
11633    /// Identifies the authorization scope for the method you are building.
11634    ///
11635    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11636    /// [`Scope::CloudPlatform`].
11637    ///
11638    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11639    /// tokens for more than one scope.
11640    ///
11641    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11642    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11643    /// sufficient, a read-write scope will do as well.
11644    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationGetCall<'a, C>
11645    where
11646        St: AsRef<str>,
11647    {
11648        self._scopes.insert(String::from(scope.as_ref()));
11649        self
11650    }
11651    /// Identifies the authorization scope(s) for the method you are building.
11652    ///
11653    /// See [`Self::add_scope()`] for details.
11654    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationGetCall<'a, C>
11655    where
11656        I: IntoIterator<Item = St>,
11657        St: AsRef<str>,
11658    {
11659        self._scopes
11660            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11661        self
11662    }
11663
11664    /// Removes all scopes, and no default scope will be used either.
11665    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11666    /// for details).
11667    pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationGetCall<'a, C> {
11668        self._scopes.clear();
11669        self
11670    }
11671}
11672
11673/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
11674///
11675/// A builder for the *instances.backups.operations.list* method supported by a *project* resource.
11676/// It is not used directly, but through a [`ProjectMethods`] instance.
11677///
11678/// # Example
11679///
11680/// Instantiate a resource method builder
11681///
11682/// ```test_harness,no_run
11683/// # extern crate hyper;
11684/// # extern crate hyper_rustls;
11685/// # extern crate google_spanner1 as spanner1;
11686/// # async fn dox() {
11687/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11688///
11689/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11690/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11691/// #     .with_native_roots()
11692/// #     .unwrap()
11693/// #     .https_only()
11694/// #     .enable_http2()
11695/// #     .build();
11696///
11697/// # let executor = hyper_util::rt::TokioExecutor::new();
11698/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11699/// #     secret,
11700/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11701/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11702/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11703/// #     ),
11704/// # ).build().await.unwrap();
11705///
11706/// # let client = hyper_util::client::legacy::Client::builder(
11707/// #     hyper_util::rt::TokioExecutor::new()
11708/// # )
11709/// # .build(
11710/// #     hyper_rustls::HttpsConnectorBuilder::new()
11711/// #         .with_native_roots()
11712/// #         .unwrap()
11713/// #         .https_or_http()
11714/// #         .enable_http2()
11715/// #         .build()
11716/// # );
11717/// # let mut hub = Spanner::new(client, auth);
11718/// // You can configure optional parameters by calling the respective setters at will, and
11719/// // execute the final call using `doit()`.
11720/// // Values shown here are possibly random and not representative !
11721/// let result = hub.projects().instances_backups_operations_list("name")
11722///              .return_partial_success(false)
11723///              .page_token("diam")
11724///              .page_size(-49)
11725///              .filter("et")
11726///              .doit().await;
11727/// # }
11728/// ```
11729pub struct ProjectInstanceBackupOperationListCall1<'a, C>
11730where
11731    C: 'a,
11732{
11733    hub: &'a Spanner<C>,
11734    _name: String,
11735    _return_partial_success: Option<bool>,
11736    _page_token: Option<String>,
11737    _page_size: Option<i32>,
11738    _filter: Option<String>,
11739    _delegate: Option<&'a mut dyn common::Delegate>,
11740    _additional_params: HashMap<String, String>,
11741    _scopes: BTreeSet<String>,
11742}
11743
11744impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationListCall1<'a, C> {}
11745
11746impl<'a, C> ProjectInstanceBackupOperationListCall1<'a, C>
11747where
11748    C: common::Connector,
11749{
11750    /// Perform the operation you have build so far.
11751    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
11752        use std::borrow::Cow;
11753        use std::io::{Read, Seek};
11754
11755        use common::{url::Params, ToParts};
11756        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11757
11758        let mut dd = common::DefaultDelegate;
11759        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11760        dlg.begin(common::MethodInfo {
11761            id: "spanner.projects.instances.backups.operations.list",
11762            http_method: hyper::Method::GET,
11763        });
11764
11765        for &field in [
11766            "alt",
11767            "name",
11768            "returnPartialSuccess",
11769            "pageToken",
11770            "pageSize",
11771            "filter",
11772        ]
11773        .iter()
11774        {
11775            if self._additional_params.contains_key(field) {
11776                dlg.finished(false);
11777                return Err(common::Error::FieldClash(field));
11778            }
11779        }
11780
11781        let mut params = Params::with_capacity(7 + self._additional_params.len());
11782        params.push("name", self._name);
11783        if let Some(value) = self._return_partial_success.as_ref() {
11784            params.push("returnPartialSuccess", value.to_string());
11785        }
11786        if let Some(value) = self._page_token.as_ref() {
11787            params.push("pageToken", value);
11788        }
11789        if let Some(value) = self._page_size.as_ref() {
11790            params.push("pageSize", value.to_string());
11791        }
11792        if let Some(value) = self._filter.as_ref() {
11793            params.push("filter", value);
11794        }
11795
11796        params.extend(self._additional_params.iter());
11797
11798        params.push("alt", "json");
11799        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11800        if self._scopes.is_empty() {
11801            self._scopes
11802                .insert(Scope::CloudPlatform.as_ref().to_string());
11803        }
11804
11805        #[allow(clippy::single_element_loop)]
11806        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11807            url = params.uri_replacement(url, param_name, find_this, true);
11808        }
11809        {
11810            let to_remove = ["name"];
11811            params.remove_params(&to_remove);
11812        }
11813
11814        let url = params.parse_with_url(&url);
11815
11816        loop {
11817            let token = match self
11818                .hub
11819                .auth
11820                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11821                .await
11822            {
11823                Ok(token) => token,
11824                Err(e) => match dlg.token(e) {
11825                    Ok(token) => token,
11826                    Err(e) => {
11827                        dlg.finished(false);
11828                        return Err(common::Error::MissingToken(e));
11829                    }
11830                },
11831            };
11832            let mut req_result = {
11833                let client = &self.hub.client;
11834                dlg.pre_request();
11835                let mut req_builder = hyper::Request::builder()
11836                    .method(hyper::Method::GET)
11837                    .uri(url.as_str())
11838                    .header(USER_AGENT, self.hub._user_agent.clone());
11839
11840                if let Some(token) = token.as_ref() {
11841                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11842                }
11843
11844                let request = req_builder
11845                    .header(CONTENT_LENGTH, 0_u64)
11846                    .body(common::to_body::<String>(None));
11847
11848                client.request(request.unwrap()).await
11849            };
11850
11851            match req_result {
11852                Err(err) => {
11853                    if let common::Retry::After(d) = dlg.http_error(&err) {
11854                        sleep(d).await;
11855                        continue;
11856                    }
11857                    dlg.finished(false);
11858                    return Err(common::Error::HttpError(err));
11859                }
11860                Ok(res) => {
11861                    let (mut parts, body) = res.into_parts();
11862                    let mut body = common::Body::new(body);
11863                    if !parts.status.is_success() {
11864                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11865                        let error = serde_json::from_str(&common::to_string(&bytes));
11866                        let response = common::to_response(parts, bytes.into());
11867
11868                        if let common::Retry::After(d) =
11869                            dlg.http_failure(&response, error.as_ref().ok())
11870                        {
11871                            sleep(d).await;
11872                            continue;
11873                        }
11874
11875                        dlg.finished(false);
11876
11877                        return Err(match error {
11878                            Ok(value) => common::Error::BadRequest(value),
11879                            _ => common::Error::Failure(response),
11880                        });
11881                    }
11882                    let response = {
11883                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11884                        let encoded = common::to_string(&bytes);
11885                        match serde_json::from_str(&encoded) {
11886                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11887                            Err(error) => {
11888                                dlg.response_json_decode_error(&encoded, &error);
11889                                return Err(common::Error::JsonDecodeError(
11890                                    encoded.to_string(),
11891                                    error,
11892                                ));
11893                            }
11894                        }
11895                    };
11896
11897                    dlg.finished(true);
11898                    return Ok(response);
11899                }
11900            }
11901        }
11902    }
11903
11904    /// The name of the operation's parent resource.
11905    ///
11906    /// Sets the *name* path property to the given value.
11907    ///
11908    /// Even though the property as already been set when instantiating this call,
11909    /// we provide this method for API completeness.
11910    pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall1<'a, C> {
11911        self._name = new_value.to_string();
11912        self
11913    }
11914    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
11915    ///
11916    /// Sets the *return partial success* query property to the given value.
11917    pub fn return_partial_success(
11918        mut self,
11919        new_value: bool,
11920    ) -> ProjectInstanceBackupOperationListCall1<'a, C> {
11921        self._return_partial_success = Some(new_value);
11922        self
11923    }
11924    /// The standard list page token.
11925    ///
11926    /// Sets the *page token* query property to the given value.
11927    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall1<'a, C> {
11928        self._page_token = Some(new_value.to_string());
11929        self
11930    }
11931    /// The standard list page size.
11932    ///
11933    /// Sets the *page size* query property to the given value.
11934    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceBackupOperationListCall1<'a, C> {
11935        self._page_size = Some(new_value);
11936        self
11937    }
11938    /// The standard list filter.
11939    ///
11940    /// Sets the *filter* query property to the given value.
11941    pub fn filter(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall1<'a, C> {
11942        self._filter = Some(new_value.to_string());
11943        self
11944    }
11945    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11946    /// while executing the actual API request.
11947    ///
11948    /// ````text
11949    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11950    /// ````
11951    ///
11952    /// Sets the *delegate* property to the given value.
11953    pub fn delegate(
11954        mut self,
11955        new_value: &'a mut dyn common::Delegate,
11956    ) -> ProjectInstanceBackupOperationListCall1<'a, C> {
11957        self._delegate = Some(new_value);
11958        self
11959    }
11960
11961    /// Set any additional parameter of the query string used in the request.
11962    /// It should be used to set parameters which are not yet available through their own
11963    /// setters.
11964    ///
11965    /// Please note that this method must not be used to set any of the known parameters
11966    /// which have their own setter method. If done anyway, the request will fail.
11967    ///
11968    /// # Additional Parameters
11969    ///
11970    /// * *$.xgafv* (query-string) - V1 error format.
11971    /// * *access_token* (query-string) - OAuth access token.
11972    /// * *alt* (query-string) - Data format for response.
11973    /// * *callback* (query-string) - JSONP
11974    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11975    /// * *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.
11976    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11977    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11978    /// * *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.
11979    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11980    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11981    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationListCall1<'a, C>
11982    where
11983        T: AsRef<str>,
11984    {
11985        self._additional_params
11986            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11987        self
11988    }
11989
11990    /// Identifies the authorization scope for the method you are building.
11991    ///
11992    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11993    /// [`Scope::CloudPlatform`].
11994    ///
11995    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11996    /// tokens for more than one scope.
11997    ///
11998    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11999    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12000    /// sufficient, a read-write scope will do as well.
12001    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationListCall1<'a, C>
12002    where
12003        St: AsRef<str>,
12004    {
12005        self._scopes.insert(String::from(scope.as_ref()));
12006        self
12007    }
12008    /// Identifies the authorization scope(s) for the method you are building.
12009    ///
12010    /// See [`Self::add_scope()`] for details.
12011    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationListCall1<'a, C>
12012    where
12013        I: IntoIterator<Item = St>,
12014        St: AsRef<str>,
12015    {
12016        self._scopes
12017            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12018        self
12019    }
12020
12021    /// Removes all scopes, and no default scope will be used either.
12022    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12023    /// for details).
12024    pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationListCall1<'a, C> {
12025        self._scopes.clear();
12026        self
12027    }
12028}
12029
12030/// Starts copying a Cloud Spanner Backup. The returned backup long-running operation will have a name of the format `projects//instances//backups//operations/` and can be used to track copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the destination backup. Concurrent CopyBackup requests can run on the same source backup.
12031///
12032/// A builder for the *instances.backups.copy* method supported by a *project* resource.
12033/// It is not used directly, but through a [`ProjectMethods`] instance.
12034///
12035/// # Example
12036///
12037/// Instantiate a resource method builder
12038///
12039/// ```test_harness,no_run
12040/// # extern crate hyper;
12041/// # extern crate hyper_rustls;
12042/// # extern crate google_spanner1 as spanner1;
12043/// use spanner1::api::CopyBackupRequest;
12044/// # async fn dox() {
12045/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12046///
12047/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12048/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12049/// #     .with_native_roots()
12050/// #     .unwrap()
12051/// #     .https_only()
12052/// #     .enable_http2()
12053/// #     .build();
12054///
12055/// # let executor = hyper_util::rt::TokioExecutor::new();
12056/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12057/// #     secret,
12058/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12059/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12060/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12061/// #     ),
12062/// # ).build().await.unwrap();
12063///
12064/// # let client = hyper_util::client::legacy::Client::builder(
12065/// #     hyper_util::rt::TokioExecutor::new()
12066/// # )
12067/// # .build(
12068/// #     hyper_rustls::HttpsConnectorBuilder::new()
12069/// #         .with_native_roots()
12070/// #         .unwrap()
12071/// #         .https_or_http()
12072/// #         .enable_http2()
12073/// #         .build()
12074/// # );
12075/// # let mut hub = Spanner::new(client, auth);
12076/// // As the method needs a request, you would usually fill it with the desired information
12077/// // into the respective structure. Some of the parts shown here might not be applicable !
12078/// // Values shown here are possibly random and not representative !
12079/// let mut req = CopyBackupRequest::default();
12080///
12081/// // You can configure optional parameters by calling the respective setters at will, and
12082/// // execute the final call using `doit()`.
12083/// // Values shown here are possibly random and not representative !
12084/// let result = hub.projects().instances_backups_copy(req, "parent")
12085///              .doit().await;
12086/// # }
12087/// ```
12088pub struct ProjectInstanceBackupCopyCall<'a, C>
12089where
12090    C: 'a,
12091{
12092    hub: &'a Spanner<C>,
12093    _request: CopyBackupRequest,
12094    _parent: String,
12095    _delegate: Option<&'a mut dyn common::Delegate>,
12096    _additional_params: HashMap<String, String>,
12097    _scopes: BTreeSet<String>,
12098}
12099
12100impl<'a, C> common::CallBuilder for ProjectInstanceBackupCopyCall<'a, C> {}
12101
12102impl<'a, C> ProjectInstanceBackupCopyCall<'a, C>
12103where
12104    C: common::Connector,
12105{
12106    /// Perform the operation you have build so far.
12107    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12108        use std::borrow::Cow;
12109        use std::io::{Read, Seek};
12110
12111        use common::{url::Params, ToParts};
12112        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12113
12114        let mut dd = common::DefaultDelegate;
12115        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12116        dlg.begin(common::MethodInfo {
12117            id: "spanner.projects.instances.backups.copy",
12118            http_method: hyper::Method::POST,
12119        });
12120
12121        for &field in ["alt", "parent"].iter() {
12122            if self._additional_params.contains_key(field) {
12123                dlg.finished(false);
12124                return Err(common::Error::FieldClash(field));
12125            }
12126        }
12127
12128        let mut params = Params::with_capacity(4 + self._additional_params.len());
12129        params.push("parent", self._parent);
12130
12131        params.extend(self._additional_params.iter());
12132
12133        params.push("alt", "json");
12134        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups:copy";
12135        if self._scopes.is_empty() {
12136            self._scopes
12137                .insert(Scope::CloudPlatform.as_ref().to_string());
12138        }
12139
12140        #[allow(clippy::single_element_loop)]
12141        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12142            url = params.uri_replacement(url, param_name, find_this, true);
12143        }
12144        {
12145            let to_remove = ["parent"];
12146            params.remove_params(&to_remove);
12147        }
12148
12149        let url = params.parse_with_url(&url);
12150
12151        let mut json_mime_type = mime::APPLICATION_JSON;
12152        let mut request_value_reader = {
12153            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12154            common::remove_json_null_values(&mut value);
12155            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12156            serde_json::to_writer(&mut dst, &value).unwrap();
12157            dst
12158        };
12159        let request_size = request_value_reader
12160            .seek(std::io::SeekFrom::End(0))
12161            .unwrap();
12162        request_value_reader
12163            .seek(std::io::SeekFrom::Start(0))
12164            .unwrap();
12165
12166        loop {
12167            let token = match self
12168                .hub
12169                .auth
12170                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12171                .await
12172            {
12173                Ok(token) => token,
12174                Err(e) => match dlg.token(e) {
12175                    Ok(token) => token,
12176                    Err(e) => {
12177                        dlg.finished(false);
12178                        return Err(common::Error::MissingToken(e));
12179                    }
12180                },
12181            };
12182            request_value_reader
12183                .seek(std::io::SeekFrom::Start(0))
12184                .unwrap();
12185            let mut req_result = {
12186                let client = &self.hub.client;
12187                dlg.pre_request();
12188                let mut req_builder = hyper::Request::builder()
12189                    .method(hyper::Method::POST)
12190                    .uri(url.as_str())
12191                    .header(USER_AGENT, self.hub._user_agent.clone());
12192
12193                if let Some(token) = token.as_ref() {
12194                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12195                }
12196
12197                let request = req_builder
12198                    .header(CONTENT_TYPE, json_mime_type.to_string())
12199                    .header(CONTENT_LENGTH, request_size as u64)
12200                    .body(common::to_body(
12201                        request_value_reader.get_ref().clone().into(),
12202                    ));
12203
12204                client.request(request.unwrap()).await
12205            };
12206
12207            match req_result {
12208                Err(err) => {
12209                    if let common::Retry::After(d) = dlg.http_error(&err) {
12210                        sleep(d).await;
12211                        continue;
12212                    }
12213                    dlg.finished(false);
12214                    return Err(common::Error::HttpError(err));
12215                }
12216                Ok(res) => {
12217                    let (mut parts, body) = res.into_parts();
12218                    let mut body = common::Body::new(body);
12219                    if !parts.status.is_success() {
12220                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12221                        let error = serde_json::from_str(&common::to_string(&bytes));
12222                        let response = common::to_response(parts, bytes.into());
12223
12224                        if let common::Retry::After(d) =
12225                            dlg.http_failure(&response, error.as_ref().ok())
12226                        {
12227                            sleep(d).await;
12228                            continue;
12229                        }
12230
12231                        dlg.finished(false);
12232
12233                        return Err(match error {
12234                            Ok(value) => common::Error::BadRequest(value),
12235                            _ => common::Error::Failure(response),
12236                        });
12237                    }
12238                    let response = {
12239                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12240                        let encoded = common::to_string(&bytes);
12241                        match serde_json::from_str(&encoded) {
12242                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12243                            Err(error) => {
12244                                dlg.response_json_decode_error(&encoded, &error);
12245                                return Err(common::Error::JsonDecodeError(
12246                                    encoded.to_string(),
12247                                    error,
12248                                ));
12249                            }
12250                        }
12251                    };
12252
12253                    dlg.finished(true);
12254                    return Ok(response);
12255                }
12256            }
12257        }
12258    }
12259
12260    ///
12261    /// Sets the *request* property to the given value.
12262    ///
12263    /// Even though the property as already been set when instantiating this call,
12264    /// we provide this method for API completeness.
12265    pub fn request(mut self, new_value: CopyBackupRequest) -> ProjectInstanceBackupCopyCall<'a, C> {
12266        self._request = new_value;
12267        self
12268    }
12269    /// Required. The name of the destination instance that will contain the backup copy. Values are of the form: `projects//instances/`.
12270    ///
12271    /// Sets the *parent* path property to the given value.
12272    ///
12273    /// Even though the property as already been set when instantiating this call,
12274    /// we provide this method for API completeness.
12275    pub fn parent(mut self, new_value: &str) -> ProjectInstanceBackupCopyCall<'a, C> {
12276        self._parent = new_value.to_string();
12277        self
12278    }
12279    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12280    /// while executing the actual API request.
12281    ///
12282    /// ````text
12283    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12284    /// ````
12285    ///
12286    /// Sets the *delegate* property to the given value.
12287    pub fn delegate(
12288        mut self,
12289        new_value: &'a mut dyn common::Delegate,
12290    ) -> ProjectInstanceBackupCopyCall<'a, C> {
12291        self._delegate = Some(new_value);
12292        self
12293    }
12294
12295    /// Set any additional parameter of the query string used in the request.
12296    /// It should be used to set parameters which are not yet available through their own
12297    /// setters.
12298    ///
12299    /// Please note that this method must not be used to set any of the known parameters
12300    /// which have their own setter method. If done anyway, the request will fail.
12301    ///
12302    /// # Additional Parameters
12303    ///
12304    /// * *$.xgafv* (query-string) - V1 error format.
12305    /// * *access_token* (query-string) - OAuth access token.
12306    /// * *alt* (query-string) - Data format for response.
12307    /// * *callback* (query-string) - JSONP
12308    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12309    /// * *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.
12310    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12311    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12312    /// * *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.
12313    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12314    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12315    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupCopyCall<'a, C>
12316    where
12317        T: AsRef<str>,
12318    {
12319        self._additional_params
12320            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12321        self
12322    }
12323
12324    /// Identifies the authorization scope for the method you are building.
12325    ///
12326    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12327    /// [`Scope::CloudPlatform`].
12328    ///
12329    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12330    /// tokens for more than one scope.
12331    ///
12332    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12333    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12334    /// sufficient, a read-write scope will do as well.
12335    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupCopyCall<'a, C>
12336    where
12337        St: AsRef<str>,
12338    {
12339        self._scopes.insert(String::from(scope.as_ref()));
12340        self
12341    }
12342    /// Identifies the authorization scope(s) for the method you are building.
12343    ///
12344    /// See [`Self::add_scope()`] for details.
12345    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupCopyCall<'a, C>
12346    where
12347        I: IntoIterator<Item = St>,
12348        St: AsRef<str>,
12349    {
12350        self._scopes
12351            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12352        self
12353    }
12354
12355    /// Removes all scopes, and no default scope will be used either.
12356    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12357    /// for details).
12358    pub fn clear_scopes(mut self) -> ProjectInstanceBackupCopyCall<'a, C> {
12359        self._scopes.clear();
12360        self
12361    }
12362}
12363
12364/// Starts creating a new Cloud Spanner Backup. The returned backup long-running operation will have a name of the format `projects//instances//backups//operations/` and can be used to track creation of the backup. The metadata field type is CreateBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the creation and delete the backup. There can be only one pending backup creation per database. Backup creation of different databases can run concurrently.
12365///
12366/// A builder for the *instances.backups.create* method supported by a *project* resource.
12367/// It is not used directly, but through a [`ProjectMethods`] instance.
12368///
12369/// # Example
12370///
12371/// Instantiate a resource method builder
12372///
12373/// ```test_harness,no_run
12374/// # extern crate hyper;
12375/// # extern crate hyper_rustls;
12376/// # extern crate google_spanner1 as spanner1;
12377/// use spanner1::api::Backup;
12378/// # async fn dox() {
12379/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12380///
12381/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12382/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12383/// #     .with_native_roots()
12384/// #     .unwrap()
12385/// #     .https_only()
12386/// #     .enable_http2()
12387/// #     .build();
12388///
12389/// # let executor = hyper_util::rt::TokioExecutor::new();
12390/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12391/// #     secret,
12392/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12393/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12394/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12395/// #     ),
12396/// # ).build().await.unwrap();
12397///
12398/// # let client = hyper_util::client::legacy::Client::builder(
12399/// #     hyper_util::rt::TokioExecutor::new()
12400/// # )
12401/// # .build(
12402/// #     hyper_rustls::HttpsConnectorBuilder::new()
12403/// #         .with_native_roots()
12404/// #         .unwrap()
12405/// #         .https_or_http()
12406/// #         .enable_http2()
12407/// #         .build()
12408/// # );
12409/// # let mut hub = Spanner::new(client, auth);
12410/// // As the method needs a request, you would usually fill it with the desired information
12411/// // into the respective structure. Some of the parts shown here might not be applicable !
12412/// // Values shown here are possibly random and not representative !
12413/// let mut req = Backup::default();
12414///
12415/// // You can configure optional parameters by calling the respective setters at will, and
12416/// // execute the final call using `doit()`.
12417/// // Values shown here are possibly random and not representative !
12418/// let result = hub.projects().instances_backups_create(req, "parent")
12419///              .add_encryption_config_kms_key_names("Stet")
12420///              .encryption_config_kms_key_name("dolor")
12421///              .encryption_config_encryption_type("duo")
12422///              .backup_id("vero")
12423///              .doit().await;
12424/// # }
12425/// ```
12426pub struct ProjectInstanceBackupCreateCall<'a, C>
12427where
12428    C: 'a,
12429{
12430    hub: &'a Spanner<C>,
12431    _request: Backup,
12432    _parent: String,
12433    _encryption_config_kms_key_names: Vec<String>,
12434    _encryption_config_kms_key_name: Option<String>,
12435    _encryption_config_encryption_type: Option<String>,
12436    _backup_id: Option<String>,
12437    _delegate: Option<&'a mut dyn common::Delegate>,
12438    _additional_params: HashMap<String, String>,
12439    _scopes: BTreeSet<String>,
12440}
12441
12442impl<'a, C> common::CallBuilder for ProjectInstanceBackupCreateCall<'a, C> {}
12443
12444impl<'a, C> ProjectInstanceBackupCreateCall<'a, C>
12445where
12446    C: common::Connector,
12447{
12448    /// Perform the operation you have build so far.
12449    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12450        use std::borrow::Cow;
12451        use std::io::{Read, Seek};
12452
12453        use common::{url::Params, ToParts};
12454        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12455
12456        let mut dd = common::DefaultDelegate;
12457        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12458        dlg.begin(common::MethodInfo {
12459            id: "spanner.projects.instances.backups.create",
12460            http_method: hyper::Method::POST,
12461        });
12462
12463        for &field in [
12464            "alt",
12465            "parent",
12466            "encryptionConfig.kmsKeyNames",
12467            "encryptionConfig.kmsKeyName",
12468            "encryptionConfig.encryptionType",
12469            "backupId",
12470        ]
12471        .iter()
12472        {
12473            if self._additional_params.contains_key(field) {
12474                dlg.finished(false);
12475                return Err(common::Error::FieldClash(field));
12476            }
12477        }
12478
12479        let mut params = Params::with_capacity(8 + self._additional_params.len());
12480        params.push("parent", self._parent);
12481        if !self._encryption_config_kms_key_names.is_empty() {
12482            for f in self._encryption_config_kms_key_names.iter() {
12483                params.push("encryptionConfig.kmsKeyNames", f);
12484            }
12485        }
12486        if let Some(value) = self._encryption_config_kms_key_name.as_ref() {
12487            params.push("encryptionConfig.kmsKeyName", value);
12488        }
12489        if let Some(value) = self._encryption_config_encryption_type.as_ref() {
12490            params.push("encryptionConfig.encryptionType", value);
12491        }
12492        if let Some(value) = self._backup_id.as_ref() {
12493            params.push("backupId", value);
12494        }
12495
12496        params.extend(self._additional_params.iter());
12497
12498        params.push("alt", "json");
12499        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
12500        if self._scopes.is_empty() {
12501            self._scopes
12502                .insert(Scope::CloudPlatform.as_ref().to_string());
12503        }
12504
12505        #[allow(clippy::single_element_loop)]
12506        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12507            url = params.uri_replacement(url, param_name, find_this, true);
12508        }
12509        {
12510            let to_remove = ["parent"];
12511            params.remove_params(&to_remove);
12512        }
12513
12514        let url = params.parse_with_url(&url);
12515
12516        let mut json_mime_type = mime::APPLICATION_JSON;
12517        let mut request_value_reader = {
12518            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12519            common::remove_json_null_values(&mut value);
12520            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12521            serde_json::to_writer(&mut dst, &value).unwrap();
12522            dst
12523        };
12524        let request_size = request_value_reader
12525            .seek(std::io::SeekFrom::End(0))
12526            .unwrap();
12527        request_value_reader
12528            .seek(std::io::SeekFrom::Start(0))
12529            .unwrap();
12530
12531        loop {
12532            let token = match self
12533                .hub
12534                .auth
12535                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12536                .await
12537            {
12538                Ok(token) => token,
12539                Err(e) => match dlg.token(e) {
12540                    Ok(token) => token,
12541                    Err(e) => {
12542                        dlg.finished(false);
12543                        return Err(common::Error::MissingToken(e));
12544                    }
12545                },
12546            };
12547            request_value_reader
12548                .seek(std::io::SeekFrom::Start(0))
12549                .unwrap();
12550            let mut req_result = {
12551                let client = &self.hub.client;
12552                dlg.pre_request();
12553                let mut req_builder = hyper::Request::builder()
12554                    .method(hyper::Method::POST)
12555                    .uri(url.as_str())
12556                    .header(USER_AGENT, self.hub._user_agent.clone());
12557
12558                if let Some(token) = token.as_ref() {
12559                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12560                }
12561
12562                let request = req_builder
12563                    .header(CONTENT_TYPE, json_mime_type.to_string())
12564                    .header(CONTENT_LENGTH, request_size as u64)
12565                    .body(common::to_body(
12566                        request_value_reader.get_ref().clone().into(),
12567                    ));
12568
12569                client.request(request.unwrap()).await
12570            };
12571
12572            match req_result {
12573                Err(err) => {
12574                    if let common::Retry::After(d) = dlg.http_error(&err) {
12575                        sleep(d).await;
12576                        continue;
12577                    }
12578                    dlg.finished(false);
12579                    return Err(common::Error::HttpError(err));
12580                }
12581                Ok(res) => {
12582                    let (mut parts, body) = res.into_parts();
12583                    let mut body = common::Body::new(body);
12584                    if !parts.status.is_success() {
12585                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12586                        let error = serde_json::from_str(&common::to_string(&bytes));
12587                        let response = common::to_response(parts, bytes.into());
12588
12589                        if let common::Retry::After(d) =
12590                            dlg.http_failure(&response, error.as_ref().ok())
12591                        {
12592                            sleep(d).await;
12593                            continue;
12594                        }
12595
12596                        dlg.finished(false);
12597
12598                        return Err(match error {
12599                            Ok(value) => common::Error::BadRequest(value),
12600                            _ => common::Error::Failure(response),
12601                        });
12602                    }
12603                    let response = {
12604                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12605                        let encoded = common::to_string(&bytes);
12606                        match serde_json::from_str(&encoded) {
12607                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12608                            Err(error) => {
12609                                dlg.response_json_decode_error(&encoded, &error);
12610                                return Err(common::Error::JsonDecodeError(
12611                                    encoded.to_string(),
12612                                    error,
12613                                ));
12614                            }
12615                        }
12616                    };
12617
12618                    dlg.finished(true);
12619                    return Ok(response);
12620                }
12621            }
12622        }
12623    }
12624
12625    ///
12626    /// Sets the *request* property to the given value.
12627    ///
12628    /// Even though the property as already been set when instantiating this call,
12629    /// we provide this method for API completeness.
12630    pub fn request(mut self, new_value: Backup) -> ProjectInstanceBackupCreateCall<'a, C> {
12631        self._request = new_value;
12632        self
12633    }
12634    /// Required. The name of the instance in which the backup is created. This must be the same instance that contains the database the backup is created from. The backup will be stored in the locations specified in the instance configuration of this instance. Values are of the form `projects//instances/`.
12635    ///
12636    /// Sets the *parent* path property to the given value.
12637    ///
12638    /// Even though the property as already been set when instantiating this call,
12639    /// we provide this method for API completeness.
12640    pub fn parent(mut self, new_value: &str) -> ProjectInstanceBackupCreateCall<'a, C> {
12641        self._parent = new_value.to_string();
12642        self
12643    }
12644    /// Optional. Specifies the KMS configuration for the one or more keys used to protect the backup. Values are of the form `projects//locations//keyRings//cryptoKeys/`. The keys referenced by `kms_key_names` must fully cover all regions of the backup's instance configuration. Some examples: * For regional (single-region) instance configurations, specify a regional location KMS key. * For multi-region instance configurations of type `GOOGLE_MANAGED`, either specify a multi-region location KMS key or multiple regional location KMS keys that cover all regions in the instance configuration. * For an instance configuration of type `USER_MANAGED`, specify only regional location KMS keys to cover each region in the instance configuration. Multi-region location KMS keys aren't supported for `USER_MANAGED` type instance configurations.
12645    ///
12646    /// Append the given value to the *encryption config.kms key names* query property.
12647    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
12648    pub fn add_encryption_config_kms_key_names(
12649        mut self,
12650        new_value: &str,
12651    ) -> ProjectInstanceBackupCreateCall<'a, C> {
12652        self._encryption_config_kms_key_names
12653            .push(new_value.to_string());
12654        self
12655    }
12656    /// Optional. This field is maintained for backwards compatibility. For new callers, we recommend using `kms_key_names` to specify the KMS key. Only use `kms_key_name` if the location of the KMS key matches the database instance's configuration (location) exactly. For example, if the KMS location is in `us-central1` or `nam3`, then the database instance must also be in `us-central1` or `nam3`. The Cloud KMS key that is used to encrypt and decrypt the restored database. Set this field only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
12657    ///
12658    /// Sets the *encryption config.kms key name* query property to the given value.
12659    pub fn encryption_config_kms_key_name(
12660        mut self,
12661        new_value: &str,
12662    ) -> ProjectInstanceBackupCreateCall<'a, C> {
12663        self._encryption_config_kms_key_name = Some(new_value.to_string());
12664        self
12665    }
12666    /// Required. The encryption type of the backup.
12667    ///
12668    /// Sets the *encryption config.encryption type* query property to the given value.
12669    pub fn encryption_config_encryption_type(
12670        mut self,
12671        new_value: &str,
12672    ) -> ProjectInstanceBackupCreateCall<'a, C> {
12673        self._encryption_config_encryption_type = Some(new_value.to_string());
12674        self
12675    }
12676    /// Required. The id of the backup to be created. The `backup_id` appended to `parent` forms the full backup name of the form `projects//instances//backups/`.
12677    ///
12678    /// Sets the *backup id* query property to the given value.
12679    pub fn backup_id(mut self, new_value: &str) -> ProjectInstanceBackupCreateCall<'a, C> {
12680        self._backup_id = Some(new_value.to_string());
12681        self
12682    }
12683    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12684    /// while executing the actual API request.
12685    ///
12686    /// ````text
12687    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12688    /// ````
12689    ///
12690    /// Sets the *delegate* property to the given value.
12691    pub fn delegate(
12692        mut self,
12693        new_value: &'a mut dyn common::Delegate,
12694    ) -> ProjectInstanceBackupCreateCall<'a, C> {
12695        self._delegate = Some(new_value);
12696        self
12697    }
12698
12699    /// Set any additional parameter of the query string used in the request.
12700    /// It should be used to set parameters which are not yet available through their own
12701    /// setters.
12702    ///
12703    /// Please note that this method must not be used to set any of the known parameters
12704    /// which have their own setter method. If done anyway, the request will fail.
12705    ///
12706    /// # Additional Parameters
12707    ///
12708    /// * *$.xgafv* (query-string) - V1 error format.
12709    /// * *access_token* (query-string) - OAuth access token.
12710    /// * *alt* (query-string) - Data format for response.
12711    /// * *callback* (query-string) - JSONP
12712    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12713    /// * *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.
12714    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12715    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12716    /// * *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.
12717    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12718    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12719    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupCreateCall<'a, C>
12720    where
12721        T: AsRef<str>,
12722    {
12723        self._additional_params
12724            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12725        self
12726    }
12727
12728    /// Identifies the authorization scope for the method you are building.
12729    ///
12730    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12731    /// [`Scope::CloudPlatform`].
12732    ///
12733    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12734    /// tokens for more than one scope.
12735    ///
12736    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12737    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12738    /// sufficient, a read-write scope will do as well.
12739    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupCreateCall<'a, C>
12740    where
12741        St: AsRef<str>,
12742    {
12743        self._scopes.insert(String::from(scope.as_ref()));
12744        self
12745    }
12746    /// Identifies the authorization scope(s) for the method you are building.
12747    ///
12748    /// See [`Self::add_scope()`] for details.
12749    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupCreateCall<'a, C>
12750    where
12751        I: IntoIterator<Item = St>,
12752        St: AsRef<str>,
12753    {
12754        self._scopes
12755            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12756        self
12757    }
12758
12759    /// Removes all scopes, and no default scope will be used either.
12760    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12761    /// for details).
12762    pub fn clear_scopes(mut self) -> ProjectInstanceBackupCreateCall<'a, C> {
12763        self._scopes.clear();
12764        self
12765    }
12766}
12767
12768/// Deletes a pending or completed Backup.
12769///
12770/// A builder for the *instances.backups.delete* method supported by a *project* resource.
12771/// It is not used directly, but through a [`ProjectMethods`] instance.
12772///
12773/// # Example
12774///
12775/// Instantiate a resource method builder
12776///
12777/// ```test_harness,no_run
12778/// # extern crate hyper;
12779/// # extern crate hyper_rustls;
12780/// # extern crate google_spanner1 as spanner1;
12781/// # async fn dox() {
12782/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12783///
12784/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12785/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12786/// #     .with_native_roots()
12787/// #     .unwrap()
12788/// #     .https_only()
12789/// #     .enable_http2()
12790/// #     .build();
12791///
12792/// # let executor = hyper_util::rt::TokioExecutor::new();
12793/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12794/// #     secret,
12795/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12796/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12797/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12798/// #     ),
12799/// # ).build().await.unwrap();
12800///
12801/// # let client = hyper_util::client::legacy::Client::builder(
12802/// #     hyper_util::rt::TokioExecutor::new()
12803/// # )
12804/// # .build(
12805/// #     hyper_rustls::HttpsConnectorBuilder::new()
12806/// #         .with_native_roots()
12807/// #         .unwrap()
12808/// #         .https_or_http()
12809/// #         .enable_http2()
12810/// #         .build()
12811/// # );
12812/// # let mut hub = Spanner::new(client, auth);
12813/// // You can configure optional parameters by calling the respective setters at will, and
12814/// // execute the final call using `doit()`.
12815/// // Values shown here are possibly random and not representative !
12816/// let result = hub.projects().instances_backups_delete("name")
12817///              .doit().await;
12818/// # }
12819/// ```
12820pub struct ProjectInstanceBackupDeleteCall<'a, C>
12821where
12822    C: 'a,
12823{
12824    hub: &'a Spanner<C>,
12825    _name: String,
12826    _delegate: Option<&'a mut dyn common::Delegate>,
12827    _additional_params: HashMap<String, String>,
12828    _scopes: BTreeSet<String>,
12829}
12830
12831impl<'a, C> common::CallBuilder for ProjectInstanceBackupDeleteCall<'a, C> {}
12832
12833impl<'a, C> ProjectInstanceBackupDeleteCall<'a, C>
12834where
12835    C: common::Connector,
12836{
12837    /// Perform the operation you have build so far.
12838    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
12839        use std::borrow::Cow;
12840        use std::io::{Read, Seek};
12841
12842        use common::{url::Params, ToParts};
12843        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12844
12845        let mut dd = common::DefaultDelegate;
12846        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12847        dlg.begin(common::MethodInfo {
12848            id: "spanner.projects.instances.backups.delete",
12849            http_method: hyper::Method::DELETE,
12850        });
12851
12852        for &field in ["alt", "name"].iter() {
12853            if self._additional_params.contains_key(field) {
12854                dlg.finished(false);
12855                return Err(common::Error::FieldClash(field));
12856            }
12857        }
12858
12859        let mut params = Params::with_capacity(3 + self._additional_params.len());
12860        params.push("name", self._name);
12861
12862        params.extend(self._additional_params.iter());
12863
12864        params.push("alt", "json");
12865        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12866        if self._scopes.is_empty() {
12867            self._scopes
12868                .insert(Scope::CloudPlatform.as_ref().to_string());
12869        }
12870
12871        #[allow(clippy::single_element_loop)]
12872        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12873            url = params.uri_replacement(url, param_name, find_this, true);
12874        }
12875        {
12876            let to_remove = ["name"];
12877            params.remove_params(&to_remove);
12878        }
12879
12880        let url = params.parse_with_url(&url);
12881
12882        loop {
12883            let token = match self
12884                .hub
12885                .auth
12886                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12887                .await
12888            {
12889                Ok(token) => token,
12890                Err(e) => match dlg.token(e) {
12891                    Ok(token) => token,
12892                    Err(e) => {
12893                        dlg.finished(false);
12894                        return Err(common::Error::MissingToken(e));
12895                    }
12896                },
12897            };
12898            let mut req_result = {
12899                let client = &self.hub.client;
12900                dlg.pre_request();
12901                let mut req_builder = hyper::Request::builder()
12902                    .method(hyper::Method::DELETE)
12903                    .uri(url.as_str())
12904                    .header(USER_AGENT, self.hub._user_agent.clone());
12905
12906                if let Some(token) = token.as_ref() {
12907                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12908                }
12909
12910                let request = req_builder
12911                    .header(CONTENT_LENGTH, 0_u64)
12912                    .body(common::to_body::<String>(None));
12913
12914                client.request(request.unwrap()).await
12915            };
12916
12917            match req_result {
12918                Err(err) => {
12919                    if let common::Retry::After(d) = dlg.http_error(&err) {
12920                        sleep(d).await;
12921                        continue;
12922                    }
12923                    dlg.finished(false);
12924                    return Err(common::Error::HttpError(err));
12925                }
12926                Ok(res) => {
12927                    let (mut parts, body) = res.into_parts();
12928                    let mut body = common::Body::new(body);
12929                    if !parts.status.is_success() {
12930                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12931                        let error = serde_json::from_str(&common::to_string(&bytes));
12932                        let response = common::to_response(parts, bytes.into());
12933
12934                        if let common::Retry::After(d) =
12935                            dlg.http_failure(&response, error.as_ref().ok())
12936                        {
12937                            sleep(d).await;
12938                            continue;
12939                        }
12940
12941                        dlg.finished(false);
12942
12943                        return Err(match error {
12944                            Ok(value) => common::Error::BadRequest(value),
12945                            _ => common::Error::Failure(response),
12946                        });
12947                    }
12948                    let response = {
12949                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12950                        let encoded = common::to_string(&bytes);
12951                        match serde_json::from_str(&encoded) {
12952                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12953                            Err(error) => {
12954                                dlg.response_json_decode_error(&encoded, &error);
12955                                return Err(common::Error::JsonDecodeError(
12956                                    encoded.to_string(),
12957                                    error,
12958                                ));
12959                            }
12960                        }
12961                    };
12962
12963                    dlg.finished(true);
12964                    return Ok(response);
12965                }
12966            }
12967        }
12968    }
12969
12970    /// Required. Name of the backup to delete. Values are of the form `projects//instances//backups/`.
12971    ///
12972    /// Sets the *name* path property to the given value.
12973    ///
12974    /// Even though the property as already been set when instantiating this call,
12975    /// we provide this method for API completeness.
12976    pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupDeleteCall<'a, C> {
12977        self._name = new_value.to_string();
12978        self
12979    }
12980    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12981    /// while executing the actual API request.
12982    ///
12983    /// ````text
12984    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12985    /// ````
12986    ///
12987    /// Sets the *delegate* property to the given value.
12988    pub fn delegate(
12989        mut self,
12990        new_value: &'a mut dyn common::Delegate,
12991    ) -> ProjectInstanceBackupDeleteCall<'a, C> {
12992        self._delegate = Some(new_value);
12993        self
12994    }
12995
12996    /// Set any additional parameter of the query string used in the request.
12997    /// It should be used to set parameters which are not yet available through their own
12998    /// setters.
12999    ///
13000    /// Please note that this method must not be used to set any of the known parameters
13001    /// which have their own setter method. If done anyway, the request will fail.
13002    ///
13003    /// # Additional Parameters
13004    ///
13005    /// * *$.xgafv* (query-string) - V1 error format.
13006    /// * *access_token* (query-string) - OAuth access token.
13007    /// * *alt* (query-string) - Data format for response.
13008    /// * *callback* (query-string) - JSONP
13009    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13010    /// * *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.
13011    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13012    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13013    /// * *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.
13014    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13015    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13016    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupDeleteCall<'a, C>
13017    where
13018        T: AsRef<str>,
13019    {
13020        self._additional_params
13021            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13022        self
13023    }
13024
13025    /// Identifies the authorization scope for the method you are building.
13026    ///
13027    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13028    /// [`Scope::CloudPlatform`].
13029    ///
13030    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13031    /// tokens for more than one scope.
13032    ///
13033    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13034    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13035    /// sufficient, a read-write scope will do as well.
13036    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupDeleteCall<'a, C>
13037    where
13038        St: AsRef<str>,
13039    {
13040        self._scopes.insert(String::from(scope.as_ref()));
13041        self
13042    }
13043    /// Identifies the authorization scope(s) for the method you are building.
13044    ///
13045    /// See [`Self::add_scope()`] for details.
13046    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupDeleteCall<'a, C>
13047    where
13048        I: IntoIterator<Item = St>,
13049        St: AsRef<str>,
13050    {
13051        self._scopes
13052            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13053        self
13054    }
13055
13056    /// Removes all scopes, and no default scope will be used either.
13057    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13058    /// for details).
13059    pub fn clear_scopes(mut self) -> ProjectInstanceBackupDeleteCall<'a, C> {
13060        self._scopes.clear();
13061        self
13062    }
13063}
13064
13065/// Gets metadata on a pending or completed Backup.
13066///
13067/// A builder for the *instances.backups.get* method supported by a *project* resource.
13068/// It is not used directly, but through a [`ProjectMethods`] instance.
13069///
13070/// # Example
13071///
13072/// Instantiate a resource method builder
13073///
13074/// ```test_harness,no_run
13075/// # extern crate hyper;
13076/// # extern crate hyper_rustls;
13077/// # extern crate google_spanner1 as spanner1;
13078/// # async fn dox() {
13079/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13080///
13081/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13082/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13083/// #     .with_native_roots()
13084/// #     .unwrap()
13085/// #     .https_only()
13086/// #     .enable_http2()
13087/// #     .build();
13088///
13089/// # let executor = hyper_util::rt::TokioExecutor::new();
13090/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13091/// #     secret,
13092/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13093/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13094/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13095/// #     ),
13096/// # ).build().await.unwrap();
13097///
13098/// # let client = hyper_util::client::legacy::Client::builder(
13099/// #     hyper_util::rt::TokioExecutor::new()
13100/// # )
13101/// # .build(
13102/// #     hyper_rustls::HttpsConnectorBuilder::new()
13103/// #         .with_native_roots()
13104/// #         .unwrap()
13105/// #         .https_or_http()
13106/// #         .enable_http2()
13107/// #         .build()
13108/// # );
13109/// # let mut hub = Spanner::new(client, auth);
13110/// // You can configure optional parameters by calling the respective setters at will, and
13111/// // execute the final call using `doit()`.
13112/// // Values shown here are possibly random and not representative !
13113/// let result = hub.projects().instances_backups_get("name")
13114///              .doit().await;
13115/// # }
13116/// ```
13117pub struct ProjectInstanceBackupGetCall<'a, C>
13118where
13119    C: 'a,
13120{
13121    hub: &'a Spanner<C>,
13122    _name: String,
13123    _delegate: Option<&'a mut dyn common::Delegate>,
13124    _additional_params: HashMap<String, String>,
13125    _scopes: BTreeSet<String>,
13126}
13127
13128impl<'a, C> common::CallBuilder for ProjectInstanceBackupGetCall<'a, C> {}
13129
13130impl<'a, C> ProjectInstanceBackupGetCall<'a, C>
13131where
13132    C: common::Connector,
13133{
13134    /// Perform the operation you have build so far.
13135    pub async fn doit(mut self) -> common::Result<(common::Response, Backup)> {
13136        use std::borrow::Cow;
13137        use std::io::{Read, Seek};
13138
13139        use common::{url::Params, ToParts};
13140        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13141
13142        let mut dd = common::DefaultDelegate;
13143        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13144        dlg.begin(common::MethodInfo {
13145            id: "spanner.projects.instances.backups.get",
13146            http_method: hyper::Method::GET,
13147        });
13148
13149        for &field in ["alt", "name"].iter() {
13150            if self._additional_params.contains_key(field) {
13151                dlg.finished(false);
13152                return Err(common::Error::FieldClash(field));
13153            }
13154        }
13155
13156        let mut params = Params::with_capacity(3 + self._additional_params.len());
13157        params.push("name", self._name);
13158
13159        params.extend(self._additional_params.iter());
13160
13161        params.push("alt", "json");
13162        let mut url = self.hub._base_url.clone() + "v1/{+name}";
13163        if self._scopes.is_empty() {
13164            self._scopes
13165                .insert(Scope::CloudPlatform.as_ref().to_string());
13166        }
13167
13168        #[allow(clippy::single_element_loop)]
13169        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13170            url = params.uri_replacement(url, param_name, find_this, true);
13171        }
13172        {
13173            let to_remove = ["name"];
13174            params.remove_params(&to_remove);
13175        }
13176
13177        let url = params.parse_with_url(&url);
13178
13179        loop {
13180            let token = match self
13181                .hub
13182                .auth
13183                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13184                .await
13185            {
13186                Ok(token) => token,
13187                Err(e) => match dlg.token(e) {
13188                    Ok(token) => token,
13189                    Err(e) => {
13190                        dlg.finished(false);
13191                        return Err(common::Error::MissingToken(e));
13192                    }
13193                },
13194            };
13195            let mut req_result = {
13196                let client = &self.hub.client;
13197                dlg.pre_request();
13198                let mut req_builder = hyper::Request::builder()
13199                    .method(hyper::Method::GET)
13200                    .uri(url.as_str())
13201                    .header(USER_AGENT, self.hub._user_agent.clone());
13202
13203                if let Some(token) = token.as_ref() {
13204                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13205                }
13206
13207                let request = req_builder
13208                    .header(CONTENT_LENGTH, 0_u64)
13209                    .body(common::to_body::<String>(None));
13210
13211                client.request(request.unwrap()).await
13212            };
13213
13214            match req_result {
13215                Err(err) => {
13216                    if let common::Retry::After(d) = dlg.http_error(&err) {
13217                        sleep(d).await;
13218                        continue;
13219                    }
13220                    dlg.finished(false);
13221                    return Err(common::Error::HttpError(err));
13222                }
13223                Ok(res) => {
13224                    let (mut parts, body) = res.into_parts();
13225                    let mut body = common::Body::new(body);
13226                    if !parts.status.is_success() {
13227                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13228                        let error = serde_json::from_str(&common::to_string(&bytes));
13229                        let response = common::to_response(parts, bytes.into());
13230
13231                        if let common::Retry::After(d) =
13232                            dlg.http_failure(&response, error.as_ref().ok())
13233                        {
13234                            sleep(d).await;
13235                            continue;
13236                        }
13237
13238                        dlg.finished(false);
13239
13240                        return Err(match error {
13241                            Ok(value) => common::Error::BadRequest(value),
13242                            _ => common::Error::Failure(response),
13243                        });
13244                    }
13245                    let response = {
13246                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13247                        let encoded = common::to_string(&bytes);
13248                        match serde_json::from_str(&encoded) {
13249                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13250                            Err(error) => {
13251                                dlg.response_json_decode_error(&encoded, &error);
13252                                return Err(common::Error::JsonDecodeError(
13253                                    encoded.to_string(),
13254                                    error,
13255                                ));
13256                            }
13257                        }
13258                    };
13259
13260                    dlg.finished(true);
13261                    return Ok(response);
13262                }
13263            }
13264        }
13265    }
13266
13267    /// Required. Name of the backup. Values are of the form `projects//instances//backups/`.
13268    ///
13269    /// Sets the *name* path property to the given value.
13270    ///
13271    /// Even though the property as already been set when instantiating this call,
13272    /// we provide this method for API completeness.
13273    pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupGetCall<'a, C> {
13274        self._name = new_value.to_string();
13275        self
13276    }
13277    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13278    /// while executing the actual API request.
13279    ///
13280    /// ````text
13281    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13282    /// ````
13283    ///
13284    /// Sets the *delegate* property to the given value.
13285    pub fn delegate(
13286        mut self,
13287        new_value: &'a mut dyn common::Delegate,
13288    ) -> ProjectInstanceBackupGetCall<'a, C> {
13289        self._delegate = Some(new_value);
13290        self
13291    }
13292
13293    /// Set any additional parameter of the query string used in the request.
13294    /// It should be used to set parameters which are not yet available through their own
13295    /// setters.
13296    ///
13297    /// Please note that this method must not be used to set any of the known parameters
13298    /// which have their own setter method. If done anyway, the request will fail.
13299    ///
13300    /// # Additional Parameters
13301    ///
13302    /// * *$.xgafv* (query-string) - V1 error format.
13303    /// * *access_token* (query-string) - OAuth access token.
13304    /// * *alt* (query-string) - Data format for response.
13305    /// * *callback* (query-string) - JSONP
13306    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13307    /// * *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.
13308    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13309    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13310    /// * *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.
13311    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13312    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13313    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupGetCall<'a, C>
13314    where
13315        T: AsRef<str>,
13316    {
13317        self._additional_params
13318            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13319        self
13320    }
13321
13322    /// Identifies the authorization scope for the method you are building.
13323    ///
13324    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13325    /// [`Scope::CloudPlatform`].
13326    ///
13327    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13328    /// tokens for more than one scope.
13329    ///
13330    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13331    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13332    /// sufficient, a read-write scope will do as well.
13333    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupGetCall<'a, C>
13334    where
13335        St: AsRef<str>,
13336    {
13337        self._scopes.insert(String::from(scope.as_ref()));
13338        self
13339    }
13340    /// Identifies the authorization scope(s) for the method you are building.
13341    ///
13342    /// See [`Self::add_scope()`] for details.
13343    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupGetCall<'a, C>
13344    where
13345        I: IntoIterator<Item = St>,
13346        St: AsRef<str>,
13347    {
13348        self._scopes
13349            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13350        self
13351    }
13352
13353    /// Removes all scopes, and no default scope will be used either.
13354    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13355    /// for details).
13356    pub fn clear_scopes(mut self) -> ProjectInstanceBackupGetCall<'a, C> {
13357        self._scopes.clear();
13358        self
13359    }
13360}
13361
13362/// Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set. Authorization requires `spanner.databases.getIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.getIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.getIamPolicy` permission on resource.
13363///
13364/// A builder for the *instances.backups.getIamPolicy* method supported by a *project* resource.
13365/// It is not used directly, but through a [`ProjectMethods`] instance.
13366///
13367/// # Example
13368///
13369/// Instantiate a resource method builder
13370///
13371/// ```test_harness,no_run
13372/// # extern crate hyper;
13373/// # extern crate hyper_rustls;
13374/// # extern crate google_spanner1 as spanner1;
13375/// use spanner1::api::GetIamPolicyRequest;
13376/// # async fn dox() {
13377/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13378///
13379/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13380/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13381/// #     .with_native_roots()
13382/// #     .unwrap()
13383/// #     .https_only()
13384/// #     .enable_http2()
13385/// #     .build();
13386///
13387/// # let executor = hyper_util::rt::TokioExecutor::new();
13388/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13389/// #     secret,
13390/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13391/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13392/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13393/// #     ),
13394/// # ).build().await.unwrap();
13395///
13396/// # let client = hyper_util::client::legacy::Client::builder(
13397/// #     hyper_util::rt::TokioExecutor::new()
13398/// # )
13399/// # .build(
13400/// #     hyper_rustls::HttpsConnectorBuilder::new()
13401/// #         .with_native_roots()
13402/// #         .unwrap()
13403/// #         .https_or_http()
13404/// #         .enable_http2()
13405/// #         .build()
13406/// # );
13407/// # let mut hub = Spanner::new(client, auth);
13408/// // As the method needs a request, you would usually fill it with the desired information
13409/// // into the respective structure. Some of the parts shown here might not be applicable !
13410/// // Values shown here are possibly random and not representative !
13411/// let mut req = GetIamPolicyRequest::default();
13412///
13413/// // You can configure optional parameters by calling the respective setters at will, and
13414/// // execute the final call using `doit()`.
13415/// // Values shown here are possibly random and not representative !
13416/// let result = hub.projects().instances_backups_get_iam_policy(req, "resource")
13417///              .doit().await;
13418/// # }
13419/// ```
13420pub struct ProjectInstanceBackupGetIamPolicyCall<'a, C>
13421where
13422    C: 'a,
13423{
13424    hub: &'a Spanner<C>,
13425    _request: GetIamPolicyRequest,
13426    _resource: String,
13427    _delegate: Option<&'a mut dyn common::Delegate>,
13428    _additional_params: HashMap<String, String>,
13429    _scopes: BTreeSet<String>,
13430}
13431
13432impl<'a, C> common::CallBuilder for ProjectInstanceBackupGetIamPolicyCall<'a, C> {}
13433
13434impl<'a, C> ProjectInstanceBackupGetIamPolicyCall<'a, C>
13435where
13436    C: common::Connector,
13437{
13438    /// Perform the operation you have build so far.
13439    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
13440        use std::borrow::Cow;
13441        use std::io::{Read, Seek};
13442
13443        use common::{url::Params, ToParts};
13444        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13445
13446        let mut dd = common::DefaultDelegate;
13447        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13448        dlg.begin(common::MethodInfo {
13449            id: "spanner.projects.instances.backups.getIamPolicy",
13450            http_method: hyper::Method::POST,
13451        });
13452
13453        for &field in ["alt", "resource"].iter() {
13454            if self._additional_params.contains_key(field) {
13455                dlg.finished(false);
13456                return Err(common::Error::FieldClash(field));
13457            }
13458        }
13459
13460        let mut params = Params::with_capacity(4 + self._additional_params.len());
13461        params.push("resource", self._resource);
13462
13463        params.extend(self._additional_params.iter());
13464
13465        params.push("alt", "json");
13466        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
13467        if self._scopes.is_empty() {
13468            self._scopes
13469                .insert(Scope::CloudPlatform.as_ref().to_string());
13470        }
13471
13472        #[allow(clippy::single_element_loop)]
13473        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
13474            url = params.uri_replacement(url, param_name, find_this, true);
13475        }
13476        {
13477            let to_remove = ["resource"];
13478            params.remove_params(&to_remove);
13479        }
13480
13481        let url = params.parse_with_url(&url);
13482
13483        let mut json_mime_type = mime::APPLICATION_JSON;
13484        let mut request_value_reader = {
13485            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13486            common::remove_json_null_values(&mut value);
13487            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13488            serde_json::to_writer(&mut dst, &value).unwrap();
13489            dst
13490        };
13491        let request_size = request_value_reader
13492            .seek(std::io::SeekFrom::End(0))
13493            .unwrap();
13494        request_value_reader
13495            .seek(std::io::SeekFrom::Start(0))
13496            .unwrap();
13497
13498        loop {
13499            let token = match self
13500                .hub
13501                .auth
13502                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13503                .await
13504            {
13505                Ok(token) => token,
13506                Err(e) => match dlg.token(e) {
13507                    Ok(token) => token,
13508                    Err(e) => {
13509                        dlg.finished(false);
13510                        return Err(common::Error::MissingToken(e));
13511                    }
13512                },
13513            };
13514            request_value_reader
13515                .seek(std::io::SeekFrom::Start(0))
13516                .unwrap();
13517            let mut req_result = {
13518                let client = &self.hub.client;
13519                dlg.pre_request();
13520                let mut req_builder = hyper::Request::builder()
13521                    .method(hyper::Method::POST)
13522                    .uri(url.as_str())
13523                    .header(USER_AGENT, self.hub._user_agent.clone());
13524
13525                if let Some(token) = token.as_ref() {
13526                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13527                }
13528
13529                let request = req_builder
13530                    .header(CONTENT_TYPE, json_mime_type.to_string())
13531                    .header(CONTENT_LENGTH, request_size as u64)
13532                    .body(common::to_body(
13533                        request_value_reader.get_ref().clone().into(),
13534                    ));
13535
13536                client.request(request.unwrap()).await
13537            };
13538
13539            match req_result {
13540                Err(err) => {
13541                    if let common::Retry::After(d) = dlg.http_error(&err) {
13542                        sleep(d).await;
13543                        continue;
13544                    }
13545                    dlg.finished(false);
13546                    return Err(common::Error::HttpError(err));
13547                }
13548                Ok(res) => {
13549                    let (mut parts, body) = res.into_parts();
13550                    let mut body = common::Body::new(body);
13551                    if !parts.status.is_success() {
13552                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13553                        let error = serde_json::from_str(&common::to_string(&bytes));
13554                        let response = common::to_response(parts, bytes.into());
13555
13556                        if let common::Retry::After(d) =
13557                            dlg.http_failure(&response, error.as_ref().ok())
13558                        {
13559                            sleep(d).await;
13560                            continue;
13561                        }
13562
13563                        dlg.finished(false);
13564
13565                        return Err(match error {
13566                            Ok(value) => common::Error::BadRequest(value),
13567                            _ => common::Error::Failure(response),
13568                        });
13569                    }
13570                    let response = {
13571                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13572                        let encoded = common::to_string(&bytes);
13573                        match serde_json::from_str(&encoded) {
13574                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13575                            Err(error) => {
13576                                dlg.response_json_decode_error(&encoded, &error);
13577                                return Err(common::Error::JsonDecodeError(
13578                                    encoded.to_string(),
13579                                    error,
13580                                ));
13581                            }
13582                        }
13583                    };
13584
13585                    dlg.finished(true);
13586                    return Ok(response);
13587                }
13588            }
13589        }
13590    }
13591
13592    ///
13593    /// Sets the *request* property to the given value.
13594    ///
13595    /// Even though the property as already been set when instantiating this call,
13596    /// we provide this method for API completeness.
13597    pub fn request(
13598        mut self,
13599        new_value: GetIamPolicyRequest,
13600    ) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
13601        self._request = new_value;
13602        self
13603    }
13604    /// REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
13605    ///
13606    /// Sets the *resource* path property to the given value.
13607    ///
13608    /// Even though the property as already been set when instantiating this call,
13609    /// we provide this method for API completeness.
13610    pub fn resource(mut self, new_value: &str) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
13611        self._resource = new_value.to_string();
13612        self
13613    }
13614    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13615    /// while executing the actual API request.
13616    ///
13617    /// ````text
13618    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13619    /// ````
13620    ///
13621    /// Sets the *delegate* property to the given value.
13622    pub fn delegate(
13623        mut self,
13624        new_value: &'a mut dyn common::Delegate,
13625    ) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
13626        self._delegate = Some(new_value);
13627        self
13628    }
13629
13630    /// Set any additional parameter of the query string used in the request.
13631    /// It should be used to set parameters which are not yet available through their own
13632    /// setters.
13633    ///
13634    /// Please note that this method must not be used to set any of the known parameters
13635    /// which have their own setter method. If done anyway, the request will fail.
13636    ///
13637    /// # Additional Parameters
13638    ///
13639    /// * *$.xgafv* (query-string) - V1 error format.
13640    /// * *access_token* (query-string) - OAuth access token.
13641    /// * *alt* (query-string) - Data format for response.
13642    /// * *callback* (query-string) - JSONP
13643    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13644    /// * *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.
13645    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13646    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13647    /// * *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.
13648    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13649    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13650    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupGetIamPolicyCall<'a, C>
13651    where
13652        T: AsRef<str>,
13653    {
13654        self._additional_params
13655            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13656        self
13657    }
13658
13659    /// Identifies the authorization scope for the method you are building.
13660    ///
13661    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13662    /// [`Scope::CloudPlatform`].
13663    ///
13664    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13665    /// tokens for more than one scope.
13666    ///
13667    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13668    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13669    /// sufficient, a read-write scope will do as well.
13670    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupGetIamPolicyCall<'a, C>
13671    where
13672        St: AsRef<str>,
13673    {
13674        self._scopes.insert(String::from(scope.as_ref()));
13675        self
13676    }
13677    /// Identifies the authorization scope(s) for the method you are building.
13678    ///
13679    /// See [`Self::add_scope()`] for details.
13680    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupGetIamPolicyCall<'a, C>
13681    where
13682        I: IntoIterator<Item = St>,
13683        St: AsRef<str>,
13684    {
13685        self._scopes
13686            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13687        self
13688    }
13689
13690    /// Removes all scopes, and no default scope will be used either.
13691    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13692    /// for details).
13693    pub fn clear_scopes(mut self) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
13694        self._scopes.clear();
13695        self
13696    }
13697}
13698
13699/// Lists completed and pending backups. Backups returned are ordered by `create_time` in descending order, starting from the most recent `create_time`.
13700///
13701/// A builder for the *instances.backups.list* method supported by a *project* resource.
13702/// It is not used directly, but through a [`ProjectMethods`] instance.
13703///
13704/// # Example
13705///
13706/// Instantiate a resource method builder
13707///
13708/// ```test_harness,no_run
13709/// # extern crate hyper;
13710/// # extern crate hyper_rustls;
13711/// # extern crate google_spanner1 as spanner1;
13712/// # async fn dox() {
13713/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13714///
13715/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13716/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13717/// #     .with_native_roots()
13718/// #     .unwrap()
13719/// #     .https_only()
13720/// #     .enable_http2()
13721/// #     .build();
13722///
13723/// # let executor = hyper_util::rt::TokioExecutor::new();
13724/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13725/// #     secret,
13726/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13727/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13728/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13729/// #     ),
13730/// # ).build().await.unwrap();
13731///
13732/// # let client = hyper_util::client::legacy::Client::builder(
13733/// #     hyper_util::rt::TokioExecutor::new()
13734/// # )
13735/// # .build(
13736/// #     hyper_rustls::HttpsConnectorBuilder::new()
13737/// #         .with_native_roots()
13738/// #         .unwrap()
13739/// #         .https_or_http()
13740/// #         .enable_http2()
13741/// #         .build()
13742/// # );
13743/// # let mut hub = Spanner::new(client, auth);
13744/// // You can configure optional parameters by calling the respective setters at will, and
13745/// // execute the final call using `doit()`.
13746/// // Values shown here are possibly random and not representative !
13747/// let result = hub.projects().instances_backups_list("parent")
13748///              .page_token("elitr")
13749///              .page_size(-6)
13750///              .filter("diam")
13751///              .doit().await;
13752/// # }
13753/// ```
13754pub struct ProjectInstanceBackupListCall<'a, C>
13755where
13756    C: 'a,
13757{
13758    hub: &'a Spanner<C>,
13759    _parent: String,
13760    _page_token: Option<String>,
13761    _page_size: Option<i32>,
13762    _filter: Option<String>,
13763    _delegate: Option<&'a mut dyn common::Delegate>,
13764    _additional_params: HashMap<String, String>,
13765    _scopes: BTreeSet<String>,
13766}
13767
13768impl<'a, C> common::CallBuilder for ProjectInstanceBackupListCall<'a, C> {}
13769
13770impl<'a, C> ProjectInstanceBackupListCall<'a, C>
13771where
13772    C: common::Connector,
13773{
13774    /// Perform the operation you have build so far.
13775    pub async fn doit(mut self) -> common::Result<(common::Response, ListBackupsResponse)> {
13776        use std::borrow::Cow;
13777        use std::io::{Read, Seek};
13778
13779        use common::{url::Params, ToParts};
13780        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13781
13782        let mut dd = common::DefaultDelegate;
13783        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13784        dlg.begin(common::MethodInfo {
13785            id: "spanner.projects.instances.backups.list",
13786            http_method: hyper::Method::GET,
13787        });
13788
13789        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
13790            if self._additional_params.contains_key(field) {
13791                dlg.finished(false);
13792                return Err(common::Error::FieldClash(field));
13793            }
13794        }
13795
13796        let mut params = Params::with_capacity(6 + self._additional_params.len());
13797        params.push("parent", self._parent);
13798        if let Some(value) = self._page_token.as_ref() {
13799            params.push("pageToken", value);
13800        }
13801        if let Some(value) = self._page_size.as_ref() {
13802            params.push("pageSize", value.to_string());
13803        }
13804        if let Some(value) = self._filter.as_ref() {
13805            params.push("filter", value);
13806        }
13807
13808        params.extend(self._additional_params.iter());
13809
13810        params.push("alt", "json");
13811        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
13812        if self._scopes.is_empty() {
13813            self._scopes
13814                .insert(Scope::CloudPlatform.as_ref().to_string());
13815        }
13816
13817        #[allow(clippy::single_element_loop)]
13818        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13819            url = params.uri_replacement(url, param_name, find_this, true);
13820        }
13821        {
13822            let to_remove = ["parent"];
13823            params.remove_params(&to_remove);
13824        }
13825
13826        let url = params.parse_with_url(&url);
13827
13828        loop {
13829            let token = match self
13830                .hub
13831                .auth
13832                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13833                .await
13834            {
13835                Ok(token) => token,
13836                Err(e) => match dlg.token(e) {
13837                    Ok(token) => token,
13838                    Err(e) => {
13839                        dlg.finished(false);
13840                        return Err(common::Error::MissingToken(e));
13841                    }
13842                },
13843            };
13844            let mut req_result = {
13845                let client = &self.hub.client;
13846                dlg.pre_request();
13847                let mut req_builder = hyper::Request::builder()
13848                    .method(hyper::Method::GET)
13849                    .uri(url.as_str())
13850                    .header(USER_AGENT, self.hub._user_agent.clone());
13851
13852                if let Some(token) = token.as_ref() {
13853                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13854                }
13855
13856                let request = req_builder
13857                    .header(CONTENT_LENGTH, 0_u64)
13858                    .body(common::to_body::<String>(None));
13859
13860                client.request(request.unwrap()).await
13861            };
13862
13863            match req_result {
13864                Err(err) => {
13865                    if let common::Retry::After(d) = dlg.http_error(&err) {
13866                        sleep(d).await;
13867                        continue;
13868                    }
13869                    dlg.finished(false);
13870                    return Err(common::Error::HttpError(err));
13871                }
13872                Ok(res) => {
13873                    let (mut parts, body) = res.into_parts();
13874                    let mut body = common::Body::new(body);
13875                    if !parts.status.is_success() {
13876                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13877                        let error = serde_json::from_str(&common::to_string(&bytes));
13878                        let response = common::to_response(parts, bytes.into());
13879
13880                        if let common::Retry::After(d) =
13881                            dlg.http_failure(&response, error.as_ref().ok())
13882                        {
13883                            sleep(d).await;
13884                            continue;
13885                        }
13886
13887                        dlg.finished(false);
13888
13889                        return Err(match error {
13890                            Ok(value) => common::Error::BadRequest(value),
13891                            _ => common::Error::Failure(response),
13892                        });
13893                    }
13894                    let response = {
13895                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13896                        let encoded = common::to_string(&bytes);
13897                        match serde_json::from_str(&encoded) {
13898                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13899                            Err(error) => {
13900                                dlg.response_json_decode_error(&encoded, &error);
13901                                return Err(common::Error::JsonDecodeError(
13902                                    encoded.to_string(),
13903                                    error,
13904                                ));
13905                            }
13906                        }
13907                    };
13908
13909                    dlg.finished(true);
13910                    return Ok(response);
13911                }
13912            }
13913        }
13914    }
13915
13916    /// Required. The instance to list backups from. Values are of the form `projects//instances/`.
13917    ///
13918    /// Sets the *parent* path property to the given value.
13919    ///
13920    /// Even though the property as already been set when instantiating this call,
13921    /// we provide this method for API completeness.
13922    pub fn parent(mut self, new_value: &str) -> ProjectInstanceBackupListCall<'a, C> {
13923        self._parent = new_value.to_string();
13924        self
13925    }
13926    /// If non-empty, `page_token` should contain a next_page_token from a previous ListBackupsResponse to the same `parent` and with the same `filter`.
13927    ///
13928    /// Sets the *page token* query property to the given value.
13929    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceBackupListCall<'a, C> {
13930        self._page_token = Some(new_value.to_string());
13931        self
13932    }
13933    /// Number of backups to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
13934    ///
13935    /// Sets the *page size* query property to the given value.
13936    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceBackupListCall<'a, C> {
13937        self._page_size = Some(new_value);
13938        self
13939    }
13940    /// An expression that filters the list of returned backups. A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. Colon `:` is the contains operator. Filter rules are not case sensitive. The following fields in the Backup are eligible for filtering: * `name` * `database` * `state` * `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) * `version_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) * `size_bytes` * `backup_schedules` You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly. Here are a few examples: * `name:Howl` - The backup's name contains the string "howl". * `database:prod` - The database's name contains the string "prod". * `state:CREATING` - The backup is pending creation. * `state:READY` - The backup is fully created and ready for use. * `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")` - The backup name contains the string "howl" and `create_time` of the backup is before 2018-03-28T14:50:00Z. * `expire_time < \"2018-03-28T14:50:00Z\"` - The backup `expire_time` is before 2018-03-28T14:50:00Z. * `size_bytes > 10000000000` - The backup's size is greater than 10GB * `backup_schedules:daily` - The backup is created from a schedule with "daily" in its name.
13941    ///
13942    /// Sets the *filter* query property to the given value.
13943    pub fn filter(mut self, new_value: &str) -> ProjectInstanceBackupListCall<'a, C> {
13944        self._filter = Some(new_value.to_string());
13945        self
13946    }
13947    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13948    /// while executing the actual API request.
13949    ///
13950    /// ````text
13951    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13952    /// ````
13953    ///
13954    /// Sets the *delegate* property to the given value.
13955    pub fn delegate(
13956        mut self,
13957        new_value: &'a mut dyn common::Delegate,
13958    ) -> ProjectInstanceBackupListCall<'a, C> {
13959        self._delegate = Some(new_value);
13960        self
13961    }
13962
13963    /// Set any additional parameter of the query string used in the request.
13964    /// It should be used to set parameters which are not yet available through their own
13965    /// setters.
13966    ///
13967    /// Please note that this method must not be used to set any of the known parameters
13968    /// which have their own setter method. If done anyway, the request will fail.
13969    ///
13970    /// # Additional Parameters
13971    ///
13972    /// * *$.xgafv* (query-string) - V1 error format.
13973    /// * *access_token* (query-string) - OAuth access token.
13974    /// * *alt* (query-string) - Data format for response.
13975    /// * *callback* (query-string) - JSONP
13976    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13977    /// * *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.
13978    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13979    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13980    /// * *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.
13981    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13982    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13983    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupListCall<'a, C>
13984    where
13985        T: AsRef<str>,
13986    {
13987        self._additional_params
13988            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13989        self
13990    }
13991
13992    /// Identifies the authorization scope for the method you are building.
13993    ///
13994    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13995    /// [`Scope::CloudPlatform`].
13996    ///
13997    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13998    /// tokens for more than one scope.
13999    ///
14000    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14001    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14002    /// sufficient, a read-write scope will do as well.
14003    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupListCall<'a, C>
14004    where
14005        St: AsRef<str>,
14006    {
14007        self._scopes.insert(String::from(scope.as_ref()));
14008        self
14009    }
14010    /// Identifies the authorization scope(s) for the method you are building.
14011    ///
14012    /// See [`Self::add_scope()`] for details.
14013    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupListCall<'a, C>
14014    where
14015        I: IntoIterator<Item = St>,
14016        St: AsRef<str>,
14017    {
14018        self._scopes
14019            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14020        self
14021    }
14022
14023    /// Removes all scopes, and no default scope will be used either.
14024    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14025    /// for details).
14026    pub fn clear_scopes(mut self) -> ProjectInstanceBackupListCall<'a, C> {
14027        self._scopes.clear();
14028        self
14029    }
14030}
14031
14032/// Updates a pending or completed Backup.
14033///
14034/// A builder for the *instances.backups.patch* method supported by a *project* resource.
14035/// It is not used directly, but through a [`ProjectMethods`] instance.
14036///
14037/// # Example
14038///
14039/// Instantiate a resource method builder
14040///
14041/// ```test_harness,no_run
14042/// # extern crate hyper;
14043/// # extern crate hyper_rustls;
14044/// # extern crate google_spanner1 as spanner1;
14045/// use spanner1::api::Backup;
14046/// # async fn dox() {
14047/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14048///
14049/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14050/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14051/// #     .with_native_roots()
14052/// #     .unwrap()
14053/// #     .https_only()
14054/// #     .enable_http2()
14055/// #     .build();
14056///
14057/// # let executor = hyper_util::rt::TokioExecutor::new();
14058/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14059/// #     secret,
14060/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14061/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14062/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14063/// #     ),
14064/// # ).build().await.unwrap();
14065///
14066/// # let client = hyper_util::client::legacy::Client::builder(
14067/// #     hyper_util::rt::TokioExecutor::new()
14068/// # )
14069/// # .build(
14070/// #     hyper_rustls::HttpsConnectorBuilder::new()
14071/// #         .with_native_roots()
14072/// #         .unwrap()
14073/// #         .https_or_http()
14074/// #         .enable_http2()
14075/// #         .build()
14076/// # );
14077/// # let mut hub = Spanner::new(client, auth);
14078/// // As the method needs a request, you would usually fill it with the desired information
14079/// // into the respective structure. Some of the parts shown here might not be applicable !
14080/// // Values shown here are possibly random and not representative !
14081/// let mut req = Backup::default();
14082///
14083/// // You can configure optional parameters by calling the respective setters at will, and
14084/// // execute the final call using `doit()`.
14085/// // Values shown here are possibly random and not representative !
14086/// let result = hub.projects().instances_backups_patch(req, "name")
14087///              .update_mask(FieldMask::new::<&str>(&[]))
14088///              .doit().await;
14089/// # }
14090/// ```
14091pub struct ProjectInstanceBackupPatchCall<'a, C>
14092where
14093    C: 'a,
14094{
14095    hub: &'a Spanner<C>,
14096    _request: Backup,
14097    _name: String,
14098    _update_mask: Option<common::FieldMask>,
14099    _delegate: Option<&'a mut dyn common::Delegate>,
14100    _additional_params: HashMap<String, String>,
14101    _scopes: BTreeSet<String>,
14102}
14103
14104impl<'a, C> common::CallBuilder for ProjectInstanceBackupPatchCall<'a, C> {}
14105
14106impl<'a, C> ProjectInstanceBackupPatchCall<'a, C>
14107where
14108    C: common::Connector,
14109{
14110    /// Perform the operation you have build so far.
14111    pub async fn doit(mut self) -> common::Result<(common::Response, Backup)> {
14112        use std::borrow::Cow;
14113        use std::io::{Read, Seek};
14114
14115        use common::{url::Params, ToParts};
14116        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14117
14118        let mut dd = common::DefaultDelegate;
14119        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14120        dlg.begin(common::MethodInfo {
14121            id: "spanner.projects.instances.backups.patch",
14122            http_method: hyper::Method::PATCH,
14123        });
14124
14125        for &field in ["alt", "name", "updateMask"].iter() {
14126            if self._additional_params.contains_key(field) {
14127                dlg.finished(false);
14128                return Err(common::Error::FieldClash(field));
14129            }
14130        }
14131
14132        let mut params = Params::with_capacity(5 + self._additional_params.len());
14133        params.push("name", self._name);
14134        if let Some(value) = self._update_mask.as_ref() {
14135            params.push("updateMask", value.to_string());
14136        }
14137
14138        params.extend(self._additional_params.iter());
14139
14140        params.push("alt", "json");
14141        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14142        if self._scopes.is_empty() {
14143            self._scopes
14144                .insert(Scope::CloudPlatform.as_ref().to_string());
14145        }
14146
14147        #[allow(clippy::single_element_loop)]
14148        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14149            url = params.uri_replacement(url, param_name, find_this, true);
14150        }
14151        {
14152            let to_remove = ["name"];
14153            params.remove_params(&to_remove);
14154        }
14155
14156        let url = params.parse_with_url(&url);
14157
14158        let mut json_mime_type = mime::APPLICATION_JSON;
14159        let mut request_value_reader = {
14160            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14161            common::remove_json_null_values(&mut value);
14162            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14163            serde_json::to_writer(&mut dst, &value).unwrap();
14164            dst
14165        };
14166        let request_size = request_value_reader
14167            .seek(std::io::SeekFrom::End(0))
14168            .unwrap();
14169        request_value_reader
14170            .seek(std::io::SeekFrom::Start(0))
14171            .unwrap();
14172
14173        loop {
14174            let token = match self
14175                .hub
14176                .auth
14177                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14178                .await
14179            {
14180                Ok(token) => token,
14181                Err(e) => match dlg.token(e) {
14182                    Ok(token) => token,
14183                    Err(e) => {
14184                        dlg.finished(false);
14185                        return Err(common::Error::MissingToken(e));
14186                    }
14187                },
14188            };
14189            request_value_reader
14190                .seek(std::io::SeekFrom::Start(0))
14191                .unwrap();
14192            let mut req_result = {
14193                let client = &self.hub.client;
14194                dlg.pre_request();
14195                let mut req_builder = hyper::Request::builder()
14196                    .method(hyper::Method::PATCH)
14197                    .uri(url.as_str())
14198                    .header(USER_AGENT, self.hub._user_agent.clone());
14199
14200                if let Some(token) = token.as_ref() {
14201                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14202                }
14203
14204                let request = req_builder
14205                    .header(CONTENT_TYPE, json_mime_type.to_string())
14206                    .header(CONTENT_LENGTH, request_size as u64)
14207                    .body(common::to_body(
14208                        request_value_reader.get_ref().clone().into(),
14209                    ));
14210
14211                client.request(request.unwrap()).await
14212            };
14213
14214            match req_result {
14215                Err(err) => {
14216                    if let common::Retry::After(d) = dlg.http_error(&err) {
14217                        sleep(d).await;
14218                        continue;
14219                    }
14220                    dlg.finished(false);
14221                    return Err(common::Error::HttpError(err));
14222                }
14223                Ok(res) => {
14224                    let (mut parts, body) = res.into_parts();
14225                    let mut body = common::Body::new(body);
14226                    if !parts.status.is_success() {
14227                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14228                        let error = serde_json::from_str(&common::to_string(&bytes));
14229                        let response = common::to_response(parts, bytes.into());
14230
14231                        if let common::Retry::After(d) =
14232                            dlg.http_failure(&response, error.as_ref().ok())
14233                        {
14234                            sleep(d).await;
14235                            continue;
14236                        }
14237
14238                        dlg.finished(false);
14239
14240                        return Err(match error {
14241                            Ok(value) => common::Error::BadRequest(value),
14242                            _ => common::Error::Failure(response),
14243                        });
14244                    }
14245                    let response = {
14246                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14247                        let encoded = common::to_string(&bytes);
14248                        match serde_json::from_str(&encoded) {
14249                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14250                            Err(error) => {
14251                                dlg.response_json_decode_error(&encoded, &error);
14252                                return Err(common::Error::JsonDecodeError(
14253                                    encoded.to_string(),
14254                                    error,
14255                                ));
14256                            }
14257                        }
14258                    };
14259
14260                    dlg.finished(true);
14261                    return Ok(response);
14262                }
14263            }
14264        }
14265    }
14266
14267    ///
14268    /// Sets the *request* property to the given value.
14269    ///
14270    /// Even though the property as already been set when instantiating this call,
14271    /// we provide this method for API completeness.
14272    pub fn request(mut self, new_value: Backup) -> ProjectInstanceBackupPatchCall<'a, C> {
14273        self._request = new_value;
14274        self
14275    }
14276    /// Output only for the CreateBackup operation. Required for the UpdateBackup operation. A globally unique identifier for the backup which cannot be changed. Values are of the form `projects//instances//backups/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length. The backup is stored in the location(s) specified in the instance configuration of the instance containing the backup, identified by the prefix of the backup name of the form `projects//instances/`.
14277    ///
14278    /// Sets the *name* path property to the given value.
14279    ///
14280    /// Even though the property as already been set when instantiating this call,
14281    /// we provide this method for API completeness.
14282    pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupPatchCall<'a, C> {
14283        self._name = new_value.to_string();
14284        self
14285    }
14286    /// Required. A mask specifying which fields (for example, `expire_time`) in the backup resource should be updated. This mask is relative to the backup resource, not to the request message. The field mask must always be specified; this prevents any future fields from being erased accidentally by clients that do not know about them.
14287    ///
14288    /// Sets the *update mask* query property to the given value.
14289    pub fn update_mask(
14290        mut self,
14291        new_value: common::FieldMask,
14292    ) -> ProjectInstanceBackupPatchCall<'a, C> {
14293        self._update_mask = Some(new_value);
14294        self
14295    }
14296    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14297    /// while executing the actual API request.
14298    ///
14299    /// ````text
14300    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14301    /// ````
14302    ///
14303    /// Sets the *delegate* property to the given value.
14304    pub fn delegate(
14305        mut self,
14306        new_value: &'a mut dyn common::Delegate,
14307    ) -> ProjectInstanceBackupPatchCall<'a, C> {
14308        self._delegate = Some(new_value);
14309        self
14310    }
14311
14312    /// Set any additional parameter of the query string used in the request.
14313    /// It should be used to set parameters which are not yet available through their own
14314    /// setters.
14315    ///
14316    /// Please note that this method must not be used to set any of the known parameters
14317    /// which have their own setter method. If done anyway, the request will fail.
14318    ///
14319    /// # Additional Parameters
14320    ///
14321    /// * *$.xgafv* (query-string) - V1 error format.
14322    /// * *access_token* (query-string) - OAuth access token.
14323    /// * *alt* (query-string) - Data format for response.
14324    /// * *callback* (query-string) - JSONP
14325    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14326    /// * *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.
14327    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14328    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14329    /// * *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.
14330    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14331    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14332    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupPatchCall<'a, C>
14333    where
14334        T: AsRef<str>,
14335    {
14336        self._additional_params
14337            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14338        self
14339    }
14340
14341    /// Identifies the authorization scope for the method you are building.
14342    ///
14343    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14344    /// [`Scope::CloudPlatform`].
14345    ///
14346    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14347    /// tokens for more than one scope.
14348    ///
14349    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14350    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14351    /// sufficient, a read-write scope will do as well.
14352    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupPatchCall<'a, C>
14353    where
14354        St: AsRef<str>,
14355    {
14356        self._scopes.insert(String::from(scope.as_ref()));
14357        self
14358    }
14359    /// Identifies the authorization scope(s) for the method you are building.
14360    ///
14361    /// See [`Self::add_scope()`] for details.
14362    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupPatchCall<'a, C>
14363    where
14364        I: IntoIterator<Item = St>,
14365        St: AsRef<str>,
14366    {
14367        self._scopes
14368            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14369        self
14370    }
14371
14372    /// Removes all scopes, and no default scope will be used either.
14373    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14374    /// for details).
14375    pub fn clear_scopes(mut self) -> ProjectInstanceBackupPatchCall<'a, C> {
14376        self._scopes.clear();
14377        self
14378    }
14379}
14380
14381/// Sets the access control policy on a database or backup resource. Replaces any existing policy. Authorization requires `spanner.databases.setIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.setIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.setIamPolicy` permission on resource.
14382///
14383/// A builder for the *instances.backups.setIamPolicy* method supported by a *project* resource.
14384/// It is not used directly, but through a [`ProjectMethods`] instance.
14385///
14386/// # Example
14387///
14388/// Instantiate a resource method builder
14389///
14390/// ```test_harness,no_run
14391/// # extern crate hyper;
14392/// # extern crate hyper_rustls;
14393/// # extern crate google_spanner1 as spanner1;
14394/// use spanner1::api::SetIamPolicyRequest;
14395/// # async fn dox() {
14396/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14397///
14398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14399/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14400/// #     .with_native_roots()
14401/// #     .unwrap()
14402/// #     .https_only()
14403/// #     .enable_http2()
14404/// #     .build();
14405///
14406/// # let executor = hyper_util::rt::TokioExecutor::new();
14407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14408/// #     secret,
14409/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14410/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14411/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14412/// #     ),
14413/// # ).build().await.unwrap();
14414///
14415/// # let client = hyper_util::client::legacy::Client::builder(
14416/// #     hyper_util::rt::TokioExecutor::new()
14417/// # )
14418/// # .build(
14419/// #     hyper_rustls::HttpsConnectorBuilder::new()
14420/// #         .with_native_roots()
14421/// #         .unwrap()
14422/// #         .https_or_http()
14423/// #         .enable_http2()
14424/// #         .build()
14425/// # );
14426/// # let mut hub = Spanner::new(client, auth);
14427/// // As the method needs a request, you would usually fill it with the desired information
14428/// // into the respective structure. Some of the parts shown here might not be applicable !
14429/// // Values shown here are possibly random and not representative !
14430/// let mut req = SetIamPolicyRequest::default();
14431///
14432/// // You can configure optional parameters by calling the respective setters at will, and
14433/// // execute the final call using `doit()`.
14434/// // Values shown here are possibly random and not representative !
14435/// let result = hub.projects().instances_backups_set_iam_policy(req, "resource")
14436///              .doit().await;
14437/// # }
14438/// ```
14439pub struct ProjectInstanceBackupSetIamPolicyCall<'a, C>
14440where
14441    C: 'a,
14442{
14443    hub: &'a Spanner<C>,
14444    _request: SetIamPolicyRequest,
14445    _resource: String,
14446    _delegate: Option<&'a mut dyn common::Delegate>,
14447    _additional_params: HashMap<String, String>,
14448    _scopes: BTreeSet<String>,
14449}
14450
14451impl<'a, C> common::CallBuilder for ProjectInstanceBackupSetIamPolicyCall<'a, C> {}
14452
14453impl<'a, C> ProjectInstanceBackupSetIamPolicyCall<'a, C>
14454where
14455    C: common::Connector,
14456{
14457    /// Perform the operation you have build so far.
14458    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
14459        use std::borrow::Cow;
14460        use std::io::{Read, Seek};
14461
14462        use common::{url::Params, ToParts};
14463        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14464
14465        let mut dd = common::DefaultDelegate;
14466        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14467        dlg.begin(common::MethodInfo {
14468            id: "spanner.projects.instances.backups.setIamPolicy",
14469            http_method: hyper::Method::POST,
14470        });
14471
14472        for &field in ["alt", "resource"].iter() {
14473            if self._additional_params.contains_key(field) {
14474                dlg.finished(false);
14475                return Err(common::Error::FieldClash(field));
14476            }
14477        }
14478
14479        let mut params = Params::with_capacity(4 + self._additional_params.len());
14480        params.push("resource", self._resource);
14481
14482        params.extend(self._additional_params.iter());
14483
14484        params.push("alt", "json");
14485        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
14486        if self._scopes.is_empty() {
14487            self._scopes
14488                .insert(Scope::CloudPlatform.as_ref().to_string());
14489        }
14490
14491        #[allow(clippy::single_element_loop)]
14492        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
14493            url = params.uri_replacement(url, param_name, find_this, true);
14494        }
14495        {
14496            let to_remove = ["resource"];
14497            params.remove_params(&to_remove);
14498        }
14499
14500        let url = params.parse_with_url(&url);
14501
14502        let mut json_mime_type = mime::APPLICATION_JSON;
14503        let mut request_value_reader = {
14504            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14505            common::remove_json_null_values(&mut value);
14506            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14507            serde_json::to_writer(&mut dst, &value).unwrap();
14508            dst
14509        };
14510        let request_size = request_value_reader
14511            .seek(std::io::SeekFrom::End(0))
14512            .unwrap();
14513        request_value_reader
14514            .seek(std::io::SeekFrom::Start(0))
14515            .unwrap();
14516
14517        loop {
14518            let token = match self
14519                .hub
14520                .auth
14521                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14522                .await
14523            {
14524                Ok(token) => token,
14525                Err(e) => match dlg.token(e) {
14526                    Ok(token) => token,
14527                    Err(e) => {
14528                        dlg.finished(false);
14529                        return Err(common::Error::MissingToken(e));
14530                    }
14531                },
14532            };
14533            request_value_reader
14534                .seek(std::io::SeekFrom::Start(0))
14535                .unwrap();
14536            let mut req_result = {
14537                let client = &self.hub.client;
14538                dlg.pre_request();
14539                let mut req_builder = hyper::Request::builder()
14540                    .method(hyper::Method::POST)
14541                    .uri(url.as_str())
14542                    .header(USER_AGENT, self.hub._user_agent.clone());
14543
14544                if let Some(token) = token.as_ref() {
14545                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14546                }
14547
14548                let request = req_builder
14549                    .header(CONTENT_TYPE, json_mime_type.to_string())
14550                    .header(CONTENT_LENGTH, request_size as u64)
14551                    .body(common::to_body(
14552                        request_value_reader.get_ref().clone().into(),
14553                    ));
14554
14555                client.request(request.unwrap()).await
14556            };
14557
14558            match req_result {
14559                Err(err) => {
14560                    if let common::Retry::After(d) = dlg.http_error(&err) {
14561                        sleep(d).await;
14562                        continue;
14563                    }
14564                    dlg.finished(false);
14565                    return Err(common::Error::HttpError(err));
14566                }
14567                Ok(res) => {
14568                    let (mut parts, body) = res.into_parts();
14569                    let mut body = common::Body::new(body);
14570                    if !parts.status.is_success() {
14571                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14572                        let error = serde_json::from_str(&common::to_string(&bytes));
14573                        let response = common::to_response(parts, bytes.into());
14574
14575                        if let common::Retry::After(d) =
14576                            dlg.http_failure(&response, error.as_ref().ok())
14577                        {
14578                            sleep(d).await;
14579                            continue;
14580                        }
14581
14582                        dlg.finished(false);
14583
14584                        return Err(match error {
14585                            Ok(value) => common::Error::BadRequest(value),
14586                            _ => common::Error::Failure(response),
14587                        });
14588                    }
14589                    let response = {
14590                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14591                        let encoded = common::to_string(&bytes);
14592                        match serde_json::from_str(&encoded) {
14593                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14594                            Err(error) => {
14595                                dlg.response_json_decode_error(&encoded, &error);
14596                                return Err(common::Error::JsonDecodeError(
14597                                    encoded.to_string(),
14598                                    error,
14599                                ));
14600                            }
14601                        }
14602                    };
14603
14604                    dlg.finished(true);
14605                    return Ok(response);
14606                }
14607            }
14608        }
14609    }
14610
14611    ///
14612    /// Sets the *request* property to the given value.
14613    ///
14614    /// Even though the property as already been set when instantiating this call,
14615    /// we provide this method for API completeness.
14616    pub fn request(
14617        mut self,
14618        new_value: SetIamPolicyRequest,
14619    ) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
14620        self._request = new_value;
14621        self
14622    }
14623    /// REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for databases resources.
14624    ///
14625    /// Sets the *resource* path property to the given value.
14626    ///
14627    /// Even though the property as already been set when instantiating this call,
14628    /// we provide this method for API completeness.
14629    pub fn resource(mut self, new_value: &str) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
14630        self._resource = new_value.to_string();
14631        self
14632    }
14633    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14634    /// while executing the actual API request.
14635    ///
14636    /// ````text
14637    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14638    /// ````
14639    ///
14640    /// Sets the *delegate* property to the given value.
14641    pub fn delegate(
14642        mut self,
14643        new_value: &'a mut dyn common::Delegate,
14644    ) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
14645        self._delegate = Some(new_value);
14646        self
14647    }
14648
14649    /// Set any additional parameter of the query string used in the request.
14650    /// It should be used to set parameters which are not yet available through their own
14651    /// setters.
14652    ///
14653    /// Please note that this method must not be used to set any of the known parameters
14654    /// which have their own setter method. If done anyway, the request will fail.
14655    ///
14656    /// # Additional Parameters
14657    ///
14658    /// * *$.xgafv* (query-string) - V1 error format.
14659    /// * *access_token* (query-string) - OAuth access token.
14660    /// * *alt* (query-string) - Data format for response.
14661    /// * *callback* (query-string) - JSONP
14662    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14663    /// * *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.
14664    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14665    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14666    /// * *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.
14667    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14668    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14669    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupSetIamPolicyCall<'a, C>
14670    where
14671        T: AsRef<str>,
14672    {
14673        self._additional_params
14674            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14675        self
14676    }
14677
14678    /// Identifies the authorization scope for the method you are building.
14679    ///
14680    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14681    /// [`Scope::CloudPlatform`].
14682    ///
14683    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14684    /// tokens for more than one scope.
14685    ///
14686    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14687    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14688    /// sufficient, a read-write scope will do as well.
14689    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupSetIamPolicyCall<'a, C>
14690    where
14691        St: AsRef<str>,
14692    {
14693        self._scopes.insert(String::from(scope.as_ref()));
14694        self
14695    }
14696    /// Identifies the authorization scope(s) for the method you are building.
14697    ///
14698    /// See [`Self::add_scope()`] for details.
14699    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupSetIamPolicyCall<'a, C>
14700    where
14701        I: IntoIterator<Item = St>,
14702        St: AsRef<str>,
14703    {
14704        self._scopes
14705            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14706        self
14707    }
14708
14709    /// Removes all scopes, and no default scope will be used either.
14710    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14711    /// for details).
14712    pub fn clear_scopes(mut self) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
14713        self._scopes.clear();
14714        self
14715    }
14716}
14717
14718/// Returns permissions that the caller has on the specified database or backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance. Calling this method on a backup schedule that does not exist will result in a NOT_FOUND error if the user has `spanner.backupSchedules.list` permission on the containing database.
14719///
14720/// A builder for the *instances.backups.testIamPermissions* method supported by a *project* resource.
14721/// It is not used directly, but through a [`ProjectMethods`] instance.
14722///
14723/// # Example
14724///
14725/// Instantiate a resource method builder
14726///
14727/// ```test_harness,no_run
14728/// # extern crate hyper;
14729/// # extern crate hyper_rustls;
14730/// # extern crate google_spanner1 as spanner1;
14731/// use spanner1::api::TestIamPermissionsRequest;
14732/// # async fn dox() {
14733/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14734///
14735/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14736/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14737/// #     .with_native_roots()
14738/// #     .unwrap()
14739/// #     .https_only()
14740/// #     .enable_http2()
14741/// #     .build();
14742///
14743/// # let executor = hyper_util::rt::TokioExecutor::new();
14744/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14745/// #     secret,
14746/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14747/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14748/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14749/// #     ),
14750/// # ).build().await.unwrap();
14751///
14752/// # let client = hyper_util::client::legacy::Client::builder(
14753/// #     hyper_util::rt::TokioExecutor::new()
14754/// # )
14755/// # .build(
14756/// #     hyper_rustls::HttpsConnectorBuilder::new()
14757/// #         .with_native_roots()
14758/// #         .unwrap()
14759/// #         .https_or_http()
14760/// #         .enable_http2()
14761/// #         .build()
14762/// # );
14763/// # let mut hub = Spanner::new(client, auth);
14764/// // As the method needs a request, you would usually fill it with the desired information
14765/// // into the respective structure. Some of the parts shown here might not be applicable !
14766/// // Values shown here are possibly random and not representative !
14767/// let mut req = TestIamPermissionsRequest::default();
14768///
14769/// // You can configure optional parameters by calling the respective setters at will, and
14770/// // execute the final call using `doit()`.
14771/// // Values shown here are possibly random and not representative !
14772/// let result = hub.projects().instances_backups_test_iam_permissions(req, "resource")
14773///              .doit().await;
14774/// # }
14775/// ```
14776pub struct ProjectInstanceBackupTestIamPermissionCall<'a, C>
14777where
14778    C: 'a,
14779{
14780    hub: &'a Spanner<C>,
14781    _request: TestIamPermissionsRequest,
14782    _resource: String,
14783    _delegate: Option<&'a mut dyn common::Delegate>,
14784    _additional_params: HashMap<String, String>,
14785    _scopes: BTreeSet<String>,
14786}
14787
14788impl<'a, C> common::CallBuilder for ProjectInstanceBackupTestIamPermissionCall<'a, C> {}
14789
14790impl<'a, C> ProjectInstanceBackupTestIamPermissionCall<'a, C>
14791where
14792    C: common::Connector,
14793{
14794    /// Perform the operation you have build so far.
14795    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
14796        use std::borrow::Cow;
14797        use std::io::{Read, Seek};
14798
14799        use common::{url::Params, ToParts};
14800        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14801
14802        let mut dd = common::DefaultDelegate;
14803        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14804        dlg.begin(common::MethodInfo {
14805            id: "spanner.projects.instances.backups.testIamPermissions",
14806            http_method: hyper::Method::POST,
14807        });
14808
14809        for &field in ["alt", "resource"].iter() {
14810            if self._additional_params.contains_key(field) {
14811                dlg.finished(false);
14812                return Err(common::Error::FieldClash(field));
14813            }
14814        }
14815
14816        let mut params = Params::with_capacity(4 + self._additional_params.len());
14817        params.push("resource", self._resource);
14818
14819        params.extend(self._additional_params.iter());
14820
14821        params.push("alt", "json");
14822        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
14823        if self._scopes.is_empty() {
14824            self._scopes
14825                .insert(Scope::CloudPlatform.as_ref().to_string());
14826        }
14827
14828        #[allow(clippy::single_element_loop)]
14829        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
14830            url = params.uri_replacement(url, param_name, find_this, true);
14831        }
14832        {
14833            let to_remove = ["resource"];
14834            params.remove_params(&to_remove);
14835        }
14836
14837        let url = params.parse_with_url(&url);
14838
14839        let mut json_mime_type = mime::APPLICATION_JSON;
14840        let mut request_value_reader = {
14841            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14842            common::remove_json_null_values(&mut value);
14843            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14844            serde_json::to_writer(&mut dst, &value).unwrap();
14845            dst
14846        };
14847        let request_size = request_value_reader
14848            .seek(std::io::SeekFrom::End(0))
14849            .unwrap();
14850        request_value_reader
14851            .seek(std::io::SeekFrom::Start(0))
14852            .unwrap();
14853
14854        loop {
14855            let token = match self
14856                .hub
14857                .auth
14858                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14859                .await
14860            {
14861                Ok(token) => token,
14862                Err(e) => match dlg.token(e) {
14863                    Ok(token) => token,
14864                    Err(e) => {
14865                        dlg.finished(false);
14866                        return Err(common::Error::MissingToken(e));
14867                    }
14868                },
14869            };
14870            request_value_reader
14871                .seek(std::io::SeekFrom::Start(0))
14872                .unwrap();
14873            let mut req_result = {
14874                let client = &self.hub.client;
14875                dlg.pre_request();
14876                let mut req_builder = hyper::Request::builder()
14877                    .method(hyper::Method::POST)
14878                    .uri(url.as_str())
14879                    .header(USER_AGENT, self.hub._user_agent.clone());
14880
14881                if let Some(token) = token.as_ref() {
14882                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14883                }
14884
14885                let request = req_builder
14886                    .header(CONTENT_TYPE, json_mime_type.to_string())
14887                    .header(CONTENT_LENGTH, request_size as u64)
14888                    .body(common::to_body(
14889                        request_value_reader.get_ref().clone().into(),
14890                    ));
14891
14892                client.request(request.unwrap()).await
14893            };
14894
14895            match req_result {
14896                Err(err) => {
14897                    if let common::Retry::After(d) = dlg.http_error(&err) {
14898                        sleep(d).await;
14899                        continue;
14900                    }
14901                    dlg.finished(false);
14902                    return Err(common::Error::HttpError(err));
14903                }
14904                Ok(res) => {
14905                    let (mut parts, body) = res.into_parts();
14906                    let mut body = common::Body::new(body);
14907                    if !parts.status.is_success() {
14908                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14909                        let error = serde_json::from_str(&common::to_string(&bytes));
14910                        let response = common::to_response(parts, bytes.into());
14911
14912                        if let common::Retry::After(d) =
14913                            dlg.http_failure(&response, error.as_ref().ok())
14914                        {
14915                            sleep(d).await;
14916                            continue;
14917                        }
14918
14919                        dlg.finished(false);
14920
14921                        return Err(match error {
14922                            Ok(value) => common::Error::BadRequest(value),
14923                            _ => common::Error::Failure(response),
14924                        });
14925                    }
14926                    let response = {
14927                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14928                        let encoded = common::to_string(&bytes);
14929                        match serde_json::from_str(&encoded) {
14930                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14931                            Err(error) => {
14932                                dlg.response_json_decode_error(&encoded, &error);
14933                                return Err(common::Error::JsonDecodeError(
14934                                    encoded.to_string(),
14935                                    error,
14936                                ));
14937                            }
14938                        }
14939                    };
14940
14941                    dlg.finished(true);
14942                    return Ok(response);
14943                }
14944            }
14945        }
14946    }
14947
14948    ///
14949    /// Sets the *request* property to the given value.
14950    ///
14951    /// Even though the property as already been set when instantiating this call,
14952    /// we provide this method for API completeness.
14953    pub fn request(
14954        mut self,
14955        new_value: TestIamPermissionsRequest,
14956    ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
14957        self._request = new_value;
14958        self
14959    }
14960    /// REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
14961    ///
14962    /// Sets the *resource* path property to the given value.
14963    ///
14964    /// Even though the property as already been set when instantiating this call,
14965    /// we provide this method for API completeness.
14966    pub fn resource(
14967        mut self,
14968        new_value: &str,
14969    ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
14970        self._resource = new_value.to_string();
14971        self
14972    }
14973    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14974    /// while executing the actual API request.
14975    ///
14976    /// ````text
14977    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14978    /// ````
14979    ///
14980    /// Sets the *delegate* property to the given value.
14981    pub fn delegate(
14982        mut self,
14983        new_value: &'a mut dyn common::Delegate,
14984    ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
14985        self._delegate = Some(new_value);
14986        self
14987    }
14988
14989    /// Set any additional parameter of the query string used in the request.
14990    /// It should be used to set parameters which are not yet available through their own
14991    /// setters.
14992    ///
14993    /// Please note that this method must not be used to set any of the known parameters
14994    /// which have their own setter method. If done anyway, the request will fail.
14995    ///
14996    /// # Additional Parameters
14997    ///
14998    /// * *$.xgafv* (query-string) - V1 error format.
14999    /// * *access_token* (query-string) - OAuth access token.
15000    /// * *alt* (query-string) - Data format for response.
15001    /// * *callback* (query-string) - JSONP
15002    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15003    /// * *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.
15004    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15005    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15006    /// * *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.
15007    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15008    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15009    pub fn param<T>(
15010        mut self,
15011        name: T,
15012        value: T,
15013    ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C>
15014    where
15015        T: AsRef<str>,
15016    {
15017        self._additional_params
15018            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15019        self
15020    }
15021
15022    /// Identifies the authorization scope for the method you are building.
15023    ///
15024    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15025    /// [`Scope::CloudPlatform`].
15026    ///
15027    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15028    /// tokens for more than one scope.
15029    ///
15030    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15031    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15032    /// sufficient, a read-write scope will do as well.
15033    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupTestIamPermissionCall<'a, C>
15034    where
15035        St: AsRef<str>,
15036    {
15037        self._scopes.insert(String::from(scope.as_ref()));
15038        self
15039    }
15040    /// Identifies the authorization scope(s) for the method you are building.
15041    ///
15042    /// See [`Self::add_scope()`] for details.
15043    pub fn add_scopes<I, St>(
15044        mut self,
15045        scopes: I,
15046    ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C>
15047    where
15048        I: IntoIterator<Item = St>,
15049        St: AsRef<str>,
15050    {
15051        self._scopes
15052            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15053        self
15054    }
15055
15056    /// Removes all scopes, and no default scope will be used either.
15057    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15058    /// for details).
15059    pub fn clear_scopes(mut self) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
15060        self._scopes.clear();
15061        self
15062    }
15063}
15064
15065/// Lists database longrunning-operations. A database operation has a name of the form `projects//instances//databases//operations/`. The long-running operation metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations.
15066///
15067/// A builder for the *instances.databaseOperations.list* method supported by a *project* resource.
15068/// It is not used directly, but through a [`ProjectMethods`] instance.
15069///
15070/// # Example
15071///
15072/// Instantiate a resource method builder
15073///
15074/// ```test_harness,no_run
15075/// # extern crate hyper;
15076/// # extern crate hyper_rustls;
15077/// # extern crate google_spanner1 as spanner1;
15078/// # async fn dox() {
15079/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15080///
15081/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15082/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15083/// #     .with_native_roots()
15084/// #     .unwrap()
15085/// #     .https_only()
15086/// #     .enable_http2()
15087/// #     .build();
15088///
15089/// # let executor = hyper_util::rt::TokioExecutor::new();
15090/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15091/// #     secret,
15092/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15093/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15094/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15095/// #     ),
15096/// # ).build().await.unwrap();
15097///
15098/// # let client = hyper_util::client::legacy::Client::builder(
15099/// #     hyper_util::rt::TokioExecutor::new()
15100/// # )
15101/// # .build(
15102/// #     hyper_rustls::HttpsConnectorBuilder::new()
15103/// #         .with_native_roots()
15104/// #         .unwrap()
15105/// #         .https_or_http()
15106/// #         .enable_http2()
15107/// #         .build()
15108/// # );
15109/// # let mut hub = Spanner::new(client, auth);
15110/// // You can configure optional parameters by calling the respective setters at will, and
15111/// // execute the final call using `doit()`.
15112/// // Values shown here are possibly random and not representative !
15113/// let result = hub.projects().instances_database_operations_list("parent")
15114///              .page_token("consetetur")
15115///              .page_size(-28)
15116///              .filter("et")
15117///              .doit().await;
15118/// # }
15119/// ```
15120pub struct ProjectInstanceDatabaseOperationListCall<'a, C>
15121where
15122    C: 'a,
15123{
15124    hub: &'a Spanner<C>,
15125    _parent: String,
15126    _page_token: Option<String>,
15127    _page_size: Option<i32>,
15128    _filter: Option<String>,
15129    _delegate: Option<&'a mut dyn common::Delegate>,
15130    _additional_params: HashMap<String, String>,
15131    _scopes: BTreeSet<String>,
15132}
15133
15134impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationListCall<'a, C> {}
15135
15136impl<'a, C> ProjectInstanceDatabaseOperationListCall<'a, C>
15137where
15138    C: common::Connector,
15139{
15140    /// Perform the operation you have build so far.
15141    pub async fn doit(
15142        mut self,
15143    ) -> common::Result<(common::Response, ListDatabaseOperationsResponse)> {
15144        use std::borrow::Cow;
15145        use std::io::{Read, Seek};
15146
15147        use common::{url::Params, ToParts};
15148        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15149
15150        let mut dd = common::DefaultDelegate;
15151        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15152        dlg.begin(common::MethodInfo {
15153            id: "spanner.projects.instances.databaseOperations.list",
15154            http_method: hyper::Method::GET,
15155        });
15156
15157        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
15158            if self._additional_params.contains_key(field) {
15159                dlg.finished(false);
15160                return Err(common::Error::FieldClash(field));
15161            }
15162        }
15163
15164        let mut params = Params::with_capacity(6 + self._additional_params.len());
15165        params.push("parent", self._parent);
15166        if let Some(value) = self._page_token.as_ref() {
15167            params.push("pageToken", value);
15168        }
15169        if let Some(value) = self._page_size.as_ref() {
15170            params.push("pageSize", value.to_string());
15171        }
15172        if let Some(value) = self._filter.as_ref() {
15173            params.push("filter", value);
15174        }
15175
15176        params.extend(self._additional_params.iter());
15177
15178        params.push("alt", "json");
15179        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databaseOperations";
15180        if self._scopes.is_empty() {
15181            self._scopes
15182                .insert(Scope::CloudPlatform.as_ref().to_string());
15183        }
15184
15185        #[allow(clippy::single_element_loop)]
15186        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15187            url = params.uri_replacement(url, param_name, find_this, true);
15188        }
15189        {
15190            let to_remove = ["parent"];
15191            params.remove_params(&to_remove);
15192        }
15193
15194        let url = params.parse_with_url(&url);
15195
15196        loop {
15197            let token = match self
15198                .hub
15199                .auth
15200                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15201                .await
15202            {
15203                Ok(token) => token,
15204                Err(e) => match dlg.token(e) {
15205                    Ok(token) => token,
15206                    Err(e) => {
15207                        dlg.finished(false);
15208                        return Err(common::Error::MissingToken(e));
15209                    }
15210                },
15211            };
15212            let mut req_result = {
15213                let client = &self.hub.client;
15214                dlg.pre_request();
15215                let mut req_builder = hyper::Request::builder()
15216                    .method(hyper::Method::GET)
15217                    .uri(url.as_str())
15218                    .header(USER_AGENT, self.hub._user_agent.clone());
15219
15220                if let Some(token) = token.as_ref() {
15221                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15222                }
15223
15224                let request = req_builder
15225                    .header(CONTENT_LENGTH, 0_u64)
15226                    .body(common::to_body::<String>(None));
15227
15228                client.request(request.unwrap()).await
15229            };
15230
15231            match req_result {
15232                Err(err) => {
15233                    if let common::Retry::After(d) = dlg.http_error(&err) {
15234                        sleep(d).await;
15235                        continue;
15236                    }
15237                    dlg.finished(false);
15238                    return Err(common::Error::HttpError(err));
15239                }
15240                Ok(res) => {
15241                    let (mut parts, body) = res.into_parts();
15242                    let mut body = common::Body::new(body);
15243                    if !parts.status.is_success() {
15244                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15245                        let error = serde_json::from_str(&common::to_string(&bytes));
15246                        let response = common::to_response(parts, bytes.into());
15247
15248                        if let common::Retry::After(d) =
15249                            dlg.http_failure(&response, error.as_ref().ok())
15250                        {
15251                            sleep(d).await;
15252                            continue;
15253                        }
15254
15255                        dlg.finished(false);
15256
15257                        return Err(match error {
15258                            Ok(value) => common::Error::BadRequest(value),
15259                            _ => common::Error::Failure(response),
15260                        });
15261                    }
15262                    let response = {
15263                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15264                        let encoded = common::to_string(&bytes);
15265                        match serde_json::from_str(&encoded) {
15266                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15267                            Err(error) => {
15268                                dlg.response_json_decode_error(&encoded, &error);
15269                                return Err(common::Error::JsonDecodeError(
15270                                    encoded.to_string(),
15271                                    error,
15272                                ));
15273                            }
15274                        }
15275                    };
15276
15277                    dlg.finished(true);
15278                    return Ok(response);
15279                }
15280            }
15281        }
15282    }
15283
15284    /// Required. The instance of the database operations. Values are of the form `projects//instances/`.
15285    ///
15286    /// Sets the *parent* path property to the given value.
15287    ///
15288    /// Even though the property as already been set when instantiating this call,
15289    /// we provide this method for API completeness.
15290    pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
15291        self._parent = new_value.to_string();
15292        self
15293    }
15294    /// If non-empty, `page_token` should contain a next_page_token from a previous ListDatabaseOperationsResponse to the same `parent` and with the same `filter`.
15295    ///
15296    /// Sets the *page token* query property to the given value.
15297    pub fn page_token(
15298        mut self,
15299        new_value: &str,
15300    ) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
15301        self._page_token = Some(new_value.to_string());
15302        self
15303    }
15304    /// Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
15305    ///
15306    /// Sets the *page size* query property to the given value.
15307    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
15308        self._page_size = Some(new_value);
15309        self
15310    }
15311    /// An expression that filters the list of returned operations. A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. Colon `:` is the contains operator. Filter rules are not case sensitive. The following fields in the operation are eligible for filtering: * `name` - The name of the long-running operation * `done` - False if the operation is in progress, else true. * `metadata.@type` - the type of metadata. For example, the type string for RestoreDatabaseMetadata is `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`. * `metadata.` - any field in metadata.value. `metadata.@type` must be specified first, if filtering on metadata fields. * `error` - Error associated with the long-running operation. * `response.@type` - the type of response. * `response.` - any field in response.value. You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly. Here are a few examples: * `done:true` - The operation is complete. * `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` \ `(metadata.source_type:BACKUP) AND` \ `(metadata.backup_info.backup:backup_howl) AND` \ `(metadata.name:restored_howl) AND` \ `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \ `(error:*)` - Return operations where: * The operation's metadata type is RestoreDatabaseMetadata. * The database is restored from a backup. * The backup name contains "backup_howl". * The restored database's name contains "restored_howl". * The operation started before 2018-03-28T14:50:00Z. * The operation resulted in an error.
15312    ///
15313    /// Sets the *filter* query property to the given value.
15314    pub fn filter(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
15315        self._filter = Some(new_value.to_string());
15316        self
15317    }
15318    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15319    /// while executing the actual API request.
15320    ///
15321    /// ````text
15322    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15323    /// ````
15324    ///
15325    /// Sets the *delegate* property to the given value.
15326    pub fn delegate(
15327        mut self,
15328        new_value: &'a mut dyn common::Delegate,
15329    ) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
15330        self._delegate = Some(new_value);
15331        self
15332    }
15333
15334    /// Set any additional parameter of the query string used in the request.
15335    /// It should be used to set parameters which are not yet available through their own
15336    /// setters.
15337    ///
15338    /// Please note that this method must not be used to set any of the known parameters
15339    /// which have their own setter method. If done anyway, the request will fail.
15340    ///
15341    /// # Additional Parameters
15342    ///
15343    /// * *$.xgafv* (query-string) - V1 error format.
15344    /// * *access_token* (query-string) - OAuth access token.
15345    /// * *alt* (query-string) - Data format for response.
15346    /// * *callback* (query-string) - JSONP
15347    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15348    /// * *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.
15349    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15350    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15351    /// * *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.
15352    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15353    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15354    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseOperationListCall<'a, C>
15355    where
15356        T: AsRef<str>,
15357    {
15358        self._additional_params
15359            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15360        self
15361    }
15362
15363    /// Identifies the authorization scope for the method you are building.
15364    ///
15365    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15366    /// [`Scope::CloudPlatform`].
15367    ///
15368    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15369    /// tokens for more than one scope.
15370    ///
15371    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15372    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15373    /// sufficient, a read-write scope will do as well.
15374    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationListCall<'a, C>
15375    where
15376        St: AsRef<str>,
15377    {
15378        self._scopes.insert(String::from(scope.as_ref()));
15379        self
15380    }
15381    /// Identifies the authorization scope(s) for the method you are building.
15382    ///
15383    /// See [`Self::add_scope()`] for details.
15384    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseOperationListCall<'a, C>
15385    where
15386        I: IntoIterator<Item = St>,
15387        St: AsRef<str>,
15388    {
15389        self._scopes
15390            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15391        self
15392    }
15393
15394    /// Removes all scopes, and no default scope will be used either.
15395    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15396    /// for details).
15397    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
15398        self._scopes.clear();
15399        self
15400    }
15401}
15402
15403/// Creates a new backup schedule.
15404///
15405/// A builder for the *instances.databases.backupSchedules.create* method supported by a *project* resource.
15406/// It is not used directly, but through a [`ProjectMethods`] instance.
15407///
15408/// # Example
15409///
15410/// Instantiate a resource method builder
15411///
15412/// ```test_harness,no_run
15413/// # extern crate hyper;
15414/// # extern crate hyper_rustls;
15415/// # extern crate google_spanner1 as spanner1;
15416/// use spanner1::api::BackupSchedule;
15417/// # async fn dox() {
15418/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15419///
15420/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15421/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15422/// #     .with_native_roots()
15423/// #     .unwrap()
15424/// #     .https_only()
15425/// #     .enable_http2()
15426/// #     .build();
15427///
15428/// # let executor = hyper_util::rt::TokioExecutor::new();
15429/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15430/// #     secret,
15431/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15432/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15433/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15434/// #     ),
15435/// # ).build().await.unwrap();
15436///
15437/// # let client = hyper_util::client::legacy::Client::builder(
15438/// #     hyper_util::rt::TokioExecutor::new()
15439/// # )
15440/// # .build(
15441/// #     hyper_rustls::HttpsConnectorBuilder::new()
15442/// #         .with_native_roots()
15443/// #         .unwrap()
15444/// #         .https_or_http()
15445/// #         .enable_http2()
15446/// #         .build()
15447/// # );
15448/// # let mut hub = Spanner::new(client, auth);
15449/// // As the method needs a request, you would usually fill it with the desired information
15450/// // into the respective structure. Some of the parts shown here might not be applicable !
15451/// // Values shown here are possibly random and not representative !
15452/// let mut req = BackupSchedule::default();
15453///
15454/// // You can configure optional parameters by calling the respective setters at will, and
15455/// // execute the final call using `doit()`.
15456/// // Values shown here are possibly random and not representative !
15457/// let result = hub.projects().instances_databases_backup_schedules_create(req, "parent")
15458///              .backup_schedule_id("consetetur")
15459///              .doit().await;
15460/// # }
15461/// ```
15462pub struct ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C>
15463where
15464    C: 'a,
15465{
15466    hub: &'a Spanner<C>,
15467    _request: BackupSchedule,
15468    _parent: String,
15469    _backup_schedule_id: Option<String>,
15470    _delegate: Option<&'a mut dyn common::Delegate>,
15471    _additional_params: HashMap<String, String>,
15472    _scopes: BTreeSet<String>,
15473}
15474
15475impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C> {}
15476
15477impl<'a, C> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C>
15478where
15479    C: common::Connector,
15480{
15481    /// Perform the operation you have build so far.
15482    pub async fn doit(mut self) -> common::Result<(common::Response, BackupSchedule)> {
15483        use std::borrow::Cow;
15484        use std::io::{Read, Seek};
15485
15486        use common::{url::Params, ToParts};
15487        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15488
15489        let mut dd = common::DefaultDelegate;
15490        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15491        dlg.begin(common::MethodInfo {
15492            id: "spanner.projects.instances.databases.backupSchedules.create",
15493            http_method: hyper::Method::POST,
15494        });
15495
15496        for &field in ["alt", "parent", "backupScheduleId"].iter() {
15497            if self._additional_params.contains_key(field) {
15498                dlg.finished(false);
15499                return Err(common::Error::FieldClash(field));
15500            }
15501        }
15502
15503        let mut params = Params::with_capacity(5 + self._additional_params.len());
15504        params.push("parent", self._parent);
15505        if let Some(value) = self._backup_schedule_id.as_ref() {
15506            params.push("backupScheduleId", value);
15507        }
15508
15509        params.extend(self._additional_params.iter());
15510
15511        params.push("alt", "json");
15512        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backupSchedules";
15513        if self._scopes.is_empty() {
15514            self._scopes
15515                .insert(Scope::CloudPlatform.as_ref().to_string());
15516        }
15517
15518        #[allow(clippy::single_element_loop)]
15519        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15520            url = params.uri_replacement(url, param_name, find_this, true);
15521        }
15522        {
15523            let to_remove = ["parent"];
15524            params.remove_params(&to_remove);
15525        }
15526
15527        let url = params.parse_with_url(&url);
15528
15529        let mut json_mime_type = mime::APPLICATION_JSON;
15530        let mut request_value_reader = {
15531            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15532            common::remove_json_null_values(&mut value);
15533            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15534            serde_json::to_writer(&mut dst, &value).unwrap();
15535            dst
15536        };
15537        let request_size = request_value_reader
15538            .seek(std::io::SeekFrom::End(0))
15539            .unwrap();
15540        request_value_reader
15541            .seek(std::io::SeekFrom::Start(0))
15542            .unwrap();
15543
15544        loop {
15545            let token = match self
15546                .hub
15547                .auth
15548                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15549                .await
15550            {
15551                Ok(token) => token,
15552                Err(e) => match dlg.token(e) {
15553                    Ok(token) => token,
15554                    Err(e) => {
15555                        dlg.finished(false);
15556                        return Err(common::Error::MissingToken(e));
15557                    }
15558                },
15559            };
15560            request_value_reader
15561                .seek(std::io::SeekFrom::Start(0))
15562                .unwrap();
15563            let mut req_result = {
15564                let client = &self.hub.client;
15565                dlg.pre_request();
15566                let mut req_builder = hyper::Request::builder()
15567                    .method(hyper::Method::POST)
15568                    .uri(url.as_str())
15569                    .header(USER_AGENT, self.hub._user_agent.clone());
15570
15571                if let Some(token) = token.as_ref() {
15572                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15573                }
15574
15575                let request = req_builder
15576                    .header(CONTENT_TYPE, json_mime_type.to_string())
15577                    .header(CONTENT_LENGTH, request_size as u64)
15578                    .body(common::to_body(
15579                        request_value_reader.get_ref().clone().into(),
15580                    ));
15581
15582                client.request(request.unwrap()).await
15583            };
15584
15585            match req_result {
15586                Err(err) => {
15587                    if let common::Retry::After(d) = dlg.http_error(&err) {
15588                        sleep(d).await;
15589                        continue;
15590                    }
15591                    dlg.finished(false);
15592                    return Err(common::Error::HttpError(err));
15593                }
15594                Ok(res) => {
15595                    let (mut parts, body) = res.into_parts();
15596                    let mut body = common::Body::new(body);
15597                    if !parts.status.is_success() {
15598                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15599                        let error = serde_json::from_str(&common::to_string(&bytes));
15600                        let response = common::to_response(parts, bytes.into());
15601
15602                        if let common::Retry::After(d) =
15603                            dlg.http_failure(&response, error.as_ref().ok())
15604                        {
15605                            sleep(d).await;
15606                            continue;
15607                        }
15608
15609                        dlg.finished(false);
15610
15611                        return Err(match error {
15612                            Ok(value) => common::Error::BadRequest(value),
15613                            _ => common::Error::Failure(response),
15614                        });
15615                    }
15616                    let response = {
15617                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15618                        let encoded = common::to_string(&bytes);
15619                        match serde_json::from_str(&encoded) {
15620                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15621                            Err(error) => {
15622                                dlg.response_json_decode_error(&encoded, &error);
15623                                return Err(common::Error::JsonDecodeError(
15624                                    encoded.to_string(),
15625                                    error,
15626                                ));
15627                            }
15628                        }
15629                    };
15630
15631                    dlg.finished(true);
15632                    return Ok(response);
15633                }
15634            }
15635        }
15636    }
15637
15638    ///
15639    /// Sets the *request* property to the given value.
15640    ///
15641    /// Even though the property as already been set when instantiating this call,
15642    /// we provide this method for API completeness.
15643    pub fn request(
15644        mut self,
15645        new_value: BackupSchedule,
15646    ) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C> {
15647        self._request = new_value;
15648        self
15649    }
15650    /// Required. The name of the database that this backup schedule applies to.
15651    ///
15652    /// Sets the *parent* path property to the given value.
15653    ///
15654    /// Even though the property as already been set when instantiating this call,
15655    /// we provide this method for API completeness.
15656    pub fn parent(
15657        mut self,
15658        new_value: &str,
15659    ) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C> {
15660        self._parent = new_value.to_string();
15661        self
15662    }
15663    /// Required. The Id to use for the backup schedule. The `backup_schedule_id` appended to `parent` forms the full backup schedule name of the form `projects//instances//databases//backupSchedules/`.
15664    ///
15665    /// Sets the *backup schedule id* query property to the given value.
15666    pub fn backup_schedule_id(
15667        mut self,
15668        new_value: &str,
15669    ) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C> {
15670        self._backup_schedule_id = Some(new_value.to_string());
15671        self
15672    }
15673    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15674    /// while executing the actual API request.
15675    ///
15676    /// ````text
15677    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15678    /// ````
15679    ///
15680    /// Sets the *delegate* property to the given value.
15681    pub fn delegate(
15682        mut self,
15683        new_value: &'a mut dyn common::Delegate,
15684    ) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C> {
15685        self._delegate = Some(new_value);
15686        self
15687    }
15688
15689    /// Set any additional parameter of the query string used in the request.
15690    /// It should be used to set parameters which are not yet available through their own
15691    /// setters.
15692    ///
15693    /// Please note that this method must not be used to set any of the known parameters
15694    /// which have their own setter method. If done anyway, the request will fail.
15695    ///
15696    /// # Additional Parameters
15697    ///
15698    /// * *$.xgafv* (query-string) - V1 error format.
15699    /// * *access_token* (query-string) - OAuth access token.
15700    /// * *alt* (query-string) - Data format for response.
15701    /// * *callback* (query-string) - JSONP
15702    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15703    /// * *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.
15704    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15705    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15706    /// * *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.
15707    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15708    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15709    pub fn param<T>(
15710        mut self,
15711        name: T,
15712        value: T,
15713    ) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C>
15714    where
15715        T: AsRef<str>,
15716    {
15717        self._additional_params
15718            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15719        self
15720    }
15721
15722    /// Identifies the authorization scope for the method you are building.
15723    ///
15724    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15725    /// [`Scope::CloudPlatform`].
15726    ///
15727    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15728    /// tokens for more than one scope.
15729    ///
15730    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15731    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15732    /// sufficient, a read-write scope will do as well.
15733    pub fn add_scope<St>(
15734        mut self,
15735        scope: St,
15736    ) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C>
15737    where
15738        St: AsRef<str>,
15739    {
15740        self._scopes.insert(String::from(scope.as_ref()));
15741        self
15742    }
15743    /// Identifies the authorization scope(s) for the method you are building.
15744    ///
15745    /// See [`Self::add_scope()`] for details.
15746    pub fn add_scopes<I, St>(
15747        mut self,
15748        scopes: I,
15749    ) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C>
15750    where
15751        I: IntoIterator<Item = St>,
15752        St: AsRef<str>,
15753    {
15754        self._scopes
15755            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15756        self
15757    }
15758
15759    /// Removes all scopes, and no default scope will be used either.
15760    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15761    /// for details).
15762    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseBackupScheduleCreateCall<'a, C> {
15763        self._scopes.clear();
15764        self
15765    }
15766}
15767
15768/// Deletes a backup schedule.
15769///
15770/// A builder for the *instances.databases.backupSchedules.delete* method supported by a *project* resource.
15771/// It is not used directly, but through a [`ProjectMethods`] instance.
15772///
15773/// # Example
15774///
15775/// Instantiate a resource method builder
15776///
15777/// ```test_harness,no_run
15778/// # extern crate hyper;
15779/// # extern crate hyper_rustls;
15780/// # extern crate google_spanner1 as spanner1;
15781/// # async fn dox() {
15782/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15783///
15784/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15785/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15786/// #     .with_native_roots()
15787/// #     .unwrap()
15788/// #     .https_only()
15789/// #     .enable_http2()
15790/// #     .build();
15791///
15792/// # let executor = hyper_util::rt::TokioExecutor::new();
15793/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15794/// #     secret,
15795/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15796/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15797/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15798/// #     ),
15799/// # ).build().await.unwrap();
15800///
15801/// # let client = hyper_util::client::legacy::Client::builder(
15802/// #     hyper_util::rt::TokioExecutor::new()
15803/// # )
15804/// # .build(
15805/// #     hyper_rustls::HttpsConnectorBuilder::new()
15806/// #         .with_native_roots()
15807/// #         .unwrap()
15808/// #         .https_or_http()
15809/// #         .enable_http2()
15810/// #         .build()
15811/// # );
15812/// # let mut hub = Spanner::new(client, auth);
15813/// // You can configure optional parameters by calling the respective setters at will, and
15814/// // execute the final call using `doit()`.
15815/// // Values shown here are possibly random and not representative !
15816/// let result = hub.projects().instances_databases_backup_schedules_delete("name")
15817///              .doit().await;
15818/// # }
15819/// ```
15820pub struct ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C>
15821where
15822    C: 'a,
15823{
15824    hub: &'a Spanner<C>,
15825    _name: String,
15826    _delegate: Option<&'a mut dyn common::Delegate>,
15827    _additional_params: HashMap<String, String>,
15828    _scopes: BTreeSet<String>,
15829}
15830
15831impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C> {}
15832
15833impl<'a, C> ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C>
15834where
15835    C: common::Connector,
15836{
15837    /// Perform the operation you have build so far.
15838    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15839        use std::borrow::Cow;
15840        use std::io::{Read, Seek};
15841
15842        use common::{url::Params, ToParts};
15843        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15844
15845        let mut dd = common::DefaultDelegate;
15846        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15847        dlg.begin(common::MethodInfo {
15848            id: "spanner.projects.instances.databases.backupSchedules.delete",
15849            http_method: hyper::Method::DELETE,
15850        });
15851
15852        for &field in ["alt", "name"].iter() {
15853            if self._additional_params.contains_key(field) {
15854                dlg.finished(false);
15855                return Err(common::Error::FieldClash(field));
15856            }
15857        }
15858
15859        let mut params = Params::with_capacity(3 + self._additional_params.len());
15860        params.push("name", self._name);
15861
15862        params.extend(self._additional_params.iter());
15863
15864        params.push("alt", "json");
15865        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15866        if self._scopes.is_empty() {
15867            self._scopes
15868                .insert(Scope::CloudPlatform.as_ref().to_string());
15869        }
15870
15871        #[allow(clippy::single_element_loop)]
15872        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15873            url = params.uri_replacement(url, param_name, find_this, true);
15874        }
15875        {
15876            let to_remove = ["name"];
15877            params.remove_params(&to_remove);
15878        }
15879
15880        let url = params.parse_with_url(&url);
15881
15882        loop {
15883            let token = match self
15884                .hub
15885                .auth
15886                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15887                .await
15888            {
15889                Ok(token) => token,
15890                Err(e) => match dlg.token(e) {
15891                    Ok(token) => token,
15892                    Err(e) => {
15893                        dlg.finished(false);
15894                        return Err(common::Error::MissingToken(e));
15895                    }
15896                },
15897            };
15898            let mut req_result = {
15899                let client = &self.hub.client;
15900                dlg.pre_request();
15901                let mut req_builder = hyper::Request::builder()
15902                    .method(hyper::Method::DELETE)
15903                    .uri(url.as_str())
15904                    .header(USER_AGENT, self.hub._user_agent.clone());
15905
15906                if let Some(token) = token.as_ref() {
15907                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15908                }
15909
15910                let request = req_builder
15911                    .header(CONTENT_LENGTH, 0_u64)
15912                    .body(common::to_body::<String>(None));
15913
15914                client.request(request.unwrap()).await
15915            };
15916
15917            match req_result {
15918                Err(err) => {
15919                    if let common::Retry::After(d) = dlg.http_error(&err) {
15920                        sleep(d).await;
15921                        continue;
15922                    }
15923                    dlg.finished(false);
15924                    return Err(common::Error::HttpError(err));
15925                }
15926                Ok(res) => {
15927                    let (mut parts, body) = res.into_parts();
15928                    let mut body = common::Body::new(body);
15929                    if !parts.status.is_success() {
15930                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15931                        let error = serde_json::from_str(&common::to_string(&bytes));
15932                        let response = common::to_response(parts, bytes.into());
15933
15934                        if let common::Retry::After(d) =
15935                            dlg.http_failure(&response, error.as_ref().ok())
15936                        {
15937                            sleep(d).await;
15938                            continue;
15939                        }
15940
15941                        dlg.finished(false);
15942
15943                        return Err(match error {
15944                            Ok(value) => common::Error::BadRequest(value),
15945                            _ => common::Error::Failure(response),
15946                        });
15947                    }
15948                    let response = {
15949                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15950                        let encoded = common::to_string(&bytes);
15951                        match serde_json::from_str(&encoded) {
15952                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15953                            Err(error) => {
15954                                dlg.response_json_decode_error(&encoded, &error);
15955                                return Err(common::Error::JsonDecodeError(
15956                                    encoded.to_string(),
15957                                    error,
15958                                ));
15959                            }
15960                        }
15961                    };
15962
15963                    dlg.finished(true);
15964                    return Ok(response);
15965                }
15966            }
15967        }
15968    }
15969
15970    /// Required. The name of the schedule to delete. Values are of the form `projects//instances//databases//backupSchedules/`.
15971    ///
15972    /// Sets the *name* path property to the given value.
15973    ///
15974    /// Even though the property as already been set when instantiating this call,
15975    /// we provide this method for API completeness.
15976    pub fn name(
15977        mut self,
15978        new_value: &str,
15979    ) -> ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C> {
15980        self._name = new_value.to_string();
15981        self
15982    }
15983    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15984    /// while executing the actual API request.
15985    ///
15986    /// ````text
15987    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15988    /// ````
15989    ///
15990    /// Sets the *delegate* property to the given value.
15991    pub fn delegate(
15992        mut self,
15993        new_value: &'a mut dyn common::Delegate,
15994    ) -> ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C> {
15995        self._delegate = Some(new_value);
15996        self
15997    }
15998
15999    /// Set any additional parameter of the query string used in the request.
16000    /// It should be used to set parameters which are not yet available through their own
16001    /// setters.
16002    ///
16003    /// Please note that this method must not be used to set any of the known parameters
16004    /// which have their own setter method. If done anyway, the request will fail.
16005    ///
16006    /// # Additional Parameters
16007    ///
16008    /// * *$.xgafv* (query-string) - V1 error format.
16009    /// * *access_token* (query-string) - OAuth access token.
16010    /// * *alt* (query-string) - Data format for response.
16011    /// * *callback* (query-string) - JSONP
16012    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16013    /// * *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.
16014    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16015    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16016    /// * *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.
16017    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16018    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16019    pub fn param<T>(
16020        mut self,
16021        name: T,
16022        value: T,
16023    ) -> ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C>
16024    where
16025        T: AsRef<str>,
16026    {
16027        self._additional_params
16028            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16029        self
16030    }
16031
16032    /// Identifies the authorization scope for the method you are building.
16033    ///
16034    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16035    /// [`Scope::CloudPlatform`].
16036    ///
16037    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16038    /// tokens for more than one scope.
16039    ///
16040    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16041    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16042    /// sufficient, a read-write scope will do as well.
16043    pub fn add_scope<St>(
16044        mut self,
16045        scope: St,
16046    ) -> ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C>
16047    where
16048        St: AsRef<str>,
16049    {
16050        self._scopes.insert(String::from(scope.as_ref()));
16051        self
16052    }
16053    /// Identifies the authorization scope(s) for the method you are building.
16054    ///
16055    /// See [`Self::add_scope()`] for details.
16056    pub fn add_scopes<I, St>(
16057        mut self,
16058        scopes: I,
16059    ) -> ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C>
16060    where
16061        I: IntoIterator<Item = St>,
16062        St: AsRef<str>,
16063    {
16064        self._scopes
16065            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16066        self
16067    }
16068
16069    /// Removes all scopes, and no default scope will be used either.
16070    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16071    /// for details).
16072    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseBackupScheduleDeleteCall<'a, C> {
16073        self._scopes.clear();
16074        self
16075    }
16076}
16077
16078/// Gets backup schedule for the input schedule name.
16079///
16080/// A builder for the *instances.databases.backupSchedules.get* method supported by a *project* resource.
16081/// It is not used directly, but through a [`ProjectMethods`] instance.
16082///
16083/// # Example
16084///
16085/// Instantiate a resource method builder
16086///
16087/// ```test_harness,no_run
16088/// # extern crate hyper;
16089/// # extern crate hyper_rustls;
16090/// # extern crate google_spanner1 as spanner1;
16091/// # async fn dox() {
16092/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16093///
16094/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16095/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16096/// #     .with_native_roots()
16097/// #     .unwrap()
16098/// #     .https_only()
16099/// #     .enable_http2()
16100/// #     .build();
16101///
16102/// # let executor = hyper_util::rt::TokioExecutor::new();
16103/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16104/// #     secret,
16105/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16106/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16107/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16108/// #     ),
16109/// # ).build().await.unwrap();
16110///
16111/// # let client = hyper_util::client::legacy::Client::builder(
16112/// #     hyper_util::rt::TokioExecutor::new()
16113/// # )
16114/// # .build(
16115/// #     hyper_rustls::HttpsConnectorBuilder::new()
16116/// #         .with_native_roots()
16117/// #         .unwrap()
16118/// #         .https_or_http()
16119/// #         .enable_http2()
16120/// #         .build()
16121/// # );
16122/// # let mut hub = Spanner::new(client, auth);
16123/// // You can configure optional parameters by calling the respective setters at will, and
16124/// // execute the final call using `doit()`.
16125/// // Values shown here are possibly random and not representative !
16126/// let result = hub.projects().instances_databases_backup_schedules_get("name")
16127///              .doit().await;
16128/// # }
16129/// ```
16130pub struct ProjectInstanceDatabaseBackupScheduleGetCall<'a, C>
16131where
16132    C: 'a,
16133{
16134    hub: &'a Spanner<C>,
16135    _name: String,
16136    _delegate: Option<&'a mut dyn common::Delegate>,
16137    _additional_params: HashMap<String, String>,
16138    _scopes: BTreeSet<String>,
16139}
16140
16141impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseBackupScheduleGetCall<'a, C> {}
16142
16143impl<'a, C> ProjectInstanceDatabaseBackupScheduleGetCall<'a, C>
16144where
16145    C: common::Connector,
16146{
16147    /// Perform the operation you have build so far.
16148    pub async fn doit(mut self) -> common::Result<(common::Response, BackupSchedule)> {
16149        use std::borrow::Cow;
16150        use std::io::{Read, Seek};
16151
16152        use common::{url::Params, ToParts};
16153        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16154
16155        let mut dd = common::DefaultDelegate;
16156        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16157        dlg.begin(common::MethodInfo {
16158            id: "spanner.projects.instances.databases.backupSchedules.get",
16159            http_method: hyper::Method::GET,
16160        });
16161
16162        for &field in ["alt", "name"].iter() {
16163            if self._additional_params.contains_key(field) {
16164                dlg.finished(false);
16165                return Err(common::Error::FieldClash(field));
16166            }
16167        }
16168
16169        let mut params = Params::with_capacity(3 + self._additional_params.len());
16170        params.push("name", self._name);
16171
16172        params.extend(self._additional_params.iter());
16173
16174        params.push("alt", "json");
16175        let mut url = self.hub._base_url.clone() + "v1/{+name}";
16176        if self._scopes.is_empty() {
16177            self._scopes
16178                .insert(Scope::CloudPlatform.as_ref().to_string());
16179        }
16180
16181        #[allow(clippy::single_element_loop)]
16182        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16183            url = params.uri_replacement(url, param_name, find_this, true);
16184        }
16185        {
16186            let to_remove = ["name"];
16187            params.remove_params(&to_remove);
16188        }
16189
16190        let url = params.parse_with_url(&url);
16191
16192        loop {
16193            let token = match self
16194                .hub
16195                .auth
16196                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16197                .await
16198            {
16199                Ok(token) => token,
16200                Err(e) => match dlg.token(e) {
16201                    Ok(token) => token,
16202                    Err(e) => {
16203                        dlg.finished(false);
16204                        return Err(common::Error::MissingToken(e));
16205                    }
16206                },
16207            };
16208            let mut req_result = {
16209                let client = &self.hub.client;
16210                dlg.pre_request();
16211                let mut req_builder = hyper::Request::builder()
16212                    .method(hyper::Method::GET)
16213                    .uri(url.as_str())
16214                    .header(USER_AGENT, self.hub._user_agent.clone());
16215
16216                if let Some(token) = token.as_ref() {
16217                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16218                }
16219
16220                let request = req_builder
16221                    .header(CONTENT_LENGTH, 0_u64)
16222                    .body(common::to_body::<String>(None));
16223
16224                client.request(request.unwrap()).await
16225            };
16226
16227            match req_result {
16228                Err(err) => {
16229                    if let common::Retry::After(d) = dlg.http_error(&err) {
16230                        sleep(d).await;
16231                        continue;
16232                    }
16233                    dlg.finished(false);
16234                    return Err(common::Error::HttpError(err));
16235                }
16236                Ok(res) => {
16237                    let (mut parts, body) = res.into_parts();
16238                    let mut body = common::Body::new(body);
16239                    if !parts.status.is_success() {
16240                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16241                        let error = serde_json::from_str(&common::to_string(&bytes));
16242                        let response = common::to_response(parts, bytes.into());
16243
16244                        if let common::Retry::After(d) =
16245                            dlg.http_failure(&response, error.as_ref().ok())
16246                        {
16247                            sleep(d).await;
16248                            continue;
16249                        }
16250
16251                        dlg.finished(false);
16252
16253                        return Err(match error {
16254                            Ok(value) => common::Error::BadRequest(value),
16255                            _ => common::Error::Failure(response),
16256                        });
16257                    }
16258                    let response = {
16259                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16260                        let encoded = common::to_string(&bytes);
16261                        match serde_json::from_str(&encoded) {
16262                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16263                            Err(error) => {
16264                                dlg.response_json_decode_error(&encoded, &error);
16265                                return Err(common::Error::JsonDecodeError(
16266                                    encoded.to_string(),
16267                                    error,
16268                                ));
16269                            }
16270                        }
16271                    };
16272
16273                    dlg.finished(true);
16274                    return Ok(response);
16275                }
16276            }
16277        }
16278    }
16279
16280    /// Required. The name of the schedule to retrieve. Values are of the form `projects//instances//databases//backupSchedules/`.
16281    ///
16282    /// Sets the *name* path property to the given value.
16283    ///
16284    /// Even though the property as already been set when instantiating this call,
16285    /// we provide this method for API completeness.
16286    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseBackupScheduleGetCall<'a, C> {
16287        self._name = new_value.to_string();
16288        self
16289    }
16290    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16291    /// while executing the actual API request.
16292    ///
16293    /// ````text
16294    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16295    /// ````
16296    ///
16297    /// Sets the *delegate* property to the given value.
16298    pub fn delegate(
16299        mut self,
16300        new_value: &'a mut dyn common::Delegate,
16301    ) -> ProjectInstanceDatabaseBackupScheduleGetCall<'a, C> {
16302        self._delegate = Some(new_value);
16303        self
16304    }
16305
16306    /// Set any additional parameter of the query string used in the request.
16307    /// It should be used to set parameters which are not yet available through their own
16308    /// setters.
16309    ///
16310    /// Please note that this method must not be used to set any of the known parameters
16311    /// which have their own setter method. If done anyway, the request will fail.
16312    ///
16313    /// # Additional Parameters
16314    ///
16315    /// * *$.xgafv* (query-string) - V1 error format.
16316    /// * *access_token* (query-string) - OAuth access token.
16317    /// * *alt* (query-string) - Data format for response.
16318    /// * *callback* (query-string) - JSONP
16319    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16320    /// * *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.
16321    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16322    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16323    /// * *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.
16324    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16325    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16326    pub fn param<T>(
16327        mut self,
16328        name: T,
16329        value: T,
16330    ) -> ProjectInstanceDatabaseBackupScheduleGetCall<'a, C>
16331    where
16332        T: AsRef<str>,
16333    {
16334        self._additional_params
16335            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16336        self
16337    }
16338
16339    /// Identifies the authorization scope for the method you are building.
16340    ///
16341    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16342    /// [`Scope::CloudPlatform`].
16343    ///
16344    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16345    /// tokens for more than one scope.
16346    ///
16347    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16348    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16349    /// sufficient, a read-write scope will do as well.
16350    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseBackupScheduleGetCall<'a, C>
16351    where
16352        St: AsRef<str>,
16353    {
16354        self._scopes.insert(String::from(scope.as_ref()));
16355        self
16356    }
16357    /// Identifies the authorization scope(s) for the method you are building.
16358    ///
16359    /// See [`Self::add_scope()`] for details.
16360    pub fn add_scopes<I, St>(
16361        mut self,
16362        scopes: I,
16363    ) -> ProjectInstanceDatabaseBackupScheduleGetCall<'a, C>
16364    where
16365        I: IntoIterator<Item = St>,
16366        St: AsRef<str>,
16367    {
16368        self._scopes
16369            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16370        self
16371    }
16372
16373    /// Removes all scopes, and no default scope will be used either.
16374    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16375    /// for details).
16376    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseBackupScheduleGetCall<'a, C> {
16377        self._scopes.clear();
16378        self
16379    }
16380}
16381
16382/// Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set. Authorization requires `spanner.databases.getIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.getIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.getIamPolicy` permission on resource.
16383///
16384/// A builder for the *instances.databases.backupSchedules.getIamPolicy* method supported by a *project* resource.
16385/// It is not used directly, but through a [`ProjectMethods`] instance.
16386///
16387/// # Example
16388///
16389/// Instantiate a resource method builder
16390///
16391/// ```test_harness,no_run
16392/// # extern crate hyper;
16393/// # extern crate hyper_rustls;
16394/// # extern crate google_spanner1 as spanner1;
16395/// use spanner1::api::GetIamPolicyRequest;
16396/// # async fn dox() {
16397/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16398///
16399/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16400/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16401/// #     .with_native_roots()
16402/// #     .unwrap()
16403/// #     .https_only()
16404/// #     .enable_http2()
16405/// #     .build();
16406///
16407/// # let executor = hyper_util::rt::TokioExecutor::new();
16408/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16409/// #     secret,
16410/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16411/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16412/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16413/// #     ),
16414/// # ).build().await.unwrap();
16415///
16416/// # let client = hyper_util::client::legacy::Client::builder(
16417/// #     hyper_util::rt::TokioExecutor::new()
16418/// # )
16419/// # .build(
16420/// #     hyper_rustls::HttpsConnectorBuilder::new()
16421/// #         .with_native_roots()
16422/// #         .unwrap()
16423/// #         .https_or_http()
16424/// #         .enable_http2()
16425/// #         .build()
16426/// # );
16427/// # let mut hub = Spanner::new(client, auth);
16428/// // As the method needs a request, you would usually fill it with the desired information
16429/// // into the respective structure. Some of the parts shown here might not be applicable !
16430/// // Values shown here are possibly random and not representative !
16431/// let mut req = GetIamPolicyRequest::default();
16432///
16433/// // You can configure optional parameters by calling the respective setters at will, and
16434/// // execute the final call using `doit()`.
16435/// // Values shown here are possibly random and not representative !
16436/// let result = hub.projects().instances_databases_backup_schedules_get_iam_policy(req, "resource")
16437///              .doit().await;
16438/// # }
16439/// ```
16440pub struct ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C>
16441where
16442    C: 'a,
16443{
16444    hub: &'a Spanner<C>,
16445    _request: GetIamPolicyRequest,
16446    _resource: String,
16447    _delegate: Option<&'a mut dyn common::Delegate>,
16448    _additional_params: HashMap<String, String>,
16449    _scopes: BTreeSet<String>,
16450}
16451
16452impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C> {}
16453
16454impl<'a, C> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C>
16455where
16456    C: common::Connector,
16457{
16458    /// Perform the operation you have build so far.
16459    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
16460        use std::borrow::Cow;
16461        use std::io::{Read, Seek};
16462
16463        use common::{url::Params, ToParts};
16464        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16465
16466        let mut dd = common::DefaultDelegate;
16467        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16468        dlg.begin(common::MethodInfo {
16469            id: "spanner.projects.instances.databases.backupSchedules.getIamPolicy",
16470            http_method: hyper::Method::POST,
16471        });
16472
16473        for &field in ["alt", "resource"].iter() {
16474            if self._additional_params.contains_key(field) {
16475                dlg.finished(false);
16476                return Err(common::Error::FieldClash(field));
16477            }
16478        }
16479
16480        let mut params = Params::with_capacity(4 + self._additional_params.len());
16481        params.push("resource", self._resource);
16482
16483        params.extend(self._additional_params.iter());
16484
16485        params.push("alt", "json");
16486        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
16487        if self._scopes.is_empty() {
16488            self._scopes
16489                .insert(Scope::CloudPlatform.as_ref().to_string());
16490        }
16491
16492        #[allow(clippy::single_element_loop)]
16493        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
16494            url = params.uri_replacement(url, param_name, find_this, true);
16495        }
16496        {
16497            let to_remove = ["resource"];
16498            params.remove_params(&to_remove);
16499        }
16500
16501        let url = params.parse_with_url(&url);
16502
16503        let mut json_mime_type = mime::APPLICATION_JSON;
16504        let mut request_value_reader = {
16505            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16506            common::remove_json_null_values(&mut value);
16507            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16508            serde_json::to_writer(&mut dst, &value).unwrap();
16509            dst
16510        };
16511        let request_size = request_value_reader
16512            .seek(std::io::SeekFrom::End(0))
16513            .unwrap();
16514        request_value_reader
16515            .seek(std::io::SeekFrom::Start(0))
16516            .unwrap();
16517
16518        loop {
16519            let token = match self
16520                .hub
16521                .auth
16522                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16523                .await
16524            {
16525                Ok(token) => token,
16526                Err(e) => match dlg.token(e) {
16527                    Ok(token) => token,
16528                    Err(e) => {
16529                        dlg.finished(false);
16530                        return Err(common::Error::MissingToken(e));
16531                    }
16532                },
16533            };
16534            request_value_reader
16535                .seek(std::io::SeekFrom::Start(0))
16536                .unwrap();
16537            let mut req_result = {
16538                let client = &self.hub.client;
16539                dlg.pre_request();
16540                let mut req_builder = hyper::Request::builder()
16541                    .method(hyper::Method::POST)
16542                    .uri(url.as_str())
16543                    .header(USER_AGENT, self.hub._user_agent.clone());
16544
16545                if let Some(token) = token.as_ref() {
16546                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16547                }
16548
16549                let request = req_builder
16550                    .header(CONTENT_TYPE, json_mime_type.to_string())
16551                    .header(CONTENT_LENGTH, request_size as u64)
16552                    .body(common::to_body(
16553                        request_value_reader.get_ref().clone().into(),
16554                    ));
16555
16556                client.request(request.unwrap()).await
16557            };
16558
16559            match req_result {
16560                Err(err) => {
16561                    if let common::Retry::After(d) = dlg.http_error(&err) {
16562                        sleep(d).await;
16563                        continue;
16564                    }
16565                    dlg.finished(false);
16566                    return Err(common::Error::HttpError(err));
16567                }
16568                Ok(res) => {
16569                    let (mut parts, body) = res.into_parts();
16570                    let mut body = common::Body::new(body);
16571                    if !parts.status.is_success() {
16572                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16573                        let error = serde_json::from_str(&common::to_string(&bytes));
16574                        let response = common::to_response(parts, bytes.into());
16575
16576                        if let common::Retry::After(d) =
16577                            dlg.http_failure(&response, error.as_ref().ok())
16578                        {
16579                            sleep(d).await;
16580                            continue;
16581                        }
16582
16583                        dlg.finished(false);
16584
16585                        return Err(match error {
16586                            Ok(value) => common::Error::BadRequest(value),
16587                            _ => common::Error::Failure(response),
16588                        });
16589                    }
16590                    let response = {
16591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16592                        let encoded = common::to_string(&bytes);
16593                        match serde_json::from_str(&encoded) {
16594                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16595                            Err(error) => {
16596                                dlg.response_json_decode_error(&encoded, &error);
16597                                return Err(common::Error::JsonDecodeError(
16598                                    encoded.to_string(),
16599                                    error,
16600                                ));
16601                            }
16602                        }
16603                    };
16604
16605                    dlg.finished(true);
16606                    return Ok(response);
16607                }
16608            }
16609        }
16610    }
16611
16612    ///
16613    /// Sets the *request* property to the given value.
16614    ///
16615    /// Even though the property as already been set when instantiating this call,
16616    /// we provide this method for API completeness.
16617    pub fn request(
16618        mut self,
16619        new_value: GetIamPolicyRequest,
16620    ) -> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C> {
16621        self._request = new_value;
16622        self
16623    }
16624    /// REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
16625    ///
16626    /// Sets the *resource* path property to the given value.
16627    ///
16628    /// Even though the property as already been set when instantiating this call,
16629    /// we provide this method for API completeness.
16630    pub fn resource(
16631        mut self,
16632        new_value: &str,
16633    ) -> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C> {
16634        self._resource = new_value.to_string();
16635        self
16636    }
16637    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16638    /// while executing the actual API request.
16639    ///
16640    /// ````text
16641    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16642    /// ````
16643    ///
16644    /// Sets the *delegate* property to the given value.
16645    pub fn delegate(
16646        mut self,
16647        new_value: &'a mut dyn common::Delegate,
16648    ) -> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C> {
16649        self._delegate = Some(new_value);
16650        self
16651    }
16652
16653    /// Set any additional parameter of the query string used in the request.
16654    /// It should be used to set parameters which are not yet available through their own
16655    /// setters.
16656    ///
16657    /// Please note that this method must not be used to set any of the known parameters
16658    /// which have their own setter method. If done anyway, the request will fail.
16659    ///
16660    /// # Additional Parameters
16661    ///
16662    /// * *$.xgafv* (query-string) - V1 error format.
16663    /// * *access_token* (query-string) - OAuth access token.
16664    /// * *alt* (query-string) - Data format for response.
16665    /// * *callback* (query-string) - JSONP
16666    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16667    /// * *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.
16668    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16669    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16670    /// * *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.
16671    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16672    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16673    pub fn param<T>(
16674        mut self,
16675        name: T,
16676        value: T,
16677    ) -> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C>
16678    where
16679        T: AsRef<str>,
16680    {
16681        self._additional_params
16682            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16683        self
16684    }
16685
16686    /// Identifies the authorization scope for the method you are building.
16687    ///
16688    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16689    /// [`Scope::CloudPlatform`].
16690    ///
16691    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16692    /// tokens for more than one scope.
16693    ///
16694    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16695    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16696    /// sufficient, a read-write scope will do as well.
16697    pub fn add_scope<St>(
16698        mut self,
16699        scope: St,
16700    ) -> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C>
16701    where
16702        St: AsRef<str>,
16703    {
16704        self._scopes.insert(String::from(scope.as_ref()));
16705        self
16706    }
16707    /// Identifies the authorization scope(s) for the method you are building.
16708    ///
16709    /// See [`Self::add_scope()`] for details.
16710    pub fn add_scopes<I, St>(
16711        mut self,
16712        scopes: I,
16713    ) -> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C>
16714    where
16715        I: IntoIterator<Item = St>,
16716        St: AsRef<str>,
16717    {
16718        self._scopes
16719            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16720        self
16721    }
16722
16723    /// Removes all scopes, and no default scope will be used either.
16724    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16725    /// for details).
16726    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseBackupScheduleGetIamPolicyCall<'a, C> {
16727        self._scopes.clear();
16728        self
16729    }
16730}
16731
16732/// Lists all the backup schedules for the database.
16733///
16734/// A builder for the *instances.databases.backupSchedules.list* method supported by a *project* resource.
16735/// It is not used directly, but through a [`ProjectMethods`] instance.
16736///
16737/// # Example
16738///
16739/// Instantiate a resource method builder
16740///
16741/// ```test_harness,no_run
16742/// # extern crate hyper;
16743/// # extern crate hyper_rustls;
16744/// # extern crate google_spanner1 as spanner1;
16745/// # async fn dox() {
16746/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16747///
16748/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16749/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16750/// #     .with_native_roots()
16751/// #     .unwrap()
16752/// #     .https_only()
16753/// #     .enable_http2()
16754/// #     .build();
16755///
16756/// # let executor = hyper_util::rt::TokioExecutor::new();
16757/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16758/// #     secret,
16759/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16760/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16761/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16762/// #     ),
16763/// # ).build().await.unwrap();
16764///
16765/// # let client = hyper_util::client::legacy::Client::builder(
16766/// #     hyper_util::rt::TokioExecutor::new()
16767/// # )
16768/// # .build(
16769/// #     hyper_rustls::HttpsConnectorBuilder::new()
16770/// #         .with_native_roots()
16771/// #         .unwrap()
16772/// #         .https_or_http()
16773/// #         .enable_http2()
16774/// #         .build()
16775/// # );
16776/// # let mut hub = Spanner::new(client, auth);
16777/// // You can configure optional parameters by calling the respective setters at will, and
16778/// // execute the final call using `doit()`.
16779/// // Values shown here are possibly random and not representative !
16780/// let result = hub.projects().instances_databases_backup_schedules_list("parent")
16781///              .page_token("gubergren")
16782///              .page_size(-74)
16783///              .doit().await;
16784/// # }
16785/// ```
16786pub struct ProjectInstanceDatabaseBackupScheduleListCall<'a, C>
16787where
16788    C: 'a,
16789{
16790    hub: &'a Spanner<C>,
16791    _parent: String,
16792    _page_token: Option<String>,
16793    _page_size: Option<i32>,
16794    _delegate: Option<&'a mut dyn common::Delegate>,
16795    _additional_params: HashMap<String, String>,
16796    _scopes: BTreeSet<String>,
16797}
16798
16799impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseBackupScheduleListCall<'a, C> {}
16800
16801impl<'a, C> ProjectInstanceDatabaseBackupScheduleListCall<'a, C>
16802where
16803    C: common::Connector,
16804{
16805    /// Perform the operation you have build so far.
16806    pub async fn doit(mut self) -> common::Result<(common::Response, ListBackupSchedulesResponse)> {
16807        use std::borrow::Cow;
16808        use std::io::{Read, Seek};
16809
16810        use common::{url::Params, ToParts};
16811        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16812
16813        let mut dd = common::DefaultDelegate;
16814        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16815        dlg.begin(common::MethodInfo {
16816            id: "spanner.projects.instances.databases.backupSchedules.list",
16817            http_method: hyper::Method::GET,
16818        });
16819
16820        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
16821            if self._additional_params.contains_key(field) {
16822                dlg.finished(false);
16823                return Err(common::Error::FieldClash(field));
16824            }
16825        }
16826
16827        let mut params = Params::with_capacity(5 + self._additional_params.len());
16828        params.push("parent", self._parent);
16829        if let Some(value) = self._page_token.as_ref() {
16830            params.push("pageToken", value);
16831        }
16832        if let Some(value) = self._page_size.as_ref() {
16833            params.push("pageSize", value.to_string());
16834        }
16835
16836        params.extend(self._additional_params.iter());
16837
16838        params.push("alt", "json");
16839        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backupSchedules";
16840        if self._scopes.is_empty() {
16841            self._scopes
16842                .insert(Scope::CloudPlatform.as_ref().to_string());
16843        }
16844
16845        #[allow(clippy::single_element_loop)]
16846        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16847            url = params.uri_replacement(url, param_name, find_this, true);
16848        }
16849        {
16850            let to_remove = ["parent"];
16851            params.remove_params(&to_remove);
16852        }
16853
16854        let url = params.parse_with_url(&url);
16855
16856        loop {
16857            let token = match self
16858                .hub
16859                .auth
16860                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16861                .await
16862            {
16863                Ok(token) => token,
16864                Err(e) => match dlg.token(e) {
16865                    Ok(token) => token,
16866                    Err(e) => {
16867                        dlg.finished(false);
16868                        return Err(common::Error::MissingToken(e));
16869                    }
16870                },
16871            };
16872            let mut req_result = {
16873                let client = &self.hub.client;
16874                dlg.pre_request();
16875                let mut req_builder = hyper::Request::builder()
16876                    .method(hyper::Method::GET)
16877                    .uri(url.as_str())
16878                    .header(USER_AGENT, self.hub._user_agent.clone());
16879
16880                if let Some(token) = token.as_ref() {
16881                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16882                }
16883
16884                let request = req_builder
16885                    .header(CONTENT_LENGTH, 0_u64)
16886                    .body(common::to_body::<String>(None));
16887
16888                client.request(request.unwrap()).await
16889            };
16890
16891            match req_result {
16892                Err(err) => {
16893                    if let common::Retry::After(d) = dlg.http_error(&err) {
16894                        sleep(d).await;
16895                        continue;
16896                    }
16897                    dlg.finished(false);
16898                    return Err(common::Error::HttpError(err));
16899                }
16900                Ok(res) => {
16901                    let (mut parts, body) = res.into_parts();
16902                    let mut body = common::Body::new(body);
16903                    if !parts.status.is_success() {
16904                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16905                        let error = serde_json::from_str(&common::to_string(&bytes));
16906                        let response = common::to_response(parts, bytes.into());
16907
16908                        if let common::Retry::After(d) =
16909                            dlg.http_failure(&response, error.as_ref().ok())
16910                        {
16911                            sleep(d).await;
16912                            continue;
16913                        }
16914
16915                        dlg.finished(false);
16916
16917                        return Err(match error {
16918                            Ok(value) => common::Error::BadRequest(value),
16919                            _ => common::Error::Failure(response),
16920                        });
16921                    }
16922                    let response = {
16923                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16924                        let encoded = common::to_string(&bytes);
16925                        match serde_json::from_str(&encoded) {
16926                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16927                            Err(error) => {
16928                                dlg.response_json_decode_error(&encoded, &error);
16929                                return Err(common::Error::JsonDecodeError(
16930                                    encoded.to_string(),
16931                                    error,
16932                                ));
16933                            }
16934                        }
16935                    };
16936
16937                    dlg.finished(true);
16938                    return Ok(response);
16939                }
16940            }
16941        }
16942    }
16943
16944    /// Required. Database is the parent resource whose backup schedules should be listed. Values are of the form projects//instances//databases/
16945    ///
16946    /// Sets the *parent* path property to the given value.
16947    ///
16948    /// Even though the property as already been set when instantiating this call,
16949    /// we provide this method for API completeness.
16950    pub fn parent(
16951        mut self,
16952        new_value: &str,
16953    ) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C> {
16954        self._parent = new_value.to_string();
16955        self
16956    }
16957    /// Optional. If non-empty, `page_token` should contain a next_page_token from a previous ListBackupSchedulesResponse to the same `parent`.
16958    ///
16959    /// Sets the *page token* query property to the given value.
16960    pub fn page_token(
16961        mut self,
16962        new_value: &str,
16963    ) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C> {
16964        self._page_token = Some(new_value.to_string());
16965        self
16966    }
16967    /// Optional. Number of backup schedules to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
16968    ///
16969    /// Sets the *page size* query property to the given value.
16970    pub fn page_size(
16971        mut self,
16972        new_value: i32,
16973    ) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C> {
16974        self._page_size = Some(new_value);
16975        self
16976    }
16977    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16978    /// while executing the actual API request.
16979    ///
16980    /// ````text
16981    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16982    /// ````
16983    ///
16984    /// Sets the *delegate* property to the given value.
16985    pub fn delegate(
16986        mut self,
16987        new_value: &'a mut dyn common::Delegate,
16988    ) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C> {
16989        self._delegate = Some(new_value);
16990        self
16991    }
16992
16993    /// Set any additional parameter of the query string used in the request.
16994    /// It should be used to set parameters which are not yet available through their own
16995    /// setters.
16996    ///
16997    /// Please note that this method must not be used to set any of the known parameters
16998    /// which have their own setter method. If done anyway, the request will fail.
16999    ///
17000    /// # Additional Parameters
17001    ///
17002    /// * *$.xgafv* (query-string) - V1 error format.
17003    /// * *access_token* (query-string) - OAuth access token.
17004    /// * *alt* (query-string) - Data format for response.
17005    /// * *callback* (query-string) - JSONP
17006    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17007    /// * *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.
17008    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17009    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17010    /// * *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.
17011    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17012    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17013    pub fn param<T>(
17014        mut self,
17015        name: T,
17016        value: T,
17017    ) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C>
17018    where
17019        T: AsRef<str>,
17020    {
17021        self._additional_params
17022            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17023        self
17024    }
17025
17026    /// Identifies the authorization scope for the method you are building.
17027    ///
17028    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17029    /// [`Scope::CloudPlatform`].
17030    ///
17031    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17032    /// tokens for more than one scope.
17033    ///
17034    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17035    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17036    /// sufficient, a read-write scope will do as well.
17037    pub fn add_scope<St>(
17038        mut self,
17039        scope: St,
17040    ) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C>
17041    where
17042        St: AsRef<str>,
17043    {
17044        self._scopes.insert(String::from(scope.as_ref()));
17045        self
17046    }
17047    /// Identifies the authorization scope(s) for the method you are building.
17048    ///
17049    /// See [`Self::add_scope()`] for details.
17050    pub fn add_scopes<I, St>(
17051        mut self,
17052        scopes: I,
17053    ) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C>
17054    where
17055        I: IntoIterator<Item = St>,
17056        St: AsRef<str>,
17057    {
17058        self._scopes
17059            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17060        self
17061    }
17062
17063    /// Removes all scopes, and no default scope will be used either.
17064    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17065    /// for details).
17066    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseBackupScheduleListCall<'a, C> {
17067        self._scopes.clear();
17068        self
17069    }
17070}
17071
17072/// Updates a backup schedule.
17073///
17074/// A builder for the *instances.databases.backupSchedules.patch* method supported by a *project* resource.
17075/// It is not used directly, but through a [`ProjectMethods`] instance.
17076///
17077/// # Example
17078///
17079/// Instantiate a resource method builder
17080///
17081/// ```test_harness,no_run
17082/// # extern crate hyper;
17083/// # extern crate hyper_rustls;
17084/// # extern crate google_spanner1 as spanner1;
17085/// use spanner1::api::BackupSchedule;
17086/// # async fn dox() {
17087/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17088///
17089/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17090/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17091/// #     .with_native_roots()
17092/// #     .unwrap()
17093/// #     .https_only()
17094/// #     .enable_http2()
17095/// #     .build();
17096///
17097/// # let executor = hyper_util::rt::TokioExecutor::new();
17098/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17099/// #     secret,
17100/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17101/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17102/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17103/// #     ),
17104/// # ).build().await.unwrap();
17105///
17106/// # let client = hyper_util::client::legacy::Client::builder(
17107/// #     hyper_util::rt::TokioExecutor::new()
17108/// # )
17109/// # .build(
17110/// #     hyper_rustls::HttpsConnectorBuilder::new()
17111/// #         .with_native_roots()
17112/// #         .unwrap()
17113/// #         .https_or_http()
17114/// #         .enable_http2()
17115/// #         .build()
17116/// # );
17117/// # let mut hub = Spanner::new(client, auth);
17118/// // As the method needs a request, you would usually fill it with the desired information
17119/// // into the respective structure. Some of the parts shown here might not be applicable !
17120/// // Values shown here are possibly random and not representative !
17121/// let mut req = BackupSchedule::default();
17122///
17123/// // You can configure optional parameters by calling the respective setters at will, and
17124/// // execute the final call using `doit()`.
17125/// // Values shown here are possibly random and not representative !
17126/// let result = hub.projects().instances_databases_backup_schedules_patch(req, "name")
17127///              .update_mask(FieldMask::new::<&str>(&[]))
17128///              .doit().await;
17129/// # }
17130/// ```
17131pub struct ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C>
17132where
17133    C: 'a,
17134{
17135    hub: &'a Spanner<C>,
17136    _request: BackupSchedule,
17137    _name: String,
17138    _update_mask: Option<common::FieldMask>,
17139    _delegate: Option<&'a mut dyn common::Delegate>,
17140    _additional_params: HashMap<String, String>,
17141    _scopes: BTreeSet<String>,
17142}
17143
17144impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C> {}
17145
17146impl<'a, C> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C>
17147where
17148    C: common::Connector,
17149{
17150    /// Perform the operation you have build so far.
17151    pub async fn doit(mut self) -> common::Result<(common::Response, BackupSchedule)> {
17152        use std::borrow::Cow;
17153        use std::io::{Read, Seek};
17154
17155        use common::{url::Params, ToParts};
17156        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17157
17158        let mut dd = common::DefaultDelegate;
17159        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17160        dlg.begin(common::MethodInfo {
17161            id: "spanner.projects.instances.databases.backupSchedules.patch",
17162            http_method: hyper::Method::PATCH,
17163        });
17164
17165        for &field in ["alt", "name", "updateMask"].iter() {
17166            if self._additional_params.contains_key(field) {
17167                dlg.finished(false);
17168                return Err(common::Error::FieldClash(field));
17169            }
17170        }
17171
17172        let mut params = Params::with_capacity(5 + self._additional_params.len());
17173        params.push("name", self._name);
17174        if let Some(value) = self._update_mask.as_ref() {
17175            params.push("updateMask", value.to_string());
17176        }
17177
17178        params.extend(self._additional_params.iter());
17179
17180        params.push("alt", "json");
17181        let mut url = self.hub._base_url.clone() + "v1/{+name}";
17182        if self._scopes.is_empty() {
17183            self._scopes
17184                .insert(Scope::CloudPlatform.as_ref().to_string());
17185        }
17186
17187        #[allow(clippy::single_element_loop)]
17188        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17189            url = params.uri_replacement(url, param_name, find_this, true);
17190        }
17191        {
17192            let to_remove = ["name"];
17193            params.remove_params(&to_remove);
17194        }
17195
17196        let url = params.parse_with_url(&url);
17197
17198        let mut json_mime_type = mime::APPLICATION_JSON;
17199        let mut request_value_reader = {
17200            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17201            common::remove_json_null_values(&mut value);
17202            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17203            serde_json::to_writer(&mut dst, &value).unwrap();
17204            dst
17205        };
17206        let request_size = request_value_reader
17207            .seek(std::io::SeekFrom::End(0))
17208            .unwrap();
17209        request_value_reader
17210            .seek(std::io::SeekFrom::Start(0))
17211            .unwrap();
17212
17213        loop {
17214            let token = match self
17215                .hub
17216                .auth
17217                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17218                .await
17219            {
17220                Ok(token) => token,
17221                Err(e) => match dlg.token(e) {
17222                    Ok(token) => token,
17223                    Err(e) => {
17224                        dlg.finished(false);
17225                        return Err(common::Error::MissingToken(e));
17226                    }
17227                },
17228            };
17229            request_value_reader
17230                .seek(std::io::SeekFrom::Start(0))
17231                .unwrap();
17232            let mut req_result = {
17233                let client = &self.hub.client;
17234                dlg.pre_request();
17235                let mut req_builder = hyper::Request::builder()
17236                    .method(hyper::Method::PATCH)
17237                    .uri(url.as_str())
17238                    .header(USER_AGENT, self.hub._user_agent.clone());
17239
17240                if let Some(token) = token.as_ref() {
17241                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17242                }
17243
17244                let request = req_builder
17245                    .header(CONTENT_TYPE, json_mime_type.to_string())
17246                    .header(CONTENT_LENGTH, request_size as u64)
17247                    .body(common::to_body(
17248                        request_value_reader.get_ref().clone().into(),
17249                    ));
17250
17251                client.request(request.unwrap()).await
17252            };
17253
17254            match req_result {
17255                Err(err) => {
17256                    if let common::Retry::After(d) = dlg.http_error(&err) {
17257                        sleep(d).await;
17258                        continue;
17259                    }
17260                    dlg.finished(false);
17261                    return Err(common::Error::HttpError(err));
17262                }
17263                Ok(res) => {
17264                    let (mut parts, body) = res.into_parts();
17265                    let mut body = common::Body::new(body);
17266                    if !parts.status.is_success() {
17267                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17268                        let error = serde_json::from_str(&common::to_string(&bytes));
17269                        let response = common::to_response(parts, bytes.into());
17270
17271                        if let common::Retry::After(d) =
17272                            dlg.http_failure(&response, error.as_ref().ok())
17273                        {
17274                            sleep(d).await;
17275                            continue;
17276                        }
17277
17278                        dlg.finished(false);
17279
17280                        return Err(match error {
17281                            Ok(value) => common::Error::BadRequest(value),
17282                            _ => common::Error::Failure(response),
17283                        });
17284                    }
17285                    let response = {
17286                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17287                        let encoded = common::to_string(&bytes);
17288                        match serde_json::from_str(&encoded) {
17289                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17290                            Err(error) => {
17291                                dlg.response_json_decode_error(&encoded, &error);
17292                                return Err(common::Error::JsonDecodeError(
17293                                    encoded.to_string(),
17294                                    error,
17295                                ));
17296                            }
17297                        }
17298                    };
17299
17300                    dlg.finished(true);
17301                    return Ok(response);
17302                }
17303            }
17304        }
17305    }
17306
17307    ///
17308    /// Sets the *request* property to the given value.
17309    ///
17310    /// Even though the property as already been set when instantiating this call,
17311    /// we provide this method for API completeness.
17312    pub fn request(
17313        mut self,
17314        new_value: BackupSchedule,
17315    ) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C> {
17316        self._request = new_value;
17317        self
17318    }
17319    /// Identifier. Output only for the CreateBackupSchedule operation. Required for the UpdateBackupSchedule operation. A globally unique identifier for the backup schedule which cannot be changed. Values are of the form `projects//instances//databases//backupSchedules/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length.
17320    ///
17321    /// Sets the *name* path property to the given value.
17322    ///
17323    /// Even though the property as already been set when instantiating this call,
17324    /// we provide this method for API completeness.
17325    pub fn name(
17326        mut self,
17327        new_value: &str,
17328    ) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C> {
17329        self._name = new_value.to_string();
17330        self
17331    }
17332    /// Required. A mask specifying which fields in the BackupSchedule resource should be updated. This mask is relative to the BackupSchedule resource, not to the request message. The field mask must always be specified; this prevents any future fields from being erased accidentally.
17333    ///
17334    /// Sets the *update mask* query property to the given value.
17335    pub fn update_mask(
17336        mut self,
17337        new_value: common::FieldMask,
17338    ) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C> {
17339        self._update_mask = Some(new_value);
17340        self
17341    }
17342    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17343    /// while executing the actual API request.
17344    ///
17345    /// ````text
17346    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17347    /// ````
17348    ///
17349    /// Sets the *delegate* property to the given value.
17350    pub fn delegate(
17351        mut self,
17352        new_value: &'a mut dyn common::Delegate,
17353    ) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C> {
17354        self._delegate = Some(new_value);
17355        self
17356    }
17357
17358    /// Set any additional parameter of the query string used in the request.
17359    /// It should be used to set parameters which are not yet available through their own
17360    /// setters.
17361    ///
17362    /// Please note that this method must not be used to set any of the known parameters
17363    /// which have their own setter method. If done anyway, the request will fail.
17364    ///
17365    /// # Additional Parameters
17366    ///
17367    /// * *$.xgafv* (query-string) - V1 error format.
17368    /// * *access_token* (query-string) - OAuth access token.
17369    /// * *alt* (query-string) - Data format for response.
17370    /// * *callback* (query-string) - JSONP
17371    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17372    /// * *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.
17373    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17374    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17375    /// * *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.
17376    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17377    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17378    pub fn param<T>(
17379        mut self,
17380        name: T,
17381        value: T,
17382    ) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C>
17383    where
17384        T: AsRef<str>,
17385    {
17386        self._additional_params
17387            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17388        self
17389    }
17390
17391    /// Identifies the authorization scope for the method you are building.
17392    ///
17393    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17394    /// [`Scope::CloudPlatform`].
17395    ///
17396    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17397    /// tokens for more than one scope.
17398    ///
17399    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17400    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17401    /// sufficient, a read-write scope will do as well.
17402    pub fn add_scope<St>(
17403        mut self,
17404        scope: St,
17405    ) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C>
17406    where
17407        St: AsRef<str>,
17408    {
17409        self._scopes.insert(String::from(scope.as_ref()));
17410        self
17411    }
17412    /// Identifies the authorization scope(s) for the method you are building.
17413    ///
17414    /// See [`Self::add_scope()`] for details.
17415    pub fn add_scopes<I, St>(
17416        mut self,
17417        scopes: I,
17418    ) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C>
17419    where
17420        I: IntoIterator<Item = St>,
17421        St: AsRef<str>,
17422    {
17423        self._scopes
17424            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17425        self
17426    }
17427
17428    /// Removes all scopes, and no default scope will be used either.
17429    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17430    /// for details).
17431    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseBackupSchedulePatchCall<'a, C> {
17432        self._scopes.clear();
17433        self
17434    }
17435}
17436
17437/// Sets the access control policy on a database or backup resource. Replaces any existing policy. Authorization requires `spanner.databases.setIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.setIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.setIamPolicy` permission on resource.
17438///
17439/// A builder for the *instances.databases.backupSchedules.setIamPolicy* method supported by a *project* resource.
17440/// It is not used directly, but through a [`ProjectMethods`] instance.
17441///
17442/// # Example
17443///
17444/// Instantiate a resource method builder
17445///
17446/// ```test_harness,no_run
17447/// # extern crate hyper;
17448/// # extern crate hyper_rustls;
17449/// # extern crate google_spanner1 as spanner1;
17450/// use spanner1::api::SetIamPolicyRequest;
17451/// # async fn dox() {
17452/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17453///
17454/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17455/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17456/// #     .with_native_roots()
17457/// #     .unwrap()
17458/// #     .https_only()
17459/// #     .enable_http2()
17460/// #     .build();
17461///
17462/// # let executor = hyper_util::rt::TokioExecutor::new();
17463/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17464/// #     secret,
17465/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17466/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17467/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17468/// #     ),
17469/// # ).build().await.unwrap();
17470///
17471/// # let client = hyper_util::client::legacy::Client::builder(
17472/// #     hyper_util::rt::TokioExecutor::new()
17473/// # )
17474/// # .build(
17475/// #     hyper_rustls::HttpsConnectorBuilder::new()
17476/// #         .with_native_roots()
17477/// #         .unwrap()
17478/// #         .https_or_http()
17479/// #         .enable_http2()
17480/// #         .build()
17481/// # );
17482/// # let mut hub = Spanner::new(client, auth);
17483/// // As the method needs a request, you would usually fill it with the desired information
17484/// // into the respective structure. Some of the parts shown here might not be applicable !
17485/// // Values shown here are possibly random and not representative !
17486/// let mut req = SetIamPolicyRequest::default();
17487///
17488/// // You can configure optional parameters by calling the respective setters at will, and
17489/// // execute the final call using `doit()`.
17490/// // Values shown here are possibly random and not representative !
17491/// let result = hub.projects().instances_databases_backup_schedules_set_iam_policy(req, "resource")
17492///              .doit().await;
17493/// # }
17494/// ```
17495pub struct ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C>
17496where
17497    C: 'a,
17498{
17499    hub: &'a Spanner<C>,
17500    _request: SetIamPolicyRequest,
17501    _resource: String,
17502    _delegate: Option<&'a mut dyn common::Delegate>,
17503    _additional_params: HashMap<String, String>,
17504    _scopes: BTreeSet<String>,
17505}
17506
17507impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C> {}
17508
17509impl<'a, C> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C>
17510where
17511    C: common::Connector,
17512{
17513    /// Perform the operation you have build so far.
17514    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17515        use std::borrow::Cow;
17516        use std::io::{Read, Seek};
17517
17518        use common::{url::Params, ToParts};
17519        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17520
17521        let mut dd = common::DefaultDelegate;
17522        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17523        dlg.begin(common::MethodInfo {
17524            id: "spanner.projects.instances.databases.backupSchedules.setIamPolicy",
17525            http_method: hyper::Method::POST,
17526        });
17527
17528        for &field in ["alt", "resource"].iter() {
17529            if self._additional_params.contains_key(field) {
17530                dlg.finished(false);
17531                return Err(common::Error::FieldClash(field));
17532            }
17533        }
17534
17535        let mut params = Params::with_capacity(4 + self._additional_params.len());
17536        params.push("resource", self._resource);
17537
17538        params.extend(self._additional_params.iter());
17539
17540        params.push("alt", "json");
17541        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
17542        if self._scopes.is_empty() {
17543            self._scopes
17544                .insert(Scope::CloudPlatform.as_ref().to_string());
17545        }
17546
17547        #[allow(clippy::single_element_loop)]
17548        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17549            url = params.uri_replacement(url, param_name, find_this, true);
17550        }
17551        {
17552            let to_remove = ["resource"];
17553            params.remove_params(&to_remove);
17554        }
17555
17556        let url = params.parse_with_url(&url);
17557
17558        let mut json_mime_type = mime::APPLICATION_JSON;
17559        let mut request_value_reader = {
17560            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17561            common::remove_json_null_values(&mut value);
17562            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17563            serde_json::to_writer(&mut dst, &value).unwrap();
17564            dst
17565        };
17566        let request_size = request_value_reader
17567            .seek(std::io::SeekFrom::End(0))
17568            .unwrap();
17569        request_value_reader
17570            .seek(std::io::SeekFrom::Start(0))
17571            .unwrap();
17572
17573        loop {
17574            let token = match self
17575                .hub
17576                .auth
17577                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17578                .await
17579            {
17580                Ok(token) => token,
17581                Err(e) => match dlg.token(e) {
17582                    Ok(token) => token,
17583                    Err(e) => {
17584                        dlg.finished(false);
17585                        return Err(common::Error::MissingToken(e));
17586                    }
17587                },
17588            };
17589            request_value_reader
17590                .seek(std::io::SeekFrom::Start(0))
17591                .unwrap();
17592            let mut req_result = {
17593                let client = &self.hub.client;
17594                dlg.pre_request();
17595                let mut req_builder = hyper::Request::builder()
17596                    .method(hyper::Method::POST)
17597                    .uri(url.as_str())
17598                    .header(USER_AGENT, self.hub._user_agent.clone());
17599
17600                if let Some(token) = token.as_ref() {
17601                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17602                }
17603
17604                let request = req_builder
17605                    .header(CONTENT_TYPE, json_mime_type.to_string())
17606                    .header(CONTENT_LENGTH, request_size as u64)
17607                    .body(common::to_body(
17608                        request_value_reader.get_ref().clone().into(),
17609                    ));
17610
17611                client.request(request.unwrap()).await
17612            };
17613
17614            match req_result {
17615                Err(err) => {
17616                    if let common::Retry::After(d) = dlg.http_error(&err) {
17617                        sleep(d).await;
17618                        continue;
17619                    }
17620                    dlg.finished(false);
17621                    return Err(common::Error::HttpError(err));
17622                }
17623                Ok(res) => {
17624                    let (mut parts, body) = res.into_parts();
17625                    let mut body = common::Body::new(body);
17626                    if !parts.status.is_success() {
17627                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17628                        let error = serde_json::from_str(&common::to_string(&bytes));
17629                        let response = common::to_response(parts, bytes.into());
17630
17631                        if let common::Retry::After(d) =
17632                            dlg.http_failure(&response, error.as_ref().ok())
17633                        {
17634                            sleep(d).await;
17635                            continue;
17636                        }
17637
17638                        dlg.finished(false);
17639
17640                        return Err(match error {
17641                            Ok(value) => common::Error::BadRequest(value),
17642                            _ => common::Error::Failure(response),
17643                        });
17644                    }
17645                    let response = {
17646                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17647                        let encoded = common::to_string(&bytes);
17648                        match serde_json::from_str(&encoded) {
17649                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17650                            Err(error) => {
17651                                dlg.response_json_decode_error(&encoded, &error);
17652                                return Err(common::Error::JsonDecodeError(
17653                                    encoded.to_string(),
17654                                    error,
17655                                ));
17656                            }
17657                        }
17658                    };
17659
17660                    dlg.finished(true);
17661                    return Ok(response);
17662                }
17663            }
17664        }
17665    }
17666
17667    ///
17668    /// Sets the *request* property to the given value.
17669    ///
17670    /// Even though the property as already been set when instantiating this call,
17671    /// we provide this method for API completeness.
17672    pub fn request(
17673        mut self,
17674        new_value: SetIamPolicyRequest,
17675    ) -> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C> {
17676        self._request = new_value;
17677        self
17678    }
17679    /// REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for databases resources.
17680    ///
17681    /// Sets the *resource* path property to the given value.
17682    ///
17683    /// Even though the property as already been set when instantiating this call,
17684    /// we provide this method for API completeness.
17685    pub fn resource(
17686        mut self,
17687        new_value: &str,
17688    ) -> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C> {
17689        self._resource = new_value.to_string();
17690        self
17691    }
17692    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17693    /// while executing the actual API request.
17694    ///
17695    /// ````text
17696    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17697    /// ````
17698    ///
17699    /// Sets the *delegate* property to the given value.
17700    pub fn delegate(
17701        mut self,
17702        new_value: &'a mut dyn common::Delegate,
17703    ) -> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C> {
17704        self._delegate = Some(new_value);
17705        self
17706    }
17707
17708    /// Set any additional parameter of the query string used in the request.
17709    /// It should be used to set parameters which are not yet available through their own
17710    /// setters.
17711    ///
17712    /// Please note that this method must not be used to set any of the known parameters
17713    /// which have their own setter method. If done anyway, the request will fail.
17714    ///
17715    /// # Additional Parameters
17716    ///
17717    /// * *$.xgafv* (query-string) - V1 error format.
17718    /// * *access_token* (query-string) - OAuth access token.
17719    /// * *alt* (query-string) - Data format for response.
17720    /// * *callback* (query-string) - JSONP
17721    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17722    /// * *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.
17723    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17724    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17725    /// * *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.
17726    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17727    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17728    pub fn param<T>(
17729        mut self,
17730        name: T,
17731        value: T,
17732    ) -> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C>
17733    where
17734        T: AsRef<str>,
17735    {
17736        self._additional_params
17737            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17738        self
17739    }
17740
17741    /// Identifies the authorization scope for the method you are building.
17742    ///
17743    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17744    /// [`Scope::CloudPlatform`].
17745    ///
17746    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17747    /// tokens for more than one scope.
17748    ///
17749    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17750    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17751    /// sufficient, a read-write scope will do as well.
17752    pub fn add_scope<St>(
17753        mut self,
17754        scope: St,
17755    ) -> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C>
17756    where
17757        St: AsRef<str>,
17758    {
17759        self._scopes.insert(String::from(scope.as_ref()));
17760        self
17761    }
17762    /// Identifies the authorization scope(s) for the method you are building.
17763    ///
17764    /// See [`Self::add_scope()`] for details.
17765    pub fn add_scopes<I, St>(
17766        mut self,
17767        scopes: I,
17768    ) -> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C>
17769    where
17770        I: IntoIterator<Item = St>,
17771        St: AsRef<str>,
17772    {
17773        self._scopes
17774            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17775        self
17776    }
17777
17778    /// Removes all scopes, and no default scope will be used either.
17779    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17780    /// for details).
17781    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseBackupScheduleSetIamPolicyCall<'a, C> {
17782        self._scopes.clear();
17783        self
17784    }
17785}
17786
17787/// Returns permissions that the caller has on the specified database or backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance. Calling this method on a backup schedule that does not exist will result in a NOT_FOUND error if the user has `spanner.backupSchedules.list` permission on the containing database.
17788///
17789/// A builder for the *instances.databases.backupSchedules.testIamPermissions* method supported by a *project* resource.
17790/// It is not used directly, but through a [`ProjectMethods`] instance.
17791///
17792/// # Example
17793///
17794/// Instantiate a resource method builder
17795///
17796/// ```test_harness,no_run
17797/// # extern crate hyper;
17798/// # extern crate hyper_rustls;
17799/// # extern crate google_spanner1 as spanner1;
17800/// use spanner1::api::TestIamPermissionsRequest;
17801/// # async fn dox() {
17802/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17803///
17804/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17805/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17806/// #     .with_native_roots()
17807/// #     .unwrap()
17808/// #     .https_only()
17809/// #     .enable_http2()
17810/// #     .build();
17811///
17812/// # let executor = hyper_util::rt::TokioExecutor::new();
17813/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17814/// #     secret,
17815/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17816/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17817/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17818/// #     ),
17819/// # ).build().await.unwrap();
17820///
17821/// # let client = hyper_util::client::legacy::Client::builder(
17822/// #     hyper_util::rt::TokioExecutor::new()
17823/// # )
17824/// # .build(
17825/// #     hyper_rustls::HttpsConnectorBuilder::new()
17826/// #         .with_native_roots()
17827/// #         .unwrap()
17828/// #         .https_or_http()
17829/// #         .enable_http2()
17830/// #         .build()
17831/// # );
17832/// # let mut hub = Spanner::new(client, auth);
17833/// // As the method needs a request, you would usually fill it with the desired information
17834/// // into the respective structure. Some of the parts shown here might not be applicable !
17835/// // Values shown here are possibly random and not representative !
17836/// let mut req = TestIamPermissionsRequest::default();
17837///
17838/// // You can configure optional parameters by calling the respective setters at will, and
17839/// // execute the final call using `doit()`.
17840/// // Values shown here are possibly random and not representative !
17841/// let result = hub.projects().instances_databases_backup_schedules_test_iam_permissions(req, "resource")
17842///              .doit().await;
17843/// # }
17844/// ```
17845pub struct ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C>
17846where
17847    C: 'a,
17848{
17849    hub: &'a Spanner<C>,
17850    _request: TestIamPermissionsRequest,
17851    _resource: String,
17852    _delegate: Option<&'a mut dyn common::Delegate>,
17853    _additional_params: HashMap<String, String>,
17854    _scopes: BTreeSet<String>,
17855}
17856
17857impl<'a, C> common::CallBuilder
17858    for ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C>
17859{
17860}
17861
17862impl<'a, C> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C>
17863where
17864    C: common::Connector,
17865{
17866    /// Perform the operation you have build so far.
17867    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
17868        use std::borrow::Cow;
17869        use std::io::{Read, Seek};
17870
17871        use common::{url::Params, ToParts};
17872        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17873
17874        let mut dd = common::DefaultDelegate;
17875        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17876        dlg.begin(common::MethodInfo {
17877            id: "spanner.projects.instances.databases.backupSchedules.testIamPermissions",
17878            http_method: hyper::Method::POST,
17879        });
17880
17881        for &field in ["alt", "resource"].iter() {
17882            if self._additional_params.contains_key(field) {
17883                dlg.finished(false);
17884                return Err(common::Error::FieldClash(field));
17885            }
17886        }
17887
17888        let mut params = Params::with_capacity(4 + self._additional_params.len());
17889        params.push("resource", self._resource);
17890
17891        params.extend(self._additional_params.iter());
17892
17893        params.push("alt", "json");
17894        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
17895        if self._scopes.is_empty() {
17896            self._scopes
17897                .insert(Scope::CloudPlatform.as_ref().to_string());
17898        }
17899
17900        #[allow(clippy::single_element_loop)]
17901        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17902            url = params.uri_replacement(url, param_name, find_this, true);
17903        }
17904        {
17905            let to_remove = ["resource"];
17906            params.remove_params(&to_remove);
17907        }
17908
17909        let url = params.parse_with_url(&url);
17910
17911        let mut json_mime_type = mime::APPLICATION_JSON;
17912        let mut request_value_reader = {
17913            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17914            common::remove_json_null_values(&mut value);
17915            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17916            serde_json::to_writer(&mut dst, &value).unwrap();
17917            dst
17918        };
17919        let request_size = request_value_reader
17920            .seek(std::io::SeekFrom::End(0))
17921            .unwrap();
17922        request_value_reader
17923            .seek(std::io::SeekFrom::Start(0))
17924            .unwrap();
17925
17926        loop {
17927            let token = match self
17928                .hub
17929                .auth
17930                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17931                .await
17932            {
17933                Ok(token) => token,
17934                Err(e) => match dlg.token(e) {
17935                    Ok(token) => token,
17936                    Err(e) => {
17937                        dlg.finished(false);
17938                        return Err(common::Error::MissingToken(e));
17939                    }
17940                },
17941            };
17942            request_value_reader
17943                .seek(std::io::SeekFrom::Start(0))
17944                .unwrap();
17945            let mut req_result = {
17946                let client = &self.hub.client;
17947                dlg.pre_request();
17948                let mut req_builder = hyper::Request::builder()
17949                    .method(hyper::Method::POST)
17950                    .uri(url.as_str())
17951                    .header(USER_AGENT, self.hub._user_agent.clone());
17952
17953                if let Some(token) = token.as_ref() {
17954                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17955                }
17956
17957                let request = req_builder
17958                    .header(CONTENT_TYPE, json_mime_type.to_string())
17959                    .header(CONTENT_LENGTH, request_size as u64)
17960                    .body(common::to_body(
17961                        request_value_reader.get_ref().clone().into(),
17962                    ));
17963
17964                client.request(request.unwrap()).await
17965            };
17966
17967            match req_result {
17968                Err(err) => {
17969                    if let common::Retry::After(d) = dlg.http_error(&err) {
17970                        sleep(d).await;
17971                        continue;
17972                    }
17973                    dlg.finished(false);
17974                    return Err(common::Error::HttpError(err));
17975                }
17976                Ok(res) => {
17977                    let (mut parts, body) = res.into_parts();
17978                    let mut body = common::Body::new(body);
17979                    if !parts.status.is_success() {
17980                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17981                        let error = serde_json::from_str(&common::to_string(&bytes));
17982                        let response = common::to_response(parts, bytes.into());
17983
17984                        if let common::Retry::After(d) =
17985                            dlg.http_failure(&response, error.as_ref().ok())
17986                        {
17987                            sleep(d).await;
17988                            continue;
17989                        }
17990
17991                        dlg.finished(false);
17992
17993                        return Err(match error {
17994                            Ok(value) => common::Error::BadRequest(value),
17995                            _ => common::Error::Failure(response),
17996                        });
17997                    }
17998                    let response = {
17999                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18000                        let encoded = common::to_string(&bytes);
18001                        match serde_json::from_str(&encoded) {
18002                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18003                            Err(error) => {
18004                                dlg.response_json_decode_error(&encoded, &error);
18005                                return Err(common::Error::JsonDecodeError(
18006                                    encoded.to_string(),
18007                                    error,
18008                                ));
18009                            }
18010                        }
18011                    };
18012
18013                    dlg.finished(true);
18014                    return Ok(response);
18015                }
18016            }
18017        }
18018    }
18019
18020    ///
18021    /// Sets the *request* property to the given value.
18022    ///
18023    /// Even though the property as already been set when instantiating this call,
18024    /// we provide this method for API completeness.
18025    pub fn request(
18026        mut self,
18027        new_value: TestIamPermissionsRequest,
18028    ) -> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C> {
18029        self._request = new_value;
18030        self
18031    }
18032    /// REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
18033    ///
18034    /// Sets the *resource* path property to the given value.
18035    ///
18036    /// Even though the property as already been set when instantiating this call,
18037    /// we provide this method for API completeness.
18038    pub fn resource(
18039        mut self,
18040        new_value: &str,
18041    ) -> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C> {
18042        self._resource = new_value.to_string();
18043        self
18044    }
18045    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18046    /// while executing the actual API request.
18047    ///
18048    /// ````text
18049    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18050    /// ````
18051    ///
18052    /// Sets the *delegate* property to the given value.
18053    pub fn delegate(
18054        mut self,
18055        new_value: &'a mut dyn common::Delegate,
18056    ) -> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C> {
18057        self._delegate = Some(new_value);
18058        self
18059    }
18060
18061    /// Set any additional parameter of the query string used in the request.
18062    /// It should be used to set parameters which are not yet available through their own
18063    /// setters.
18064    ///
18065    /// Please note that this method must not be used to set any of the known parameters
18066    /// which have their own setter method. If done anyway, the request will fail.
18067    ///
18068    /// # Additional Parameters
18069    ///
18070    /// * *$.xgafv* (query-string) - V1 error format.
18071    /// * *access_token* (query-string) - OAuth access token.
18072    /// * *alt* (query-string) - Data format for response.
18073    /// * *callback* (query-string) - JSONP
18074    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18075    /// * *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.
18076    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18077    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18078    /// * *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.
18079    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18080    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18081    pub fn param<T>(
18082        mut self,
18083        name: T,
18084        value: T,
18085    ) -> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C>
18086    where
18087        T: AsRef<str>,
18088    {
18089        self._additional_params
18090            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18091        self
18092    }
18093
18094    /// Identifies the authorization scope for the method you are building.
18095    ///
18096    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18097    /// [`Scope::CloudPlatform`].
18098    ///
18099    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18100    /// tokens for more than one scope.
18101    ///
18102    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18103    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18104    /// sufficient, a read-write scope will do as well.
18105    pub fn add_scope<St>(
18106        mut self,
18107        scope: St,
18108    ) -> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C>
18109    where
18110        St: AsRef<str>,
18111    {
18112        self._scopes.insert(String::from(scope.as_ref()));
18113        self
18114    }
18115    /// Identifies the authorization scope(s) for the method you are building.
18116    ///
18117    /// See [`Self::add_scope()`] for details.
18118    pub fn add_scopes<I, St>(
18119        mut self,
18120        scopes: I,
18121    ) -> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C>
18122    where
18123        I: IntoIterator<Item = St>,
18124        St: AsRef<str>,
18125    {
18126        self._scopes
18127            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18128        self
18129    }
18130
18131    /// Removes all scopes, and no default scope will be used either.
18132    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18133    /// for details).
18134    pub fn clear_scopes(
18135        mut self,
18136    ) -> ProjectInstanceDatabaseBackupScheduleTestIamPermissionCall<'a, C> {
18137        self._scopes.clear();
18138        self
18139    }
18140}
18141
18142/// Lists Cloud Spanner database roles.
18143///
18144/// A builder for the *instances.databases.databaseRoles.list* method supported by a *project* resource.
18145/// It is not used directly, but through a [`ProjectMethods`] instance.
18146///
18147/// # Example
18148///
18149/// Instantiate a resource method builder
18150///
18151/// ```test_harness,no_run
18152/// # extern crate hyper;
18153/// # extern crate hyper_rustls;
18154/// # extern crate google_spanner1 as spanner1;
18155/// # async fn dox() {
18156/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18157///
18158/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18159/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18160/// #     .with_native_roots()
18161/// #     .unwrap()
18162/// #     .https_only()
18163/// #     .enable_http2()
18164/// #     .build();
18165///
18166/// # let executor = hyper_util::rt::TokioExecutor::new();
18167/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18168/// #     secret,
18169/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18170/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18171/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18172/// #     ),
18173/// # ).build().await.unwrap();
18174///
18175/// # let client = hyper_util::client::legacy::Client::builder(
18176/// #     hyper_util::rt::TokioExecutor::new()
18177/// # )
18178/// # .build(
18179/// #     hyper_rustls::HttpsConnectorBuilder::new()
18180/// #         .with_native_roots()
18181/// #         .unwrap()
18182/// #         .https_or_http()
18183/// #         .enable_http2()
18184/// #         .build()
18185/// # );
18186/// # let mut hub = Spanner::new(client, auth);
18187/// // You can configure optional parameters by calling the respective setters at will, and
18188/// // execute the final call using `doit()`.
18189/// // Values shown here are possibly random and not representative !
18190/// let result = hub.projects().instances_databases_database_roles_list("parent")
18191///              .page_token("dolore")
18192///              .page_size(-78)
18193///              .doit().await;
18194/// # }
18195/// ```
18196pub struct ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
18197where
18198    C: 'a,
18199{
18200    hub: &'a Spanner<C>,
18201    _parent: String,
18202    _page_token: Option<String>,
18203    _page_size: Option<i32>,
18204    _delegate: Option<&'a mut dyn common::Delegate>,
18205    _additional_params: HashMap<String, String>,
18206    _scopes: BTreeSet<String>,
18207}
18208
18209impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {}
18210
18211impl<'a, C> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
18212where
18213    C: common::Connector,
18214{
18215    /// Perform the operation you have build so far.
18216    pub async fn doit(mut self) -> common::Result<(common::Response, ListDatabaseRolesResponse)> {
18217        use std::borrow::Cow;
18218        use std::io::{Read, Seek};
18219
18220        use common::{url::Params, ToParts};
18221        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18222
18223        let mut dd = common::DefaultDelegate;
18224        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18225        dlg.begin(common::MethodInfo {
18226            id: "spanner.projects.instances.databases.databaseRoles.list",
18227            http_method: hyper::Method::GET,
18228        });
18229
18230        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
18231            if self._additional_params.contains_key(field) {
18232                dlg.finished(false);
18233                return Err(common::Error::FieldClash(field));
18234            }
18235        }
18236
18237        let mut params = Params::with_capacity(5 + self._additional_params.len());
18238        params.push("parent", self._parent);
18239        if let Some(value) = self._page_token.as_ref() {
18240            params.push("pageToken", value);
18241        }
18242        if let Some(value) = self._page_size.as_ref() {
18243            params.push("pageSize", value.to_string());
18244        }
18245
18246        params.extend(self._additional_params.iter());
18247
18248        params.push("alt", "json");
18249        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databaseRoles";
18250        if self._scopes.is_empty() {
18251            self._scopes
18252                .insert(Scope::CloudPlatform.as_ref().to_string());
18253        }
18254
18255        #[allow(clippy::single_element_loop)]
18256        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18257            url = params.uri_replacement(url, param_name, find_this, true);
18258        }
18259        {
18260            let to_remove = ["parent"];
18261            params.remove_params(&to_remove);
18262        }
18263
18264        let url = params.parse_with_url(&url);
18265
18266        loop {
18267            let token = match self
18268                .hub
18269                .auth
18270                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18271                .await
18272            {
18273                Ok(token) => token,
18274                Err(e) => match dlg.token(e) {
18275                    Ok(token) => token,
18276                    Err(e) => {
18277                        dlg.finished(false);
18278                        return Err(common::Error::MissingToken(e));
18279                    }
18280                },
18281            };
18282            let mut req_result = {
18283                let client = &self.hub.client;
18284                dlg.pre_request();
18285                let mut req_builder = hyper::Request::builder()
18286                    .method(hyper::Method::GET)
18287                    .uri(url.as_str())
18288                    .header(USER_AGENT, self.hub._user_agent.clone());
18289
18290                if let Some(token) = token.as_ref() {
18291                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18292                }
18293
18294                let request = req_builder
18295                    .header(CONTENT_LENGTH, 0_u64)
18296                    .body(common::to_body::<String>(None));
18297
18298                client.request(request.unwrap()).await
18299            };
18300
18301            match req_result {
18302                Err(err) => {
18303                    if let common::Retry::After(d) = dlg.http_error(&err) {
18304                        sleep(d).await;
18305                        continue;
18306                    }
18307                    dlg.finished(false);
18308                    return Err(common::Error::HttpError(err));
18309                }
18310                Ok(res) => {
18311                    let (mut parts, body) = res.into_parts();
18312                    let mut body = common::Body::new(body);
18313                    if !parts.status.is_success() {
18314                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18315                        let error = serde_json::from_str(&common::to_string(&bytes));
18316                        let response = common::to_response(parts, bytes.into());
18317
18318                        if let common::Retry::After(d) =
18319                            dlg.http_failure(&response, error.as_ref().ok())
18320                        {
18321                            sleep(d).await;
18322                            continue;
18323                        }
18324
18325                        dlg.finished(false);
18326
18327                        return Err(match error {
18328                            Ok(value) => common::Error::BadRequest(value),
18329                            _ => common::Error::Failure(response),
18330                        });
18331                    }
18332                    let response = {
18333                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18334                        let encoded = common::to_string(&bytes);
18335                        match serde_json::from_str(&encoded) {
18336                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18337                            Err(error) => {
18338                                dlg.response_json_decode_error(&encoded, &error);
18339                                return Err(common::Error::JsonDecodeError(
18340                                    encoded.to_string(),
18341                                    error,
18342                                ));
18343                            }
18344                        }
18345                    };
18346
18347                    dlg.finished(true);
18348                    return Ok(response);
18349                }
18350            }
18351        }
18352    }
18353
18354    /// Required. The database whose roles should be listed. Values are of the form `projects//instances//databases/`.
18355    ///
18356    /// Sets the *parent* path property to the given value.
18357    ///
18358    /// Even though the property as already been set when instantiating this call,
18359    /// we provide this method for API completeness.
18360    pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
18361        self._parent = new_value.to_string();
18362        self
18363    }
18364    /// If non-empty, `page_token` should contain a next_page_token from a previous ListDatabaseRolesResponse.
18365    ///
18366    /// Sets the *page token* query property to the given value.
18367    pub fn page_token(
18368        mut self,
18369        new_value: &str,
18370    ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
18371        self._page_token = Some(new_value.to_string());
18372        self
18373    }
18374    /// Number of database roles to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
18375    ///
18376    /// Sets the *page size* query property to the given value.
18377    pub fn page_size(
18378        mut self,
18379        new_value: i32,
18380    ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
18381        self._page_size = Some(new_value);
18382        self
18383    }
18384    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18385    /// while executing the actual API request.
18386    ///
18387    /// ````text
18388    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18389    /// ````
18390    ///
18391    /// Sets the *delegate* property to the given value.
18392    pub fn delegate(
18393        mut self,
18394        new_value: &'a mut dyn common::Delegate,
18395    ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
18396        self._delegate = Some(new_value);
18397        self
18398    }
18399
18400    /// Set any additional parameter of the query string used in the request.
18401    /// It should be used to set parameters which are not yet available through their own
18402    /// setters.
18403    ///
18404    /// Please note that this method must not be used to set any of the known parameters
18405    /// which have their own setter method. If done anyway, the request will fail.
18406    ///
18407    /// # Additional Parameters
18408    ///
18409    /// * *$.xgafv* (query-string) - V1 error format.
18410    /// * *access_token* (query-string) - OAuth access token.
18411    /// * *alt* (query-string) - Data format for response.
18412    /// * *callback* (query-string) - JSONP
18413    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18414    /// * *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.
18415    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18416    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18417    /// * *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.
18418    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18419    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18420    pub fn param<T>(
18421        mut self,
18422        name: T,
18423        value: T,
18424    ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
18425    where
18426        T: AsRef<str>,
18427    {
18428        self._additional_params
18429            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18430        self
18431    }
18432
18433    /// Identifies the authorization scope for the method you are building.
18434    ///
18435    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18436    /// [`Scope::CloudPlatform`].
18437    ///
18438    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18439    /// tokens for more than one scope.
18440    ///
18441    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18442    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18443    /// sufficient, a read-write scope will do as well.
18444    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
18445    where
18446        St: AsRef<str>,
18447    {
18448        self._scopes.insert(String::from(scope.as_ref()));
18449        self
18450    }
18451    /// Identifies the authorization scope(s) for the method you are building.
18452    ///
18453    /// See [`Self::add_scope()`] for details.
18454    pub fn add_scopes<I, St>(
18455        mut self,
18456        scopes: I,
18457    ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
18458    where
18459        I: IntoIterator<Item = St>,
18460        St: AsRef<str>,
18461    {
18462        self._scopes
18463            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18464        self
18465    }
18466
18467    /// Removes all scopes, and no default scope will be used either.
18468    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18469    /// for details).
18470    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
18471        self._scopes.clear();
18472        self
18473    }
18474}
18475
18476/// Returns permissions that the caller has on the specified database or backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance. Calling this method on a backup schedule that does not exist will result in a NOT_FOUND error if the user has `spanner.backupSchedules.list` permission on the containing database.
18477///
18478/// A builder for the *instances.databases.databaseRoles.testIamPermissions* method supported by a *project* resource.
18479/// It is not used directly, but through a [`ProjectMethods`] instance.
18480///
18481/// # Example
18482///
18483/// Instantiate a resource method builder
18484///
18485/// ```test_harness,no_run
18486/// # extern crate hyper;
18487/// # extern crate hyper_rustls;
18488/// # extern crate google_spanner1 as spanner1;
18489/// use spanner1::api::TestIamPermissionsRequest;
18490/// # async fn dox() {
18491/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18492///
18493/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18494/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18495/// #     .with_native_roots()
18496/// #     .unwrap()
18497/// #     .https_only()
18498/// #     .enable_http2()
18499/// #     .build();
18500///
18501/// # let executor = hyper_util::rt::TokioExecutor::new();
18502/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18503/// #     secret,
18504/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18505/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18506/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18507/// #     ),
18508/// # ).build().await.unwrap();
18509///
18510/// # let client = hyper_util::client::legacy::Client::builder(
18511/// #     hyper_util::rt::TokioExecutor::new()
18512/// # )
18513/// # .build(
18514/// #     hyper_rustls::HttpsConnectorBuilder::new()
18515/// #         .with_native_roots()
18516/// #         .unwrap()
18517/// #         .https_or_http()
18518/// #         .enable_http2()
18519/// #         .build()
18520/// # );
18521/// # let mut hub = Spanner::new(client, auth);
18522/// // As the method needs a request, you would usually fill it with the desired information
18523/// // into the respective structure. Some of the parts shown here might not be applicable !
18524/// // Values shown here are possibly random and not representative !
18525/// let mut req = TestIamPermissionsRequest::default();
18526///
18527/// // You can configure optional parameters by calling the respective setters at will, and
18528/// // execute the final call using `doit()`.
18529/// // Values shown here are possibly random and not representative !
18530/// let result = hub.projects().instances_databases_database_roles_test_iam_permissions(req, "resource")
18531///              .doit().await;
18532/// # }
18533/// ```
18534pub struct ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
18535where
18536    C: 'a,
18537{
18538    hub: &'a Spanner<C>,
18539    _request: TestIamPermissionsRequest,
18540    _resource: String,
18541    _delegate: Option<&'a mut dyn common::Delegate>,
18542    _additional_params: HashMap<String, String>,
18543    _scopes: BTreeSet<String>,
18544}
18545
18546impl<'a, C> common::CallBuilder
18547    for ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
18548{
18549}
18550
18551impl<'a, C> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
18552where
18553    C: common::Connector,
18554{
18555    /// Perform the operation you have build so far.
18556    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
18557        use std::borrow::Cow;
18558        use std::io::{Read, Seek};
18559
18560        use common::{url::Params, ToParts};
18561        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18562
18563        let mut dd = common::DefaultDelegate;
18564        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18565        dlg.begin(common::MethodInfo {
18566            id: "spanner.projects.instances.databases.databaseRoles.testIamPermissions",
18567            http_method: hyper::Method::POST,
18568        });
18569
18570        for &field in ["alt", "resource"].iter() {
18571            if self._additional_params.contains_key(field) {
18572                dlg.finished(false);
18573                return Err(common::Error::FieldClash(field));
18574            }
18575        }
18576
18577        let mut params = Params::with_capacity(4 + self._additional_params.len());
18578        params.push("resource", self._resource);
18579
18580        params.extend(self._additional_params.iter());
18581
18582        params.push("alt", "json");
18583        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
18584        if self._scopes.is_empty() {
18585            self._scopes
18586                .insert(Scope::CloudPlatform.as_ref().to_string());
18587        }
18588
18589        #[allow(clippy::single_element_loop)]
18590        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
18591            url = params.uri_replacement(url, param_name, find_this, true);
18592        }
18593        {
18594            let to_remove = ["resource"];
18595            params.remove_params(&to_remove);
18596        }
18597
18598        let url = params.parse_with_url(&url);
18599
18600        let mut json_mime_type = mime::APPLICATION_JSON;
18601        let mut request_value_reader = {
18602            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18603            common::remove_json_null_values(&mut value);
18604            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18605            serde_json::to_writer(&mut dst, &value).unwrap();
18606            dst
18607        };
18608        let request_size = request_value_reader
18609            .seek(std::io::SeekFrom::End(0))
18610            .unwrap();
18611        request_value_reader
18612            .seek(std::io::SeekFrom::Start(0))
18613            .unwrap();
18614
18615        loop {
18616            let token = match self
18617                .hub
18618                .auth
18619                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18620                .await
18621            {
18622                Ok(token) => token,
18623                Err(e) => match dlg.token(e) {
18624                    Ok(token) => token,
18625                    Err(e) => {
18626                        dlg.finished(false);
18627                        return Err(common::Error::MissingToken(e));
18628                    }
18629                },
18630            };
18631            request_value_reader
18632                .seek(std::io::SeekFrom::Start(0))
18633                .unwrap();
18634            let mut req_result = {
18635                let client = &self.hub.client;
18636                dlg.pre_request();
18637                let mut req_builder = hyper::Request::builder()
18638                    .method(hyper::Method::POST)
18639                    .uri(url.as_str())
18640                    .header(USER_AGENT, self.hub._user_agent.clone());
18641
18642                if let Some(token) = token.as_ref() {
18643                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18644                }
18645
18646                let request = req_builder
18647                    .header(CONTENT_TYPE, json_mime_type.to_string())
18648                    .header(CONTENT_LENGTH, request_size as u64)
18649                    .body(common::to_body(
18650                        request_value_reader.get_ref().clone().into(),
18651                    ));
18652
18653                client.request(request.unwrap()).await
18654            };
18655
18656            match req_result {
18657                Err(err) => {
18658                    if let common::Retry::After(d) = dlg.http_error(&err) {
18659                        sleep(d).await;
18660                        continue;
18661                    }
18662                    dlg.finished(false);
18663                    return Err(common::Error::HttpError(err));
18664                }
18665                Ok(res) => {
18666                    let (mut parts, body) = res.into_parts();
18667                    let mut body = common::Body::new(body);
18668                    if !parts.status.is_success() {
18669                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18670                        let error = serde_json::from_str(&common::to_string(&bytes));
18671                        let response = common::to_response(parts, bytes.into());
18672
18673                        if let common::Retry::After(d) =
18674                            dlg.http_failure(&response, error.as_ref().ok())
18675                        {
18676                            sleep(d).await;
18677                            continue;
18678                        }
18679
18680                        dlg.finished(false);
18681
18682                        return Err(match error {
18683                            Ok(value) => common::Error::BadRequest(value),
18684                            _ => common::Error::Failure(response),
18685                        });
18686                    }
18687                    let response = {
18688                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18689                        let encoded = common::to_string(&bytes);
18690                        match serde_json::from_str(&encoded) {
18691                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18692                            Err(error) => {
18693                                dlg.response_json_decode_error(&encoded, &error);
18694                                return Err(common::Error::JsonDecodeError(
18695                                    encoded.to_string(),
18696                                    error,
18697                                ));
18698                            }
18699                        }
18700                    };
18701
18702                    dlg.finished(true);
18703                    return Ok(response);
18704                }
18705            }
18706        }
18707    }
18708
18709    ///
18710    /// Sets the *request* property to the given value.
18711    ///
18712    /// Even though the property as already been set when instantiating this call,
18713    /// we provide this method for API completeness.
18714    pub fn request(
18715        mut self,
18716        new_value: TestIamPermissionsRequest,
18717    ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
18718        self._request = new_value;
18719        self
18720    }
18721    /// REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
18722    ///
18723    /// Sets the *resource* path property to the given value.
18724    ///
18725    /// Even though the property as already been set when instantiating this call,
18726    /// we provide this method for API completeness.
18727    pub fn resource(
18728        mut self,
18729        new_value: &str,
18730    ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
18731        self._resource = new_value.to_string();
18732        self
18733    }
18734    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18735    /// while executing the actual API request.
18736    ///
18737    /// ````text
18738    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18739    /// ````
18740    ///
18741    /// Sets the *delegate* property to the given value.
18742    pub fn delegate(
18743        mut self,
18744        new_value: &'a mut dyn common::Delegate,
18745    ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
18746        self._delegate = Some(new_value);
18747        self
18748    }
18749
18750    /// Set any additional parameter of the query string used in the request.
18751    /// It should be used to set parameters which are not yet available through their own
18752    /// setters.
18753    ///
18754    /// Please note that this method must not be used to set any of the known parameters
18755    /// which have their own setter method. If done anyway, the request will fail.
18756    ///
18757    /// # Additional Parameters
18758    ///
18759    /// * *$.xgafv* (query-string) - V1 error format.
18760    /// * *access_token* (query-string) - OAuth access token.
18761    /// * *alt* (query-string) - Data format for response.
18762    /// * *callback* (query-string) - JSONP
18763    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18764    /// * *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.
18765    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18766    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18767    /// * *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.
18768    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18769    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18770    pub fn param<T>(
18771        mut self,
18772        name: T,
18773        value: T,
18774    ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
18775    where
18776        T: AsRef<str>,
18777    {
18778        self._additional_params
18779            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18780        self
18781    }
18782
18783    /// Identifies the authorization scope for the method you are building.
18784    ///
18785    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18786    /// [`Scope::CloudPlatform`].
18787    ///
18788    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18789    /// tokens for more than one scope.
18790    ///
18791    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18792    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18793    /// sufficient, a read-write scope will do as well.
18794    pub fn add_scope<St>(
18795        mut self,
18796        scope: St,
18797    ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
18798    where
18799        St: AsRef<str>,
18800    {
18801        self._scopes.insert(String::from(scope.as_ref()));
18802        self
18803    }
18804    /// Identifies the authorization scope(s) for the method you are building.
18805    ///
18806    /// See [`Self::add_scope()`] for details.
18807    pub fn add_scopes<I, St>(
18808        mut self,
18809        scopes: I,
18810    ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
18811    where
18812        I: IntoIterator<Item = St>,
18813        St: AsRef<str>,
18814    {
18815        self._scopes
18816            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18817        self
18818    }
18819
18820    /// Removes all scopes, and no default scope will be used either.
18821    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18822    /// for details).
18823    pub fn clear_scopes(
18824        mut self,
18825    ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
18826        self._scopes.clear();
18827        self
18828    }
18829}
18830
18831/// 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`.
18832///
18833/// A builder for the *instances.databases.operations.cancel* method supported by a *project* resource.
18834/// It is not used directly, but through a [`ProjectMethods`] instance.
18835///
18836/// # Example
18837///
18838/// Instantiate a resource method builder
18839///
18840/// ```test_harness,no_run
18841/// # extern crate hyper;
18842/// # extern crate hyper_rustls;
18843/// # extern crate google_spanner1 as spanner1;
18844/// # async fn dox() {
18845/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18846///
18847/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18848/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18849/// #     .with_native_roots()
18850/// #     .unwrap()
18851/// #     .https_only()
18852/// #     .enable_http2()
18853/// #     .build();
18854///
18855/// # let executor = hyper_util::rt::TokioExecutor::new();
18856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18857/// #     secret,
18858/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18859/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18860/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18861/// #     ),
18862/// # ).build().await.unwrap();
18863///
18864/// # let client = hyper_util::client::legacy::Client::builder(
18865/// #     hyper_util::rt::TokioExecutor::new()
18866/// # )
18867/// # .build(
18868/// #     hyper_rustls::HttpsConnectorBuilder::new()
18869/// #         .with_native_roots()
18870/// #         .unwrap()
18871/// #         .https_or_http()
18872/// #         .enable_http2()
18873/// #         .build()
18874/// # );
18875/// # let mut hub = Spanner::new(client, auth);
18876/// // You can configure optional parameters by calling the respective setters at will, and
18877/// // execute the final call using `doit()`.
18878/// // Values shown here are possibly random and not representative !
18879/// let result = hub.projects().instances_databases_operations_cancel("name")
18880///              .doit().await;
18881/// # }
18882/// ```
18883pub struct ProjectInstanceDatabaseOperationCancelCall<'a, C>
18884where
18885    C: 'a,
18886{
18887    hub: &'a Spanner<C>,
18888    _name: String,
18889    _delegate: Option<&'a mut dyn common::Delegate>,
18890    _additional_params: HashMap<String, String>,
18891    _scopes: BTreeSet<String>,
18892}
18893
18894impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationCancelCall<'a, C> {}
18895
18896impl<'a, C> ProjectInstanceDatabaseOperationCancelCall<'a, C>
18897where
18898    C: common::Connector,
18899{
18900    /// Perform the operation you have build so far.
18901    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
18902        use std::borrow::Cow;
18903        use std::io::{Read, Seek};
18904
18905        use common::{url::Params, ToParts};
18906        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18907
18908        let mut dd = common::DefaultDelegate;
18909        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18910        dlg.begin(common::MethodInfo {
18911            id: "spanner.projects.instances.databases.operations.cancel",
18912            http_method: hyper::Method::POST,
18913        });
18914
18915        for &field in ["alt", "name"].iter() {
18916            if self._additional_params.contains_key(field) {
18917                dlg.finished(false);
18918                return Err(common::Error::FieldClash(field));
18919            }
18920        }
18921
18922        let mut params = Params::with_capacity(3 + self._additional_params.len());
18923        params.push("name", self._name);
18924
18925        params.extend(self._additional_params.iter());
18926
18927        params.push("alt", "json");
18928        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
18929        if self._scopes.is_empty() {
18930            self._scopes
18931                .insert(Scope::CloudPlatform.as_ref().to_string());
18932        }
18933
18934        #[allow(clippy::single_element_loop)]
18935        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18936            url = params.uri_replacement(url, param_name, find_this, true);
18937        }
18938        {
18939            let to_remove = ["name"];
18940            params.remove_params(&to_remove);
18941        }
18942
18943        let url = params.parse_with_url(&url);
18944
18945        loop {
18946            let token = match self
18947                .hub
18948                .auth
18949                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18950                .await
18951            {
18952                Ok(token) => token,
18953                Err(e) => match dlg.token(e) {
18954                    Ok(token) => token,
18955                    Err(e) => {
18956                        dlg.finished(false);
18957                        return Err(common::Error::MissingToken(e));
18958                    }
18959                },
18960            };
18961            let mut req_result = {
18962                let client = &self.hub.client;
18963                dlg.pre_request();
18964                let mut req_builder = hyper::Request::builder()
18965                    .method(hyper::Method::POST)
18966                    .uri(url.as_str())
18967                    .header(USER_AGENT, self.hub._user_agent.clone());
18968
18969                if let Some(token) = token.as_ref() {
18970                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18971                }
18972
18973                let request = req_builder
18974                    .header(CONTENT_LENGTH, 0_u64)
18975                    .body(common::to_body::<String>(None));
18976
18977                client.request(request.unwrap()).await
18978            };
18979
18980            match req_result {
18981                Err(err) => {
18982                    if let common::Retry::After(d) = dlg.http_error(&err) {
18983                        sleep(d).await;
18984                        continue;
18985                    }
18986                    dlg.finished(false);
18987                    return Err(common::Error::HttpError(err));
18988                }
18989                Ok(res) => {
18990                    let (mut parts, body) = res.into_parts();
18991                    let mut body = common::Body::new(body);
18992                    if !parts.status.is_success() {
18993                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18994                        let error = serde_json::from_str(&common::to_string(&bytes));
18995                        let response = common::to_response(parts, bytes.into());
18996
18997                        if let common::Retry::After(d) =
18998                            dlg.http_failure(&response, error.as_ref().ok())
18999                        {
19000                            sleep(d).await;
19001                            continue;
19002                        }
19003
19004                        dlg.finished(false);
19005
19006                        return Err(match error {
19007                            Ok(value) => common::Error::BadRequest(value),
19008                            _ => common::Error::Failure(response),
19009                        });
19010                    }
19011                    let response = {
19012                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19013                        let encoded = common::to_string(&bytes);
19014                        match serde_json::from_str(&encoded) {
19015                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19016                            Err(error) => {
19017                                dlg.response_json_decode_error(&encoded, &error);
19018                                return Err(common::Error::JsonDecodeError(
19019                                    encoded.to_string(),
19020                                    error,
19021                                ));
19022                            }
19023                        }
19024                    };
19025
19026                    dlg.finished(true);
19027                    return Ok(response);
19028                }
19029            }
19030        }
19031    }
19032
19033    /// The name of the operation resource to be cancelled.
19034    ///
19035    /// Sets the *name* path property to the given value.
19036    ///
19037    /// Even though the property as already been set when instantiating this call,
19038    /// we provide this method for API completeness.
19039    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationCancelCall<'a, C> {
19040        self._name = new_value.to_string();
19041        self
19042    }
19043    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19044    /// while executing the actual API request.
19045    ///
19046    /// ````text
19047    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19048    /// ````
19049    ///
19050    /// Sets the *delegate* property to the given value.
19051    pub fn delegate(
19052        mut self,
19053        new_value: &'a mut dyn common::Delegate,
19054    ) -> ProjectInstanceDatabaseOperationCancelCall<'a, C> {
19055        self._delegate = Some(new_value);
19056        self
19057    }
19058
19059    /// Set any additional parameter of the query string used in the request.
19060    /// It should be used to set parameters which are not yet available through their own
19061    /// setters.
19062    ///
19063    /// Please note that this method must not be used to set any of the known parameters
19064    /// which have their own setter method. If done anyway, the request will fail.
19065    ///
19066    /// # Additional Parameters
19067    ///
19068    /// * *$.xgafv* (query-string) - V1 error format.
19069    /// * *access_token* (query-string) - OAuth access token.
19070    /// * *alt* (query-string) - Data format for response.
19071    /// * *callback* (query-string) - JSONP
19072    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19073    /// * *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.
19074    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19075    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19076    /// * *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.
19077    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19078    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19079    pub fn param<T>(
19080        mut self,
19081        name: T,
19082        value: T,
19083    ) -> ProjectInstanceDatabaseOperationCancelCall<'a, C>
19084    where
19085        T: AsRef<str>,
19086    {
19087        self._additional_params
19088            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19089        self
19090    }
19091
19092    /// Identifies the authorization scope for the method you are building.
19093    ///
19094    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19095    /// [`Scope::CloudPlatform`].
19096    ///
19097    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19098    /// tokens for more than one scope.
19099    ///
19100    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19101    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19102    /// sufficient, a read-write scope will do as well.
19103    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationCancelCall<'a, C>
19104    where
19105        St: AsRef<str>,
19106    {
19107        self._scopes.insert(String::from(scope.as_ref()));
19108        self
19109    }
19110    /// Identifies the authorization scope(s) for the method you are building.
19111    ///
19112    /// See [`Self::add_scope()`] for details.
19113    pub fn add_scopes<I, St>(
19114        mut self,
19115        scopes: I,
19116    ) -> ProjectInstanceDatabaseOperationCancelCall<'a, C>
19117    where
19118        I: IntoIterator<Item = St>,
19119        St: AsRef<str>,
19120    {
19121        self._scopes
19122            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19123        self
19124    }
19125
19126    /// Removes all scopes, and no default scope will be used either.
19127    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19128    /// for details).
19129    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationCancelCall<'a, C> {
19130        self._scopes.clear();
19131        self
19132    }
19133}
19134
19135/// 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`.
19136///
19137/// A builder for the *instances.databases.operations.delete* method supported by a *project* resource.
19138/// It is not used directly, but through a [`ProjectMethods`] instance.
19139///
19140/// # Example
19141///
19142/// Instantiate a resource method builder
19143///
19144/// ```test_harness,no_run
19145/// # extern crate hyper;
19146/// # extern crate hyper_rustls;
19147/// # extern crate google_spanner1 as spanner1;
19148/// # async fn dox() {
19149/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19150///
19151/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19152/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19153/// #     .with_native_roots()
19154/// #     .unwrap()
19155/// #     .https_only()
19156/// #     .enable_http2()
19157/// #     .build();
19158///
19159/// # let executor = hyper_util::rt::TokioExecutor::new();
19160/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19161/// #     secret,
19162/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19163/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19164/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19165/// #     ),
19166/// # ).build().await.unwrap();
19167///
19168/// # let client = hyper_util::client::legacy::Client::builder(
19169/// #     hyper_util::rt::TokioExecutor::new()
19170/// # )
19171/// # .build(
19172/// #     hyper_rustls::HttpsConnectorBuilder::new()
19173/// #         .with_native_roots()
19174/// #         .unwrap()
19175/// #         .https_or_http()
19176/// #         .enable_http2()
19177/// #         .build()
19178/// # );
19179/// # let mut hub = Spanner::new(client, auth);
19180/// // You can configure optional parameters by calling the respective setters at will, and
19181/// // execute the final call using `doit()`.
19182/// // Values shown here are possibly random and not representative !
19183/// let result = hub.projects().instances_databases_operations_delete("name")
19184///              .doit().await;
19185/// # }
19186/// ```
19187pub struct ProjectInstanceDatabaseOperationDeleteCall<'a, C>
19188where
19189    C: 'a,
19190{
19191    hub: &'a Spanner<C>,
19192    _name: String,
19193    _delegate: Option<&'a mut dyn common::Delegate>,
19194    _additional_params: HashMap<String, String>,
19195    _scopes: BTreeSet<String>,
19196}
19197
19198impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationDeleteCall<'a, C> {}
19199
19200impl<'a, C> ProjectInstanceDatabaseOperationDeleteCall<'a, C>
19201where
19202    C: common::Connector,
19203{
19204    /// Perform the operation you have build so far.
19205    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
19206        use std::borrow::Cow;
19207        use std::io::{Read, Seek};
19208
19209        use common::{url::Params, ToParts};
19210        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19211
19212        let mut dd = common::DefaultDelegate;
19213        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19214        dlg.begin(common::MethodInfo {
19215            id: "spanner.projects.instances.databases.operations.delete",
19216            http_method: hyper::Method::DELETE,
19217        });
19218
19219        for &field in ["alt", "name"].iter() {
19220            if self._additional_params.contains_key(field) {
19221                dlg.finished(false);
19222                return Err(common::Error::FieldClash(field));
19223            }
19224        }
19225
19226        let mut params = Params::with_capacity(3 + self._additional_params.len());
19227        params.push("name", self._name);
19228
19229        params.extend(self._additional_params.iter());
19230
19231        params.push("alt", "json");
19232        let mut url = self.hub._base_url.clone() + "v1/{+name}";
19233        if self._scopes.is_empty() {
19234            self._scopes
19235                .insert(Scope::CloudPlatform.as_ref().to_string());
19236        }
19237
19238        #[allow(clippy::single_element_loop)]
19239        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19240            url = params.uri_replacement(url, param_name, find_this, true);
19241        }
19242        {
19243            let to_remove = ["name"];
19244            params.remove_params(&to_remove);
19245        }
19246
19247        let url = params.parse_with_url(&url);
19248
19249        loop {
19250            let token = match self
19251                .hub
19252                .auth
19253                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19254                .await
19255            {
19256                Ok(token) => token,
19257                Err(e) => match dlg.token(e) {
19258                    Ok(token) => token,
19259                    Err(e) => {
19260                        dlg.finished(false);
19261                        return Err(common::Error::MissingToken(e));
19262                    }
19263                },
19264            };
19265            let mut req_result = {
19266                let client = &self.hub.client;
19267                dlg.pre_request();
19268                let mut req_builder = hyper::Request::builder()
19269                    .method(hyper::Method::DELETE)
19270                    .uri(url.as_str())
19271                    .header(USER_AGENT, self.hub._user_agent.clone());
19272
19273                if let Some(token) = token.as_ref() {
19274                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19275                }
19276
19277                let request = req_builder
19278                    .header(CONTENT_LENGTH, 0_u64)
19279                    .body(common::to_body::<String>(None));
19280
19281                client.request(request.unwrap()).await
19282            };
19283
19284            match req_result {
19285                Err(err) => {
19286                    if let common::Retry::After(d) = dlg.http_error(&err) {
19287                        sleep(d).await;
19288                        continue;
19289                    }
19290                    dlg.finished(false);
19291                    return Err(common::Error::HttpError(err));
19292                }
19293                Ok(res) => {
19294                    let (mut parts, body) = res.into_parts();
19295                    let mut body = common::Body::new(body);
19296                    if !parts.status.is_success() {
19297                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19298                        let error = serde_json::from_str(&common::to_string(&bytes));
19299                        let response = common::to_response(parts, bytes.into());
19300
19301                        if let common::Retry::After(d) =
19302                            dlg.http_failure(&response, error.as_ref().ok())
19303                        {
19304                            sleep(d).await;
19305                            continue;
19306                        }
19307
19308                        dlg.finished(false);
19309
19310                        return Err(match error {
19311                            Ok(value) => common::Error::BadRequest(value),
19312                            _ => common::Error::Failure(response),
19313                        });
19314                    }
19315                    let response = {
19316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19317                        let encoded = common::to_string(&bytes);
19318                        match serde_json::from_str(&encoded) {
19319                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19320                            Err(error) => {
19321                                dlg.response_json_decode_error(&encoded, &error);
19322                                return Err(common::Error::JsonDecodeError(
19323                                    encoded.to_string(),
19324                                    error,
19325                                ));
19326                            }
19327                        }
19328                    };
19329
19330                    dlg.finished(true);
19331                    return Ok(response);
19332                }
19333            }
19334        }
19335    }
19336
19337    /// The name of the operation resource to be deleted.
19338    ///
19339    /// Sets the *name* path property to the given value.
19340    ///
19341    /// Even though the property as already been set when instantiating this call,
19342    /// we provide this method for API completeness.
19343    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C> {
19344        self._name = new_value.to_string();
19345        self
19346    }
19347    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19348    /// while executing the actual API request.
19349    ///
19350    /// ````text
19351    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19352    /// ````
19353    ///
19354    /// Sets the *delegate* property to the given value.
19355    pub fn delegate(
19356        mut self,
19357        new_value: &'a mut dyn common::Delegate,
19358    ) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C> {
19359        self._delegate = Some(new_value);
19360        self
19361    }
19362
19363    /// Set any additional parameter of the query string used in the request.
19364    /// It should be used to set parameters which are not yet available through their own
19365    /// setters.
19366    ///
19367    /// Please note that this method must not be used to set any of the known parameters
19368    /// which have their own setter method. If done anyway, the request will fail.
19369    ///
19370    /// # Additional Parameters
19371    ///
19372    /// * *$.xgafv* (query-string) - V1 error format.
19373    /// * *access_token* (query-string) - OAuth access token.
19374    /// * *alt* (query-string) - Data format for response.
19375    /// * *callback* (query-string) - JSONP
19376    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19377    /// * *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.
19378    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19379    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19380    /// * *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.
19381    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19382    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19383    pub fn param<T>(
19384        mut self,
19385        name: T,
19386        value: T,
19387    ) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C>
19388    where
19389        T: AsRef<str>,
19390    {
19391        self._additional_params
19392            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19393        self
19394    }
19395
19396    /// Identifies the authorization scope for the method you are building.
19397    ///
19398    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19399    /// [`Scope::CloudPlatform`].
19400    ///
19401    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19402    /// tokens for more than one scope.
19403    ///
19404    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19405    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19406    /// sufficient, a read-write scope will do as well.
19407    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C>
19408    where
19409        St: AsRef<str>,
19410    {
19411        self._scopes.insert(String::from(scope.as_ref()));
19412        self
19413    }
19414    /// Identifies the authorization scope(s) for the method you are building.
19415    ///
19416    /// See [`Self::add_scope()`] for details.
19417    pub fn add_scopes<I, St>(
19418        mut self,
19419        scopes: I,
19420    ) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C>
19421    where
19422        I: IntoIterator<Item = St>,
19423        St: AsRef<str>,
19424    {
19425        self._scopes
19426            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19427        self
19428    }
19429
19430    /// Removes all scopes, and no default scope will be used either.
19431    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19432    /// for details).
19433    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C> {
19434        self._scopes.clear();
19435        self
19436    }
19437}
19438
19439/// 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.
19440///
19441/// A builder for the *instances.databases.operations.get* method supported by a *project* resource.
19442/// It is not used directly, but through a [`ProjectMethods`] instance.
19443///
19444/// # Example
19445///
19446/// Instantiate a resource method builder
19447///
19448/// ```test_harness,no_run
19449/// # extern crate hyper;
19450/// # extern crate hyper_rustls;
19451/// # extern crate google_spanner1 as spanner1;
19452/// # async fn dox() {
19453/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19454///
19455/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19456/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19457/// #     .with_native_roots()
19458/// #     .unwrap()
19459/// #     .https_only()
19460/// #     .enable_http2()
19461/// #     .build();
19462///
19463/// # let executor = hyper_util::rt::TokioExecutor::new();
19464/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19465/// #     secret,
19466/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19467/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19468/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19469/// #     ),
19470/// # ).build().await.unwrap();
19471///
19472/// # let client = hyper_util::client::legacy::Client::builder(
19473/// #     hyper_util::rt::TokioExecutor::new()
19474/// # )
19475/// # .build(
19476/// #     hyper_rustls::HttpsConnectorBuilder::new()
19477/// #         .with_native_roots()
19478/// #         .unwrap()
19479/// #         .https_or_http()
19480/// #         .enable_http2()
19481/// #         .build()
19482/// # );
19483/// # let mut hub = Spanner::new(client, auth);
19484/// // You can configure optional parameters by calling the respective setters at will, and
19485/// // execute the final call using `doit()`.
19486/// // Values shown here are possibly random and not representative !
19487/// let result = hub.projects().instances_databases_operations_get("name")
19488///              .doit().await;
19489/// # }
19490/// ```
19491pub struct ProjectInstanceDatabaseOperationGetCall<'a, C>
19492where
19493    C: 'a,
19494{
19495    hub: &'a Spanner<C>,
19496    _name: String,
19497    _delegate: Option<&'a mut dyn common::Delegate>,
19498    _additional_params: HashMap<String, String>,
19499    _scopes: BTreeSet<String>,
19500}
19501
19502impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationGetCall<'a, C> {}
19503
19504impl<'a, C> ProjectInstanceDatabaseOperationGetCall<'a, C>
19505where
19506    C: common::Connector,
19507{
19508    /// Perform the operation you have build so far.
19509    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19510        use std::borrow::Cow;
19511        use std::io::{Read, Seek};
19512
19513        use common::{url::Params, ToParts};
19514        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19515
19516        let mut dd = common::DefaultDelegate;
19517        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19518        dlg.begin(common::MethodInfo {
19519            id: "spanner.projects.instances.databases.operations.get",
19520            http_method: hyper::Method::GET,
19521        });
19522
19523        for &field in ["alt", "name"].iter() {
19524            if self._additional_params.contains_key(field) {
19525                dlg.finished(false);
19526                return Err(common::Error::FieldClash(field));
19527            }
19528        }
19529
19530        let mut params = Params::with_capacity(3 + self._additional_params.len());
19531        params.push("name", self._name);
19532
19533        params.extend(self._additional_params.iter());
19534
19535        params.push("alt", "json");
19536        let mut url = self.hub._base_url.clone() + "v1/{+name}";
19537        if self._scopes.is_empty() {
19538            self._scopes
19539                .insert(Scope::CloudPlatform.as_ref().to_string());
19540        }
19541
19542        #[allow(clippy::single_element_loop)]
19543        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19544            url = params.uri_replacement(url, param_name, find_this, true);
19545        }
19546        {
19547            let to_remove = ["name"];
19548            params.remove_params(&to_remove);
19549        }
19550
19551        let url = params.parse_with_url(&url);
19552
19553        loop {
19554            let token = match self
19555                .hub
19556                .auth
19557                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19558                .await
19559            {
19560                Ok(token) => token,
19561                Err(e) => match dlg.token(e) {
19562                    Ok(token) => token,
19563                    Err(e) => {
19564                        dlg.finished(false);
19565                        return Err(common::Error::MissingToken(e));
19566                    }
19567                },
19568            };
19569            let mut req_result = {
19570                let client = &self.hub.client;
19571                dlg.pre_request();
19572                let mut req_builder = hyper::Request::builder()
19573                    .method(hyper::Method::GET)
19574                    .uri(url.as_str())
19575                    .header(USER_AGENT, self.hub._user_agent.clone());
19576
19577                if let Some(token) = token.as_ref() {
19578                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19579                }
19580
19581                let request = req_builder
19582                    .header(CONTENT_LENGTH, 0_u64)
19583                    .body(common::to_body::<String>(None));
19584
19585                client.request(request.unwrap()).await
19586            };
19587
19588            match req_result {
19589                Err(err) => {
19590                    if let common::Retry::After(d) = dlg.http_error(&err) {
19591                        sleep(d).await;
19592                        continue;
19593                    }
19594                    dlg.finished(false);
19595                    return Err(common::Error::HttpError(err));
19596                }
19597                Ok(res) => {
19598                    let (mut parts, body) = res.into_parts();
19599                    let mut body = common::Body::new(body);
19600                    if !parts.status.is_success() {
19601                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19602                        let error = serde_json::from_str(&common::to_string(&bytes));
19603                        let response = common::to_response(parts, bytes.into());
19604
19605                        if let common::Retry::After(d) =
19606                            dlg.http_failure(&response, error.as_ref().ok())
19607                        {
19608                            sleep(d).await;
19609                            continue;
19610                        }
19611
19612                        dlg.finished(false);
19613
19614                        return Err(match error {
19615                            Ok(value) => common::Error::BadRequest(value),
19616                            _ => common::Error::Failure(response),
19617                        });
19618                    }
19619                    let response = {
19620                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19621                        let encoded = common::to_string(&bytes);
19622                        match serde_json::from_str(&encoded) {
19623                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19624                            Err(error) => {
19625                                dlg.response_json_decode_error(&encoded, &error);
19626                                return Err(common::Error::JsonDecodeError(
19627                                    encoded.to_string(),
19628                                    error,
19629                                ));
19630                            }
19631                        }
19632                    };
19633
19634                    dlg.finished(true);
19635                    return Ok(response);
19636                }
19637            }
19638        }
19639    }
19640
19641    /// The name of the operation resource.
19642    ///
19643    /// Sets the *name* path property to the given value.
19644    ///
19645    /// Even though the property as already been set when instantiating this call,
19646    /// we provide this method for API completeness.
19647    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationGetCall<'a, C> {
19648        self._name = new_value.to_string();
19649        self
19650    }
19651    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19652    /// while executing the actual API request.
19653    ///
19654    /// ````text
19655    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19656    /// ````
19657    ///
19658    /// Sets the *delegate* property to the given value.
19659    pub fn delegate(
19660        mut self,
19661        new_value: &'a mut dyn common::Delegate,
19662    ) -> ProjectInstanceDatabaseOperationGetCall<'a, C> {
19663        self._delegate = Some(new_value);
19664        self
19665    }
19666
19667    /// Set any additional parameter of the query string used in the request.
19668    /// It should be used to set parameters which are not yet available through their own
19669    /// setters.
19670    ///
19671    /// Please note that this method must not be used to set any of the known parameters
19672    /// which have their own setter method. If done anyway, the request will fail.
19673    ///
19674    /// # Additional Parameters
19675    ///
19676    /// * *$.xgafv* (query-string) - V1 error format.
19677    /// * *access_token* (query-string) - OAuth access token.
19678    /// * *alt* (query-string) - Data format for response.
19679    /// * *callback* (query-string) - JSONP
19680    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19681    /// * *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.
19682    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19683    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19684    /// * *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.
19685    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19686    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19687    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseOperationGetCall<'a, C>
19688    where
19689        T: AsRef<str>,
19690    {
19691        self._additional_params
19692            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19693        self
19694    }
19695
19696    /// Identifies the authorization scope for the method you are building.
19697    ///
19698    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19699    /// [`Scope::CloudPlatform`].
19700    ///
19701    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19702    /// tokens for more than one scope.
19703    ///
19704    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19705    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19706    /// sufficient, a read-write scope will do as well.
19707    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationGetCall<'a, C>
19708    where
19709        St: AsRef<str>,
19710    {
19711        self._scopes.insert(String::from(scope.as_ref()));
19712        self
19713    }
19714    /// Identifies the authorization scope(s) for the method you are building.
19715    ///
19716    /// See [`Self::add_scope()`] for details.
19717    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseOperationGetCall<'a, C>
19718    where
19719        I: IntoIterator<Item = St>,
19720        St: AsRef<str>,
19721    {
19722        self._scopes
19723            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19724        self
19725    }
19726
19727    /// Removes all scopes, and no default scope will be used either.
19728    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19729    /// for details).
19730    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationGetCall<'a, C> {
19731        self._scopes.clear();
19732        self
19733    }
19734}
19735
19736/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
19737///
19738/// A builder for the *instances.databases.operations.list* method supported by a *project* resource.
19739/// It is not used directly, but through a [`ProjectMethods`] instance.
19740///
19741/// # Example
19742///
19743/// Instantiate a resource method builder
19744///
19745/// ```test_harness,no_run
19746/// # extern crate hyper;
19747/// # extern crate hyper_rustls;
19748/// # extern crate google_spanner1 as spanner1;
19749/// # async fn dox() {
19750/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19751///
19752/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19753/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19754/// #     .with_native_roots()
19755/// #     .unwrap()
19756/// #     .https_only()
19757/// #     .enable_http2()
19758/// #     .build();
19759///
19760/// # let executor = hyper_util::rt::TokioExecutor::new();
19761/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19762/// #     secret,
19763/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19764/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19765/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19766/// #     ),
19767/// # ).build().await.unwrap();
19768///
19769/// # let client = hyper_util::client::legacy::Client::builder(
19770/// #     hyper_util::rt::TokioExecutor::new()
19771/// # )
19772/// # .build(
19773/// #     hyper_rustls::HttpsConnectorBuilder::new()
19774/// #         .with_native_roots()
19775/// #         .unwrap()
19776/// #         .https_or_http()
19777/// #         .enable_http2()
19778/// #         .build()
19779/// # );
19780/// # let mut hub = Spanner::new(client, auth);
19781/// // You can configure optional parameters by calling the respective setters at will, and
19782/// // execute the final call using `doit()`.
19783/// // Values shown here are possibly random and not representative !
19784/// let result = hub.projects().instances_databases_operations_list("name")
19785///              .return_partial_success(true)
19786///              .page_token("sit")
19787///              .page_size(-35)
19788///              .filter("tempor")
19789///              .doit().await;
19790/// # }
19791/// ```
19792pub struct ProjectInstanceDatabaseOperationListCall1<'a, C>
19793where
19794    C: 'a,
19795{
19796    hub: &'a Spanner<C>,
19797    _name: String,
19798    _return_partial_success: Option<bool>,
19799    _page_token: Option<String>,
19800    _page_size: Option<i32>,
19801    _filter: Option<String>,
19802    _delegate: Option<&'a mut dyn common::Delegate>,
19803    _additional_params: HashMap<String, String>,
19804    _scopes: BTreeSet<String>,
19805}
19806
19807impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationListCall1<'a, C> {}
19808
19809impl<'a, C> ProjectInstanceDatabaseOperationListCall1<'a, C>
19810where
19811    C: common::Connector,
19812{
19813    /// Perform the operation you have build so far.
19814    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
19815        use std::borrow::Cow;
19816        use std::io::{Read, Seek};
19817
19818        use common::{url::Params, ToParts};
19819        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19820
19821        let mut dd = common::DefaultDelegate;
19822        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19823        dlg.begin(common::MethodInfo {
19824            id: "spanner.projects.instances.databases.operations.list",
19825            http_method: hyper::Method::GET,
19826        });
19827
19828        for &field in [
19829            "alt",
19830            "name",
19831            "returnPartialSuccess",
19832            "pageToken",
19833            "pageSize",
19834            "filter",
19835        ]
19836        .iter()
19837        {
19838            if self._additional_params.contains_key(field) {
19839                dlg.finished(false);
19840                return Err(common::Error::FieldClash(field));
19841            }
19842        }
19843
19844        let mut params = Params::with_capacity(7 + self._additional_params.len());
19845        params.push("name", self._name);
19846        if let Some(value) = self._return_partial_success.as_ref() {
19847            params.push("returnPartialSuccess", value.to_string());
19848        }
19849        if let Some(value) = self._page_token.as_ref() {
19850            params.push("pageToken", value);
19851        }
19852        if let Some(value) = self._page_size.as_ref() {
19853            params.push("pageSize", value.to_string());
19854        }
19855        if let Some(value) = self._filter.as_ref() {
19856            params.push("filter", value);
19857        }
19858
19859        params.extend(self._additional_params.iter());
19860
19861        params.push("alt", "json");
19862        let mut url = self.hub._base_url.clone() + "v1/{+name}";
19863        if self._scopes.is_empty() {
19864            self._scopes
19865                .insert(Scope::CloudPlatform.as_ref().to_string());
19866        }
19867
19868        #[allow(clippy::single_element_loop)]
19869        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19870            url = params.uri_replacement(url, param_name, find_this, true);
19871        }
19872        {
19873            let to_remove = ["name"];
19874            params.remove_params(&to_remove);
19875        }
19876
19877        let url = params.parse_with_url(&url);
19878
19879        loop {
19880            let token = match self
19881                .hub
19882                .auth
19883                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19884                .await
19885            {
19886                Ok(token) => token,
19887                Err(e) => match dlg.token(e) {
19888                    Ok(token) => token,
19889                    Err(e) => {
19890                        dlg.finished(false);
19891                        return Err(common::Error::MissingToken(e));
19892                    }
19893                },
19894            };
19895            let mut req_result = {
19896                let client = &self.hub.client;
19897                dlg.pre_request();
19898                let mut req_builder = hyper::Request::builder()
19899                    .method(hyper::Method::GET)
19900                    .uri(url.as_str())
19901                    .header(USER_AGENT, self.hub._user_agent.clone());
19902
19903                if let Some(token) = token.as_ref() {
19904                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19905                }
19906
19907                let request = req_builder
19908                    .header(CONTENT_LENGTH, 0_u64)
19909                    .body(common::to_body::<String>(None));
19910
19911                client.request(request.unwrap()).await
19912            };
19913
19914            match req_result {
19915                Err(err) => {
19916                    if let common::Retry::After(d) = dlg.http_error(&err) {
19917                        sleep(d).await;
19918                        continue;
19919                    }
19920                    dlg.finished(false);
19921                    return Err(common::Error::HttpError(err));
19922                }
19923                Ok(res) => {
19924                    let (mut parts, body) = res.into_parts();
19925                    let mut body = common::Body::new(body);
19926                    if !parts.status.is_success() {
19927                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19928                        let error = serde_json::from_str(&common::to_string(&bytes));
19929                        let response = common::to_response(parts, bytes.into());
19930
19931                        if let common::Retry::After(d) =
19932                            dlg.http_failure(&response, error.as_ref().ok())
19933                        {
19934                            sleep(d).await;
19935                            continue;
19936                        }
19937
19938                        dlg.finished(false);
19939
19940                        return Err(match error {
19941                            Ok(value) => common::Error::BadRequest(value),
19942                            _ => common::Error::Failure(response),
19943                        });
19944                    }
19945                    let response = {
19946                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19947                        let encoded = common::to_string(&bytes);
19948                        match serde_json::from_str(&encoded) {
19949                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19950                            Err(error) => {
19951                                dlg.response_json_decode_error(&encoded, &error);
19952                                return Err(common::Error::JsonDecodeError(
19953                                    encoded.to_string(),
19954                                    error,
19955                                ));
19956                            }
19957                        }
19958                    };
19959
19960                    dlg.finished(true);
19961                    return Ok(response);
19962                }
19963            }
19964        }
19965    }
19966
19967    /// The name of the operation's parent resource.
19968    ///
19969    /// Sets the *name* path property to the given value.
19970    ///
19971    /// Even though the property as already been set when instantiating this call,
19972    /// we provide this method for API completeness.
19973    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
19974        self._name = new_value.to_string();
19975        self
19976    }
19977    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
19978    ///
19979    /// Sets the *return partial success* query property to the given value.
19980    pub fn return_partial_success(
19981        mut self,
19982        new_value: bool,
19983    ) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
19984        self._return_partial_success = Some(new_value);
19985        self
19986    }
19987    /// The standard list page token.
19988    ///
19989    /// Sets the *page token* query property to the given value.
19990    pub fn page_token(
19991        mut self,
19992        new_value: &str,
19993    ) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
19994        self._page_token = Some(new_value.to_string());
19995        self
19996    }
19997    /// The standard list page size.
19998    ///
19999    /// Sets the *page size* query property to the given value.
20000    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
20001        self._page_size = Some(new_value);
20002        self
20003    }
20004    /// The standard list filter.
20005    ///
20006    /// Sets the *filter* query property to the given value.
20007    pub fn filter(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
20008        self._filter = Some(new_value.to_string());
20009        self
20010    }
20011    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20012    /// while executing the actual API request.
20013    ///
20014    /// ````text
20015    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20016    /// ````
20017    ///
20018    /// Sets the *delegate* property to the given value.
20019    pub fn delegate(
20020        mut self,
20021        new_value: &'a mut dyn common::Delegate,
20022    ) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
20023        self._delegate = Some(new_value);
20024        self
20025    }
20026
20027    /// Set any additional parameter of the query string used in the request.
20028    /// It should be used to set parameters which are not yet available through their own
20029    /// setters.
20030    ///
20031    /// Please note that this method must not be used to set any of the known parameters
20032    /// which have their own setter method. If done anyway, the request will fail.
20033    ///
20034    /// # Additional Parameters
20035    ///
20036    /// * *$.xgafv* (query-string) - V1 error format.
20037    /// * *access_token* (query-string) - OAuth access token.
20038    /// * *alt* (query-string) - Data format for response.
20039    /// * *callback* (query-string) - JSONP
20040    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20041    /// * *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.
20042    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20043    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20044    /// * *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.
20045    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20046    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20047    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseOperationListCall1<'a, C>
20048    where
20049        T: AsRef<str>,
20050    {
20051        self._additional_params
20052            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20053        self
20054    }
20055
20056    /// Identifies the authorization scope for the method you are building.
20057    ///
20058    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20059    /// [`Scope::CloudPlatform`].
20060    ///
20061    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20062    /// tokens for more than one scope.
20063    ///
20064    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20065    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20066    /// sufficient, a read-write scope will do as well.
20067    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationListCall1<'a, C>
20068    where
20069        St: AsRef<str>,
20070    {
20071        self._scopes.insert(String::from(scope.as_ref()));
20072        self
20073    }
20074    /// Identifies the authorization scope(s) for the method you are building.
20075    ///
20076    /// See [`Self::add_scope()`] for details.
20077    pub fn add_scopes<I, St>(
20078        mut self,
20079        scopes: I,
20080    ) -> ProjectInstanceDatabaseOperationListCall1<'a, C>
20081    where
20082        I: IntoIterator<Item = St>,
20083        St: AsRef<str>,
20084    {
20085        self._scopes
20086            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20087        self
20088    }
20089
20090    /// Removes all scopes, and no default scope will be used either.
20091    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20092    /// for details).
20093    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
20094        self._scopes.clear();
20095        self
20096    }
20097}
20098
20099/// Handles a single message from the client and returns the result as a stream. The server will interpret the message frame and respond with message frames to the client.
20100///
20101/// A builder for the *instances.databases.sessions.adaptMessage* method supported by a *project* resource.
20102/// It is not used directly, but through a [`ProjectMethods`] instance.
20103///
20104/// # Example
20105///
20106/// Instantiate a resource method builder
20107///
20108/// ```test_harness,no_run
20109/// # extern crate hyper;
20110/// # extern crate hyper_rustls;
20111/// # extern crate google_spanner1 as spanner1;
20112/// use spanner1::api::AdaptMessageRequest;
20113/// # async fn dox() {
20114/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20115///
20116/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20117/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20118/// #     .with_native_roots()
20119/// #     .unwrap()
20120/// #     .https_only()
20121/// #     .enable_http2()
20122/// #     .build();
20123///
20124/// # let executor = hyper_util::rt::TokioExecutor::new();
20125/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20126/// #     secret,
20127/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20128/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20129/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20130/// #     ),
20131/// # ).build().await.unwrap();
20132///
20133/// # let client = hyper_util::client::legacy::Client::builder(
20134/// #     hyper_util::rt::TokioExecutor::new()
20135/// # )
20136/// # .build(
20137/// #     hyper_rustls::HttpsConnectorBuilder::new()
20138/// #         .with_native_roots()
20139/// #         .unwrap()
20140/// #         .https_or_http()
20141/// #         .enable_http2()
20142/// #         .build()
20143/// # );
20144/// # let mut hub = Spanner::new(client, auth);
20145/// // As the method needs a request, you would usually fill it with the desired information
20146/// // into the respective structure. Some of the parts shown here might not be applicable !
20147/// // Values shown here are possibly random and not representative !
20148/// let mut req = AdaptMessageRequest::default();
20149///
20150/// // You can configure optional parameters by calling the respective setters at will, and
20151/// // execute the final call using `doit()`.
20152/// // Values shown here are possibly random and not representative !
20153/// let result = hub.projects().instances_databases_sessions_adapt_message(req, "name")
20154///              .doit().await;
20155/// # }
20156/// ```
20157pub struct ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C>
20158where
20159    C: 'a,
20160{
20161    hub: &'a Spanner<C>,
20162    _request: AdaptMessageRequest,
20163    _name: String,
20164    _delegate: Option<&'a mut dyn common::Delegate>,
20165    _additional_params: HashMap<String, String>,
20166    _scopes: BTreeSet<String>,
20167}
20168
20169impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C> {}
20170
20171impl<'a, C> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C>
20172where
20173    C: common::Connector,
20174{
20175    /// Perform the operation you have build so far.
20176    pub async fn doit(mut self) -> common::Result<(common::Response, AdaptMessageResponse)> {
20177        use std::borrow::Cow;
20178        use std::io::{Read, Seek};
20179
20180        use common::{url::Params, ToParts};
20181        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20182
20183        let mut dd = common::DefaultDelegate;
20184        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20185        dlg.begin(common::MethodInfo {
20186            id: "spanner.projects.instances.databases.sessions.adaptMessage",
20187            http_method: hyper::Method::POST,
20188        });
20189
20190        for &field in ["alt", "name"].iter() {
20191            if self._additional_params.contains_key(field) {
20192                dlg.finished(false);
20193                return Err(common::Error::FieldClash(field));
20194            }
20195        }
20196
20197        let mut params = Params::with_capacity(4 + self._additional_params.len());
20198        params.push("name", self._name);
20199
20200        params.extend(self._additional_params.iter());
20201
20202        params.push("alt", "json");
20203        let mut url = self.hub._base_url.clone() + "v1/{+name}:adaptMessage";
20204        if self._scopes.is_empty() {
20205            self._scopes
20206                .insert(Scope::CloudPlatform.as_ref().to_string());
20207        }
20208
20209        #[allow(clippy::single_element_loop)]
20210        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20211            url = params.uri_replacement(url, param_name, find_this, true);
20212        }
20213        {
20214            let to_remove = ["name"];
20215            params.remove_params(&to_remove);
20216        }
20217
20218        let url = params.parse_with_url(&url);
20219
20220        let mut json_mime_type = mime::APPLICATION_JSON;
20221        let mut request_value_reader = {
20222            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20223            common::remove_json_null_values(&mut value);
20224            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20225            serde_json::to_writer(&mut dst, &value).unwrap();
20226            dst
20227        };
20228        let request_size = request_value_reader
20229            .seek(std::io::SeekFrom::End(0))
20230            .unwrap();
20231        request_value_reader
20232            .seek(std::io::SeekFrom::Start(0))
20233            .unwrap();
20234
20235        loop {
20236            let token = match self
20237                .hub
20238                .auth
20239                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20240                .await
20241            {
20242                Ok(token) => token,
20243                Err(e) => match dlg.token(e) {
20244                    Ok(token) => token,
20245                    Err(e) => {
20246                        dlg.finished(false);
20247                        return Err(common::Error::MissingToken(e));
20248                    }
20249                },
20250            };
20251            request_value_reader
20252                .seek(std::io::SeekFrom::Start(0))
20253                .unwrap();
20254            let mut req_result = {
20255                let client = &self.hub.client;
20256                dlg.pre_request();
20257                let mut req_builder = hyper::Request::builder()
20258                    .method(hyper::Method::POST)
20259                    .uri(url.as_str())
20260                    .header(USER_AGENT, self.hub._user_agent.clone());
20261
20262                if let Some(token) = token.as_ref() {
20263                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20264                }
20265
20266                let request = req_builder
20267                    .header(CONTENT_TYPE, json_mime_type.to_string())
20268                    .header(CONTENT_LENGTH, request_size as u64)
20269                    .body(common::to_body(
20270                        request_value_reader.get_ref().clone().into(),
20271                    ));
20272
20273                client.request(request.unwrap()).await
20274            };
20275
20276            match req_result {
20277                Err(err) => {
20278                    if let common::Retry::After(d) = dlg.http_error(&err) {
20279                        sleep(d).await;
20280                        continue;
20281                    }
20282                    dlg.finished(false);
20283                    return Err(common::Error::HttpError(err));
20284                }
20285                Ok(res) => {
20286                    let (mut parts, body) = res.into_parts();
20287                    let mut body = common::Body::new(body);
20288                    if !parts.status.is_success() {
20289                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20290                        let error = serde_json::from_str(&common::to_string(&bytes));
20291                        let response = common::to_response(parts, bytes.into());
20292
20293                        if let common::Retry::After(d) =
20294                            dlg.http_failure(&response, error.as_ref().ok())
20295                        {
20296                            sleep(d).await;
20297                            continue;
20298                        }
20299
20300                        dlg.finished(false);
20301
20302                        return Err(match error {
20303                            Ok(value) => common::Error::BadRequest(value),
20304                            _ => common::Error::Failure(response),
20305                        });
20306                    }
20307                    let response = {
20308                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20309                        let encoded = common::to_string(&bytes);
20310                        match serde_json::from_str(&encoded) {
20311                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20312                            Err(error) => {
20313                                dlg.response_json_decode_error(&encoded, &error);
20314                                return Err(common::Error::JsonDecodeError(
20315                                    encoded.to_string(),
20316                                    error,
20317                                ));
20318                            }
20319                        }
20320                    };
20321
20322                    dlg.finished(true);
20323                    return Ok(response);
20324                }
20325            }
20326        }
20327    }
20328
20329    ///
20330    /// Sets the *request* property to the given value.
20331    ///
20332    /// Even though the property as already been set when instantiating this call,
20333    /// we provide this method for API completeness.
20334    pub fn request(
20335        mut self,
20336        new_value: AdaptMessageRequest,
20337    ) -> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C> {
20338        self._request = new_value;
20339        self
20340    }
20341    /// Required. The database session in which the adapter request is processed.
20342    ///
20343    /// Sets the *name* path property to the given value.
20344    ///
20345    /// Even though the property as already been set when instantiating this call,
20346    /// we provide this method for API completeness.
20347    pub fn name(
20348        mut self,
20349        new_value: &str,
20350    ) -> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C> {
20351        self._name = new_value.to_string();
20352        self
20353    }
20354    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20355    /// while executing the actual API request.
20356    ///
20357    /// ````text
20358    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20359    /// ````
20360    ///
20361    /// Sets the *delegate* property to the given value.
20362    pub fn delegate(
20363        mut self,
20364        new_value: &'a mut dyn common::Delegate,
20365    ) -> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C> {
20366        self._delegate = Some(new_value);
20367        self
20368    }
20369
20370    /// Set any additional parameter of the query string used in the request.
20371    /// It should be used to set parameters which are not yet available through their own
20372    /// setters.
20373    ///
20374    /// Please note that this method must not be used to set any of the known parameters
20375    /// which have their own setter method. If done anyway, the request will fail.
20376    ///
20377    /// # Additional Parameters
20378    ///
20379    /// * *$.xgafv* (query-string) - V1 error format.
20380    /// * *access_token* (query-string) - OAuth access token.
20381    /// * *alt* (query-string) - Data format for response.
20382    /// * *callback* (query-string) - JSONP
20383    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20384    /// * *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.
20385    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20386    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20387    /// * *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.
20388    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20389    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20390    pub fn param<T>(
20391        mut self,
20392        name: T,
20393        value: T,
20394    ) -> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C>
20395    where
20396        T: AsRef<str>,
20397    {
20398        self._additional_params
20399            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20400        self
20401    }
20402
20403    /// Identifies the authorization scope for the method you are building.
20404    ///
20405    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20406    /// [`Scope::CloudPlatform`].
20407    ///
20408    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20409    /// tokens for more than one scope.
20410    ///
20411    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20412    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20413    /// sufficient, a read-write scope will do as well.
20414    pub fn add_scope<St>(
20415        mut self,
20416        scope: St,
20417    ) -> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C>
20418    where
20419        St: AsRef<str>,
20420    {
20421        self._scopes.insert(String::from(scope.as_ref()));
20422        self
20423    }
20424    /// Identifies the authorization scope(s) for the method you are building.
20425    ///
20426    /// See [`Self::add_scope()`] for details.
20427    pub fn add_scopes<I, St>(
20428        mut self,
20429        scopes: I,
20430    ) -> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C>
20431    where
20432        I: IntoIterator<Item = St>,
20433        St: AsRef<str>,
20434    {
20435        self._scopes
20436            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20437        self
20438    }
20439
20440    /// Removes all scopes, and no default scope will be used either.
20441    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20442    /// for details).
20443    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionAdaptMessageCall<'a, C> {
20444        self._scopes.clear();
20445        self
20446    }
20447}
20448
20449/// Creates a new session to be used for requests made by the adapter. A session identifies a specific incarnation of a database resource and is meant to be reused across many `AdaptMessage` calls.
20450///
20451/// A builder for the *instances.databases.sessions.adapter* method supported by a *project* resource.
20452/// It is not used directly, but through a [`ProjectMethods`] instance.
20453///
20454/// # Example
20455///
20456/// Instantiate a resource method builder
20457///
20458/// ```test_harness,no_run
20459/// # extern crate hyper;
20460/// # extern crate hyper_rustls;
20461/// # extern crate google_spanner1 as spanner1;
20462/// use spanner1::api::AdapterSession;
20463/// # async fn dox() {
20464/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20465///
20466/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20467/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20468/// #     .with_native_roots()
20469/// #     .unwrap()
20470/// #     .https_only()
20471/// #     .enable_http2()
20472/// #     .build();
20473///
20474/// # let executor = hyper_util::rt::TokioExecutor::new();
20475/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20476/// #     secret,
20477/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20478/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20479/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20480/// #     ),
20481/// # ).build().await.unwrap();
20482///
20483/// # let client = hyper_util::client::legacy::Client::builder(
20484/// #     hyper_util::rt::TokioExecutor::new()
20485/// # )
20486/// # .build(
20487/// #     hyper_rustls::HttpsConnectorBuilder::new()
20488/// #         .with_native_roots()
20489/// #         .unwrap()
20490/// #         .https_or_http()
20491/// #         .enable_http2()
20492/// #         .build()
20493/// # );
20494/// # let mut hub = Spanner::new(client, auth);
20495/// // As the method needs a request, you would usually fill it with the desired information
20496/// // into the respective structure. Some of the parts shown here might not be applicable !
20497/// // Values shown here are possibly random and not representative !
20498/// let mut req = AdapterSession::default();
20499///
20500/// // You can configure optional parameters by calling the respective setters at will, and
20501/// // execute the final call using `doit()`.
20502/// // Values shown here are possibly random and not representative !
20503/// let result = hub.projects().instances_databases_sessions_adapter(req, "parent")
20504///              .doit().await;
20505/// # }
20506/// ```
20507pub struct ProjectInstanceDatabaseSessionAdapterCall<'a, C>
20508where
20509    C: 'a,
20510{
20511    hub: &'a Spanner<C>,
20512    _request: AdapterSession,
20513    _parent: String,
20514    _delegate: Option<&'a mut dyn common::Delegate>,
20515    _additional_params: HashMap<String, String>,
20516    _scopes: BTreeSet<String>,
20517}
20518
20519impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionAdapterCall<'a, C> {}
20520
20521impl<'a, C> ProjectInstanceDatabaseSessionAdapterCall<'a, C>
20522where
20523    C: common::Connector,
20524{
20525    /// Perform the operation you have build so far.
20526    pub async fn doit(mut self) -> common::Result<(common::Response, AdapterSession)> {
20527        use std::borrow::Cow;
20528        use std::io::{Read, Seek};
20529
20530        use common::{url::Params, ToParts};
20531        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20532
20533        let mut dd = common::DefaultDelegate;
20534        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20535        dlg.begin(common::MethodInfo {
20536            id: "spanner.projects.instances.databases.sessions.adapter",
20537            http_method: hyper::Method::POST,
20538        });
20539
20540        for &field in ["alt", "parent"].iter() {
20541            if self._additional_params.contains_key(field) {
20542                dlg.finished(false);
20543                return Err(common::Error::FieldClash(field));
20544            }
20545        }
20546
20547        let mut params = Params::with_capacity(4 + self._additional_params.len());
20548        params.push("parent", self._parent);
20549
20550        params.extend(self._additional_params.iter());
20551
20552        params.push("alt", "json");
20553        let mut url = self.hub._base_url.clone() + "v1/{+parent}/sessions:adapter";
20554        if self._scopes.is_empty() {
20555            self._scopes
20556                .insert(Scope::CloudPlatform.as_ref().to_string());
20557        }
20558
20559        #[allow(clippy::single_element_loop)]
20560        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20561            url = params.uri_replacement(url, param_name, find_this, true);
20562        }
20563        {
20564            let to_remove = ["parent"];
20565            params.remove_params(&to_remove);
20566        }
20567
20568        let url = params.parse_with_url(&url);
20569
20570        let mut json_mime_type = mime::APPLICATION_JSON;
20571        let mut request_value_reader = {
20572            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20573            common::remove_json_null_values(&mut value);
20574            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20575            serde_json::to_writer(&mut dst, &value).unwrap();
20576            dst
20577        };
20578        let request_size = request_value_reader
20579            .seek(std::io::SeekFrom::End(0))
20580            .unwrap();
20581        request_value_reader
20582            .seek(std::io::SeekFrom::Start(0))
20583            .unwrap();
20584
20585        loop {
20586            let token = match self
20587                .hub
20588                .auth
20589                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20590                .await
20591            {
20592                Ok(token) => token,
20593                Err(e) => match dlg.token(e) {
20594                    Ok(token) => token,
20595                    Err(e) => {
20596                        dlg.finished(false);
20597                        return Err(common::Error::MissingToken(e));
20598                    }
20599                },
20600            };
20601            request_value_reader
20602                .seek(std::io::SeekFrom::Start(0))
20603                .unwrap();
20604            let mut req_result = {
20605                let client = &self.hub.client;
20606                dlg.pre_request();
20607                let mut req_builder = hyper::Request::builder()
20608                    .method(hyper::Method::POST)
20609                    .uri(url.as_str())
20610                    .header(USER_AGENT, self.hub._user_agent.clone());
20611
20612                if let Some(token) = token.as_ref() {
20613                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20614                }
20615
20616                let request = req_builder
20617                    .header(CONTENT_TYPE, json_mime_type.to_string())
20618                    .header(CONTENT_LENGTH, request_size as u64)
20619                    .body(common::to_body(
20620                        request_value_reader.get_ref().clone().into(),
20621                    ));
20622
20623                client.request(request.unwrap()).await
20624            };
20625
20626            match req_result {
20627                Err(err) => {
20628                    if let common::Retry::After(d) = dlg.http_error(&err) {
20629                        sleep(d).await;
20630                        continue;
20631                    }
20632                    dlg.finished(false);
20633                    return Err(common::Error::HttpError(err));
20634                }
20635                Ok(res) => {
20636                    let (mut parts, body) = res.into_parts();
20637                    let mut body = common::Body::new(body);
20638                    if !parts.status.is_success() {
20639                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20640                        let error = serde_json::from_str(&common::to_string(&bytes));
20641                        let response = common::to_response(parts, bytes.into());
20642
20643                        if let common::Retry::After(d) =
20644                            dlg.http_failure(&response, error.as_ref().ok())
20645                        {
20646                            sleep(d).await;
20647                            continue;
20648                        }
20649
20650                        dlg.finished(false);
20651
20652                        return Err(match error {
20653                            Ok(value) => common::Error::BadRequest(value),
20654                            _ => common::Error::Failure(response),
20655                        });
20656                    }
20657                    let response = {
20658                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20659                        let encoded = common::to_string(&bytes);
20660                        match serde_json::from_str(&encoded) {
20661                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20662                            Err(error) => {
20663                                dlg.response_json_decode_error(&encoded, &error);
20664                                return Err(common::Error::JsonDecodeError(
20665                                    encoded.to_string(),
20666                                    error,
20667                                ));
20668                            }
20669                        }
20670                    };
20671
20672                    dlg.finished(true);
20673                    return Ok(response);
20674                }
20675            }
20676        }
20677    }
20678
20679    ///
20680    /// Sets the *request* property to the given value.
20681    ///
20682    /// Even though the property as already been set when instantiating this call,
20683    /// we provide this method for API completeness.
20684    pub fn request(
20685        mut self,
20686        new_value: AdapterSession,
20687    ) -> ProjectInstanceDatabaseSessionAdapterCall<'a, C> {
20688        self._request = new_value;
20689        self
20690    }
20691    /// Required. The database in which the new session is created.
20692    ///
20693    /// Sets the *parent* path property to the given value.
20694    ///
20695    /// Even though the property as already been set when instantiating this call,
20696    /// we provide this method for API completeness.
20697    pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionAdapterCall<'a, C> {
20698        self._parent = new_value.to_string();
20699        self
20700    }
20701    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20702    /// while executing the actual API request.
20703    ///
20704    /// ````text
20705    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20706    /// ````
20707    ///
20708    /// Sets the *delegate* property to the given value.
20709    pub fn delegate(
20710        mut self,
20711        new_value: &'a mut dyn common::Delegate,
20712    ) -> ProjectInstanceDatabaseSessionAdapterCall<'a, C> {
20713        self._delegate = Some(new_value);
20714        self
20715    }
20716
20717    /// Set any additional parameter of the query string used in the request.
20718    /// It should be used to set parameters which are not yet available through their own
20719    /// setters.
20720    ///
20721    /// Please note that this method must not be used to set any of the known parameters
20722    /// which have their own setter method. If done anyway, the request will fail.
20723    ///
20724    /// # Additional Parameters
20725    ///
20726    /// * *$.xgafv* (query-string) - V1 error format.
20727    /// * *access_token* (query-string) - OAuth access token.
20728    /// * *alt* (query-string) - Data format for response.
20729    /// * *callback* (query-string) - JSONP
20730    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20731    /// * *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.
20732    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20733    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20734    /// * *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.
20735    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20736    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20737    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionAdapterCall<'a, C>
20738    where
20739        T: AsRef<str>,
20740    {
20741        self._additional_params
20742            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20743        self
20744    }
20745
20746    /// Identifies the authorization scope for the method you are building.
20747    ///
20748    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20749    /// [`Scope::CloudPlatform`].
20750    ///
20751    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20752    /// tokens for more than one scope.
20753    ///
20754    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20755    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20756    /// sufficient, a read-write scope will do as well.
20757    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionAdapterCall<'a, C>
20758    where
20759        St: AsRef<str>,
20760    {
20761        self._scopes.insert(String::from(scope.as_ref()));
20762        self
20763    }
20764    /// Identifies the authorization scope(s) for the method you are building.
20765    ///
20766    /// See [`Self::add_scope()`] for details.
20767    pub fn add_scopes<I, St>(
20768        mut self,
20769        scopes: I,
20770    ) -> ProjectInstanceDatabaseSessionAdapterCall<'a, C>
20771    where
20772        I: IntoIterator<Item = St>,
20773        St: AsRef<str>,
20774    {
20775        self._scopes
20776            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20777        self
20778    }
20779
20780    /// Removes all scopes, and no default scope will be used either.
20781    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20782    /// for details).
20783    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionAdapterCall<'a, C> {
20784        self._scopes.clear();
20785        self
20786    }
20787}
20788
20789/// Creates multiple new sessions. This API can be used to initialize a session cache on the clients. See https://goo.gl/TgSFN2 for best practices on session cache management.
20790///
20791/// A builder for the *instances.databases.sessions.batchCreate* method supported by a *project* resource.
20792/// It is not used directly, but through a [`ProjectMethods`] instance.
20793///
20794/// # Example
20795///
20796/// Instantiate a resource method builder
20797///
20798/// ```test_harness,no_run
20799/// # extern crate hyper;
20800/// # extern crate hyper_rustls;
20801/// # extern crate google_spanner1 as spanner1;
20802/// use spanner1::api::BatchCreateSessionsRequest;
20803/// # async fn dox() {
20804/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20805///
20806/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20807/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20808/// #     .with_native_roots()
20809/// #     .unwrap()
20810/// #     .https_only()
20811/// #     .enable_http2()
20812/// #     .build();
20813///
20814/// # let executor = hyper_util::rt::TokioExecutor::new();
20815/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20816/// #     secret,
20817/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20818/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20819/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20820/// #     ),
20821/// # ).build().await.unwrap();
20822///
20823/// # let client = hyper_util::client::legacy::Client::builder(
20824/// #     hyper_util::rt::TokioExecutor::new()
20825/// # )
20826/// # .build(
20827/// #     hyper_rustls::HttpsConnectorBuilder::new()
20828/// #         .with_native_roots()
20829/// #         .unwrap()
20830/// #         .https_or_http()
20831/// #         .enable_http2()
20832/// #         .build()
20833/// # );
20834/// # let mut hub = Spanner::new(client, auth);
20835/// // As the method needs a request, you would usually fill it with the desired information
20836/// // into the respective structure. Some of the parts shown here might not be applicable !
20837/// // Values shown here are possibly random and not representative !
20838/// let mut req = BatchCreateSessionsRequest::default();
20839///
20840/// // You can configure optional parameters by calling the respective setters at will, and
20841/// // execute the final call using `doit()`.
20842/// // Values shown here are possibly random and not representative !
20843/// let result = hub.projects().instances_databases_sessions_batch_create(req, "database")
20844///              .doit().await;
20845/// # }
20846/// ```
20847pub struct ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
20848where
20849    C: 'a,
20850{
20851    hub: &'a Spanner<C>,
20852    _request: BatchCreateSessionsRequest,
20853    _database: String,
20854    _delegate: Option<&'a mut dyn common::Delegate>,
20855    _additional_params: HashMap<String, String>,
20856    _scopes: BTreeSet<String>,
20857}
20858
20859impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {}
20860
20861impl<'a, C> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
20862where
20863    C: common::Connector,
20864{
20865    /// Perform the operation you have build so far.
20866    pub async fn doit(mut self) -> common::Result<(common::Response, BatchCreateSessionsResponse)> {
20867        use std::borrow::Cow;
20868        use std::io::{Read, Seek};
20869
20870        use common::{url::Params, ToParts};
20871        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20872
20873        let mut dd = common::DefaultDelegate;
20874        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20875        dlg.begin(common::MethodInfo {
20876            id: "spanner.projects.instances.databases.sessions.batchCreate",
20877            http_method: hyper::Method::POST,
20878        });
20879
20880        for &field in ["alt", "database"].iter() {
20881            if self._additional_params.contains_key(field) {
20882                dlg.finished(false);
20883                return Err(common::Error::FieldClash(field));
20884            }
20885        }
20886
20887        let mut params = Params::with_capacity(4 + self._additional_params.len());
20888        params.push("database", self._database);
20889
20890        params.extend(self._additional_params.iter());
20891
20892        params.push("alt", "json");
20893        let mut url = self.hub._base_url.clone() + "v1/{+database}/sessions:batchCreate";
20894        if self._scopes.is_empty() {
20895            self._scopes
20896                .insert(Scope::CloudPlatform.as_ref().to_string());
20897        }
20898
20899        #[allow(clippy::single_element_loop)]
20900        for &(find_this, param_name) in [("{+database}", "database")].iter() {
20901            url = params.uri_replacement(url, param_name, find_this, true);
20902        }
20903        {
20904            let to_remove = ["database"];
20905            params.remove_params(&to_remove);
20906        }
20907
20908        let url = params.parse_with_url(&url);
20909
20910        let mut json_mime_type = mime::APPLICATION_JSON;
20911        let mut request_value_reader = {
20912            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20913            common::remove_json_null_values(&mut value);
20914            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20915            serde_json::to_writer(&mut dst, &value).unwrap();
20916            dst
20917        };
20918        let request_size = request_value_reader
20919            .seek(std::io::SeekFrom::End(0))
20920            .unwrap();
20921        request_value_reader
20922            .seek(std::io::SeekFrom::Start(0))
20923            .unwrap();
20924
20925        loop {
20926            let token = match self
20927                .hub
20928                .auth
20929                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20930                .await
20931            {
20932                Ok(token) => token,
20933                Err(e) => match dlg.token(e) {
20934                    Ok(token) => token,
20935                    Err(e) => {
20936                        dlg.finished(false);
20937                        return Err(common::Error::MissingToken(e));
20938                    }
20939                },
20940            };
20941            request_value_reader
20942                .seek(std::io::SeekFrom::Start(0))
20943                .unwrap();
20944            let mut req_result = {
20945                let client = &self.hub.client;
20946                dlg.pre_request();
20947                let mut req_builder = hyper::Request::builder()
20948                    .method(hyper::Method::POST)
20949                    .uri(url.as_str())
20950                    .header(USER_AGENT, self.hub._user_agent.clone());
20951
20952                if let Some(token) = token.as_ref() {
20953                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20954                }
20955
20956                let request = req_builder
20957                    .header(CONTENT_TYPE, json_mime_type.to_string())
20958                    .header(CONTENT_LENGTH, request_size as u64)
20959                    .body(common::to_body(
20960                        request_value_reader.get_ref().clone().into(),
20961                    ));
20962
20963                client.request(request.unwrap()).await
20964            };
20965
20966            match req_result {
20967                Err(err) => {
20968                    if let common::Retry::After(d) = dlg.http_error(&err) {
20969                        sleep(d).await;
20970                        continue;
20971                    }
20972                    dlg.finished(false);
20973                    return Err(common::Error::HttpError(err));
20974                }
20975                Ok(res) => {
20976                    let (mut parts, body) = res.into_parts();
20977                    let mut body = common::Body::new(body);
20978                    if !parts.status.is_success() {
20979                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20980                        let error = serde_json::from_str(&common::to_string(&bytes));
20981                        let response = common::to_response(parts, bytes.into());
20982
20983                        if let common::Retry::After(d) =
20984                            dlg.http_failure(&response, error.as_ref().ok())
20985                        {
20986                            sleep(d).await;
20987                            continue;
20988                        }
20989
20990                        dlg.finished(false);
20991
20992                        return Err(match error {
20993                            Ok(value) => common::Error::BadRequest(value),
20994                            _ => common::Error::Failure(response),
20995                        });
20996                    }
20997                    let response = {
20998                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20999                        let encoded = common::to_string(&bytes);
21000                        match serde_json::from_str(&encoded) {
21001                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21002                            Err(error) => {
21003                                dlg.response_json_decode_error(&encoded, &error);
21004                                return Err(common::Error::JsonDecodeError(
21005                                    encoded.to_string(),
21006                                    error,
21007                                ));
21008                            }
21009                        }
21010                    };
21011
21012                    dlg.finished(true);
21013                    return Ok(response);
21014                }
21015            }
21016        }
21017    }
21018
21019    ///
21020    /// Sets the *request* property to the given value.
21021    ///
21022    /// Even though the property as already been set when instantiating this call,
21023    /// we provide this method for API completeness.
21024    pub fn request(
21025        mut self,
21026        new_value: BatchCreateSessionsRequest,
21027    ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
21028        self._request = new_value;
21029        self
21030    }
21031    /// Required. The database in which the new sessions are created.
21032    ///
21033    /// Sets the *database* path property to the given value.
21034    ///
21035    /// Even though the property as already been set when instantiating this call,
21036    /// we provide this method for API completeness.
21037    pub fn database(
21038        mut self,
21039        new_value: &str,
21040    ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
21041        self._database = new_value.to_string();
21042        self
21043    }
21044    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21045    /// while executing the actual API request.
21046    ///
21047    /// ````text
21048    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21049    /// ````
21050    ///
21051    /// Sets the *delegate* property to the given value.
21052    pub fn delegate(
21053        mut self,
21054        new_value: &'a mut dyn common::Delegate,
21055    ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
21056        self._delegate = Some(new_value);
21057        self
21058    }
21059
21060    /// Set any additional parameter of the query string used in the request.
21061    /// It should be used to set parameters which are not yet available through their own
21062    /// setters.
21063    ///
21064    /// Please note that this method must not be used to set any of the known parameters
21065    /// which have their own setter method. If done anyway, the request will fail.
21066    ///
21067    /// # Additional Parameters
21068    ///
21069    /// * *$.xgafv* (query-string) - V1 error format.
21070    /// * *access_token* (query-string) - OAuth access token.
21071    /// * *alt* (query-string) - Data format for response.
21072    /// * *callback* (query-string) - JSONP
21073    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21074    /// * *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.
21075    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21076    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21077    /// * *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.
21078    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21079    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21080    pub fn param<T>(
21081        mut self,
21082        name: T,
21083        value: T,
21084    ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
21085    where
21086        T: AsRef<str>,
21087    {
21088        self._additional_params
21089            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21090        self
21091    }
21092
21093    /// Identifies the authorization scope for the method you are building.
21094    ///
21095    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21096    /// [`Scope::CloudPlatform`].
21097    ///
21098    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21099    /// tokens for more than one scope.
21100    ///
21101    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21102    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21103    /// sufficient, a read-write scope will do as well.
21104    pub fn add_scope<St>(
21105        mut self,
21106        scope: St,
21107    ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
21108    where
21109        St: AsRef<str>,
21110    {
21111        self._scopes.insert(String::from(scope.as_ref()));
21112        self
21113    }
21114    /// Identifies the authorization scope(s) for the method you are building.
21115    ///
21116    /// See [`Self::add_scope()`] for details.
21117    pub fn add_scopes<I, St>(
21118        mut self,
21119        scopes: I,
21120    ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
21121    where
21122        I: IntoIterator<Item = St>,
21123        St: AsRef<str>,
21124    {
21125        self._scopes
21126            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21127        self
21128    }
21129
21130    /// Removes all scopes, and no default scope will be used either.
21131    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21132    /// for details).
21133    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
21134        self._scopes.clear();
21135        self
21136    }
21137}
21138
21139/// Batches the supplied mutation groups in a collection of efficient transactions. All mutations in a group are committed atomically. However, mutations across groups can be committed non-atomically in an unspecified order and thus, they must be independent of each other. Partial failure is possible, that is, some groups might have been committed successfully, while some might have failed. The results of individual batches are streamed into the response as the batches are applied. `BatchWrite` requests are not replay protected, meaning that each mutation group can be applied more than once. Replays of non-idempotent mutations can have undesirable effects. For example, replays of an insert mutation can produce an already exists error or if you use generated or commit timestamp-based keys, it can result in additional rows being added to the mutation's table. We recommend structuring your mutation groups to be idempotent to avoid this issue.
21140///
21141/// A builder for the *instances.databases.sessions.batchWrite* method supported by a *project* resource.
21142/// It is not used directly, but through a [`ProjectMethods`] instance.
21143///
21144/// # Example
21145///
21146/// Instantiate a resource method builder
21147///
21148/// ```test_harness,no_run
21149/// # extern crate hyper;
21150/// # extern crate hyper_rustls;
21151/// # extern crate google_spanner1 as spanner1;
21152/// use spanner1::api::BatchWriteRequest;
21153/// # async fn dox() {
21154/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21155///
21156/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21157/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21158/// #     .with_native_roots()
21159/// #     .unwrap()
21160/// #     .https_only()
21161/// #     .enable_http2()
21162/// #     .build();
21163///
21164/// # let executor = hyper_util::rt::TokioExecutor::new();
21165/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21166/// #     secret,
21167/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21168/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21169/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21170/// #     ),
21171/// # ).build().await.unwrap();
21172///
21173/// # let client = hyper_util::client::legacy::Client::builder(
21174/// #     hyper_util::rt::TokioExecutor::new()
21175/// # )
21176/// # .build(
21177/// #     hyper_rustls::HttpsConnectorBuilder::new()
21178/// #         .with_native_roots()
21179/// #         .unwrap()
21180/// #         .https_or_http()
21181/// #         .enable_http2()
21182/// #         .build()
21183/// # );
21184/// # let mut hub = Spanner::new(client, auth);
21185/// // As the method needs a request, you would usually fill it with the desired information
21186/// // into the respective structure. Some of the parts shown here might not be applicable !
21187/// // Values shown here are possibly random and not representative !
21188/// let mut req = BatchWriteRequest::default();
21189///
21190/// // You can configure optional parameters by calling the respective setters at will, and
21191/// // execute the final call using `doit()`.
21192/// // Values shown here are possibly random and not representative !
21193/// let result = hub.projects().instances_databases_sessions_batch_write(req, "session")
21194///              .doit().await;
21195/// # }
21196/// ```
21197pub struct ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
21198where
21199    C: 'a,
21200{
21201    hub: &'a Spanner<C>,
21202    _request: BatchWriteRequest,
21203    _session: String,
21204    _delegate: Option<&'a mut dyn common::Delegate>,
21205    _additional_params: HashMap<String, String>,
21206    _scopes: BTreeSet<String>,
21207}
21208
21209impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {}
21210
21211impl<'a, C> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
21212where
21213    C: common::Connector,
21214{
21215    /// Perform the operation you have build so far.
21216    pub async fn doit(mut self) -> common::Result<(common::Response, BatchWriteResponse)> {
21217        use std::borrow::Cow;
21218        use std::io::{Read, Seek};
21219
21220        use common::{url::Params, ToParts};
21221        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21222
21223        let mut dd = common::DefaultDelegate;
21224        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21225        dlg.begin(common::MethodInfo {
21226            id: "spanner.projects.instances.databases.sessions.batchWrite",
21227            http_method: hyper::Method::POST,
21228        });
21229
21230        for &field in ["alt", "session"].iter() {
21231            if self._additional_params.contains_key(field) {
21232                dlg.finished(false);
21233                return Err(common::Error::FieldClash(field));
21234            }
21235        }
21236
21237        let mut params = Params::with_capacity(4 + self._additional_params.len());
21238        params.push("session", self._session);
21239
21240        params.extend(self._additional_params.iter());
21241
21242        params.push("alt", "json");
21243        let mut url = self.hub._base_url.clone() + "v1/{+session}:batchWrite";
21244        if self._scopes.is_empty() {
21245            self._scopes
21246                .insert(Scope::CloudPlatform.as_ref().to_string());
21247        }
21248
21249        #[allow(clippy::single_element_loop)]
21250        for &(find_this, param_name) in [("{+session}", "session")].iter() {
21251            url = params.uri_replacement(url, param_name, find_this, true);
21252        }
21253        {
21254            let to_remove = ["session"];
21255            params.remove_params(&to_remove);
21256        }
21257
21258        let url = params.parse_with_url(&url);
21259
21260        let mut json_mime_type = mime::APPLICATION_JSON;
21261        let mut request_value_reader = {
21262            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21263            common::remove_json_null_values(&mut value);
21264            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21265            serde_json::to_writer(&mut dst, &value).unwrap();
21266            dst
21267        };
21268        let request_size = request_value_reader
21269            .seek(std::io::SeekFrom::End(0))
21270            .unwrap();
21271        request_value_reader
21272            .seek(std::io::SeekFrom::Start(0))
21273            .unwrap();
21274
21275        loop {
21276            let token = match self
21277                .hub
21278                .auth
21279                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21280                .await
21281            {
21282                Ok(token) => token,
21283                Err(e) => match dlg.token(e) {
21284                    Ok(token) => token,
21285                    Err(e) => {
21286                        dlg.finished(false);
21287                        return Err(common::Error::MissingToken(e));
21288                    }
21289                },
21290            };
21291            request_value_reader
21292                .seek(std::io::SeekFrom::Start(0))
21293                .unwrap();
21294            let mut req_result = {
21295                let client = &self.hub.client;
21296                dlg.pre_request();
21297                let mut req_builder = hyper::Request::builder()
21298                    .method(hyper::Method::POST)
21299                    .uri(url.as_str())
21300                    .header(USER_AGENT, self.hub._user_agent.clone());
21301
21302                if let Some(token) = token.as_ref() {
21303                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21304                }
21305
21306                let request = req_builder
21307                    .header(CONTENT_TYPE, json_mime_type.to_string())
21308                    .header(CONTENT_LENGTH, request_size as u64)
21309                    .body(common::to_body(
21310                        request_value_reader.get_ref().clone().into(),
21311                    ));
21312
21313                client.request(request.unwrap()).await
21314            };
21315
21316            match req_result {
21317                Err(err) => {
21318                    if let common::Retry::After(d) = dlg.http_error(&err) {
21319                        sleep(d).await;
21320                        continue;
21321                    }
21322                    dlg.finished(false);
21323                    return Err(common::Error::HttpError(err));
21324                }
21325                Ok(res) => {
21326                    let (mut parts, body) = res.into_parts();
21327                    let mut body = common::Body::new(body);
21328                    if !parts.status.is_success() {
21329                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21330                        let error = serde_json::from_str(&common::to_string(&bytes));
21331                        let response = common::to_response(parts, bytes.into());
21332
21333                        if let common::Retry::After(d) =
21334                            dlg.http_failure(&response, error.as_ref().ok())
21335                        {
21336                            sleep(d).await;
21337                            continue;
21338                        }
21339
21340                        dlg.finished(false);
21341
21342                        return Err(match error {
21343                            Ok(value) => common::Error::BadRequest(value),
21344                            _ => common::Error::Failure(response),
21345                        });
21346                    }
21347                    let response = {
21348                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21349                        let encoded = common::to_string(&bytes);
21350                        match serde_json::from_str(&encoded) {
21351                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21352                            Err(error) => {
21353                                dlg.response_json_decode_error(&encoded, &error);
21354                                return Err(common::Error::JsonDecodeError(
21355                                    encoded.to_string(),
21356                                    error,
21357                                ));
21358                            }
21359                        }
21360                    };
21361
21362                    dlg.finished(true);
21363                    return Ok(response);
21364                }
21365            }
21366        }
21367    }
21368
21369    ///
21370    /// Sets the *request* property to the given value.
21371    ///
21372    /// Even though the property as already been set when instantiating this call,
21373    /// we provide this method for API completeness.
21374    pub fn request(
21375        mut self,
21376        new_value: BatchWriteRequest,
21377    ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
21378        self._request = new_value;
21379        self
21380    }
21381    /// Required. The session in which the batch request is to be run.
21382    ///
21383    /// Sets the *session* path property to the given value.
21384    ///
21385    /// Even though the property as already been set when instantiating this call,
21386    /// we provide this method for API completeness.
21387    pub fn session(
21388        mut self,
21389        new_value: &str,
21390    ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
21391        self._session = new_value.to_string();
21392        self
21393    }
21394    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21395    /// while executing the actual API request.
21396    ///
21397    /// ````text
21398    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21399    /// ````
21400    ///
21401    /// Sets the *delegate* property to the given value.
21402    pub fn delegate(
21403        mut self,
21404        new_value: &'a mut dyn common::Delegate,
21405    ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
21406        self._delegate = Some(new_value);
21407        self
21408    }
21409
21410    /// Set any additional parameter of the query string used in the request.
21411    /// It should be used to set parameters which are not yet available through their own
21412    /// setters.
21413    ///
21414    /// Please note that this method must not be used to set any of the known parameters
21415    /// which have their own setter method. If done anyway, the request will fail.
21416    ///
21417    /// # Additional Parameters
21418    ///
21419    /// * *$.xgafv* (query-string) - V1 error format.
21420    /// * *access_token* (query-string) - OAuth access token.
21421    /// * *alt* (query-string) - Data format for response.
21422    /// * *callback* (query-string) - JSONP
21423    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21424    /// * *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.
21425    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21426    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21427    /// * *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.
21428    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21429    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21430    pub fn param<T>(
21431        mut self,
21432        name: T,
21433        value: T,
21434    ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
21435    where
21436        T: AsRef<str>,
21437    {
21438        self._additional_params
21439            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21440        self
21441    }
21442
21443    /// Identifies the authorization scope for the method you are building.
21444    ///
21445    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21446    /// [`Scope::CloudPlatform`].
21447    ///
21448    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21449    /// tokens for more than one scope.
21450    ///
21451    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21452    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21453    /// sufficient, a read-write scope will do as well.
21454    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
21455    where
21456        St: AsRef<str>,
21457    {
21458        self._scopes.insert(String::from(scope.as_ref()));
21459        self
21460    }
21461    /// Identifies the authorization scope(s) for the method you are building.
21462    ///
21463    /// See [`Self::add_scope()`] for details.
21464    pub fn add_scopes<I, St>(
21465        mut self,
21466        scopes: I,
21467    ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
21468    where
21469        I: IntoIterator<Item = St>,
21470        St: AsRef<str>,
21471    {
21472        self._scopes
21473            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21474        self
21475    }
21476
21477    /// Removes all scopes, and no default scope will be used either.
21478    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21479    /// for details).
21480    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
21481        self._scopes.clear();
21482        self
21483    }
21484}
21485
21486/// Begins a new transaction. This step can often be skipped: Read, ExecuteSql and Commit can begin a new transaction as a side-effect.
21487///
21488/// A builder for the *instances.databases.sessions.beginTransaction* method supported by a *project* resource.
21489/// It is not used directly, but through a [`ProjectMethods`] instance.
21490///
21491/// # Example
21492///
21493/// Instantiate a resource method builder
21494///
21495/// ```test_harness,no_run
21496/// # extern crate hyper;
21497/// # extern crate hyper_rustls;
21498/// # extern crate google_spanner1 as spanner1;
21499/// use spanner1::api::BeginTransactionRequest;
21500/// # async fn dox() {
21501/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21502///
21503/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21504/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21505/// #     .with_native_roots()
21506/// #     .unwrap()
21507/// #     .https_only()
21508/// #     .enable_http2()
21509/// #     .build();
21510///
21511/// # let executor = hyper_util::rt::TokioExecutor::new();
21512/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21513/// #     secret,
21514/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21515/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21516/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21517/// #     ),
21518/// # ).build().await.unwrap();
21519///
21520/// # let client = hyper_util::client::legacy::Client::builder(
21521/// #     hyper_util::rt::TokioExecutor::new()
21522/// # )
21523/// # .build(
21524/// #     hyper_rustls::HttpsConnectorBuilder::new()
21525/// #         .with_native_roots()
21526/// #         .unwrap()
21527/// #         .https_or_http()
21528/// #         .enable_http2()
21529/// #         .build()
21530/// # );
21531/// # let mut hub = Spanner::new(client, auth);
21532/// // As the method needs a request, you would usually fill it with the desired information
21533/// // into the respective structure. Some of the parts shown here might not be applicable !
21534/// // Values shown here are possibly random and not representative !
21535/// let mut req = BeginTransactionRequest::default();
21536///
21537/// // You can configure optional parameters by calling the respective setters at will, and
21538/// // execute the final call using `doit()`.
21539/// // Values shown here are possibly random and not representative !
21540/// let result = hub.projects().instances_databases_sessions_begin_transaction(req, "session")
21541///              .doit().await;
21542/// # }
21543/// ```
21544pub struct ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
21545where
21546    C: 'a,
21547{
21548    hub: &'a Spanner<C>,
21549    _request: BeginTransactionRequest,
21550    _session: String,
21551    _delegate: Option<&'a mut dyn common::Delegate>,
21552    _additional_params: HashMap<String, String>,
21553    _scopes: BTreeSet<String>,
21554}
21555
21556impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {}
21557
21558impl<'a, C> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
21559where
21560    C: common::Connector,
21561{
21562    /// Perform the operation you have build so far.
21563    pub async fn doit(mut self) -> common::Result<(common::Response, Transaction)> {
21564        use std::borrow::Cow;
21565        use std::io::{Read, Seek};
21566
21567        use common::{url::Params, ToParts};
21568        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21569
21570        let mut dd = common::DefaultDelegate;
21571        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21572        dlg.begin(common::MethodInfo {
21573            id: "spanner.projects.instances.databases.sessions.beginTransaction",
21574            http_method: hyper::Method::POST,
21575        });
21576
21577        for &field in ["alt", "session"].iter() {
21578            if self._additional_params.contains_key(field) {
21579                dlg.finished(false);
21580                return Err(common::Error::FieldClash(field));
21581            }
21582        }
21583
21584        let mut params = Params::with_capacity(4 + self._additional_params.len());
21585        params.push("session", self._session);
21586
21587        params.extend(self._additional_params.iter());
21588
21589        params.push("alt", "json");
21590        let mut url = self.hub._base_url.clone() + "v1/{+session}:beginTransaction";
21591        if self._scopes.is_empty() {
21592            self._scopes
21593                .insert(Scope::CloudPlatform.as_ref().to_string());
21594        }
21595
21596        #[allow(clippy::single_element_loop)]
21597        for &(find_this, param_name) in [("{+session}", "session")].iter() {
21598            url = params.uri_replacement(url, param_name, find_this, true);
21599        }
21600        {
21601            let to_remove = ["session"];
21602            params.remove_params(&to_remove);
21603        }
21604
21605        let url = params.parse_with_url(&url);
21606
21607        let mut json_mime_type = mime::APPLICATION_JSON;
21608        let mut request_value_reader = {
21609            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21610            common::remove_json_null_values(&mut value);
21611            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21612            serde_json::to_writer(&mut dst, &value).unwrap();
21613            dst
21614        };
21615        let request_size = request_value_reader
21616            .seek(std::io::SeekFrom::End(0))
21617            .unwrap();
21618        request_value_reader
21619            .seek(std::io::SeekFrom::Start(0))
21620            .unwrap();
21621
21622        loop {
21623            let token = match self
21624                .hub
21625                .auth
21626                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21627                .await
21628            {
21629                Ok(token) => token,
21630                Err(e) => match dlg.token(e) {
21631                    Ok(token) => token,
21632                    Err(e) => {
21633                        dlg.finished(false);
21634                        return Err(common::Error::MissingToken(e));
21635                    }
21636                },
21637            };
21638            request_value_reader
21639                .seek(std::io::SeekFrom::Start(0))
21640                .unwrap();
21641            let mut req_result = {
21642                let client = &self.hub.client;
21643                dlg.pre_request();
21644                let mut req_builder = hyper::Request::builder()
21645                    .method(hyper::Method::POST)
21646                    .uri(url.as_str())
21647                    .header(USER_AGENT, self.hub._user_agent.clone());
21648
21649                if let Some(token) = token.as_ref() {
21650                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21651                }
21652
21653                let request = req_builder
21654                    .header(CONTENT_TYPE, json_mime_type.to_string())
21655                    .header(CONTENT_LENGTH, request_size as u64)
21656                    .body(common::to_body(
21657                        request_value_reader.get_ref().clone().into(),
21658                    ));
21659
21660                client.request(request.unwrap()).await
21661            };
21662
21663            match req_result {
21664                Err(err) => {
21665                    if let common::Retry::After(d) = dlg.http_error(&err) {
21666                        sleep(d).await;
21667                        continue;
21668                    }
21669                    dlg.finished(false);
21670                    return Err(common::Error::HttpError(err));
21671                }
21672                Ok(res) => {
21673                    let (mut parts, body) = res.into_parts();
21674                    let mut body = common::Body::new(body);
21675                    if !parts.status.is_success() {
21676                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21677                        let error = serde_json::from_str(&common::to_string(&bytes));
21678                        let response = common::to_response(parts, bytes.into());
21679
21680                        if let common::Retry::After(d) =
21681                            dlg.http_failure(&response, error.as_ref().ok())
21682                        {
21683                            sleep(d).await;
21684                            continue;
21685                        }
21686
21687                        dlg.finished(false);
21688
21689                        return Err(match error {
21690                            Ok(value) => common::Error::BadRequest(value),
21691                            _ => common::Error::Failure(response),
21692                        });
21693                    }
21694                    let response = {
21695                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21696                        let encoded = common::to_string(&bytes);
21697                        match serde_json::from_str(&encoded) {
21698                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21699                            Err(error) => {
21700                                dlg.response_json_decode_error(&encoded, &error);
21701                                return Err(common::Error::JsonDecodeError(
21702                                    encoded.to_string(),
21703                                    error,
21704                                ));
21705                            }
21706                        }
21707                    };
21708
21709                    dlg.finished(true);
21710                    return Ok(response);
21711                }
21712            }
21713        }
21714    }
21715
21716    ///
21717    /// Sets the *request* property to the given value.
21718    ///
21719    /// Even though the property as already been set when instantiating this call,
21720    /// we provide this method for API completeness.
21721    pub fn request(
21722        mut self,
21723        new_value: BeginTransactionRequest,
21724    ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
21725        self._request = new_value;
21726        self
21727    }
21728    /// Required. The session in which the transaction runs.
21729    ///
21730    /// Sets the *session* path property to the given value.
21731    ///
21732    /// Even though the property as already been set when instantiating this call,
21733    /// we provide this method for API completeness.
21734    pub fn session(
21735        mut self,
21736        new_value: &str,
21737    ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
21738        self._session = new_value.to_string();
21739        self
21740    }
21741    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21742    /// while executing the actual API request.
21743    ///
21744    /// ````text
21745    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21746    /// ````
21747    ///
21748    /// Sets the *delegate* property to the given value.
21749    pub fn delegate(
21750        mut self,
21751        new_value: &'a mut dyn common::Delegate,
21752    ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
21753        self._delegate = Some(new_value);
21754        self
21755    }
21756
21757    /// Set any additional parameter of the query string used in the request.
21758    /// It should be used to set parameters which are not yet available through their own
21759    /// setters.
21760    ///
21761    /// Please note that this method must not be used to set any of the known parameters
21762    /// which have their own setter method. If done anyway, the request will fail.
21763    ///
21764    /// # Additional Parameters
21765    ///
21766    /// * *$.xgafv* (query-string) - V1 error format.
21767    /// * *access_token* (query-string) - OAuth access token.
21768    /// * *alt* (query-string) - Data format for response.
21769    /// * *callback* (query-string) - JSONP
21770    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21771    /// * *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.
21772    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21773    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21774    /// * *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.
21775    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21776    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21777    pub fn param<T>(
21778        mut self,
21779        name: T,
21780        value: T,
21781    ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
21782    where
21783        T: AsRef<str>,
21784    {
21785        self._additional_params
21786            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21787        self
21788    }
21789
21790    /// Identifies the authorization scope for the method you are building.
21791    ///
21792    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21793    /// [`Scope::CloudPlatform`].
21794    ///
21795    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21796    /// tokens for more than one scope.
21797    ///
21798    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21799    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21800    /// sufficient, a read-write scope will do as well.
21801    pub fn add_scope<St>(
21802        mut self,
21803        scope: St,
21804    ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
21805    where
21806        St: AsRef<str>,
21807    {
21808        self._scopes.insert(String::from(scope.as_ref()));
21809        self
21810    }
21811    /// Identifies the authorization scope(s) for the method you are building.
21812    ///
21813    /// See [`Self::add_scope()`] for details.
21814    pub fn add_scopes<I, St>(
21815        mut self,
21816        scopes: I,
21817    ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
21818    where
21819        I: IntoIterator<Item = St>,
21820        St: AsRef<str>,
21821    {
21822        self._scopes
21823            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21824        self
21825    }
21826
21827    /// Removes all scopes, and no default scope will be used either.
21828    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21829    /// for details).
21830    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
21831        self._scopes.clear();
21832        self
21833    }
21834}
21835
21836/// Commits a transaction. The request includes the mutations to be applied to rows in the database. `Commit` might return an `ABORTED` error. This can occur at any time; commonly, the cause is conflicts with concurrent transactions. However, it can also happen for a variety of other reasons. If `Commit` returns `ABORTED`, the caller should retry the transaction from the beginning, reusing the same session. On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, for example, if the client job experiences a 1+ hour networking failure. At that point, Cloud Spanner has lost track of the transaction outcome and we recommend that you perform another read from the database to see the state of things as they are now.
21837///
21838/// A builder for the *instances.databases.sessions.commit* method supported by a *project* resource.
21839/// It is not used directly, but through a [`ProjectMethods`] instance.
21840///
21841/// # Example
21842///
21843/// Instantiate a resource method builder
21844///
21845/// ```test_harness,no_run
21846/// # extern crate hyper;
21847/// # extern crate hyper_rustls;
21848/// # extern crate google_spanner1 as spanner1;
21849/// use spanner1::api::CommitRequest;
21850/// # async fn dox() {
21851/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21852///
21853/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21854/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21855/// #     .with_native_roots()
21856/// #     .unwrap()
21857/// #     .https_only()
21858/// #     .enable_http2()
21859/// #     .build();
21860///
21861/// # let executor = hyper_util::rt::TokioExecutor::new();
21862/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21863/// #     secret,
21864/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21865/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21866/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21867/// #     ),
21868/// # ).build().await.unwrap();
21869///
21870/// # let client = hyper_util::client::legacy::Client::builder(
21871/// #     hyper_util::rt::TokioExecutor::new()
21872/// # )
21873/// # .build(
21874/// #     hyper_rustls::HttpsConnectorBuilder::new()
21875/// #         .with_native_roots()
21876/// #         .unwrap()
21877/// #         .https_or_http()
21878/// #         .enable_http2()
21879/// #         .build()
21880/// # );
21881/// # let mut hub = Spanner::new(client, auth);
21882/// // As the method needs a request, you would usually fill it with the desired information
21883/// // into the respective structure. Some of the parts shown here might not be applicable !
21884/// // Values shown here are possibly random and not representative !
21885/// let mut req = CommitRequest::default();
21886///
21887/// // You can configure optional parameters by calling the respective setters at will, and
21888/// // execute the final call using `doit()`.
21889/// // Values shown here are possibly random and not representative !
21890/// let result = hub.projects().instances_databases_sessions_commit(req, "session")
21891///              .doit().await;
21892/// # }
21893/// ```
21894pub struct ProjectInstanceDatabaseSessionCommitCall<'a, C>
21895where
21896    C: 'a,
21897{
21898    hub: &'a Spanner<C>,
21899    _request: CommitRequest,
21900    _session: String,
21901    _delegate: Option<&'a mut dyn common::Delegate>,
21902    _additional_params: HashMap<String, String>,
21903    _scopes: BTreeSet<String>,
21904}
21905
21906impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionCommitCall<'a, C> {}
21907
21908impl<'a, C> ProjectInstanceDatabaseSessionCommitCall<'a, C>
21909where
21910    C: common::Connector,
21911{
21912    /// Perform the operation you have build so far.
21913    pub async fn doit(mut self) -> common::Result<(common::Response, CommitResponse)> {
21914        use std::borrow::Cow;
21915        use std::io::{Read, Seek};
21916
21917        use common::{url::Params, ToParts};
21918        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21919
21920        let mut dd = common::DefaultDelegate;
21921        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21922        dlg.begin(common::MethodInfo {
21923            id: "spanner.projects.instances.databases.sessions.commit",
21924            http_method: hyper::Method::POST,
21925        });
21926
21927        for &field in ["alt", "session"].iter() {
21928            if self._additional_params.contains_key(field) {
21929                dlg.finished(false);
21930                return Err(common::Error::FieldClash(field));
21931            }
21932        }
21933
21934        let mut params = Params::with_capacity(4 + self._additional_params.len());
21935        params.push("session", self._session);
21936
21937        params.extend(self._additional_params.iter());
21938
21939        params.push("alt", "json");
21940        let mut url = self.hub._base_url.clone() + "v1/{+session}:commit";
21941        if self._scopes.is_empty() {
21942            self._scopes
21943                .insert(Scope::CloudPlatform.as_ref().to_string());
21944        }
21945
21946        #[allow(clippy::single_element_loop)]
21947        for &(find_this, param_name) in [("{+session}", "session")].iter() {
21948            url = params.uri_replacement(url, param_name, find_this, true);
21949        }
21950        {
21951            let to_remove = ["session"];
21952            params.remove_params(&to_remove);
21953        }
21954
21955        let url = params.parse_with_url(&url);
21956
21957        let mut json_mime_type = mime::APPLICATION_JSON;
21958        let mut request_value_reader = {
21959            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21960            common::remove_json_null_values(&mut value);
21961            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21962            serde_json::to_writer(&mut dst, &value).unwrap();
21963            dst
21964        };
21965        let request_size = request_value_reader
21966            .seek(std::io::SeekFrom::End(0))
21967            .unwrap();
21968        request_value_reader
21969            .seek(std::io::SeekFrom::Start(0))
21970            .unwrap();
21971
21972        loop {
21973            let token = match self
21974                .hub
21975                .auth
21976                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21977                .await
21978            {
21979                Ok(token) => token,
21980                Err(e) => match dlg.token(e) {
21981                    Ok(token) => token,
21982                    Err(e) => {
21983                        dlg.finished(false);
21984                        return Err(common::Error::MissingToken(e));
21985                    }
21986                },
21987            };
21988            request_value_reader
21989                .seek(std::io::SeekFrom::Start(0))
21990                .unwrap();
21991            let mut req_result = {
21992                let client = &self.hub.client;
21993                dlg.pre_request();
21994                let mut req_builder = hyper::Request::builder()
21995                    .method(hyper::Method::POST)
21996                    .uri(url.as_str())
21997                    .header(USER_AGENT, self.hub._user_agent.clone());
21998
21999                if let Some(token) = token.as_ref() {
22000                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22001                }
22002
22003                let request = req_builder
22004                    .header(CONTENT_TYPE, json_mime_type.to_string())
22005                    .header(CONTENT_LENGTH, request_size as u64)
22006                    .body(common::to_body(
22007                        request_value_reader.get_ref().clone().into(),
22008                    ));
22009
22010                client.request(request.unwrap()).await
22011            };
22012
22013            match req_result {
22014                Err(err) => {
22015                    if let common::Retry::After(d) = dlg.http_error(&err) {
22016                        sleep(d).await;
22017                        continue;
22018                    }
22019                    dlg.finished(false);
22020                    return Err(common::Error::HttpError(err));
22021                }
22022                Ok(res) => {
22023                    let (mut parts, body) = res.into_parts();
22024                    let mut body = common::Body::new(body);
22025                    if !parts.status.is_success() {
22026                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22027                        let error = serde_json::from_str(&common::to_string(&bytes));
22028                        let response = common::to_response(parts, bytes.into());
22029
22030                        if let common::Retry::After(d) =
22031                            dlg.http_failure(&response, error.as_ref().ok())
22032                        {
22033                            sleep(d).await;
22034                            continue;
22035                        }
22036
22037                        dlg.finished(false);
22038
22039                        return Err(match error {
22040                            Ok(value) => common::Error::BadRequest(value),
22041                            _ => common::Error::Failure(response),
22042                        });
22043                    }
22044                    let response = {
22045                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22046                        let encoded = common::to_string(&bytes);
22047                        match serde_json::from_str(&encoded) {
22048                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22049                            Err(error) => {
22050                                dlg.response_json_decode_error(&encoded, &error);
22051                                return Err(common::Error::JsonDecodeError(
22052                                    encoded.to_string(),
22053                                    error,
22054                                ));
22055                            }
22056                        }
22057                    };
22058
22059                    dlg.finished(true);
22060                    return Ok(response);
22061                }
22062            }
22063        }
22064    }
22065
22066    ///
22067    /// Sets the *request* property to the given value.
22068    ///
22069    /// Even though the property as already been set when instantiating this call,
22070    /// we provide this method for API completeness.
22071    pub fn request(
22072        mut self,
22073        new_value: CommitRequest,
22074    ) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
22075        self._request = new_value;
22076        self
22077    }
22078    /// Required. The session in which the transaction to be committed is running.
22079    ///
22080    /// Sets the *session* path property to the given value.
22081    ///
22082    /// Even though the property as already been set when instantiating this call,
22083    /// we provide this method for API completeness.
22084    pub fn session(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
22085        self._session = new_value.to_string();
22086        self
22087    }
22088    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22089    /// while executing the actual API request.
22090    ///
22091    /// ````text
22092    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22093    /// ````
22094    ///
22095    /// Sets the *delegate* property to the given value.
22096    pub fn delegate(
22097        mut self,
22098        new_value: &'a mut dyn common::Delegate,
22099    ) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
22100        self._delegate = Some(new_value);
22101        self
22102    }
22103
22104    /// Set any additional parameter of the query string used in the request.
22105    /// It should be used to set parameters which are not yet available through their own
22106    /// setters.
22107    ///
22108    /// Please note that this method must not be used to set any of the known parameters
22109    /// which have their own setter method. If done anyway, the request will fail.
22110    ///
22111    /// # Additional Parameters
22112    ///
22113    /// * *$.xgafv* (query-string) - V1 error format.
22114    /// * *access_token* (query-string) - OAuth access token.
22115    /// * *alt* (query-string) - Data format for response.
22116    /// * *callback* (query-string) - JSONP
22117    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22118    /// * *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.
22119    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22120    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22121    /// * *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.
22122    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22123    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22124    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionCommitCall<'a, C>
22125    where
22126        T: AsRef<str>,
22127    {
22128        self._additional_params
22129            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22130        self
22131    }
22132
22133    /// Identifies the authorization scope for the method you are building.
22134    ///
22135    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22136    /// [`Scope::CloudPlatform`].
22137    ///
22138    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22139    /// tokens for more than one scope.
22140    ///
22141    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22142    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22143    /// sufficient, a read-write scope will do as well.
22144    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionCommitCall<'a, C>
22145    where
22146        St: AsRef<str>,
22147    {
22148        self._scopes.insert(String::from(scope.as_ref()));
22149        self
22150    }
22151    /// Identifies the authorization scope(s) for the method you are building.
22152    ///
22153    /// See [`Self::add_scope()`] for details.
22154    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionCommitCall<'a, C>
22155    where
22156        I: IntoIterator<Item = St>,
22157        St: AsRef<str>,
22158    {
22159        self._scopes
22160            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22161        self
22162    }
22163
22164    /// Removes all scopes, and no default scope will be used either.
22165    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22166    /// for details).
22167    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
22168        self._scopes.clear();
22169        self
22170    }
22171}
22172
22173/// Creates a new session. A session can be used to perform transactions that read and/or modify data in a Cloud Spanner database. Sessions are meant to be reused for many consecutive transactions. Sessions can only execute one transaction at a time. To execute multiple concurrent read-write/write-only transactions, create multiple sessions. Note that standalone reads and queries use a transaction internally, and count toward the one transaction limit. Active sessions use additional server resources, so it's a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner can delete sessions when no operations are sent for more than an hour. If a session is deleted, requests to it return `NOT_FOUND`. Idle sessions can be kept alive by sending a trivial SQL query periodically, for example, `"SELECT 1"`.
22174///
22175/// A builder for the *instances.databases.sessions.create* method supported by a *project* resource.
22176/// It is not used directly, but through a [`ProjectMethods`] instance.
22177///
22178/// # Example
22179///
22180/// Instantiate a resource method builder
22181///
22182/// ```test_harness,no_run
22183/// # extern crate hyper;
22184/// # extern crate hyper_rustls;
22185/// # extern crate google_spanner1 as spanner1;
22186/// use spanner1::api::CreateSessionRequest;
22187/// # async fn dox() {
22188/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22189///
22190/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22191/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22192/// #     .with_native_roots()
22193/// #     .unwrap()
22194/// #     .https_only()
22195/// #     .enable_http2()
22196/// #     .build();
22197///
22198/// # let executor = hyper_util::rt::TokioExecutor::new();
22199/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22200/// #     secret,
22201/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22202/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22203/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22204/// #     ),
22205/// # ).build().await.unwrap();
22206///
22207/// # let client = hyper_util::client::legacy::Client::builder(
22208/// #     hyper_util::rt::TokioExecutor::new()
22209/// # )
22210/// # .build(
22211/// #     hyper_rustls::HttpsConnectorBuilder::new()
22212/// #         .with_native_roots()
22213/// #         .unwrap()
22214/// #         .https_or_http()
22215/// #         .enable_http2()
22216/// #         .build()
22217/// # );
22218/// # let mut hub = Spanner::new(client, auth);
22219/// // As the method needs a request, you would usually fill it with the desired information
22220/// // into the respective structure. Some of the parts shown here might not be applicable !
22221/// // Values shown here are possibly random and not representative !
22222/// let mut req = CreateSessionRequest::default();
22223///
22224/// // You can configure optional parameters by calling the respective setters at will, and
22225/// // execute the final call using `doit()`.
22226/// // Values shown here are possibly random and not representative !
22227/// let result = hub.projects().instances_databases_sessions_create(req, "database")
22228///              .doit().await;
22229/// # }
22230/// ```
22231pub struct ProjectInstanceDatabaseSessionCreateCall<'a, C>
22232where
22233    C: 'a,
22234{
22235    hub: &'a Spanner<C>,
22236    _request: CreateSessionRequest,
22237    _database: String,
22238    _delegate: Option<&'a mut dyn common::Delegate>,
22239    _additional_params: HashMap<String, String>,
22240    _scopes: BTreeSet<String>,
22241}
22242
22243impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionCreateCall<'a, C> {}
22244
22245impl<'a, C> ProjectInstanceDatabaseSessionCreateCall<'a, C>
22246where
22247    C: common::Connector,
22248{
22249    /// Perform the operation you have build so far.
22250    pub async fn doit(mut self) -> common::Result<(common::Response, Session)> {
22251        use std::borrow::Cow;
22252        use std::io::{Read, Seek};
22253
22254        use common::{url::Params, ToParts};
22255        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22256
22257        let mut dd = common::DefaultDelegate;
22258        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22259        dlg.begin(common::MethodInfo {
22260            id: "spanner.projects.instances.databases.sessions.create",
22261            http_method: hyper::Method::POST,
22262        });
22263
22264        for &field in ["alt", "database"].iter() {
22265            if self._additional_params.contains_key(field) {
22266                dlg.finished(false);
22267                return Err(common::Error::FieldClash(field));
22268            }
22269        }
22270
22271        let mut params = Params::with_capacity(4 + self._additional_params.len());
22272        params.push("database", self._database);
22273
22274        params.extend(self._additional_params.iter());
22275
22276        params.push("alt", "json");
22277        let mut url = self.hub._base_url.clone() + "v1/{+database}/sessions";
22278        if self._scopes.is_empty() {
22279            self._scopes
22280                .insert(Scope::CloudPlatform.as_ref().to_string());
22281        }
22282
22283        #[allow(clippy::single_element_loop)]
22284        for &(find_this, param_name) in [("{+database}", "database")].iter() {
22285            url = params.uri_replacement(url, param_name, find_this, true);
22286        }
22287        {
22288            let to_remove = ["database"];
22289            params.remove_params(&to_remove);
22290        }
22291
22292        let url = params.parse_with_url(&url);
22293
22294        let mut json_mime_type = mime::APPLICATION_JSON;
22295        let mut request_value_reader = {
22296            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22297            common::remove_json_null_values(&mut value);
22298            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22299            serde_json::to_writer(&mut dst, &value).unwrap();
22300            dst
22301        };
22302        let request_size = request_value_reader
22303            .seek(std::io::SeekFrom::End(0))
22304            .unwrap();
22305        request_value_reader
22306            .seek(std::io::SeekFrom::Start(0))
22307            .unwrap();
22308
22309        loop {
22310            let token = match self
22311                .hub
22312                .auth
22313                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22314                .await
22315            {
22316                Ok(token) => token,
22317                Err(e) => match dlg.token(e) {
22318                    Ok(token) => token,
22319                    Err(e) => {
22320                        dlg.finished(false);
22321                        return Err(common::Error::MissingToken(e));
22322                    }
22323                },
22324            };
22325            request_value_reader
22326                .seek(std::io::SeekFrom::Start(0))
22327                .unwrap();
22328            let mut req_result = {
22329                let client = &self.hub.client;
22330                dlg.pre_request();
22331                let mut req_builder = hyper::Request::builder()
22332                    .method(hyper::Method::POST)
22333                    .uri(url.as_str())
22334                    .header(USER_AGENT, self.hub._user_agent.clone());
22335
22336                if let Some(token) = token.as_ref() {
22337                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22338                }
22339
22340                let request = req_builder
22341                    .header(CONTENT_TYPE, json_mime_type.to_string())
22342                    .header(CONTENT_LENGTH, request_size as u64)
22343                    .body(common::to_body(
22344                        request_value_reader.get_ref().clone().into(),
22345                    ));
22346
22347                client.request(request.unwrap()).await
22348            };
22349
22350            match req_result {
22351                Err(err) => {
22352                    if let common::Retry::After(d) = dlg.http_error(&err) {
22353                        sleep(d).await;
22354                        continue;
22355                    }
22356                    dlg.finished(false);
22357                    return Err(common::Error::HttpError(err));
22358                }
22359                Ok(res) => {
22360                    let (mut parts, body) = res.into_parts();
22361                    let mut body = common::Body::new(body);
22362                    if !parts.status.is_success() {
22363                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22364                        let error = serde_json::from_str(&common::to_string(&bytes));
22365                        let response = common::to_response(parts, bytes.into());
22366
22367                        if let common::Retry::After(d) =
22368                            dlg.http_failure(&response, error.as_ref().ok())
22369                        {
22370                            sleep(d).await;
22371                            continue;
22372                        }
22373
22374                        dlg.finished(false);
22375
22376                        return Err(match error {
22377                            Ok(value) => common::Error::BadRequest(value),
22378                            _ => common::Error::Failure(response),
22379                        });
22380                    }
22381                    let response = {
22382                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22383                        let encoded = common::to_string(&bytes);
22384                        match serde_json::from_str(&encoded) {
22385                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22386                            Err(error) => {
22387                                dlg.response_json_decode_error(&encoded, &error);
22388                                return Err(common::Error::JsonDecodeError(
22389                                    encoded.to_string(),
22390                                    error,
22391                                ));
22392                            }
22393                        }
22394                    };
22395
22396                    dlg.finished(true);
22397                    return Ok(response);
22398                }
22399            }
22400        }
22401    }
22402
22403    ///
22404    /// Sets the *request* property to the given value.
22405    ///
22406    /// Even though the property as already been set when instantiating this call,
22407    /// we provide this method for API completeness.
22408    pub fn request(
22409        mut self,
22410        new_value: CreateSessionRequest,
22411    ) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
22412        self._request = new_value;
22413        self
22414    }
22415    /// Required. The database in which the new session is created.
22416    ///
22417    /// Sets the *database* path property to the given value.
22418    ///
22419    /// Even though the property as already been set when instantiating this call,
22420    /// we provide this method for API completeness.
22421    pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
22422        self._database = new_value.to_string();
22423        self
22424    }
22425    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22426    /// while executing the actual API request.
22427    ///
22428    /// ````text
22429    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22430    /// ````
22431    ///
22432    /// Sets the *delegate* property to the given value.
22433    pub fn delegate(
22434        mut self,
22435        new_value: &'a mut dyn common::Delegate,
22436    ) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
22437        self._delegate = Some(new_value);
22438        self
22439    }
22440
22441    /// Set any additional parameter of the query string used in the request.
22442    /// It should be used to set parameters which are not yet available through their own
22443    /// setters.
22444    ///
22445    /// Please note that this method must not be used to set any of the known parameters
22446    /// which have their own setter method. If done anyway, the request will fail.
22447    ///
22448    /// # Additional Parameters
22449    ///
22450    /// * *$.xgafv* (query-string) - V1 error format.
22451    /// * *access_token* (query-string) - OAuth access token.
22452    /// * *alt* (query-string) - Data format for response.
22453    /// * *callback* (query-string) - JSONP
22454    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22455    /// * *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.
22456    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22457    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22458    /// * *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.
22459    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22460    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22461    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionCreateCall<'a, C>
22462    where
22463        T: AsRef<str>,
22464    {
22465        self._additional_params
22466            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22467        self
22468    }
22469
22470    /// Identifies the authorization scope for the method you are building.
22471    ///
22472    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22473    /// [`Scope::CloudPlatform`].
22474    ///
22475    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22476    /// tokens for more than one scope.
22477    ///
22478    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22479    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22480    /// sufficient, a read-write scope will do as well.
22481    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionCreateCall<'a, C>
22482    where
22483        St: AsRef<str>,
22484    {
22485        self._scopes.insert(String::from(scope.as_ref()));
22486        self
22487    }
22488    /// Identifies the authorization scope(s) for the method you are building.
22489    ///
22490    /// See [`Self::add_scope()`] for details.
22491    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionCreateCall<'a, C>
22492    where
22493        I: IntoIterator<Item = St>,
22494        St: AsRef<str>,
22495    {
22496        self._scopes
22497            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22498        self
22499    }
22500
22501    /// Removes all scopes, and no default scope will be used either.
22502    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22503    /// for details).
22504    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
22505        self._scopes.clear();
22506        self
22507    }
22508}
22509
22510/// Ends a session, releasing server resources associated with it. This asynchronously triggers the cancellation of any operations that are running with this session.
22511///
22512/// A builder for the *instances.databases.sessions.delete* method supported by a *project* resource.
22513/// It is not used directly, but through a [`ProjectMethods`] instance.
22514///
22515/// # Example
22516///
22517/// Instantiate a resource method builder
22518///
22519/// ```test_harness,no_run
22520/// # extern crate hyper;
22521/// # extern crate hyper_rustls;
22522/// # extern crate google_spanner1 as spanner1;
22523/// # async fn dox() {
22524/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22525///
22526/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22527/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22528/// #     .with_native_roots()
22529/// #     .unwrap()
22530/// #     .https_only()
22531/// #     .enable_http2()
22532/// #     .build();
22533///
22534/// # let executor = hyper_util::rt::TokioExecutor::new();
22535/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22536/// #     secret,
22537/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22538/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22539/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22540/// #     ),
22541/// # ).build().await.unwrap();
22542///
22543/// # let client = hyper_util::client::legacy::Client::builder(
22544/// #     hyper_util::rt::TokioExecutor::new()
22545/// # )
22546/// # .build(
22547/// #     hyper_rustls::HttpsConnectorBuilder::new()
22548/// #         .with_native_roots()
22549/// #         .unwrap()
22550/// #         .https_or_http()
22551/// #         .enable_http2()
22552/// #         .build()
22553/// # );
22554/// # let mut hub = Spanner::new(client, auth);
22555/// // You can configure optional parameters by calling the respective setters at will, and
22556/// // execute the final call using `doit()`.
22557/// // Values shown here are possibly random and not representative !
22558/// let result = hub.projects().instances_databases_sessions_delete("name")
22559///              .doit().await;
22560/// # }
22561/// ```
22562pub struct ProjectInstanceDatabaseSessionDeleteCall<'a, C>
22563where
22564    C: 'a,
22565{
22566    hub: &'a Spanner<C>,
22567    _name: String,
22568    _delegate: Option<&'a mut dyn common::Delegate>,
22569    _additional_params: HashMap<String, String>,
22570    _scopes: BTreeSet<String>,
22571}
22572
22573impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionDeleteCall<'a, C> {}
22574
22575impl<'a, C> ProjectInstanceDatabaseSessionDeleteCall<'a, C>
22576where
22577    C: common::Connector,
22578{
22579    /// Perform the operation you have build so far.
22580    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
22581        use std::borrow::Cow;
22582        use std::io::{Read, Seek};
22583
22584        use common::{url::Params, ToParts};
22585        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22586
22587        let mut dd = common::DefaultDelegate;
22588        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22589        dlg.begin(common::MethodInfo {
22590            id: "spanner.projects.instances.databases.sessions.delete",
22591            http_method: hyper::Method::DELETE,
22592        });
22593
22594        for &field in ["alt", "name"].iter() {
22595            if self._additional_params.contains_key(field) {
22596                dlg.finished(false);
22597                return Err(common::Error::FieldClash(field));
22598            }
22599        }
22600
22601        let mut params = Params::with_capacity(3 + self._additional_params.len());
22602        params.push("name", self._name);
22603
22604        params.extend(self._additional_params.iter());
22605
22606        params.push("alt", "json");
22607        let mut url = self.hub._base_url.clone() + "v1/{+name}";
22608        if self._scopes.is_empty() {
22609            self._scopes
22610                .insert(Scope::CloudPlatform.as_ref().to_string());
22611        }
22612
22613        #[allow(clippy::single_element_loop)]
22614        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22615            url = params.uri_replacement(url, param_name, find_this, true);
22616        }
22617        {
22618            let to_remove = ["name"];
22619            params.remove_params(&to_remove);
22620        }
22621
22622        let url = params.parse_with_url(&url);
22623
22624        loop {
22625            let token = match self
22626                .hub
22627                .auth
22628                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22629                .await
22630            {
22631                Ok(token) => token,
22632                Err(e) => match dlg.token(e) {
22633                    Ok(token) => token,
22634                    Err(e) => {
22635                        dlg.finished(false);
22636                        return Err(common::Error::MissingToken(e));
22637                    }
22638                },
22639            };
22640            let mut req_result = {
22641                let client = &self.hub.client;
22642                dlg.pre_request();
22643                let mut req_builder = hyper::Request::builder()
22644                    .method(hyper::Method::DELETE)
22645                    .uri(url.as_str())
22646                    .header(USER_AGENT, self.hub._user_agent.clone());
22647
22648                if let Some(token) = token.as_ref() {
22649                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22650                }
22651
22652                let request = req_builder
22653                    .header(CONTENT_LENGTH, 0_u64)
22654                    .body(common::to_body::<String>(None));
22655
22656                client.request(request.unwrap()).await
22657            };
22658
22659            match req_result {
22660                Err(err) => {
22661                    if let common::Retry::After(d) = dlg.http_error(&err) {
22662                        sleep(d).await;
22663                        continue;
22664                    }
22665                    dlg.finished(false);
22666                    return Err(common::Error::HttpError(err));
22667                }
22668                Ok(res) => {
22669                    let (mut parts, body) = res.into_parts();
22670                    let mut body = common::Body::new(body);
22671                    if !parts.status.is_success() {
22672                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22673                        let error = serde_json::from_str(&common::to_string(&bytes));
22674                        let response = common::to_response(parts, bytes.into());
22675
22676                        if let common::Retry::After(d) =
22677                            dlg.http_failure(&response, error.as_ref().ok())
22678                        {
22679                            sleep(d).await;
22680                            continue;
22681                        }
22682
22683                        dlg.finished(false);
22684
22685                        return Err(match error {
22686                            Ok(value) => common::Error::BadRequest(value),
22687                            _ => common::Error::Failure(response),
22688                        });
22689                    }
22690                    let response = {
22691                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22692                        let encoded = common::to_string(&bytes);
22693                        match serde_json::from_str(&encoded) {
22694                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22695                            Err(error) => {
22696                                dlg.response_json_decode_error(&encoded, &error);
22697                                return Err(common::Error::JsonDecodeError(
22698                                    encoded.to_string(),
22699                                    error,
22700                                ));
22701                            }
22702                        }
22703                    };
22704
22705                    dlg.finished(true);
22706                    return Ok(response);
22707                }
22708            }
22709        }
22710    }
22711
22712    /// Required. The name of the session to delete.
22713    ///
22714    /// Sets the *name* path property to the given value.
22715    ///
22716    /// Even though the property as already been set when instantiating this call,
22717    /// we provide this method for API completeness.
22718    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C> {
22719        self._name = new_value.to_string();
22720        self
22721    }
22722    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22723    /// while executing the actual API request.
22724    ///
22725    /// ````text
22726    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22727    /// ````
22728    ///
22729    /// Sets the *delegate* property to the given value.
22730    pub fn delegate(
22731        mut self,
22732        new_value: &'a mut dyn common::Delegate,
22733    ) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C> {
22734        self._delegate = Some(new_value);
22735        self
22736    }
22737
22738    /// Set any additional parameter of the query string used in the request.
22739    /// It should be used to set parameters which are not yet available through their own
22740    /// setters.
22741    ///
22742    /// Please note that this method must not be used to set any of the known parameters
22743    /// which have their own setter method. If done anyway, the request will fail.
22744    ///
22745    /// # Additional Parameters
22746    ///
22747    /// * *$.xgafv* (query-string) - V1 error format.
22748    /// * *access_token* (query-string) - OAuth access token.
22749    /// * *alt* (query-string) - Data format for response.
22750    /// * *callback* (query-string) - JSONP
22751    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22752    /// * *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.
22753    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22754    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22755    /// * *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.
22756    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22757    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22758    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C>
22759    where
22760        T: AsRef<str>,
22761    {
22762        self._additional_params
22763            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22764        self
22765    }
22766
22767    /// Identifies the authorization scope for the method you are building.
22768    ///
22769    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22770    /// [`Scope::CloudPlatform`].
22771    ///
22772    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22773    /// tokens for more than one scope.
22774    ///
22775    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22776    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22777    /// sufficient, a read-write scope will do as well.
22778    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C>
22779    where
22780        St: AsRef<str>,
22781    {
22782        self._scopes.insert(String::from(scope.as_ref()));
22783        self
22784    }
22785    /// Identifies the authorization scope(s) for the method you are building.
22786    ///
22787    /// See [`Self::add_scope()`] for details.
22788    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C>
22789    where
22790        I: IntoIterator<Item = St>,
22791        St: AsRef<str>,
22792    {
22793        self._scopes
22794            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22795        self
22796    }
22797
22798    /// Removes all scopes, and no default scope will be used either.
22799    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22800    /// for details).
22801    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C> {
22802        self._scopes.clear();
22803        self
22804    }
22805}
22806
22807/// Executes a batch of SQL DML statements. This method allows many statements to be run with lower latency than submitting them sequentially with ExecuteSql. Statements are executed in sequential order. A request can succeed even if a statement fails. The ExecuteBatchDmlResponse.status field in the response provides information about the statement that failed. Clients must inspect this field to determine whether an error occurred. Execution stops after the first failed statement; the remaining statements are not executed.
22808///
22809/// A builder for the *instances.databases.sessions.executeBatchDml* method supported by a *project* resource.
22810/// It is not used directly, but through a [`ProjectMethods`] instance.
22811///
22812/// # Example
22813///
22814/// Instantiate a resource method builder
22815///
22816/// ```test_harness,no_run
22817/// # extern crate hyper;
22818/// # extern crate hyper_rustls;
22819/// # extern crate google_spanner1 as spanner1;
22820/// use spanner1::api::ExecuteBatchDmlRequest;
22821/// # async fn dox() {
22822/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22823///
22824/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22825/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22826/// #     .with_native_roots()
22827/// #     .unwrap()
22828/// #     .https_only()
22829/// #     .enable_http2()
22830/// #     .build();
22831///
22832/// # let executor = hyper_util::rt::TokioExecutor::new();
22833/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22834/// #     secret,
22835/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22836/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22837/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22838/// #     ),
22839/// # ).build().await.unwrap();
22840///
22841/// # let client = hyper_util::client::legacy::Client::builder(
22842/// #     hyper_util::rt::TokioExecutor::new()
22843/// # )
22844/// # .build(
22845/// #     hyper_rustls::HttpsConnectorBuilder::new()
22846/// #         .with_native_roots()
22847/// #         .unwrap()
22848/// #         .https_or_http()
22849/// #         .enable_http2()
22850/// #         .build()
22851/// # );
22852/// # let mut hub = Spanner::new(client, auth);
22853/// // As the method needs a request, you would usually fill it with the desired information
22854/// // into the respective structure. Some of the parts shown here might not be applicable !
22855/// // Values shown here are possibly random and not representative !
22856/// let mut req = ExecuteBatchDmlRequest::default();
22857///
22858/// // You can configure optional parameters by calling the respective setters at will, and
22859/// // execute the final call using `doit()`.
22860/// // Values shown here are possibly random and not representative !
22861/// let result = hub.projects().instances_databases_sessions_execute_batch_dml(req, "session")
22862///              .doit().await;
22863/// # }
22864/// ```
22865pub struct ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
22866where
22867    C: 'a,
22868{
22869    hub: &'a Spanner<C>,
22870    _request: ExecuteBatchDmlRequest,
22871    _session: String,
22872    _delegate: Option<&'a mut dyn common::Delegate>,
22873    _additional_params: HashMap<String, String>,
22874    _scopes: BTreeSet<String>,
22875}
22876
22877impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {}
22878
22879impl<'a, C> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
22880where
22881    C: common::Connector,
22882{
22883    /// Perform the operation you have build so far.
22884    pub async fn doit(mut self) -> common::Result<(common::Response, ExecuteBatchDmlResponse)> {
22885        use std::borrow::Cow;
22886        use std::io::{Read, Seek};
22887
22888        use common::{url::Params, ToParts};
22889        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22890
22891        let mut dd = common::DefaultDelegate;
22892        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22893        dlg.begin(common::MethodInfo {
22894            id: "spanner.projects.instances.databases.sessions.executeBatchDml",
22895            http_method: hyper::Method::POST,
22896        });
22897
22898        for &field in ["alt", "session"].iter() {
22899            if self._additional_params.contains_key(field) {
22900                dlg.finished(false);
22901                return Err(common::Error::FieldClash(field));
22902            }
22903        }
22904
22905        let mut params = Params::with_capacity(4 + self._additional_params.len());
22906        params.push("session", self._session);
22907
22908        params.extend(self._additional_params.iter());
22909
22910        params.push("alt", "json");
22911        let mut url = self.hub._base_url.clone() + "v1/{+session}:executeBatchDml";
22912        if self._scopes.is_empty() {
22913            self._scopes
22914                .insert(Scope::CloudPlatform.as_ref().to_string());
22915        }
22916
22917        #[allow(clippy::single_element_loop)]
22918        for &(find_this, param_name) in [("{+session}", "session")].iter() {
22919            url = params.uri_replacement(url, param_name, find_this, true);
22920        }
22921        {
22922            let to_remove = ["session"];
22923            params.remove_params(&to_remove);
22924        }
22925
22926        let url = params.parse_with_url(&url);
22927
22928        let mut json_mime_type = mime::APPLICATION_JSON;
22929        let mut request_value_reader = {
22930            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22931            common::remove_json_null_values(&mut value);
22932            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22933            serde_json::to_writer(&mut dst, &value).unwrap();
22934            dst
22935        };
22936        let request_size = request_value_reader
22937            .seek(std::io::SeekFrom::End(0))
22938            .unwrap();
22939        request_value_reader
22940            .seek(std::io::SeekFrom::Start(0))
22941            .unwrap();
22942
22943        loop {
22944            let token = match self
22945                .hub
22946                .auth
22947                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22948                .await
22949            {
22950                Ok(token) => token,
22951                Err(e) => match dlg.token(e) {
22952                    Ok(token) => token,
22953                    Err(e) => {
22954                        dlg.finished(false);
22955                        return Err(common::Error::MissingToken(e));
22956                    }
22957                },
22958            };
22959            request_value_reader
22960                .seek(std::io::SeekFrom::Start(0))
22961                .unwrap();
22962            let mut req_result = {
22963                let client = &self.hub.client;
22964                dlg.pre_request();
22965                let mut req_builder = hyper::Request::builder()
22966                    .method(hyper::Method::POST)
22967                    .uri(url.as_str())
22968                    .header(USER_AGENT, self.hub._user_agent.clone());
22969
22970                if let Some(token) = token.as_ref() {
22971                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22972                }
22973
22974                let request = req_builder
22975                    .header(CONTENT_TYPE, json_mime_type.to_string())
22976                    .header(CONTENT_LENGTH, request_size as u64)
22977                    .body(common::to_body(
22978                        request_value_reader.get_ref().clone().into(),
22979                    ));
22980
22981                client.request(request.unwrap()).await
22982            };
22983
22984            match req_result {
22985                Err(err) => {
22986                    if let common::Retry::After(d) = dlg.http_error(&err) {
22987                        sleep(d).await;
22988                        continue;
22989                    }
22990                    dlg.finished(false);
22991                    return Err(common::Error::HttpError(err));
22992                }
22993                Ok(res) => {
22994                    let (mut parts, body) = res.into_parts();
22995                    let mut body = common::Body::new(body);
22996                    if !parts.status.is_success() {
22997                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22998                        let error = serde_json::from_str(&common::to_string(&bytes));
22999                        let response = common::to_response(parts, bytes.into());
23000
23001                        if let common::Retry::After(d) =
23002                            dlg.http_failure(&response, error.as_ref().ok())
23003                        {
23004                            sleep(d).await;
23005                            continue;
23006                        }
23007
23008                        dlg.finished(false);
23009
23010                        return Err(match error {
23011                            Ok(value) => common::Error::BadRequest(value),
23012                            _ => common::Error::Failure(response),
23013                        });
23014                    }
23015                    let response = {
23016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23017                        let encoded = common::to_string(&bytes);
23018                        match serde_json::from_str(&encoded) {
23019                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23020                            Err(error) => {
23021                                dlg.response_json_decode_error(&encoded, &error);
23022                                return Err(common::Error::JsonDecodeError(
23023                                    encoded.to_string(),
23024                                    error,
23025                                ));
23026                            }
23027                        }
23028                    };
23029
23030                    dlg.finished(true);
23031                    return Ok(response);
23032                }
23033            }
23034        }
23035    }
23036
23037    ///
23038    /// Sets the *request* property to the given value.
23039    ///
23040    /// Even though the property as already been set when instantiating this call,
23041    /// we provide this method for API completeness.
23042    pub fn request(
23043        mut self,
23044        new_value: ExecuteBatchDmlRequest,
23045    ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
23046        self._request = new_value;
23047        self
23048    }
23049    /// Required. The session in which the DML statements should be performed.
23050    ///
23051    /// Sets the *session* path property to the given value.
23052    ///
23053    /// Even though the property as already been set when instantiating this call,
23054    /// we provide this method for API completeness.
23055    pub fn session(
23056        mut self,
23057        new_value: &str,
23058    ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
23059        self._session = new_value.to_string();
23060        self
23061    }
23062    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23063    /// while executing the actual API request.
23064    ///
23065    /// ````text
23066    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23067    /// ````
23068    ///
23069    /// Sets the *delegate* property to the given value.
23070    pub fn delegate(
23071        mut self,
23072        new_value: &'a mut dyn common::Delegate,
23073    ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
23074        self._delegate = Some(new_value);
23075        self
23076    }
23077
23078    /// Set any additional parameter of the query string used in the request.
23079    /// It should be used to set parameters which are not yet available through their own
23080    /// setters.
23081    ///
23082    /// Please note that this method must not be used to set any of the known parameters
23083    /// which have their own setter method. If done anyway, the request will fail.
23084    ///
23085    /// # Additional Parameters
23086    ///
23087    /// * *$.xgafv* (query-string) - V1 error format.
23088    /// * *access_token* (query-string) - OAuth access token.
23089    /// * *alt* (query-string) - Data format for response.
23090    /// * *callback* (query-string) - JSONP
23091    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23092    /// * *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.
23093    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23094    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23095    /// * *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.
23096    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23097    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23098    pub fn param<T>(
23099        mut self,
23100        name: T,
23101        value: T,
23102    ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
23103    where
23104        T: AsRef<str>,
23105    {
23106        self._additional_params
23107            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23108        self
23109    }
23110
23111    /// Identifies the authorization scope for the method you are building.
23112    ///
23113    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23114    /// [`Scope::CloudPlatform`].
23115    ///
23116    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23117    /// tokens for more than one scope.
23118    ///
23119    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23120    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23121    /// sufficient, a read-write scope will do as well.
23122    pub fn add_scope<St>(
23123        mut self,
23124        scope: St,
23125    ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
23126    where
23127        St: AsRef<str>,
23128    {
23129        self._scopes.insert(String::from(scope.as_ref()));
23130        self
23131    }
23132    /// Identifies the authorization scope(s) for the method you are building.
23133    ///
23134    /// See [`Self::add_scope()`] for details.
23135    pub fn add_scopes<I, St>(
23136        mut self,
23137        scopes: I,
23138    ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
23139    where
23140        I: IntoIterator<Item = St>,
23141        St: AsRef<str>,
23142    {
23143        self._scopes
23144            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23145        self
23146    }
23147
23148    /// Removes all scopes, and no default scope will be used either.
23149    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23150    /// for details).
23151    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
23152        self._scopes.clear();
23153        self
23154    }
23155}
23156
23157/// Executes an SQL statement, returning all results in a single reply. This method can't be used to return a result set larger than 10 MiB; if the query yields more data than that, the query fails with a `FAILED_PRECONDITION` error. Operations inside read-write transactions might return `ABORTED`. If this occurs, the application should restart the transaction from the beginning. See Transaction for more details. Larger result sets can be fetched in streaming fashion by calling ExecuteStreamingSql instead. The query string can be SQL or [Graph Query Language (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro).
23158///
23159/// A builder for the *instances.databases.sessions.executeSql* method supported by a *project* resource.
23160/// It is not used directly, but through a [`ProjectMethods`] instance.
23161///
23162/// # Example
23163///
23164/// Instantiate a resource method builder
23165///
23166/// ```test_harness,no_run
23167/// # extern crate hyper;
23168/// # extern crate hyper_rustls;
23169/// # extern crate google_spanner1 as spanner1;
23170/// use spanner1::api::ExecuteSqlRequest;
23171/// # async fn dox() {
23172/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23173///
23174/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23175/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23176/// #     .with_native_roots()
23177/// #     .unwrap()
23178/// #     .https_only()
23179/// #     .enable_http2()
23180/// #     .build();
23181///
23182/// # let executor = hyper_util::rt::TokioExecutor::new();
23183/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23184/// #     secret,
23185/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23186/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23187/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23188/// #     ),
23189/// # ).build().await.unwrap();
23190///
23191/// # let client = hyper_util::client::legacy::Client::builder(
23192/// #     hyper_util::rt::TokioExecutor::new()
23193/// # )
23194/// # .build(
23195/// #     hyper_rustls::HttpsConnectorBuilder::new()
23196/// #         .with_native_roots()
23197/// #         .unwrap()
23198/// #         .https_or_http()
23199/// #         .enable_http2()
23200/// #         .build()
23201/// # );
23202/// # let mut hub = Spanner::new(client, auth);
23203/// // As the method needs a request, you would usually fill it with the desired information
23204/// // into the respective structure. Some of the parts shown here might not be applicable !
23205/// // Values shown here are possibly random and not representative !
23206/// let mut req = ExecuteSqlRequest::default();
23207///
23208/// // You can configure optional parameters by calling the respective setters at will, and
23209/// // execute the final call using `doit()`.
23210/// // Values shown here are possibly random and not representative !
23211/// let result = hub.projects().instances_databases_sessions_execute_sql(req, "session")
23212///              .doit().await;
23213/// # }
23214/// ```
23215pub struct ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
23216where
23217    C: 'a,
23218{
23219    hub: &'a Spanner<C>,
23220    _request: ExecuteSqlRequest,
23221    _session: String,
23222    _delegate: Option<&'a mut dyn common::Delegate>,
23223    _additional_params: HashMap<String, String>,
23224    _scopes: BTreeSet<String>,
23225}
23226
23227impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {}
23228
23229impl<'a, C> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
23230where
23231    C: common::Connector,
23232{
23233    /// Perform the operation you have build so far.
23234    pub async fn doit(mut self) -> common::Result<(common::Response, ResultSet)> {
23235        use std::borrow::Cow;
23236        use std::io::{Read, Seek};
23237
23238        use common::{url::Params, ToParts};
23239        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23240
23241        let mut dd = common::DefaultDelegate;
23242        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23243        dlg.begin(common::MethodInfo {
23244            id: "spanner.projects.instances.databases.sessions.executeSql",
23245            http_method: hyper::Method::POST,
23246        });
23247
23248        for &field in ["alt", "session"].iter() {
23249            if self._additional_params.contains_key(field) {
23250                dlg.finished(false);
23251                return Err(common::Error::FieldClash(field));
23252            }
23253        }
23254
23255        let mut params = Params::with_capacity(4 + self._additional_params.len());
23256        params.push("session", self._session);
23257
23258        params.extend(self._additional_params.iter());
23259
23260        params.push("alt", "json");
23261        let mut url = self.hub._base_url.clone() + "v1/{+session}:executeSql";
23262        if self._scopes.is_empty() {
23263            self._scopes
23264                .insert(Scope::CloudPlatform.as_ref().to_string());
23265        }
23266
23267        #[allow(clippy::single_element_loop)]
23268        for &(find_this, param_name) in [("{+session}", "session")].iter() {
23269            url = params.uri_replacement(url, param_name, find_this, true);
23270        }
23271        {
23272            let to_remove = ["session"];
23273            params.remove_params(&to_remove);
23274        }
23275
23276        let url = params.parse_with_url(&url);
23277
23278        let mut json_mime_type = mime::APPLICATION_JSON;
23279        let mut request_value_reader = {
23280            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23281            common::remove_json_null_values(&mut value);
23282            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23283            serde_json::to_writer(&mut dst, &value).unwrap();
23284            dst
23285        };
23286        let request_size = request_value_reader
23287            .seek(std::io::SeekFrom::End(0))
23288            .unwrap();
23289        request_value_reader
23290            .seek(std::io::SeekFrom::Start(0))
23291            .unwrap();
23292
23293        loop {
23294            let token = match self
23295                .hub
23296                .auth
23297                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23298                .await
23299            {
23300                Ok(token) => token,
23301                Err(e) => match dlg.token(e) {
23302                    Ok(token) => token,
23303                    Err(e) => {
23304                        dlg.finished(false);
23305                        return Err(common::Error::MissingToken(e));
23306                    }
23307                },
23308            };
23309            request_value_reader
23310                .seek(std::io::SeekFrom::Start(0))
23311                .unwrap();
23312            let mut req_result = {
23313                let client = &self.hub.client;
23314                dlg.pre_request();
23315                let mut req_builder = hyper::Request::builder()
23316                    .method(hyper::Method::POST)
23317                    .uri(url.as_str())
23318                    .header(USER_AGENT, self.hub._user_agent.clone());
23319
23320                if let Some(token) = token.as_ref() {
23321                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23322                }
23323
23324                let request = req_builder
23325                    .header(CONTENT_TYPE, json_mime_type.to_string())
23326                    .header(CONTENT_LENGTH, request_size as u64)
23327                    .body(common::to_body(
23328                        request_value_reader.get_ref().clone().into(),
23329                    ));
23330
23331                client.request(request.unwrap()).await
23332            };
23333
23334            match req_result {
23335                Err(err) => {
23336                    if let common::Retry::After(d) = dlg.http_error(&err) {
23337                        sleep(d).await;
23338                        continue;
23339                    }
23340                    dlg.finished(false);
23341                    return Err(common::Error::HttpError(err));
23342                }
23343                Ok(res) => {
23344                    let (mut parts, body) = res.into_parts();
23345                    let mut body = common::Body::new(body);
23346                    if !parts.status.is_success() {
23347                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23348                        let error = serde_json::from_str(&common::to_string(&bytes));
23349                        let response = common::to_response(parts, bytes.into());
23350
23351                        if let common::Retry::After(d) =
23352                            dlg.http_failure(&response, error.as_ref().ok())
23353                        {
23354                            sleep(d).await;
23355                            continue;
23356                        }
23357
23358                        dlg.finished(false);
23359
23360                        return Err(match error {
23361                            Ok(value) => common::Error::BadRequest(value),
23362                            _ => common::Error::Failure(response),
23363                        });
23364                    }
23365                    let response = {
23366                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23367                        let encoded = common::to_string(&bytes);
23368                        match serde_json::from_str(&encoded) {
23369                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23370                            Err(error) => {
23371                                dlg.response_json_decode_error(&encoded, &error);
23372                                return Err(common::Error::JsonDecodeError(
23373                                    encoded.to_string(),
23374                                    error,
23375                                ));
23376                            }
23377                        }
23378                    };
23379
23380                    dlg.finished(true);
23381                    return Ok(response);
23382                }
23383            }
23384        }
23385    }
23386
23387    ///
23388    /// Sets the *request* property to the given value.
23389    ///
23390    /// Even though the property as already been set when instantiating this call,
23391    /// we provide this method for API completeness.
23392    pub fn request(
23393        mut self,
23394        new_value: ExecuteSqlRequest,
23395    ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
23396        self._request = new_value;
23397        self
23398    }
23399    /// Required. The session in which the SQL query should be performed.
23400    ///
23401    /// Sets the *session* path property to the given value.
23402    ///
23403    /// Even though the property as already been set when instantiating this call,
23404    /// we provide this method for API completeness.
23405    pub fn session(
23406        mut self,
23407        new_value: &str,
23408    ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
23409        self._session = new_value.to_string();
23410        self
23411    }
23412    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23413    /// while executing the actual API request.
23414    ///
23415    /// ````text
23416    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23417    /// ````
23418    ///
23419    /// Sets the *delegate* property to the given value.
23420    pub fn delegate(
23421        mut self,
23422        new_value: &'a mut dyn common::Delegate,
23423    ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
23424        self._delegate = Some(new_value);
23425        self
23426    }
23427
23428    /// Set any additional parameter of the query string used in the request.
23429    /// It should be used to set parameters which are not yet available through their own
23430    /// setters.
23431    ///
23432    /// Please note that this method must not be used to set any of the known parameters
23433    /// which have their own setter method. If done anyway, the request will fail.
23434    ///
23435    /// # Additional Parameters
23436    ///
23437    /// * *$.xgafv* (query-string) - V1 error format.
23438    /// * *access_token* (query-string) - OAuth access token.
23439    /// * *alt* (query-string) - Data format for response.
23440    /// * *callback* (query-string) - JSONP
23441    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23442    /// * *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.
23443    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23444    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23445    /// * *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.
23446    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23447    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23448    pub fn param<T>(
23449        mut self,
23450        name: T,
23451        value: T,
23452    ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
23453    where
23454        T: AsRef<str>,
23455    {
23456        self._additional_params
23457            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23458        self
23459    }
23460
23461    /// Identifies the authorization scope for the method you are building.
23462    ///
23463    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23464    /// [`Scope::CloudPlatform`].
23465    ///
23466    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23467    /// tokens for more than one scope.
23468    ///
23469    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23470    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23471    /// sufficient, a read-write scope will do as well.
23472    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
23473    where
23474        St: AsRef<str>,
23475    {
23476        self._scopes.insert(String::from(scope.as_ref()));
23477        self
23478    }
23479    /// Identifies the authorization scope(s) for the method you are building.
23480    ///
23481    /// See [`Self::add_scope()`] for details.
23482    pub fn add_scopes<I, St>(
23483        mut self,
23484        scopes: I,
23485    ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
23486    where
23487        I: IntoIterator<Item = St>,
23488        St: AsRef<str>,
23489    {
23490        self._scopes
23491            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23492        self
23493    }
23494
23495    /// Removes all scopes, and no default scope will be used either.
23496    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23497    /// for details).
23498    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
23499        self._scopes.clear();
23500        self
23501    }
23502}
23503
23504/// Like ExecuteSql, except returns the result set as a stream. Unlike ExecuteSql, there is no limit on the size of the returned result set. However, no individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB. The query string can be SQL or [Graph Query Language (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro).
23505///
23506/// A builder for the *instances.databases.sessions.executeStreamingSql* method supported by a *project* resource.
23507/// It is not used directly, but through a [`ProjectMethods`] instance.
23508///
23509/// # Example
23510///
23511/// Instantiate a resource method builder
23512///
23513/// ```test_harness,no_run
23514/// # extern crate hyper;
23515/// # extern crate hyper_rustls;
23516/// # extern crate google_spanner1 as spanner1;
23517/// use spanner1::api::ExecuteSqlRequest;
23518/// # async fn dox() {
23519/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23520///
23521/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23522/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23523/// #     .with_native_roots()
23524/// #     .unwrap()
23525/// #     .https_only()
23526/// #     .enable_http2()
23527/// #     .build();
23528///
23529/// # let executor = hyper_util::rt::TokioExecutor::new();
23530/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23531/// #     secret,
23532/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23533/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23534/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23535/// #     ),
23536/// # ).build().await.unwrap();
23537///
23538/// # let client = hyper_util::client::legacy::Client::builder(
23539/// #     hyper_util::rt::TokioExecutor::new()
23540/// # )
23541/// # .build(
23542/// #     hyper_rustls::HttpsConnectorBuilder::new()
23543/// #         .with_native_roots()
23544/// #         .unwrap()
23545/// #         .https_or_http()
23546/// #         .enable_http2()
23547/// #         .build()
23548/// # );
23549/// # let mut hub = Spanner::new(client, auth);
23550/// // As the method needs a request, you would usually fill it with the desired information
23551/// // into the respective structure. Some of the parts shown here might not be applicable !
23552/// // Values shown here are possibly random and not representative !
23553/// let mut req = ExecuteSqlRequest::default();
23554///
23555/// // You can configure optional parameters by calling the respective setters at will, and
23556/// // execute the final call using `doit()`.
23557/// // Values shown here are possibly random and not representative !
23558/// let result = hub.projects().instances_databases_sessions_execute_streaming_sql(req, "session")
23559///              .doit().await;
23560/// # }
23561/// ```
23562pub struct ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
23563where
23564    C: 'a,
23565{
23566    hub: &'a Spanner<C>,
23567    _request: ExecuteSqlRequest,
23568    _session: String,
23569    _delegate: Option<&'a mut dyn common::Delegate>,
23570    _additional_params: HashMap<String, String>,
23571    _scopes: BTreeSet<String>,
23572}
23573
23574impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {}
23575
23576impl<'a, C> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
23577where
23578    C: common::Connector,
23579{
23580    /// Perform the operation you have build so far.
23581    pub async fn doit(mut self) -> common::Result<(common::Response, PartialResultSet)> {
23582        use std::borrow::Cow;
23583        use std::io::{Read, Seek};
23584
23585        use common::{url::Params, ToParts};
23586        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23587
23588        let mut dd = common::DefaultDelegate;
23589        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23590        dlg.begin(common::MethodInfo {
23591            id: "spanner.projects.instances.databases.sessions.executeStreamingSql",
23592            http_method: hyper::Method::POST,
23593        });
23594
23595        for &field in ["alt", "session"].iter() {
23596            if self._additional_params.contains_key(field) {
23597                dlg.finished(false);
23598                return Err(common::Error::FieldClash(field));
23599            }
23600        }
23601
23602        let mut params = Params::with_capacity(4 + self._additional_params.len());
23603        params.push("session", self._session);
23604
23605        params.extend(self._additional_params.iter());
23606
23607        params.push("alt", "json");
23608        let mut url = self.hub._base_url.clone() + "v1/{+session}:executeStreamingSql";
23609        if self._scopes.is_empty() {
23610            self._scopes
23611                .insert(Scope::CloudPlatform.as_ref().to_string());
23612        }
23613
23614        #[allow(clippy::single_element_loop)]
23615        for &(find_this, param_name) in [("{+session}", "session")].iter() {
23616            url = params.uri_replacement(url, param_name, find_this, true);
23617        }
23618        {
23619            let to_remove = ["session"];
23620            params.remove_params(&to_remove);
23621        }
23622
23623        let url = params.parse_with_url(&url);
23624
23625        let mut json_mime_type = mime::APPLICATION_JSON;
23626        let mut request_value_reader = {
23627            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23628            common::remove_json_null_values(&mut value);
23629            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23630            serde_json::to_writer(&mut dst, &value).unwrap();
23631            dst
23632        };
23633        let request_size = request_value_reader
23634            .seek(std::io::SeekFrom::End(0))
23635            .unwrap();
23636        request_value_reader
23637            .seek(std::io::SeekFrom::Start(0))
23638            .unwrap();
23639
23640        loop {
23641            let token = match self
23642                .hub
23643                .auth
23644                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23645                .await
23646            {
23647                Ok(token) => token,
23648                Err(e) => match dlg.token(e) {
23649                    Ok(token) => token,
23650                    Err(e) => {
23651                        dlg.finished(false);
23652                        return Err(common::Error::MissingToken(e));
23653                    }
23654                },
23655            };
23656            request_value_reader
23657                .seek(std::io::SeekFrom::Start(0))
23658                .unwrap();
23659            let mut req_result = {
23660                let client = &self.hub.client;
23661                dlg.pre_request();
23662                let mut req_builder = hyper::Request::builder()
23663                    .method(hyper::Method::POST)
23664                    .uri(url.as_str())
23665                    .header(USER_AGENT, self.hub._user_agent.clone());
23666
23667                if let Some(token) = token.as_ref() {
23668                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23669                }
23670
23671                let request = req_builder
23672                    .header(CONTENT_TYPE, json_mime_type.to_string())
23673                    .header(CONTENT_LENGTH, request_size as u64)
23674                    .body(common::to_body(
23675                        request_value_reader.get_ref().clone().into(),
23676                    ));
23677
23678                client.request(request.unwrap()).await
23679            };
23680
23681            match req_result {
23682                Err(err) => {
23683                    if let common::Retry::After(d) = dlg.http_error(&err) {
23684                        sleep(d).await;
23685                        continue;
23686                    }
23687                    dlg.finished(false);
23688                    return Err(common::Error::HttpError(err));
23689                }
23690                Ok(res) => {
23691                    let (mut parts, body) = res.into_parts();
23692                    let mut body = common::Body::new(body);
23693                    if !parts.status.is_success() {
23694                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23695                        let error = serde_json::from_str(&common::to_string(&bytes));
23696                        let response = common::to_response(parts, bytes.into());
23697
23698                        if let common::Retry::After(d) =
23699                            dlg.http_failure(&response, error.as_ref().ok())
23700                        {
23701                            sleep(d).await;
23702                            continue;
23703                        }
23704
23705                        dlg.finished(false);
23706
23707                        return Err(match error {
23708                            Ok(value) => common::Error::BadRequest(value),
23709                            _ => common::Error::Failure(response),
23710                        });
23711                    }
23712                    let response = {
23713                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23714                        let encoded = common::to_string(&bytes);
23715                        match serde_json::from_str(&encoded) {
23716                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23717                            Err(error) => {
23718                                dlg.response_json_decode_error(&encoded, &error);
23719                                return Err(common::Error::JsonDecodeError(
23720                                    encoded.to_string(),
23721                                    error,
23722                                ));
23723                            }
23724                        }
23725                    };
23726
23727                    dlg.finished(true);
23728                    return Ok(response);
23729                }
23730            }
23731        }
23732    }
23733
23734    ///
23735    /// Sets the *request* property to the given value.
23736    ///
23737    /// Even though the property as already been set when instantiating this call,
23738    /// we provide this method for API completeness.
23739    pub fn request(
23740        mut self,
23741        new_value: ExecuteSqlRequest,
23742    ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
23743        self._request = new_value;
23744        self
23745    }
23746    /// Required. The session in which the SQL query should be performed.
23747    ///
23748    /// Sets the *session* path property to the given value.
23749    ///
23750    /// Even though the property as already been set when instantiating this call,
23751    /// we provide this method for API completeness.
23752    pub fn session(
23753        mut self,
23754        new_value: &str,
23755    ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
23756        self._session = new_value.to_string();
23757        self
23758    }
23759    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23760    /// while executing the actual API request.
23761    ///
23762    /// ````text
23763    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23764    /// ````
23765    ///
23766    /// Sets the *delegate* property to the given value.
23767    pub fn delegate(
23768        mut self,
23769        new_value: &'a mut dyn common::Delegate,
23770    ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
23771        self._delegate = Some(new_value);
23772        self
23773    }
23774
23775    /// Set any additional parameter of the query string used in the request.
23776    /// It should be used to set parameters which are not yet available through their own
23777    /// setters.
23778    ///
23779    /// Please note that this method must not be used to set any of the known parameters
23780    /// which have their own setter method. If done anyway, the request will fail.
23781    ///
23782    /// # Additional Parameters
23783    ///
23784    /// * *$.xgafv* (query-string) - V1 error format.
23785    /// * *access_token* (query-string) - OAuth access token.
23786    /// * *alt* (query-string) - Data format for response.
23787    /// * *callback* (query-string) - JSONP
23788    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23789    /// * *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.
23790    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23791    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23792    /// * *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.
23793    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23794    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23795    pub fn param<T>(
23796        mut self,
23797        name: T,
23798        value: T,
23799    ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
23800    where
23801        T: AsRef<str>,
23802    {
23803        self._additional_params
23804            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23805        self
23806    }
23807
23808    /// Identifies the authorization scope for the method you are building.
23809    ///
23810    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23811    /// [`Scope::CloudPlatform`].
23812    ///
23813    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23814    /// tokens for more than one scope.
23815    ///
23816    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23817    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23818    /// sufficient, a read-write scope will do as well.
23819    pub fn add_scope<St>(
23820        mut self,
23821        scope: St,
23822    ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
23823    where
23824        St: AsRef<str>,
23825    {
23826        self._scopes.insert(String::from(scope.as_ref()));
23827        self
23828    }
23829    /// Identifies the authorization scope(s) for the method you are building.
23830    ///
23831    /// See [`Self::add_scope()`] for details.
23832    pub fn add_scopes<I, St>(
23833        mut self,
23834        scopes: I,
23835    ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
23836    where
23837        I: IntoIterator<Item = St>,
23838        St: AsRef<str>,
23839    {
23840        self._scopes
23841            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23842        self
23843    }
23844
23845    /// Removes all scopes, and no default scope will be used either.
23846    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23847    /// for details).
23848    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
23849        self._scopes.clear();
23850        self
23851    }
23852}
23853
23854/// Gets a session. Returns `NOT_FOUND` if the session doesn't exist. This is mainly useful for determining whether a session is still alive.
23855///
23856/// A builder for the *instances.databases.sessions.get* method supported by a *project* resource.
23857/// It is not used directly, but through a [`ProjectMethods`] instance.
23858///
23859/// # Example
23860///
23861/// Instantiate a resource method builder
23862///
23863/// ```test_harness,no_run
23864/// # extern crate hyper;
23865/// # extern crate hyper_rustls;
23866/// # extern crate google_spanner1 as spanner1;
23867/// # async fn dox() {
23868/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23869///
23870/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23871/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23872/// #     .with_native_roots()
23873/// #     .unwrap()
23874/// #     .https_only()
23875/// #     .enable_http2()
23876/// #     .build();
23877///
23878/// # let executor = hyper_util::rt::TokioExecutor::new();
23879/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23880/// #     secret,
23881/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23882/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23883/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23884/// #     ),
23885/// # ).build().await.unwrap();
23886///
23887/// # let client = hyper_util::client::legacy::Client::builder(
23888/// #     hyper_util::rt::TokioExecutor::new()
23889/// # )
23890/// # .build(
23891/// #     hyper_rustls::HttpsConnectorBuilder::new()
23892/// #         .with_native_roots()
23893/// #         .unwrap()
23894/// #         .https_or_http()
23895/// #         .enable_http2()
23896/// #         .build()
23897/// # );
23898/// # let mut hub = Spanner::new(client, auth);
23899/// // You can configure optional parameters by calling the respective setters at will, and
23900/// // execute the final call using `doit()`.
23901/// // Values shown here are possibly random and not representative !
23902/// let result = hub.projects().instances_databases_sessions_get("name")
23903///              .doit().await;
23904/// # }
23905/// ```
23906pub struct ProjectInstanceDatabaseSessionGetCall<'a, C>
23907where
23908    C: 'a,
23909{
23910    hub: &'a Spanner<C>,
23911    _name: String,
23912    _delegate: Option<&'a mut dyn common::Delegate>,
23913    _additional_params: HashMap<String, String>,
23914    _scopes: BTreeSet<String>,
23915}
23916
23917impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionGetCall<'a, C> {}
23918
23919impl<'a, C> ProjectInstanceDatabaseSessionGetCall<'a, C>
23920where
23921    C: common::Connector,
23922{
23923    /// Perform the operation you have build so far.
23924    pub async fn doit(mut self) -> common::Result<(common::Response, Session)> {
23925        use std::borrow::Cow;
23926        use std::io::{Read, Seek};
23927
23928        use common::{url::Params, ToParts};
23929        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23930
23931        let mut dd = common::DefaultDelegate;
23932        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23933        dlg.begin(common::MethodInfo {
23934            id: "spanner.projects.instances.databases.sessions.get",
23935            http_method: hyper::Method::GET,
23936        });
23937
23938        for &field in ["alt", "name"].iter() {
23939            if self._additional_params.contains_key(field) {
23940                dlg.finished(false);
23941                return Err(common::Error::FieldClash(field));
23942            }
23943        }
23944
23945        let mut params = Params::with_capacity(3 + self._additional_params.len());
23946        params.push("name", self._name);
23947
23948        params.extend(self._additional_params.iter());
23949
23950        params.push("alt", "json");
23951        let mut url = self.hub._base_url.clone() + "v1/{+name}";
23952        if self._scopes.is_empty() {
23953            self._scopes
23954                .insert(Scope::CloudPlatform.as_ref().to_string());
23955        }
23956
23957        #[allow(clippy::single_element_loop)]
23958        for &(find_this, param_name) in [("{+name}", "name")].iter() {
23959            url = params.uri_replacement(url, param_name, find_this, true);
23960        }
23961        {
23962            let to_remove = ["name"];
23963            params.remove_params(&to_remove);
23964        }
23965
23966        let url = params.parse_with_url(&url);
23967
23968        loop {
23969            let token = match self
23970                .hub
23971                .auth
23972                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23973                .await
23974            {
23975                Ok(token) => token,
23976                Err(e) => match dlg.token(e) {
23977                    Ok(token) => token,
23978                    Err(e) => {
23979                        dlg.finished(false);
23980                        return Err(common::Error::MissingToken(e));
23981                    }
23982                },
23983            };
23984            let mut req_result = {
23985                let client = &self.hub.client;
23986                dlg.pre_request();
23987                let mut req_builder = hyper::Request::builder()
23988                    .method(hyper::Method::GET)
23989                    .uri(url.as_str())
23990                    .header(USER_AGENT, self.hub._user_agent.clone());
23991
23992                if let Some(token) = token.as_ref() {
23993                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23994                }
23995
23996                let request = req_builder
23997                    .header(CONTENT_LENGTH, 0_u64)
23998                    .body(common::to_body::<String>(None));
23999
24000                client.request(request.unwrap()).await
24001            };
24002
24003            match req_result {
24004                Err(err) => {
24005                    if let common::Retry::After(d) = dlg.http_error(&err) {
24006                        sleep(d).await;
24007                        continue;
24008                    }
24009                    dlg.finished(false);
24010                    return Err(common::Error::HttpError(err));
24011                }
24012                Ok(res) => {
24013                    let (mut parts, body) = res.into_parts();
24014                    let mut body = common::Body::new(body);
24015                    if !parts.status.is_success() {
24016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24017                        let error = serde_json::from_str(&common::to_string(&bytes));
24018                        let response = common::to_response(parts, bytes.into());
24019
24020                        if let common::Retry::After(d) =
24021                            dlg.http_failure(&response, error.as_ref().ok())
24022                        {
24023                            sleep(d).await;
24024                            continue;
24025                        }
24026
24027                        dlg.finished(false);
24028
24029                        return Err(match error {
24030                            Ok(value) => common::Error::BadRequest(value),
24031                            _ => common::Error::Failure(response),
24032                        });
24033                    }
24034                    let response = {
24035                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24036                        let encoded = common::to_string(&bytes);
24037                        match serde_json::from_str(&encoded) {
24038                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24039                            Err(error) => {
24040                                dlg.response_json_decode_error(&encoded, &error);
24041                                return Err(common::Error::JsonDecodeError(
24042                                    encoded.to_string(),
24043                                    error,
24044                                ));
24045                            }
24046                        }
24047                    };
24048
24049                    dlg.finished(true);
24050                    return Ok(response);
24051                }
24052            }
24053        }
24054    }
24055
24056    /// Required. The name of the session to retrieve.
24057    ///
24058    /// Sets the *name* path property to the given value.
24059    ///
24060    /// Even though the property as already been set when instantiating this call,
24061    /// we provide this method for API completeness.
24062    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionGetCall<'a, C> {
24063        self._name = new_value.to_string();
24064        self
24065    }
24066    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24067    /// while executing the actual API request.
24068    ///
24069    /// ````text
24070    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24071    /// ````
24072    ///
24073    /// Sets the *delegate* property to the given value.
24074    pub fn delegate(
24075        mut self,
24076        new_value: &'a mut dyn common::Delegate,
24077    ) -> ProjectInstanceDatabaseSessionGetCall<'a, C> {
24078        self._delegate = Some(new_value);
24079        self
24080    }
24081
24082    /// Set any additional parameter of the query string used in the request.
24083    /// It should be used to set parameters which are not yet available through their own
24084    /// setters.
24085    ///
24086    /// Please note that this method must not be used to set any of the known parameters
24087    /// which have their own setter method. If done anyway, the request will fail.
24088    ///
24089    /// # Additional Parameters
24090    ///
24091    /// * *$.xgafv* (query-string) - V1 error format.
24092    /// * *access_token* (query-string) - OAuth access token.
24093    /// * *alt* (query-string) - Data format for response.
24094    /// * *callback* (query-string) - JSONP
24095    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24096    /// * *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.
24097    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24098    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24099    /// * *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.
24100    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24101    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24102    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionGetCall<'a, C>
24103    where
24104        T: AsRef<str>,
24105    {
24106        self._additional_params
24107            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24108        self
24109    }
24110
24111    /// Identifies the authorization scope for the method you are building.
24112    ///
24113    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24114    /// [`Scope::CloudPlatform`].
24115    ///
24116    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24117    /// tokens for more than one scope.
24118    ///
24119    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24120    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24121    /// sufficient, a read-write scope will do as well.
24122    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionGetCall<'a, C>
24123    where
24124        St: AsRef<str>,
24125    {
24126        self._scopes.insert(String::from(scope.as_ref()));
24127        self
24128    }
24129    /// Identifies the authorization scope(s) for the method you are building.
24130    ///
24131    /// See [`Self::add_scope()`] for details.
24132    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionGetCall<'a, C>
24133    where
24134        I: IntoIterator<Item = St>,
24135        St: AsRef<str>,
24136    {
24137        self._scopes
24138            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24139        self
24140    }
24141
24142    /// Removes all scopes, and no default scope will be used either.
24143    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24144    /// for details).
24145    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionGetCall<'a, C> {
24146        self._scopes.clear();
24147        self
24148    }
24149}
24150
24151/// Lists all sessions in a given database.
24152///
24153/// A builder for the *instances.databases.sessions.list* method supported by a *project* resource.
24154/// It is not used directly, but through a [`ProjectMethods`] instance.
24155///
24156/// # Example
24157///
24158/// Instantiate a resource method builder
24159///
24160/// ```test_harness,no_run
24161/// # extern crate hyper;
24162/// # extern crate hyper_rustls;
24163/// # extern crate google_spanner1 as spanner1;
24164/// # async fn dox() {
24165/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24166///
24167/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24168/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24169/// #     .with_native_roots()
24170/// #     .unwrap()
24171/// #     .https_only()
24172/// #     .enable_http2()
24173/// #     .build();
24174///
24175/// # let executor = hyper_util::rt::TokioExecutor::new();
24176/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24177/// #     secret,
24178/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24179/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24180/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24181/// #     ),
24182/// # ).build().await.unwrap();
24183///
24184/// # let client = hyper_util::client::legacy::Client::builder(
24185/// #     hyper_util::rt::TokioExecutor::new()
24186/// # )
24187/// # .build(
24188/// #     hyper_rustls::HttpsConnectorBuilder::new()
24189/// #         .with_native_roots()
24190/// #         .unwrap()
24191/// #         .https_or_http()
24192/// #         .enable_http2()
24193/// #         .build()
24194/// # );
24195/// # let mut hub = Spanner::new(client, auth);
24196/// // You can configure optional parameters by calling the respective setters at will, and
24197/// // execute the final call using `doit()`.
24198/// // Values shown here are possibly random and not representative !
24199/// let result = hub.projects().instances_databases_sessions_list("database")
24200///              .page_token("et")
24201///              .page_size(-94)
24202///              .filter("sed")
24203///              .doit().await;
24204/// # }
24205/// ```
24206pub struct ProjectInstanceDatabaseSessionListCall<'a, C>
24207where
24208    C: 'a,
24209{
24210    hub: &'a Spanner<C>,
24211    _database: String,
24212    _page_token: Option<String>,
24213    _page_size: Option<i32>,
24214    _filter: Option<String>,
24215    _delegate: Option<&'a mut dyn common::Delegate>,
24216    _additional_params: HashMap<String, String>,
24217    _scopes: BTreeSet<String>,
24218}
24219
24220impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionListCall<'a, C> {}
24221
24222impl<'a, C> ProjectInstanceDatabaseSessionListCall<'a, C>
24223where
24224    C: common::Connector,
24225{
24226    /// Perform the operation you have build so far.
24227    pub async fn doit(mut self) -> common::Result<(common::Response, ListSessionsResponse)> {
24228        use std::borrow::Cow;
24229        use std::io::{Read, Seek};
24230
24231        use common::{url::Params, ToParts};
24232        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24233
24234        let mut dd = common::DefaultDelegate;
24235        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24236        dlg.begin(common::MethodInfo {
24237            id: "spanner.projects.instances.databases.sessions.list",
24238            http_method: hyper::Method::GET,
24239        });
24240
24241        for &field in ["alt", "database", "pageToken", "pageSize", "filter"].iter() {
24242            if self._additional_params.contains_key(field) {
24243                dlg.finished(false);
24244                return Err(common::Error::FieldClash(field));
24245            }
24246        }
24247
24248        let mut params = Params::with_capacity(6 + self._additional_params.len());
24249        params.push("database", self._database);
24250        if let Some(value) = self._page_token.as_ref() {
24251            params.push("pageToken", value);
24252        }
24253        if let Some(value) = self._page_size.as_ref() {
24254            params.push("pageSize", value.to_string());
24255        }
24256        if let Some(value) = self._filter.as_ref() {
24257            params.push("filter", value);
24258        }
24259
24260        params.extend(self._additional_params.iter());
24261
24262        params.push("alt", "json");
24263        let mut url = self.hub._base_url.clone() + "v1/{+database}/sessions";
24264        if self._scopes.is_empty() {
24265            self._scopes
24266                .insert(Scope::CloudPlatform.as_ref().to_string());
24267        }
24268
24269        #[allow(clippy::single_element_loop)]
24270        for &(find_this, param_name) in [("{+database}", "database")].iter() {
24271            url = params.uri_replacement(url, param_name, find_this, true);
24272        }
24273        {
24274            let to_remove = ["database"];
24275            params.remove_params(&to_remove);
24276        }
24277
24278        let url = params.parse_with_url(&url);
24279
24280        loop {
24281            let token = match self
24282                .hub
24283                .auth
24284                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24285                .await
24286            {
24287                Ok(token) => token,
24288                Err(e) => match dlg.token(e) {
24289                    Ok(token) => token,
24290                    Err(e) => {
24291                        dlg.finished(false);
24292                        return Err(common::Error::MissingToken(e));
24293                    }
24294                },
24295            };
24296            let mut req_result = {
24297                let client = &self.hub.client;
24298                dlg.pre_request();
24299                let mut req_builder = hyper::Request::builder()
24300                    .method(hyper::Method::GET)
24301                    .uri(url.as_str())
24302                    .header(USER_AGENT, self.hub._user_agent.clone());
24303
24304                if let Some(token) = token.as_ref() {
24305                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24306                }
24307
24308                let request = req_builder
24309                    .header(CONTENT_LENGTH, 0_u64)
24310                    .body(common::to_body::<String>(None));
24311
24312                client.request(request.unwrap()).await
24313            };
24314
24315            match req_result {
24316                Err(err) => {
24317                    if let common::Retry::After(d) = dlg.http_error(&err) {
24318                        sleep(d).await;
24319                        continue;
24320                    }
24321                    dlg.finished(false);
24322                    return Err(common::Error::HttpError(err));
24323                }
24324                Ok(res) => {
24325                    let (mut parts, body) = res.into_parts();
24326                    let mut body = common::Body::new(body);
24327                    if !parts.status.is_success() {
24328                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24329                        let error = serde_json::from_str(&common::to_string(&bytes));
24330                        let response = common::to_response(parts, bytes.into());
24331
24332                        if let common::Retry::After(d) =
24333                            dlg.http_failure(&response, error.as_ref().ok())
24334                        {
24335                            sleep(d).await;
24336                            continue;
24337                        }
24338
24339                        dlg.finished(false);
24340
24341                        return Err(match error {
24342                            Ok(value) => common::Error::BadRequest(value),
24343                            _ => common::Error::Failure(response),
24344                        });
24345                    }
24346                    let response = {
24347                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24348                        let encoded = common::to_string(&bytes);
24349                        match serde_json::from_str(&encoded) {
24350                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24351                            Err(error) => {
24352                                dlg.response_json_decode_error(&encoded, &error);
24353                                return Err(common::Error::JsonDecodeError(
24354                                    encoded.to_string(),
24355                                    error,
24356                                ));
24357                            }
24358                        }
24359                    };
24360
24361                    dlg.finished(true);
24362                    return Ok(response);
24363                }
24364            }
24365        }
24366    }
24367
24368    /// Required. The database in which to list sessions.
24369    ///
24370    /// Sets the *database* path property to the given value.
24371    ///
24372    /// Even though the property as already been set when instantiating this call,
24373    /// we provide this method for API completeness.
24374    pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
24375        self._database = new_value.to_string();
24376        self
24377    }
24378    /// If non-empty, `page_token` should contain a next_page_token from a previous ListSessionsResponse.
24379    ///
24380    /// Sets the *page token* query property to the given value.
24381    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
24382        self._page_token = Some(new_value.to_string());
24383        self
24384    }
24385    /// Number of sessions to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
24386    ///
24387    /// Sets the *page size* query property to the given value.
24388    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
24389        self._page_size = Some(new_value);
24390        self
24391    }
24392    /// An expression for filtering the results of the request. Filter rules are case insensitive. The fields eligible for filtering are: * `labels.key` where key is the name of a label Some examples of using filters are: * `labels.env:*` --> The session has the label "env". * `labels.env:dev` --> The session has the label "env" and the value of the label contains the string "dev".
24393    ///
24394    /// Sets the *filter* query property to the given value.
24395    pub fn filter(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
24396        self._filter = Some(new_value.to_string());
24397        self
24398    }
24399    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24400    /// while executing the actual API request.
24401    ///
24402    /// ````text
24403    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24404    /// ````
24405    ///
24406    /// Sets the *delegate* property to the given value.
24407    pub fn delegate(
24408        mut self,
24409        new_value: &'a mut dyn common::Delegate,
24410    ) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
24411        self._delegate = Some(new_value);
24412        self
24413    }
24414
24415    /// Set any additional parameter of the query string used in the request.
24416    /// It should be used to set parameters which are not yet available through their own
24417    /// setters.
24418    ///
24419    /// Please note that this method must not be used to set any of the known parameters
24420    /// which have their own setter method. If done anyway, the request will fail.
24421    ///
24422    /// # Additional Parameters
24423    ///
24424    /// * *$.xgafv* (query-string) - V1 error format.
24425    /// * *access_token* (query-string) - OAuth access token.
24426    /// * *alt* (query-string) - Data format for response.
24427    /// * *callback* (query-string) - JSONP
24428    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24429    /// * *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.
24430    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24431    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24432    /// * *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.
24433    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24434    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24435    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionListCall<'a, C>
24436    where
24437        T: AsRef<str>,
24438    {
24439        self._additional_params
24440            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24441        self
24442    }
24443
24444    /// Identifies the authorization scope for the method you are building.
24445    ///
24446    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24447    /// [`Scope::CloudPlatform`].
24448    ///
24449    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24450    /// tokens for more than one scope.
24451    ///
24452    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24453    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24454    /// sufficient, a read-write scope will do as well.
24455    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionListCall<'a, C>
24456    where
24457        St: AsRef<str>,
24458    {
24459        self._scopes.insert(String::from(scope.as_ref()));
24460        self
24461    }
24462    /// Identifies the authorization scope(s) for the method you are building.
24463    ///
24464    /// See [`Self::add_scope()`] for details.
24465    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionListCall<'a, C>
24466    where
24467        I: IntoIterator<Item = St>,
24468        St: AsRef<str>,
24469    {
24470        self._scopes
24471            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24472        self
24473    }
24474
24475    /// Removes all scopes, and no default scope will be used either.
24476    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24477    /// for details).
24478    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
24479        self._scopes.clear();
24480        self
24481    }
24482}
24483
24484/// Creates a set of partition tokens that can be used to execute a query operation in parallel. Each of the returned partition tokens can be used by ExecuteStreamingSql to specify a subset of the query result to read. The same session and read-only transaction must be used by the `PartitionQueryRequest` used to create the partition tokens and the `ExecuteSqlRequests` that use the partition tokens. Partition tokens become invalid when the session used to create them is deleted, is idle for too long, begins a new transaction, or becomes too old. When any of these happen, it isn't possible to resume the query, and the whole operation must be restarted from the beginning.
24485///
24486/// A builder for the *instances.databases.sessions.partitionQuery* method supported by a *project* resource.
24487/// It is not used directly, but through a [`ProjectMethods`] instance.
24488///
24489/// # Example
24490///
24491/// Instantiate a resource method builder
24492///
24493/// ```test_harness,no_run
24494/// # extern crate hyper;
24495/// # extern crate hyper_rustls;
24496/// # extern crate google_spanner1 as spanner1;
24497/// use spanner1::api::PartitionQueryRequest;
24498/// # async fn dox() {
24499/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24500///
24501/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24502/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24503/// #     .with_native_roots()
24504/// #     .unwrap()
24505/// #     .https_only()
24506/// #     .enable_http2()
24507/// #     .build();
24508///
24509/// # let executor = hyper_util::rt::TokioExecutor::new();
24510/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24511/// #     secret,
24512/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24513/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24514/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24515/// #     ),
24516/// # ).build().await.unwrap();
24517///
24518/// # let client = hyper_util::client::legacy::Client::builder(
24519/// #     hyper_util::rt::TokioExecutor::new()
24520/// # )
24521/// # .build(
24522/// #     hyper_rustls::HttpsConnectorBuilder::new()
24523/// #         .with_native_roots()
24524/// #         .unwrap()
24525/// #         .https_or_http()
24526/// #         .enable_http2()
24527/// #         .build()
24528/// # );
24529/// # let mut hub = Spanner::new(client, auth);
24530/// // As the method needs a request, you would usually fill it with the desired information
24531/// // into the respective structure. Some of the parts shown here might not be applicable !
24532/// // Values shown here are possibly random and not representative !
24533/// let mut req = PartitionQueryRequest::default();
24534///
24535/// // You can configure optional parameters by calling the respective setters at will, and
24536/// // execute the final call using `doit()`.
24537/// // Values shown here are possibly random and not representative !
24538/// let result = hub.projects().instances_databases_sessions_partition_query(req, "session")
24539///              .doit().await;
24540/// # }
24541/// ```
24542pub struct ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
24543where
24544    C: 'a,
24545{
24546    hub: &'a Spanner<C>,
24547    _request: PartitionQueryRequest,
24548    _session: String,
24549    _delegate: Option<&'a mut dyn common::Delegate>,
24550    _additional_params: HashMap<String, String>,
24551    _scopes: BTreeSet<String>,
24552}
24553
24554impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {}
24555
24556impl<'a, C> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
24557where
24558    C: common::Connector,
24559{
24560    /// Perform the operation you have build so far.
24561    pub async fn doit(mut self) -> common::Result<(common::Response, PartitionResponse)> {
24562        use std::borrow::Cow;
24563        use std::io::{Read, Seek};
24564
24565        use common::{url::Params, ToParts};
24566        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24567
24568        let mut dd = common::DefaultDelegate;
24569        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24570        dlg.begin(common::MethodInfo {
24571            id: "spanner.projects.instances.databases.sessions.partitionQuery",
24572            http_method: hyper::Method::POST,
24573        });
24574
24575        for &field in ["alt", "session"].iter() {
24576            if self._additional_params.contains_key(field) {
24577                dlg.finished(false);
24578                return Err(common::Error::FieldClash(field));
24579            }
24580        }
24581
24582        let mut params = Params::with_capacity(4 + self._additional_params.len());
24583        params.push("session", self._session);
24584
24585        params.extend(self._additional_params.iter());
24586
24587        params.push("alt", "json");
24588        let mut url = self.hub._base_url.clone() + "v1/{+session}:partitionQuery";
24589        if self._scopes.is_empty() {
24590            self._scopes
24591                .insert(Scope::CloudPlatform.as_ref().to_string());
24592        }
24593
24594        #[allow(clippy::single_element_loop)]
24595        for &(find_this, param_name) in [("{+session}", "session")].iter() {
24596            url = params.uri_replacement(url, param_name, find_this, true);
24597        }
24598        {
24599            let to_remove = ["session"];
24600            params.remove_params(&to_remove);
24601        }
24602
24603        let url = params.parse_with_url(&url);
24604
24605        let mut json_mime_type = mime::APPLICATION_JSON;
24606        let mut request_value_reader = {
24607            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24608            common::remove_json_null_values(&mut value);
24609            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24610            serde_json::to_writer(&mut dst, &value).unwrap();
24611            dst
24612        };
24613        let request_size = request_value_reader
24614            .seek(std::io::SeekFrom::End(0))
24615            .unwrap();
24616        request_value_reader
24617            .seek(std::io::SeekFrom::Start(0))
24618            .unwrap();
24619
24620        loop {
24621            let token = match self
24622                .hub
24623                .auth
24624                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24625                .await
24626            {
24627                Ok(token) => token,
24628                Err(e) => match dlg.token(e) {
24629                    Ok(token) => token,
24630                    Err(e) => {
24631                        dlg.finished(false);
24632                        return Err(common::Error::MissingToken(e));
24633                    }
24634                },
24635            };
24636            request_value_reader
24637                .seek(std::io::SeekFrom::Start(0))
24638                .unwrap();
24639            let mut req_result = {
24640                let client = &self.hub.client;
24641                dlg.pre_request();
24642                let mut req_builder = hyper::Request::builder()
24643                    .method(hyper::Method::POST)
24644                    .uri(url.as_str())
24645                    .header(USER_AGENT, self.hub._user_agent.clone());
24646
24647                if let Some(token) = token.as_ref() {
24648                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24649                }
24650
24651                let request = req_builder
24652                    .header(CONTENT_TYPE, json_mime_type.to_string())
24653                    .header(CONTENT_LENGTH, request_size as u64)
24654                    .body(common::to_body(
24655                        request_value_reader.get_ref().clone().into(),
24656                    ));
24657
24658                client.request(request.unwrap()).await
24659            };
24660
24661            match req_result {
24662                Err(err) => {
24663                    if let common::Retry::After(d) = dlg.http_error(&err) {
24664                        sleep(d).await;
24665                        continue;
24666                    }
24667                    dlg.finished(false);
24668                    return Err(common::Error::HttpError(err));
24669                }
24670                Ok(res) => {
24671                    let (mut parts, body) = res.into_parts();
24672                    let mut body = common::Body::new(body);
24673                    if !parts.status.is_success() {
24674                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24675                        let error = serde_json::from_str(&common::to_string(&bytes));
24676                        let response = common::to_response(parts, bytes.into());
24677
24678                        if let common::Retry::After(d) =
24679                            dlg.http_failure(&response, error.as_ref().ok())
24680                        {
24681                            sleep(d).await;
24682                            continue;
24683                        }
24684
24685                        dlg.finished(false);
24686
24687                        return Err(match error {
24688                            Ok(value) => common::Error::BadRequest(value),
24689                            _ => common::Error::Failure(response),
24690                        });
24691                    }
24692                    let response = {
24693                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24694                        let encoded = common::to_string(&bytes);
24695                        match serde_json::from_str(&encoded) {
24696                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24697                            Err(error) => {
24698                                dlg.response_json_decode_error(&encoded, &error);
24699                                return Err(common::Error::JsonDecodeError(
24700                                    encoded.to_string(),
24701                                    error,
24702                                ));
24703                            }
24704                        }
24705                    };
24706
24707                    dlg.finished(true);
24708                    return Ok(response);
24709                }
24710            }
24711        }
24712    }
24713
24714    ///
24715    /// Sets the *request* property to the given value.
24716    ///
24717    /// Even though the property as already been set when instantiating this call,
24718    /// we provide this method for API completeness.
24719    pub fn request(
24720        mut self,
24721        new_value: PartitionQueryRequest,
24722    ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
24723        self._request = new_value;
24724        self
24725    }
24726    /// Required. The session used to create the partitions.
24727    ///
24728    /// Sets the *session* path property to the given value.
24729    ///
24730    /// Even though the property as already been set when instantiating this call,
24731    /// we provide this method for API completeness.
24732    pub fn session(
24733        mut self,
24734        new_value: &str,
24735    ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
24736        self._session = new_value.to_string();
24737        self
24738    }
24739    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24740    /// while executing the actual API request.
24741    ///
24742    /// ````text
24743    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24744    /// ````
24745    ///
24746    /// Sets the *delegate* property to the given value.
24747    pub fn delegate(
24748        mut self,
24749        new_value: &'a mut dyn common::Delegate,
24750    ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
24751        self._delegate = Some(new_value);
24752        self
24753    }
24754
24755    /// Set any additional parameter of the query string used in the request.
24756    /// It should be used to set parameters which are not yet available through their own
24757    /// setters.
24758    ///
24759    /// Please note that this method must not be used to set any of the known parameters
24760    /// which have their own setter method. If done anyway, the request will fail.
24761    ///
24762    /// # Additional Parameters
24763    ///
24764    /// * *$.xgafv* (query-string) - V1 error format.
24765    /// * *access_token* (query-string) - OAuth access token.
24766    /// * *alt* (query-string) - Data format for response.
24767    /// * *callback* (query-string) - JSONP
24768    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24769    /// * *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.
24770    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24771    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24772    /// * *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.
24773    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24774    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24775    pub fn param<T>(
24776        mut self,
24777        name: T,
24778        value: T,
24779    ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
24780    where
24781        T: AsRef<str>,
24782    {
24783        self._additional_params
24784            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24785        self
24786    }
24787
24788    /// Identifies the authorization scope for the method you are building.
24789    ///
24790    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24791    /// [`Scope::CloudPlatform`].
24792    ///
24793    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24794    /// tokens for more than one scope.
24795    ///
24796    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24797    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24798    /// sufficient, a read-write scope will do as well.
24799    pub fn add_scope<St>(
24800        mut self,
24801        scope: St,
24802    ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
24803    where
24804        St: AsRef<str>,
24805    {
24806        self._scopes.insert(String::from(scope.as_ref()));
24807        self
24808    }
24809    /// Identifies the authorization scope(s) for the method you are building.
24810    ///
24811    /// See [`Self::add_scope()`] for details.
24812    pub fn add_scopes<I, St>(
24813        mut self,
24814        scopes: I,
24815    ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
24816    where
24817        I: IntoIterator<Item = St>,
24818        St: AsRef<str>,
24819    {
24820        self._scopes
24821            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24822        self
24823    }
24824
24825    /// Removes all scopes, and no default scope will be used either.
24826    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24827    /// for details).
24828    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
24829        self._scopes.clear();
24830        self
24831    }
24832}
24833
24834/// Creates a set of partition tokens that can be used to execute a read operation in parallel. Each of the returned partition tokens can be used by StreamingRead to specify a subset of the read result to read. The same session and read-only transaction must be used by the `PartitionReadRequest` used to create the partition tokens and the `ReadRequests` that use the partition tokens. There are no ordering guarantees on rows returned among the returned partition tokens, or even within each individual `StreamingRead` call issued with a `partition_token`. Partition tokens become invalid when the session used to create them is deleted, is idle for too long, begins a new transaction, or becomes too old. When any of these happen, it isn't possible to resume the read, and the whole operation must be restarted from the beginning.
24835///
24836/// A builder for the *instances.databases.sessions.partitionRead* method supported by a *project* resource.
24837/// It is not used directly, but through a [`ProjectMethods`] instance.
24838///
24839/// # Example
24840///
24841/// Instantiate a resource method builder
24842///
24843/// ```test_harness,no_run
24844/// # extern crate hyper;
24845/// # extern crate hyper_rustls;
24846/// # extern crate google_spanner1 as spanner1;
24847/// use spanner1::api::PartitionReadRequest;
24848/// # async fn dox() {
24849/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24850///
24851/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24852/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24853/// #     .with_native_roots()
24854/// #     .unwrap()
24855/// #     .https_only()
24856/// #     .enable_http2()
24857/// #     .build();
24858///
24859/// # let executor = hyper_util::rt::TokioExecutor::new();
24860/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24861/// #     secret,
24862/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24863/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24864/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24865/// #     ),
24866/// # ).build().await.unwrap();
24867///
24868/// # let client = hyper_util::client::legacy::Client::builder(
24869/// #     hyper_util::rt::TokioExecutor::new()
24870/// # )
24871/// # .build(
24872/// #     hyper_rustls::HttpsConnectorBuilder::new()
24873/// #         .with_native_roots()
24874/// #         .unwrap()
24875/// #         .https_or_http()
24876/// #         .enable_http2()
24877/// #         .build()
24878/// # );
24879/// # let mut hub = Spanner::new(client, auth);
24880/// // As the method needs a request, you would usually fill it with the desired information
24881/// // into the respective structure. Some of the parts shown here might not be applicable !
24882/// // Values shown here are possibly random and not representative !
24883/// let mut req = PartitionReadRequest::default();
24884///
24885/// // You can configure optional parameters by calling the respective setters at will, and
24886/// // execute the final call using `doit()`.
24887/// // Values shown here are possibly random and not representative !
24888/// let result = hub.projects().instances_databases_sessions_partition_read(req, "session")
24889///              .doit().await;
24890/// # }
24891/// ```
24892pub struct ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
24893where
24894    C: 'a,
24895{
24896    hub: &'a Spanner<C>,
24897    _request: PartitionReadRequest,
24898    _session: String,
24899    _delegate: Option<&'a mut dyn common::Delegate>,
24900    _additional_params: HashMap<String, String>,
24901    _scopes: BTreeSet<String>,
24902}
24903
24904impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {}
24905
24906impl<'a, C> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
24907where
24908    C: common::Connector,
24909{
24910    /// Perform the operation you have build so far.
24911    pub async fn doit(mut self) -> common::Result<(common::Response, PartitionResponse)> {
24912        use std::borrow::Cow;
24913        use std::io::{Read, Seek};
24914
24915        use common::{url::Params, ToParts};
24916        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24917
24918        let mut dd = common::DefaultDelegate;
24919        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24920        dlg.begin(common::MethodInfo {
24921            id: "spanner.projects.instances.databases.sessions.partitionRead",
24922            http_method: hyper::Method::POST,
24923        });
24924
24925        for &field in ["alt", "session"].iter() {
24926            if self._additional_params.contains_key(field) {
24927                dlg.finished(false);
24928                return Err(common::Error::FieldClash(field));
24929            }
24930        }
24931
24932        let mut params = Params::with_capacity(4 + self._additional_params.len());
24933        params.push("session", self._session);
24934
24935        params.extend(self._additional_params.iter());
24936
24937        params.push("alt", "json");
24938        let mut url = self.hub._base_url.clone() + "v1/{+session}:partitionRead";
24939        if self._scopes.is_empty() {
24940            self._scopes
24941                .insert(Scope::CloudPlatform.as_ref().to_string());
24942        }
24943
24944        #[allow(clippy::single_element_loop)]
24945        for &(find_this, param_name) in [("{+session}", "session")].iter() {
24946            url = params.uri_replacement(url, param_name, find_this, true);
24947        }
24948        {
24949            let to_remove = ["session"];
24950            params.remove_params(&to_remove);
24951        }
24952
24953        let url = params.parse_with_url(&url);
24954
24955        let mut json_mime_type = mime::APPLICATION_JSON;
24956        let mut request_value_reader = {
24957            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24958            common::remove_json_null_values(&mut value);
24959            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24960            serde_json::to_writer(&mut dst, &value).unwrap();
24961            dst
24962        };
24963        let request_size = request_value_reader
24964            .seek(std::io::SeekFrom::End(0))
24965            .unwrap();
24966        request_value_reader
24967            .seek(std::io::SeekFrom::Start(0))
24968            .unwrap();
24969
24970        loop {
24971            let token = match self
24972                .hub
24973                .auth
24974                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24975                .await
24976            {
24977                Ok(token) => token,
24978                Err(e) => match dlg.token(e) {
24979                    Ok(token) => token,
24980                    Err(e) => {
24981                        dlg.finished(false);
24982                        return Err(common::Error::MissingToken(e));
24983                    }
24984                },
24985            };
24986            request_value_reader
24987                .seek(std::io::SeekFrom::Start(0))
24988                .unwrap();
24989            let mut req_result = {
24990                let client = &self.hub.client;
24991                dlg.pre_request();
24992                let mut req_builder = hyper::Request::builder()
24993                    .method(hyper::Method::POST)
24994                    .uri(url.as_str())
24995                    .header(USER_AGENT, self.hub._user_agent.clone());
24996
24997                if let Some(token) = token.as_ref() {
24998                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24999                }
25000
25001                let request = req_builder
25002                    .header(CONTENT_TYPE, json_mime_type.to_string())
25003                    .header(CONTENT_LENGTH, request_size as u64)
25004                    .body(common::to_body(
25005                        request_value_reader.get_ref().clone().into(),
25006                    ));
25007
25008                client.request(request.unwrap()).await
25009            };
25010
25011            match req_result {
25012                Err(err) => {
25013                    if let common::Retry::After(d) = dlg.http_error(&err) {
25014                        sleep(d).await;
25015                        continue;
25016                    }
25017                    dlg.finished(false);
25018                    return Err(common::Error::HttpError(err));
25019                }
25020                Ok(res) => {
25021                    let (mut parts, body) = res.into_parts();
25022                    let mut body = common::Body::new(body);
25023                    if !parts.status.is_success() {
25024                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25025                        let error = serde_json::from_str(&common::to_string(&bytes));
25026                        let response = common::to_response(parts, bytes.into());
25027
25028                        if let common::Retry::After(d) =
25029                            dlg.http_failure(&response, error.as_ref().ok())
25030                        {
25031                            sleep(d).await;
25032                            continue;
25033                        }
25034
25035                        dlg.finished(false);
25036
25037                        return Err(match error {
25038                            Ok(value) => common::Error::BadRequest(value),
25039                            _ => common::Error::Failure(response),
25040                        });
25041                    }
25042                    let response = {
25043                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25044                        let encoded = common::to_string(&bytes);
25045                        match serde_json::from_str(&encoded) {
25046                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25047                            Err(error) => {
25048                                dlg.response_json_decode_error(&encoded, &error);
25049                                return Err(common::Error::JsonDecodeError(
25050                                    encoded.to_string(),
25051                                    error,
25052                                ));
25053                            }
25054                        }
25055                    };
25056
25057                    dlg.finished(true);
25058                    return Ok(response);
25059                }
25060            }
25061        }
25062    }
25063
25064    ///
25065    /// Sets the *request* property to the given value.
25066    ///
25067    /// Even though the property as already been set when instantiating this call,
25068    /// we provide this method for API completeness.
25069    pub fn request(
25070        mut self,
25071        new_value: PartitionReadRequest,
25072    ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
25073        self._request = new_value;
25074        self
25075    }
25076    /// Required. The session used to create the partitions.
25077    ///
25078    /// Sets the *session* path property to the given value.
25079    ///
25080    /// Even though the property as already been set when instantiating this call,
25081    /// we provide this method for API completeness.
25082    pub fn session(
25083        mut self,
25084        new_value: &str,
25085    ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
25086        self._session = new_value.to_string();
25087        self
25088    }
25089    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25090    /// while executing the actual API request.
25091    ///
25092    /// ````text
25093    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25094    /// ````
25095    ///
25096    /// Sets the *delegate* property to the given value.
25097    pub fn delegate(
25098        mut self,
25099        new_value: &'a mut dyn common::Delegate,
25100    ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
25101        self._delegate = Some(new_value);
25102        self
25103    }
25104
25105    /// Set any additional parameter of the query string used in the request.
25106    /// It should be used to set parameters which are not yet available through their own
25107    /// setters.
25108    ///
25109    /// Please note that this method must not be used to set any of the known parameters
25110    /// which have their own setter method. If done anyway, the request will fail.
25111    ///
25112    /// # Additional Parameters
25113    ///
25114    /// * *$.xgafv* (query-string) - V1 error format.
25115    /// * *access_token* (query-string) - OAuth access token.
25116    /// * *alt* (query-string) - Data format for response.
25117    /// * *callback* (query-string) - JSONP
25118    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25119    /// * *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.
25120    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25121    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25122    /// * *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.
25123    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25124    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25125    pub fn param<T>(
25126        mut self,
25127        name: T,
25128        value: T,
25129    ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
25130    where
25131        T: AsRef<str>,
25132    {
25133        self._additional_params
25134            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25135        self
25136    }
25137
25138    /// Identifies the authorization scope for the method you are building.
25139    ///
25140    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25141    /// [`Scope::CloudPlatform`].
25142    ///
25143    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25144    /// tokens for more than one scope.
25145    ///
25146    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25147    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25148    /// sufficient, a read-write scope will do as well.
25149    pub fn add_scope<St>(
25150        mut self,
25151        scope: St,
25152    ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
25153    where
25154        St: AsRef<str>,
25155    {
25156        self._scopes.insert(String::from(scope.as_ref()));
25157        self
25158    }
25159    /// Identifies the authorization scope(s) for the method you are building.
25160    ///
25161    /// See [`Self::add_scope()`] for details.
25162    pub fn add_scopes<I, St>(
25163        mut self,
25164        scopes: I,
25165    ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
25166    where
25167        I: IntoIterator<Item = St>,
25168        St: AsRef<str>,
25169    {
25170        self._scopes
25171            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25172        self
25173    }
25174
25175    /// Removes all scopes, and no default scope will be used either.
25176    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25177    /// for details).
25178    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
25179        self._scopes.clear();
25180        self
25181    }
25182}
25183
25184/// Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteSql. This method can't be used to return a result set larger than 10 MiB; if the read matches more data than that, the read fails with a `FAILED_PRECONDITION` error. Reads inside read-write transactions might return `ABORTED`. If this occurs, the application should restart the transaction from the beginning. See Transaction for more details. Larger result sets can be yielded in streaming fashion by calling StreamingRead instead.
25185///
25186/// A builder for the *instances.databases.sessions.read* method supported by a *project* resource.
25187/// It is not used directly, but through a [`ProjectMethods`] instance.
25188///
25189/// # Example
25190///
25191/// Instantiate a resource method builder
25192///
25193/// ```test_harness,no_run
25194/// # extern crate hyper;
25195/// # extern crate hyper_rustls;
25196/// # extern crate google_spanner1 as spanner1;
25197/// use spanner1::api::ReadRequest;
25198/// # async fn dox() {
25199/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25200///
25201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25202/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25203/// #     .with_native_roots()
25204/// #     .unwrap()
25205/// #     .https_only()
25206/// #     .enable_http2()
25207/// #     .build();
25208///
25209/// # let executor = hyper_util::rt::TokioExecutor::new();
25210/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25211/// #     secret,
25212/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25213/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25214/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25215/// #     ),
25216/// # ).build().await.unwrap();
25217///
25218/// # let client = hyper_util::client::legacy::Client::builder(
25219/// #     hyper_util::rt::TokioExecutor::new()
25220/// # )
25221/// # .build(
25222/// #     hyper_rustls::HttpsConnectorBuilder::new()
25223/// #         .with_native_roots()
25224/// #         .unwrap()
25225/// #         .https_or_http()
25226/// #         .enable_http2()
25227/// #         .build()
25228/// # );
25229/// # let mut hub = Spanner::new(client, auth);
25230/// // As the method needs a request, you would usually fill it with the desired information
25231/// // into the respective structure. Some of the parts shown here might not be applicable !
25232/// // Values shown here are possibly random and not representative !
25233/// let mut req = ReadRequest::default();
25234///
25235/// // You can configure optional parameters by calling the respective setters at will, and
25236/// // execute the final call using `doit()`.
25237/// // Values shown here are possibly random and not representative !
25238/// let result = hub.projects().instances_databases_sessions_read(req, "session")
25239///              .doit().await;
25240/// # }
25241/// ```
25242pub struct ProjectInstanceDatabaseSessionReadCall<'a, C>
25243where
25244    C: 'a,
25245{
25246    hub: &'a Spanner<C>,
25247    _request: ReadRequest,
25248    _session: String,
25249    _delegate: Option<&'a mut dyn common::Delegate>,
25250    _additional_params: HashMap<String, String>,
25251    _scopes: BTreeSet<String>,
25252}
25253
25254impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionReadCall<'a, C> {}
25255
25256impl<'a, C> ProjectInstanceDatabaseSessionReadCall<'a, C>
25257where
25258    C: common::Connector,
25259{
25260    /// Perform the operation you have build so far.
25261    pub async fn doit(mut self) -> common::Result<(common::Response, ResultSet)> {
25262        use std::borrow::Cow;
25263        use std::io::{Read, Seek};
25264
25265        use common::{url::Params, ToParts};
25266        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25267
25268        let mut dd = common::DefaultDelegate;
25269        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25270        dlg.begin(common::MethodInfo {
25271            id: "spanner.projects.instances.databases.sessions.read",
25272            http_method: hyper::Method::POST,
25273        });
25274
25275        for &field in ["alt", "session"].iter() {
25276            if self._additional_params.contains_key(field) {
25277                dlg.finished(false);
25278                return Err(common::Error::FieldClash(field));
25279            }
25280        }
25281
25282        let mut params = Params::with_capacity(4 + self._additional_params.len());
25283        params.push("session", self._session);
25284
25285        params.extend(self._additional_params.iter());
25286
25287        params.push("alt", "json");
25288        let mut url = self.hub._base_url.clone() + "v1/{+session}:read";
25289        if self._scopes.is_empty() {
25290            self._scopes
25291                .insert(Scope::CloudPlatform.as_ref().to_string());
25292        }
25293
25294        #[allow(clippy::single_element_loop)]
25295        for &(find_this, param_name) in [("{+session}", "session")].iter() {
25296            url = params.uri_replacement(url, param_name, find_this, true);
25297        }
25298        {
25299            let to_remove = ["session"];
25300            params.remove_params(&to_remove);
25301        }
25302
25303        let url = params.parse_with_url(&url);
25304
25305        let mut json_mime_type = mime::APPLICATION_JSON;
25306        let mut request_value_reader = {
25307            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25308            common::remove_json_null_values(&mut value);
25309            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25310            serde_json::to_writer(&mut dst, &value).unwrap();
25311            dst
25312        };
25313        let request_size = request_value_reader
25314            .seek(std::io::SeekFrom::End(0))
25315            .unwrap();
25316        request_value_reader
25317            .seek(std::io::SeekFrom::Start(0))
25318            .unwrap();
25319
25320        loop {
25321            let token = match self
25322                .hub
25323                .auth
25324                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25325                .await
25326            {
25327                Ok(token) => token,
25328                Err(e) => match dlg.token(e) {
25329                    Ok(token) => token,
25330                    Err(e) => {
25331                        dlg.finished(false);
25332                        return Err(common::Error::MissingToken(e));
25333                    }
25334                },
25335            };
25336            request_value_reader
25337                .seek(std::io::SeekFrom::Start(0))
25338                .unwrap();
25339            let mut req_result = {
25340                let client = &self.hub.client;
25341                dlg.pre_request();
25342                let mut req_builder = hyper::Request::builder()
25343                    .method(hyper::Method::POST)
25344                    .uri(url.as_str())
25345                    .header(USER_AGENT, self.hub._user_agent.clone());
25346
25347                if let Some(token) = token.as_ref() {
25348                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25349                }
25350
25351                let request = req_builder
25352                    .header(CONTENT_TYPE, json_mime_type.to_string())
25353                    .header(CONTENT_LENGTH, request_size as u64)
25354                    .body(common::to_body(
25355                        request_value_reader.get_ref().clone().into(),
25356                    ));
25357
25358                client.request(request.unwrap()).await
25359            };
25360
25361            match req_result {
25362                Err(err) => {
25363                    if let common::Retry::After(d) = dlg.http_error(&err) {
25364                        sleep(d).await;
25365                        continue;
25366                    }
25367                    dlg.finished(false);
25368                    return Err(common::Error::HttpError(err));
25369                }
25370                Ok(res) => {
25371                    let (mut parts, body) = res.into_parts();
25372                    let mut body = common::Body::new(body);
25373                    if !parts.status.is_success() {
25374                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25375                        let error = serde_json::from_str(&common::to_string(&bytes));
25376                        let response = common::to_response(parts, bytes.into());
25377
25378                        if let common::Retry::After(d) =
25379                            dlg.http_failure(&response, error.as_ref().ok())
25380                        {
25381                            sleep(d).await;
25382                            continue;
25383                        }
25384
25385                        dlg.finished(false);
25386
25387                        return Err(match error {
25388                            Ok(value) => common::Error::BadRequest(value),
25389                            _ => common::Error::Failure(response),
25390                        });
25391                    }
25392                    let response = {
25393                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25394                        let encoded = common::to_string(&bytes);
25395                        match serde_json::from_str(&encoded) {
25396                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25397                            Err(error) => {
25398                                dlg.response_json_decode_error(&encoded, &error);
25399                                return Err(common::Error::JsonDecodeError(
25400                                    encoded.to_string(),
25401                                    error,
25402                                ));
25403                            }
25404                        }
25405                    };
25406
25407                    dlg.finished(true);
25408                    return Ok(response);
25409                }
25410            }
25411        }
25412    }
25413
25414    ///
25415    /// Sets the *request* property to the given value.
25416    ///
25417    /// Even though the property as already been set when instantiating this call,
25418    /// we provide this method for API completeness.
25419    pub fn request(
25420        mut self,
25421        new_value: ReadRequest,
25422    ) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
25423        self._request = new_value;
25424        self
25425    }
25426    /// Required. The session in which the read should be performed.
25427    ///
25428    /// Sets the *session* path property to the given value.
25429    ///
25430    /// Even though the property as already been set when instantiating this call,
25431    /// we provide this method for API completeness.
25432    pub fn session(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
25433        self._session = new_value.to_string();
25434        self
25435    }
25436    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25437    /// while executing the actual API request.
25438    ///
25439    /// ````text
25440    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25441    /// ````
25442    ///
25443    /// Sets the *delegate* property to the given value.
25444    pub fn delegate(
25445        mut self,
25446        new_value: &'a mut dyn common::Delegate,
25447    ) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
25448        self._delegate = Some(new_value);
25449        self
25450    }
25451
25452    /// Set any additional parameter of the query string used in the request.
25453    /// It should be used to set parameters which are not yet available through their own
25454    /// setters.
25455    ///
25456    /// Please note that this method must not be used to set any of the known parameters
25457    /// which have their own setter method. If done anyway, the request will fail.
25458    ///
25459    /// # Additional Parameters
25460    ///
25461    /// * *$.xgafv* (query-string) - V1 error format.
25462    /// * *access_token* (query-string) - OAuth access token.
25463    /// * *alt* (query-string) - Data format for response.
25464    /// * *callback* (query-string) - JSONP
25465    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25466    /// * *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.
25467    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25468    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25469    /// * *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.
25470    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25471    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25472    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionReadCall<'a, C>
25473    where
25474        T: AsRef<str>,
25475    {
25476        self._additional_params
25477            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25478        self
25479    }
25480
25481    /// Identifies the authorization scope for the method you are building.
25482    ///
25483    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25484    /// [`Scope::CloudPlatform`].
25485    ///
25486    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25487    /// tokens for more than one scope.
25488    ///
25489    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25490    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25491    /// sufficient, a read-write scope will do as well.
25492    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionReadCall<'a, C>
25493    where
25494        St: AsRef<str>,
25495    {
25496        self._scopes.insert(String::from(scope.as_ref()));
25497        self
25498    }
25499    /// Identifies the authorization scope(s) for the method you are building.
25500    ///
25501    /// See [`Self::add_scope()`] for details.
25502    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionReadCall<'a, C>
25503    where
25504        I: IntoIterator<Item = St>,
25505        St: AsRef<str>,
25506    {
25507        self._scopes
25508            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25509        self
25510    }
25511
25512    /// Removes all scopes, and no default scope will be used either.
25513    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25514    /// for details).
25515    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
25516        self._scopes.clear();
25517        self
25518    }
25519}
25520
25521/// Rolls back a transaction, releasing any locks it holds. It's a good idea to call this for any transaction that includes one or more Read or ExecuteSql requests and ultimately decides not to commit. `Rollback` returns `OK` if it successfully aborts the transaction, the transaction was already aborted, or the transaction isn't found. `Rollback` never returns `ABORTED`.
25522///
25523/// A builder for the *instances.databases.sessions.rollback* method supported by a *project* resource.
25524/// It is not used directly, but through a [`ProjectMethods`] instance.
25525///
25526/// # Example
25527///
25528/// Instantiate a resource method builder
25529///
25530/// ```test_harness,no_run
25531/// # extern crate hyper;
25532/// # extern crate hyper_rustls;
25533/// # extern crate google_spanner1 as spanner1;
25534/// use spanner1::api::RollbackRequest;
25535/// # async fn dox() {
25536/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25537///
25538/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25539/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25540/// #     .with_native_roots()
25541/// #     .unwrap()
25542/// #     .https_only()
25543/// #     .enable_http2()
25544/// #     .build();
25545///
25546/// # let executor = hyper_util::rt::TokioExecutor::new();
25547/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25548/// #     secret,
25549/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25550/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25551/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25552/// #     ),
25553/// # ).build().await.unwrap();
25554///
25555/// # let client = hyper_util::client::legacy::Client::builder(
25556/// #     hyper_util::rt::TokioExecutor::new()
25557/// # )
25558/// # .build(
25559/// #     hyper_rustls::HttpsConnectorBuilder::new()
25560/// #         .with_native_roots()
25561/// #         .unwrap()
25562/// #         .https_or_http()
25563/// #         .enable_http2()
25564/// #         .build()
25565/// # );
25566/// # let mut hub = Spanner::new(client, auth);
25567/// // As the method needs a request, you would usually fill it with the desired information
25568/// // into the respective structure. Some of the parts shown here might not be applicable !
25569/// // Values shown here are possibly random and not representative !
25570/// let mut req = RollbackRequest::default();
25571///
25572/// // You can configure optional parameters by calling the respective setters at will, and
25573/// // execute the final call using `doit()`.
25574/// // Values shown here are possibly random and not representative !
25575/// let result = hub.projects().instances_databases_sessions_rollback(req, "session")
25576///              .doit().await;
25577/// # }
25578/// ```
25579pub struct ProjectInstanceDatabaseSessionRollbackCall<'a, C>
25580where
25581    C: 'a,
25582{
25583    hub: &'a Spanner<C>,
25584    _request: RollbackRequest,
25585    _session: String,
25586    _delegate: Option<&'a mut dyn common::Delegate>,
25587    _additional_params: HashMap<String, String>,
25588    _scopes: BTreeSet<String>,
25589}
25590
25591impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionRollbackCall<'a, C> {}
25592
25593impl<'a, C> ProjectInstanceDatabaseSessionRollbackCall<'a, C>
25594where
25595    C: common::Connector,
25596{
25597    /// Perform the operation you have build so far.
25598    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
25599        use std::borrow::Cow;
25600        use std::io::{Read, Seek};
25601
25602        use common::{url::Params, ToParts};
25603        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25604
25605        let mut dd = common::DefaultDelegate;
25606        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25607        dlg.begin(common::MethodInfo {
25608            id: "spanner.projects.instances.databases.sessions.rollback",
25609            http_method: hyper::Method::POST,
25610        });
25611
25612        for &field in ["alt", "session"].iter() {
25613            if self._additional_params.contains_key(field) {
25614                dlg.finished(false);
25615                return Err(common::Error::FieldClash(field));
25616            }
25617        }
25618
25619        let mut params = Params::with_capacity(4 + self._additional_params.len());
25620        params.push("session", self._session);
25621
25622        params.extend(self._additional_params.iter());
25623
25624        params.push("alt", "json");
25625        let mut url = self.hub._base_url.clone() + "v1/{+session}:rollback";
25626        if self._scopes.is_empty() {
25627            self._scopes
25628                .insert(Scope::CloudPlatform.as_ref().to_string());
25629        }
25630
25631        #[allow(clippy::single_element_loop)]
25632        for &(find_this, param_name) in [("{+session}", "session")].iter() {
25633            url = params.uri_replacement(url, param_name, find_this, true);
25634        }
25635        {
25636            let to_remove = ["session"];
25637            params.remove_params(&to_remove);
25638        }
25639
25640        let url = params.parse_with_url(&url);
25641
25642        let mut json_mime_type = mime::APPLICATION_JSON;
25643        let mut request_value_reader = {
25644            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25645            common::remove_json_null_values(&mut value);
25646            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25647            serde_json::to_writer(&mut dst, &value).unwrap();
25648            dst
25649        };
25650        let request_size = request_value_reader
25651            .seek(std::io::SeekFrom::End(0))
25652            .unwrap();
25653        request_value_reader
25654            .seek(std::io::SeekFrom::Start(0))
25655            .unwrap();
25656
25657        loop {
25658            let token = match self
25659                .hub
25660                .auth
25661                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25662                .await
25663            {
25664                Ok(token) => token,
25665                Err(e) => match dlg.token(e) {
25666                    Ok(token) => token,
25667                    Err(e) => {
25668                        dlg.finished(false);
25669                        return Err(common::Error::MissingToken(e));
25670                    }
25671                },
25672            };
25673            request_value_reader
25674                .seek(std::io::SeekFrom::Start(0))
25675                .unwrap();
25676            let mut req_result = {
25677                let client = &self.hub.client;
25678                dlg.pre_request();
25679                let mut req_builder = hyper::Request::builder()
25680                    .method(hyper::Method::POST)
25681                    .uri(url.as_str())
25682                    .header(USER_AGENT, self.hub._user_agent.clone());
25683
25684                if let Some(token) = token.as_ref() {
25685                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25686                }
25687
25688                let request = req_builder
25689                    .header(CONTENT_TYPE, json_mime_type.to_string())
25690                    .header(CONTENT_LENGTH, request_size as u64)
25691                    .body(common::to_body(
25692                        request_value_reader.get_ref().clone().into(),
25693                    ));
25694
25695                client.request(request.unwrap()).await
25696            };
25697
25698            match req_result {
25699                Err(err) => {
25700                    if let common::Retry::After(d) = dlg.http_error(&err) {
25701                        sleep(d).await;
25702                        continue;
25703                    }
25704                    dlg.finished(false);
25705                    return Err(common::Error::HttpError(err));
25706                }
25707                Ok(res) => {
25708                    let (mut parts, body) = res.into_parts();
25709                    let mut body = common::Body::new(body);
25710                    if !parts.status.is_success() {
25711                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25712                        let error = serde_json::from_str(&common::to_string(&bytes));
25713                        let response = common::to_response(parts, bytes.into());
25714
25715                        if let common::Retry::After(d) =
25716                            dlg.http_failure(&response, error.as_ref().ok())
25717                        {
25718                            sleep(d).await;
25719                            continue;
25720                        }
25721
25722                        dlg.finished(false);
25723
25724                        return Err(match error {
25725                            Ok(value) => common::Error::BadRequest(value),
25726                            _ => common::Error::Failure(response),
25727                        });
25728                    }
25729                    let response = {
25730                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25731                        let encoded = common::to_string(&bytes);
25732                        match serde_json::from_str(&encoded) {
25733                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25734                            Err(error) => {
25735                                dlg.response_json_decode_error(&encoded, &error);
25736                                return Err(common::Error::JsonDecodeError(
25737                                    encoded.to_string(),
25738                                    error,
25739                                ));
25740                            }
25741                        }
25742                    };
25743
25744                    dlg.finished(true);
25745                    return Ok(response);
25746                }
25747            }
25748        }
25749    }
25750
25751    ///
25752    /// Sets the *request* property to the given value.
25753    ///
25754    /// Even though the property as already been set when instantiating this call,
25755    /// we provide this method for API completeness.
25756    pub fn request(
25757        mut self,
25758        new_value: RollbackRequest,
25759    ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
25760        self._request = new_value;
25761        self
25762    }
25763    /// Required. The session in which the transaction to roll back is running.
25764    ///
25765    /// Sets the *session* path property to the given value.
25766    ///
25767    /// Even though the property as already been set when instantiating this call,
25768    /// we provide this method for API completeness.
25769    pub fn session(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
25770        self._session = new_value.to_string();
25771        self
25772    }
25773    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25774    /// while executing the actual API request.
25775    ///
25776    /// ````text
25777    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25778    /// ````
25779    ///
25780    /// Sets the *delegate* property to the given value.
25781    pub fn delegate(
25782        mut self,
25783        new_value: &'a mut dyn common::Delegate,
25784    ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
25785        self._delegate = Some(new_value);
25786        self
25787    }
25788
25789    /// Set any additional parameter of the query string used in the request.
25790    /// It should be used to set parameters which are not yet available through their own
25791    /// setters.
25792    ///
25793    /// Please note that this method must not be used to set any of the known parameters
25794    /// which have their own setter method. If done anyway, the request will fail.
25795    ///
25796    /// # Additional Parameters
25797    ///
25798    /// * *$.xgafv* (query-string) - V1 error format.
25799    /// * *access_token* (query-string) - OAuth access token.
25800    /// * *alt* (query-string) - Data format for response.
25801    /// * *callback* (query-string) - JSONP
25802    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25803    /// * *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.
25804    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25805    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25806    /// * *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.
25807    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25808    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25809    pub fn param<T>(
25810        mut self,
25811        name: T,
25812        value: T,
25813    ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C>
25814    where
25815        T: AsRef<str>,
25816    {
25817        self._additional_params
25818            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25819        self
25820    }
25821
25822    /// Identifies the authorization scope for the method you are building.
25823    ///
25824    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25825    /// [`Scope::CloudPlatform`].
25826    ///
25827    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25828    /// tokens for more than one scope.
25829    ///
25830    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25831    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25832    /// sufficient, a read-write scope will do as well.
25833    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C>
25834    where
25835        St: AsRef<str>,
25836    {
25837        self._scopes.insert(String::from(scope.as_ref()));
25838        self
25839    }
25840    /// Identifies the authorization scope(s) for the method you are building.
25841    ///
25842    /// See [`Self::add_scope()`] for details.
25843    pub fn add_scopes<I, St>(
25844        mut self,
25845        scopes: I,
25846    ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C>
25847    where
25848        I: IntoIterator<Item = St>,
25849        St: AsRef<str>,
25850    {
25851        self._scopes
25852            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25853        self
25854    }
25855
25856    /// Removes all scopes, and no default scope will be used either.
25857    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25858    /// for details).
25859    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
25860        self._scopes.clear();
25861        self
25862    }
25863}
25864
25865/// Like Read, except returns the result set as a stream. Unlike Read, there is no limit on the size of the returned result set. However, no individual row in the result set can exceed 100 MiB, and no column value can exceed 10 MiB.
25866///
25867/// A builder for the *instances.databases.sessions.streamingRead* method supported by a *project* resource.
25868/// It is not used directly, but through a [`ProjectMethods`] instance.
25869///
25870/// # Example
25871///
25872/// Instantiate a resource method builder
25873///
25874/// ```test_harness,no_run
25875/// # extern crate hyper;
25876/// # extern crate hyper_rustls;
25877/// # extern crate google_spanner1 as spanner1;
25878/// use spanner1::api::ReadRequest;
25879/// # async fn dox() {
25880/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25881///
25882/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25883/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25884/// #     .with_native_roots()
25885/// #     .unwrap()
25886/// #     .https_only()
25887/// #     .enable_http2()
25888/// #     .build();
25889///
25890/// # let executor = hyper_util::rt::TokioExecutor::new();
25891/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25892/// #     secret,
25893/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25894/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25895/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25896/// #     ),
25897/// # ).build().await.unwrap();
25898///
25899/// # let client = hyper_util::client::legacy::Client::builder(
25900/// #     hyper_util::rt::TokioExecutor::new()
25901/// # )
25902/// # .build(
25903/// #     hyper_rustls::HttpsConnectorBuilder::new()
25904/// #         .with_native_roots()
25905/// #         .unwrap()
25906/// #         .https_or_http()
25907/// #         .enable_http2()
25908/// #         .build()
25909/// # );
25910/// # let mut hub = Spanner::new(client, auth);
25911/// // As the method needs a request, you would usually fill it with the desired information
25912/// // into the respective structure. Some of the parts shown here might not be applicable !
25913/// // Values shown here are possibly random and not representative !
25914/// let mut req = ReadRequest::default();
25915///
25916/// // You can configure optional parameters by calling the respective setters at will, and
25917/// // execute the final call using `doit()`.
25918/// // Values shown here are possibly random and not representative !
25919/// let result = hub.projects().instances_databases_sessions_streaming_read(req, "session")
25920///              .doit().await;
25921/// # }
25922/// ```
25923pub struct ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
25924where
25925    C: 'a,
25926{
25927    hub: &'a Spanner<C>,
25928    _request: ReadRequest,
25929    _session: String,
25930    _delegate: Option<&'a mut dyn common::Delegate>,
25931    _additional_params: HashMap<String, String>,
25932    _scopes: BTreeSet<String>,
25933}
25934
25935impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {}
25936
25937impl<'a, C> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
25938where
25939    C: common::Connector,
25940{
25941    /// Perform the operation you have build so far.
25942    pub async fn doit(mut self) -> common::Result<(common::Response, PartialResultSet)> {
25943        use std::borrow::Cow;
25944        use std::io::{Read, Seek};
25945
25946        use common::{url::Params, ToParts};
25947        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25948
25949        let mut dd = common::DefaultDelegate;
25950        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25951        dlg.begin(common::MethodInfo {
25952            id: "spanner.projects.instances.databases.sessions.streamingRead",
25953            http_method: hyper::Method::POST,
25954        });
25955
25956        for &field in ["alt", "session"].iter() {
25957            if self._additional_params.contains_key(field) {
25958                dlg.finished(false);
25959                return Err(common::Error::FieldClash(field));
25960            }
25961        }
25962
25963        let mut params = Params::with_capacity(4 + self._additional_params.len());
25964        params.push("session", self._session);
25965
25966        params.extend(self._additional_params.iter());
25967
25968        params.push("alt", "json");
25969        let mut url = self.hub._base_url.clone() + "v1/{+session}:streamingRead";
25970        if self._scopes.is_empty() {
25971            self._scopes
25972                .insert(Scope::CloudPlatform.as_ref().to_string());
25973        }
25974
25975        #[allow(clippy::single_element_loop)]
25976        for &(find_this, param_name) in [("{+session}", "session")].iter() {
25977            url = params.uri_replacement(url, param_name, find_this, true);
25978        }
25979        {
25980            let to_remove = ["session"];
25981            params.remove_params(&to_remove);
25982        }
25983
25984        let url = params.parse_with_url(&url);
25985
25986        let mut json_mime_type = mime::APPLICATION_JSON;
25987        let mut request_value_reader = {
25988            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25989            common::remove_json_null_values(&mut value);
25990            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25991            serde_json::to_writer(&mut dst, &value).unwrap();
25992            dst
25993        };
25994        let request_size = request_value_reader
25995            .seek(std::io::SeekFrom::End(0))
25996            .unwrap();
25997        request_value_reader
25998            .seek(std::io::SeekFrom::Start(0))
25999            .unwrap();
26000
26001        loop {
26002            let token = match self
26003                .hub
26004                .auth
26005                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26006                .await
26007            {
26008                Ok(token) => token,
26009                Err(e) => match dlg.token(e) {
26010                    Ok(token) => token,
26011                    Err(e) => {
26012                        dlg.finished(false);
26013                        return Err(common::Error::MissingToken(e));
26014                    }
26015                },
26016            };
26017            request_value_reader
26018                .seek(std::io::SeekFrom::Start(0))
26019                .unwrap();
26020            let mut req_result = {
26021                let client = &self.hub.client;
26022                dlg.pre_request();
26023                let mut req_builder = hyper::Request::builder()
26024                    .method(hyper::Method::POST)
26025                    .uri(url.as_str())
26026                    .header(USER_AGENT, self.hub._user_agent.clone());
26027
26028                if let Some(token) = token.as_ref() {
26029                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26030                }
26031
26032                let request = req_builder
26033                    .header(CONTENT_TYPE, json_mime_type.to_string())
26034                    .header(CONTENT_LENGTH, request_size as u64)
26035                    .body(common::to_body(
26036                        request_value_reader.get_ref().clone().into(),
26037                    ));
26038
26039                client.request(request.unwrap()).await
26040            };
26041
26042            match req_result {
26043                Err(err) => {
26044                    if let common::Retry::After(d) = dlg.http_error(&err) {
26045                        sleep(d).await;
26046                        continue;
26047                    }
26048                    dlg.finished(false);
26049                    return Err(common::Error::HttpError(err));
26050                }
26051                Ok(res) => {
26052                    let (mut parts, body) = res.into_parts();
26053                    let mut body = common::Body::new(body);
26054                    if !parts.status.is_success() {
26055                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26056                        let error = serde_json::from_str(&common::to_string(&bytes));
26057                        let response = common::to_response(parts, bytes.into());
26058
26059                        if let common::Retry::After(d) =
26060                            dlg.http_failure(&response, error.as_ref().ok())
26061                        {
26062                            sleep(d).await;
26063                            continue;
26064                        }
26065
26066                        dlg.finished(false);
26067
26068                        return Err(match error {
26069                            Ok(value) => common::Error::BadRequest(value),
26070                            _ => common::Error::Failure(response),
26071                        });
26072                    }
26073                    let response = {
26074                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26075                        let encoded = common::to_string(&bytes);
26076                        match serde_json::from_str(&encoded) {
26077                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26078                            Err(error) => {
26079                                dlg.response_json_decode_error(&encoded, &error);
26080                                return Err(common::Error::JsonDecodeError(
26081                                    encoded.to_string(),
26082                                    error,
26083                                ));
26084                            }
26085                        }
26086                    };
26087
26088                    dlg.finished(true);
26089                    return Ok(response);
26090                }
26091            }
26092        }
26093    }
26094
26095    ///
26096    /// Sets the *request* property to the given value.
26097    ///
26098    /// Even though the property as already been set when instantiating this call,
26099    /// we provide this method for API completeness.
26100    pub fn request(
26101        mut self,
26102        new_value: ReadRequest,
26103    ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
26104        self._request = new_value;
26105        self
26106    }
26107    /// Required. The session in which the read should be performed.
26108    ///
26109    /// Sets the *session* path property to the given value.
26110    ///
26111    /// Even though the property as already been set when instantiating this call,
26112    /// we provide this method for API completeness.
26113    pub fn session(
26114        mut self,
26115        new_value: &str,
26116    ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
26117        self._session = new_value.to_string();
26118        self
26119    }
26120    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26121    /// while executing the actual API request.
26122    ///
26123    /// ````text
26124    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26125    /// ````
26126    ///
26127    /// Sets the *delegate* property to the given value.
26128    pub fn delegate(
26129        mut self,
26130        new_value: &'a mut dyn common::Delegate,
26131    ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
26132        self._delegate = Some(new_value);
26133        self
26134    }
26135
26136    /// Set any additional parameter of the query string used in the request.
26137    /// It should be used to set parameters which are not yet available through their own
26138    /// setters.
26139    ///
26140    /// Please note that this method must not be used to set any of the known parameters
26141    /// which have their own setter method. If done anyway, the request will fail.
26142    ///
26143    /// # Additional Parameters
26144    ///
26145    /// * *$.xgafv* (query-string) - V1 error format.
26146    /// * *access_token* (query-string) - OAuth access token.
26147    /// * *alt* (query-string) - Data format for response.
26148    /// * *callback* (query-string) - JSONP
26149    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26150    /// * *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.
26151    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26152    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26153    /// * *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.
26154    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26155    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26156    pub fn param<T>(
26157        mut self,
26158        name: T,
26159        value: T,
26160    ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
26161    where
26162        T: AsRef<str>,
26163    {
26164        self._additional_params
26165            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26166        self
26167    }
26168
26169    /// Identifies the authorization scope for the method you are building.
26170    ///
26171    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26172    /// [`Scope::CloudPlatform`].
26173    ///
26174    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26175    /// tokens for more than one scope.
26176    ///
26177    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26178    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26179    /// sufficient, a read-write scope will do as well.
26180    pub fn add_scope<St>(
26181        mut self,
26182        scope: St,
26183    ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
26184    where
26185        St: AsRef<str>,
26186    {
26187        self._scopes.insert(String::from(scope.as_ref()));
26188        self
26189    }
26190    /// Identifies the authorization scope(s) for the method you are building.
26191    ///
26192    /// See [`Self::add_scope()`] for details.
26193    pub fn add_scopes<I, St>(
26194        mut self,
26195        scopes: I,
26196    ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
26197    where
26198        I: IntoIterator<Item = St>,
26199        St: AsRef<str>,
26200    {
26201        self._scopes
26202            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26203        self
26204    }
26205
26206    /// Removes all scopes, and no default scope will be used either.
26207    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26208    /// for details).
26209    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
26210        self._scopes.clear();
26211        self
26212    }
26213}
26214
26215/// Adds split points to specified tables and indexes of a database.
26216///
26217/// A builder for the *instances.databases.addSplitPoints* method supported by a *project* resource.
26218/// It is not used directly, but through a [`ProjectMethods`] instance.
26219///
26220/// # Example
26221///
26222/// Instantiate a resource method builder
26223///
26224/// ```test_harness,no_run
26225/// # extern crate hyper;
26226/// # extern crate hyper_rustls;
26227/// # extern crate google_spanner1 as spanner1;
26228/// use spanner1::api::AddSplitPointsRequest;
26229/// # async fn dox() {
26230/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26231///
26232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26233/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26234/// #     .with_native_roots()
26235/// #     .unwrap()
26236/// #     .https_only()
26237/// #     .enable_http2()
26238/// #     .build();
26239///
26240/// # let executor = hyper_util::rt::TokioExecutor::new();
26241/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26242/// #     secret,
26243/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26244/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26245/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26246/// #     ),
26247/// # ).build().await.unwrap();
26248///
26249/// # let client = hyper_util::client::legacy::Client::builder(
26250/// #     hyper_util::rt::TokioExecutor::new()
26251/// # )
26252/// # .build(
26253/// #     hyper_rustls::HttpsConnectorBuilder::new()
26254/// #         .with_native_roots()
26255/// #         .unwrap()
26256/// #         .https_or_http()
26257/// #         .enable_http2()
26258/// #         .build()
26259/// # );
26260/// # let mut hub = Spanner::new(client, auth);
26261/// // As the method needs a request, you would usually fill it with the desired information
26262/// // into the respective structure. Some of the parts shown here might not be applicable !
26263/// // Values shown here are possibly random and not representative !
26264/// let mut req = AddSplitPointsRequest::default();
26265///
26266/// // You can configure optional parameters by calling the respective setters at will, and
26267/// // execute the final call using `doit()`.
26268/// // Values shown here are possibly random and not representative !
26269/// let result = hub.projects().instances_databases_add_split_points(req, "database")
26270///              .doit().await;
26271/// # }
26272/// ```
26273pub struct ProjectInstanceDatabaseAddSplitPointCall<'a, C>
26274where
26275    C: 'a,
26276{
26277    hub: &'a Spanner<C>,
26278    _request: AddSplitPointsRequest,
26279    _database: String,
26280    _delegate: Option<&'a mut dyn common::Delegate>,
26281    _additional_params: HashMap<String, String>,
26282    _scopes: BTreeSet<String>,
26283}
26284
26285impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseAddSplitPointCall<'a, C> {}
26286
26287impl<'a, C> ProjectInstanceDatabaseAddSplitPointCall<'a, C>
26288where
26289    C: common::Connector,
26290{
26291    /// Perform the operation you have build so far.
26292    pub async fn doit(mut self) -> common::Result<(common::Response, AddSplitPointsResponse)> {
26293        use std::borrow::Cow;
26294        use std::io::{Read, Seek};
26295
26296        use common::{url::Params, ToParts};
26297        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26298
26299        let mut dd = common::DefaultDelegate;
26300        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26301        dlg.begin(common::MethodInfo {
26302            id: "spanner.projects.instances.databases.addSplitPoints",
26303            http_method: hyper::Method::POST,
26304        });
26305
26306        for &field in ["alt", "database"].iter() {
26307            if self._additional_params.contains_key(field) {
26308                dlg.finished(false);
26309                return Err(common::Error::FieldClash(field));
26310            }
26311        }
26312
26313        let mut params = Params::with_capacity(4 + self._additional_params.len());
26314        params.push("database", self._database);
26315
26316        params.extend(self._additional_params.iter());
26317
26318        params.push("alt", "json");
26319        let mut url = self.hub._base_url.clone() + "v1/{+database}:addSplitPoints";
26320        if self._scopes.is_empty() {
26321            self._scopes
26322                .insert(Scope::CloudPlatform.as_ref().to_string());
26323        }
26324
26325        #[allow(clippy::single_element_loop)]
26326        for &(find_this, param_name) in [("{+database}", "database")].iter() {
26327            url = params.uri_replacement(url, param_name, find_this, true);
26328        }
26329        {
26330            let to_remove = ["database"];
26331            params.remove_params(&to_remove);
26332        }
26333
26334        let url = params.parse_with_url(&url);
26335
26336        let mut json_mime_type = mime::APPLICATION_JSON;
26337        let mut request_value_reader = {
26338            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26339            common::remove_json_null_values(&mut value);
26340            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26341            serde_json::to_writer(&mut dst, &value).unwrap();
26342            dst
26343        };
26344        let request_size = request_value_reader
26345            .seek(std::io::SeekFrom::End(0))
26346            .unwrap();
26347        request_value_reader
26348            .seek(std::io::SeekFrom::Start(0))
26349            .unwrap();
26350
26351        loop {
26352            let token = match self
26353                .hub
26354                .auth
26355                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26356                .await
26357            {
26358                Ok(token) => token,
26359                Err(e) => match dlg.token(e) {
26360                    Ok(token) => token,
26361                    Err(e) => {
26362                        dlg.finished(false);
26363                        return Err(common::Error::MissingToken(e));
26364                    }
26365                },
26366            };
26367            request_value_reader
26368                .seek(std::io::SeekFrom::Start(0))
26369                .unwrap();
26370            let mut req_result = {
26371                let client = &self.hub.client;
26372                dlg.pre_request();
26373                let mut req_builder = hyper::Request::builder()
26374                    .method(hyper::Method::POST)
26375                    .uri(url.as_str())
26376                    .header(USER_AGENT, self.hub._user_agent.clone());
26377
26378                if let Some(token) = token.as_ref() {
26379                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26380                }
26381
26382                let request = req_builder
26383                    .header(CONTENT_TYPE, json_mime_type.to_string())
26384                    .header(CONTENT_LENGTH, request_size as u64)
26385                    .body(common::to_body(
26386                        request_value_reader.get_ref().clone().into(),
26387                    ));
26388
26389                client.request(request.unwrap()).await
26390            };
26391
26392            match req_result {
26393                Err(err) => {
26394                    if let common::Retry::After(d) = dlg.http_error(&err) {
26395                        sleep(d).await;
26396                        continue;
26397                    }
26398                    dlg.finished(false);
26399                    return Err(common::Error::HttpError(err));
26400                }
26401                Ok(res) => {
26402                    let (mut parts, body) = res.into_parts();
26403                    let mut body = common::Body::new(body);
26404                    if !parts.status.is_success() {
26405                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26406                        let error = serde_json::from_str(&common::to_string(&bytes));
26407                        let response = common::to_response(parts, bytes.into());
26408
26409                        if let common::Retry::After(d) =
26410                            dlg.http_failure(&response, error.as_ref().ok())
26411                        {
26412                            sleep(d).await;
26413                            continue;
26414                        }
26415
26416                        dlg.finished(false);
26417
26418                        return Err(match error {
26419                            Ok(value) => common::Error::BadRequest(value),
26420                            _ => common::Error::Failure(response),
26421                        });
26422                    }
26423                    let response = {
26424                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26425                        let encoded = common::to_string(&bytes);
26426                        match serde_json::from_str(&encoded) {
26427                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26428                            Err(error) => {
26429                                dlg.response_json_decode_error(&encoded, &error);
26430                                return Err(common::Error::JsonDecodeError(
26431                                    encoded.to_string(),
26432                                    error,
26433                                ));
26434                            }
26435                        }
26436                    };
26437
26438                    dlg.finished(true);
26439                    return Ok(response);
26440                }
26441            }
26442        }
26443    }
26444
26445    ///
26446    /// Sets the *request* property to the given value.
26447    ///
26448    /// Even though the property as already been set when instantiating this call,
26449    /// we provide this method for API completeness.
26450    pub fn request(
26451        mut self,
26452        new_value: AddSplitPointsRequest,
26453    ) -> ProjectInstanceDatabaseAddSplitPointCall<'a, C> {
26454        self._request = new_value;
26455        self
26456    }
26457    /// Required. The database on whose tables or indexes the split points are to be added. Values are of the form `projects//instances//databases/`.
26458    ///
26459    /// Sets the *database* path property to the given value.
26460    ///
26461    /// Even though the property as already been set when instantiating this call,
26462    /// we provide this method for API completeness.
26463    pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseAddSplitPointCall<'a, C> {
26464        self._database = new_value.to_string();
26465        self
26466    }
26467    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26468    /// while executing the actual API request.
26469    ///
26470    /// ````text
26471    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26472    /// ````
26473    ///
26474    /// Sets the *delegate* property to the given value.
26475    pub fn delegate(
26476        mut self,
26477        new_value: &'a mut dyn common::Delegate,
26478    ) -> ProjectInstanceDatabaseAddSplitPointCall<'a, C> {
26479        self._delegate = Some(new_value);
26480        self
26481    }
26482
26483    /// Set any additional parameter of the query string used in the request.
26484    /// It should be used to set parameters which are not yet available through their own
26485    /// setters.
26486    ///
26487    /// Please note that this method must not be used to set any of the known parameters
26488    /// which have their own setter method. If done anyway, the request will fail.
26489    ///
26490    /// # Additional Parameters
26491    ///
26492    /// * *$.xgafv* (query-string) - V1 error format.
26493    /// * *access_token* (query-string) - OAuth access token.
26494    /// * *alt* (query-string) - Data format for response.
26495    /// * *callback* (query-string) - JSONP
26496    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26497    /// * *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.
26498    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26499    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26500    /// * *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.
26501    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26502    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26503    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseAddSplitPointCall<'a, C>
26504    where
26505        T: AsRef<str>,
26506    {
26507        self._additional_params
26508            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26509        self
26510    }
26511
26512    /// Identifies the authorization scope for the method you are building.
26513    ///
26514    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26515    /// [`Scope::CloudPlatform`].
26516    ///
26517    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26518    /// tokens for more than one scope.
26519    ///
26520    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26521    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26522    /// sufficient, a read-write scope will do as well.
26523    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseAddSplitPointCall<'a, C>
26524    where
26525        St: AsRef<str>,
26526    {
26527        self._scopes.insert(String::from(scope.as_ref()));
26528        self
26529    }
26530    /// Identifies the authorization scope(s) for the method you are building.
26531    ///
26532    /// See [`Self::add_scope()`] for details.
26533    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseAddSplitPointCall<'a, C>
26534    where
26535        I: IntoIterator<Item = St>,
26536        St: AsRef<str>,
26537    {
26538        self._scopes
26539            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26540        self
26541    }
26542
26543    /// Removes all scopes, and no default scope will be used either.
26544    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26545    /// for details).
26546    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseAddSplitPointCall<'a, C> {
26547        self._scopes.clear();
26548        self
26549    }
26550}
26551
26552/// `ChangeQuorum` is strictly restricted to databases that use dual-region instance configurations. Initiates a background operation to change the quorum of a database from dual-region mode to single-region mode or vice versa. The returned long-running operation has a name of the format `projects//instances//databases//operations/` and can be used to track execution of the `ChangeQuorum`. The metadata field type is ChangeQuorumMetadata. Authorization requires `spanner.databases.changequorum` permission on the resource database.
26553///
26554/// A builder for the *instances.databases.changequorum* method supported by a *project* resource.
26555/// It is not used directly, but through a [`ProjectMethods`] instance.
26556///
26557/// # Example
26558///
26559/// Instantiate a resource method builder
26560///
26561/// ```test_harness,no_run
26562/// # extern crate hyper;
26563/// # extern crate hyper_rustls;
26564/// # extern crate google_spanner1 as spanner1;
26565/// use spanner1::api::ChangeQuorumRequest;
26566/// # async fn dox() {
26567/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26568///
26569/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26570/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26571/// #     .with_native_roots()
26572/// #     .unwrap()
26573/// #     .https_only()
26574/// #     .enable_http2()
26575/// #     .build();
26576///
26577/// # let executor = hyper_util::rt::TokioExecutor::new();
26578/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26579/// #     secret,
26580/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26581/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26582/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26583/// #     ),
26584/// # ).build().await.unwrap();
26585///
26586/// # let client = hyper_util::client::legacy::Client::builder(
26587/// #     hyper_util::rt::TokioExecutor::new()
26588/// # )
26589/// # .build(
26590/// #     hyper_rustls::HttpsConnectorBuilder::new()
26591/// #         .with_native_roots()
26592/// #         .unwrap()
26593/// #         .https_or_http()
26594/// #         .enable_http2()
26595/// #         .build()
26596/// # );
26597/// # let mut hub = Spanner::new(client, auth);
26598/// // As the method needs a request, you would usually fill it with the desired information
26599/// // into the respective structure. Some of the parts shown here might not be applicable !
26600/// // Values shown here are possibly random and not representative !
26601/// let mut req = ChangeQuorumRequest::default();
26602///
26603/// // You can configure optional parameters by calling the respective setters at will, and
26604/// // execute the final call using `doit()`.
26605/// // Values shown here are possibly random and not representative !
26606/// let result = hub.projects().instances_databases_changequorum(req, "name")
26607///              .doit().await;
26608/// # }
26609/// ```
26610pub struct ProjectInstanceDatabaseChangequorumCall<'a, C>
26611where
26612    C: 'a,
26613{
26614    hub: &'a Spanner<C>,
26615    _request: ChangeQuorumRequest,
26616    _name: String,
26617    _delegate: Option<&'a mut dyn common::Delegate>,
26618    _additional_params: HashMap<String, String>,
26619    _scopes: BTreeSet<String>,
26620}
26621
26622impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseChangequorumCall<'a, C> {}
26623
26624impl<'a, C> ProjectInstanceDatabaseChangequorumCall<'a, C>
26625where
26626    C: common::Connector,
26627{
26628    /// Perform the operation you have build so far.
26629    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
26630        use std::borrow::Cow;
26631        use std::io::{Read, Seek};
26632
26633        use common::{url::Params, ToParts};
26634        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26635
26636        let mut dd = common::DefaultDelegate;
26637        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26638        dlg.begin(common::MethodInfo {
26639            id: "spanner.projects.instances.databases.changequorum",
26640            http_method: hyper::Method::POST,
26641        });
26642
26643        for &field in ["alt", "name"].iter() {
26644            if self._additional_params.contains_key(field) {
26645                dlg.finished(false);
26646                return Err(common::Error::FieldClash(field));
26647            }
26648        }
26649
26650        let mut params = Params::with_capacity(4 + self._additional_params.len());
26651        params.push("name", self._name);
26652
26653        params.extend(self._additional_params.iter());
26654
26655        params.push("alt", "json");
26656        let mut url = self.hub._base_url.clone() + "v1/{+name}:changequorum";
26657        if self._scopes.is_empty() {
26658            self._scopes
26659                .insert(Scope::CloudPlatform.as_ref().to_string());
26660        }
26661
26662        #[allow(clippy::single_element_loop)]
26663        for &(find_this, param_name) in [("{+name}", "name")].iter() {
26664            url = params.uri_replacement(url, param_name, find_this, true);
26665        }
26666        {
26667            let to_remove = ["name"];
26668            params.remove_params(&to_remove);
26669        }
26670
26671        let url = params.parse_with_url(&url);
26672
26673        let mut json_mime_type = mime::APPLICATION_JSON;
26674        let mut request_value_reader = {
26675            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26676            common::remove_json_null_values(&mut value);
26677            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26678            serde_json::to_writer(&mut dst, &value).unwrap();
26679            dst
26680        };
26681        let request_size = request_value_reader
26682            .seek(std::io::SeekFrom::End(0))
26683            .unwrap();
26684        request_value_reader
26685            .seek(std::io::SeekFrom::Start(0))
26686            .unwrap();
26687
26688        loop {
26689            let token = match self
26690                .hub
26691                .auth
26692                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26693                .await
26694            {
26695                Ok(token) => token,
26696                Err(e) => match dlg.token(e) {
26697                    Ok(token) => token,
26698                    Err(e) => {
26699                        dlg.finished(false);
26700                        return Err(common::Error::MissingToken(e));
26701                    }
26702                },
26703            };
26704            request_value_reader
26705                .seek(std::io::SeekFrom::Start(0))
26706                .unwrap();
26707            let mut req_result = {
26708                let client = &self.hub.client;
26709                dlg.pre_request();
26710                let mut req_builder = hyper::Request::builder()
26711                    .method(hyper::Method::POST)
26712                    .uri(url.as_str())
26713                    .header(USER_AGENT, self.hub._user_agent.clone());
26714
26715                if let Some(token) = token.as_ref() {
26716                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26717                }
26718
26719                let request = req_builder
26720                    .header(CONTENT_TYPE, json_mime_type.to_string())
26721                    .header(CONTENT_LENGTH, request_size as u64)
26722                    .body(common::to_body(
26723                        request_value_reader.get_ref().clone().into(),
26724                    ));
26725
26726                client.request(request.unwrap()).await
26727            };
26728
26729            match req_result {
26730                Err(err) => {
26731                    if let common::Retry::After(d) = dlg.http_error(&err) {
26732                        sleep(d).await;
26733                        continue;
26734                    }
26735                    dlg.finished(false);
26736                    return Err(common::Error::HttpError(err));
26737                }
26738                Ok(res) => {
26739                    let (mut parts, body) = res.into_parts();
26740                    let mut body = common::Body::new(body);
26741                    if !parts.status.is_success() {
26742                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26743                        let error = serde_json::from_str(&common::to_string(&bytes));
26744                        let response = common::to_response(parts, bytes.into());
26745
26746                        if let common::Retry::After(d) =
26747                            dlg.http_failure(&response, error.as_ref().ok())
26748                        {
26749                            sleep(d).await;
26750                            continue;
26751                        }
26752
26753                        dlg.finished(false);
26754
26755                        return Err(match error {
26756                            Ok(value) => common::Error::BadRequest(value),
26757                            _ => common::Error::Failure(response),
26758                        });
26759                    }
26760                    let response = {
26761                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26762                        let encoded = common::to_string(&bytes);
26763                        match serde_json::from_str(&encoded) {
26764                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26765                            Err(error) => {
26766                                dlg.response_json_decode_error(&encoded, &error);
26767                                return Err(common::Error::JsonDecodeError(
26768                                    encoded.to_string(),
26769                                    error,
26770                                ));
26771                            }
26772                        }
26773                    };
26774
26775                    dlg.finished(true);
26776                    return Ok(response);
26777                }
26778            }
26779        }
26780    }
26781
26782    ///
26783    /// Sets the *request* property to the given value.
26784    ///
26785    /// Even though the property as already been set when instantiating this call,
26786    /// we provide this method for API completeness.
26787    pub fn request(
26788        mut self,
26789        new_value: ChangeQuorumRequest,
26790    ) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
26791        self._request = new_value;
26792        self
26793    }
26794    /// Required. Name of the database in which to apply `ChangeQuorum`. Values are of the form `projects//instances//databases/`.
26795    ///
26796    /// Sets the *name* path property to the given value.
26797    ///
26798    /// Even though the property as already been set when instantiating this call,
26799    /// we provide this method for API completeness.
26800    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
26801        self._name = new_value.to_string();
26802        self
26803    }
26804    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26805    /// while executing the actual API request.
26806    ///
26807    /// ````text
26808    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26809    /// ````
26810    ///
26811    /// Sets the *delegate* property to the given value.
26812    pub fn delegate(
26813        mut self,
26814        new_value: &'a mut dyn common::Delegate,
26815    ) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
26816        self._delegate = Some(new_value);
26817        self
26818    }
26819
26820    /// Set any additional parameter of the query string used in the request.
26821    /// It should be used to set parameters which are not yet available through their own
26822    /// setters.
26823    ///
26824    /// Please note that this method must not be used to set any of the known parameters
26825    /// which have their own setter method. If done anyway, the request will fail.
26826    ///
26827    /// # Additional Parameters
26828    ///
26829    /// * *$.xgafv* (query-string) - V1 error format.
26830    /// * *access_token* (query-string) - OAuth access token.
26831    /// * *alt* (query-string) - Data format for response.
26832    /// * *callback* (query-string) - JSONP
26833    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26834    /// * *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.
26835    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26836    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26837    /// * *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.
26838    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26839    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26840    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseChangequorumCall<'a, C>
26841    where
26842        T: AsRef<str>,
26843    {
26844        self._additional_params
26845            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26846        self
26847    }
26848
26849    /// Identifies the authorization scope for the method you are building.
26850    ///
26851    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26852    /// [`Scope::CloudPlatform`].
26853    ///
26854    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26855    /// tokens for more than one scope.
26856    ///
26857    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26858    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26859    /// sufficient, a read-write scope will do as well.
26860    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseChangequorumCall<'a, C>
26861    where
26862        St: AsRef<str>,
26863    {
26864        self._scopes.insert(String::from(scope.as_ref()));
26865        self
26866    }
26867    /// Identifies the authorization scope(s) for the method you are building.
26868    ///
26869    /// See [`Self::add_scope()`] for details.
26870    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseChangequorumCall<'a, C>
26871    where
26872        I: IntoIterator<Item = St>,
26873        St: AsRef<str>,
26874    {
26875        self._scopes
26876            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26877        self
26878    }
26879
26880    /// Removes all scopes, and no default scope will be used either.
26881    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26882    /// for details).
26883    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
26884        self._scopes.clear();
26885        self
26886    }
26887}
26888
26889/// Creates a new Spanner database and starts to prepare it for serving. The returned long-running operation will have a name of the format `/operations/` and can be used to track preparation of the database. The metadata field type is CreateDatabaseMetadata. The response field type is Database, if successful.
26890///
26891/// A builder for the *instances.databases.create* method supported by a *project* resource.
26892/// It is not used directly, but through a [`ProjectMethods`] instance.
26893///
26894/// # Example
26895///
26896/// Instantiate a resource method builder
26897///
26898/// ```test_harness,no_run
26899/// # extern crate hyper;
26900/// # extern crate hyper_rustls;
26901/// # extern crate google_spanner1 as spanner1;
26902/// use spanner1::api::CreateDatabaseRequest;
26903/// # async fn dox() {
26904/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26905///
26906/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26907/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26908/// #     .with_native_roots()
26909/// #     .unwrap()
26910/// #     .https_only()
26911/// #     .enable_http2()
26912/// #     .build();
26913///
26914/// # let executor = hyper_util::rt::TokioExecutor::new();
26915/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26916/// #     secret,
26917/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26918/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26919/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26920/// #     ),
26921/// # ).build().await.unwrap();
26922///
26923/// # let client = hyper_util::client::legacy::Client::builder(
26924/// #     hyper_util::rt::TokioExecutor::new()
26925/// # )
26926/// # .build(
26927/// #     hyper_rustls::HttpsConnectorBuilder::new()
26928/// #         .with_native_roots()
26929/// #         .unwrap()
26930/// #         .https_or_http()
26931/// #         .enable_http2()
26932/// #         .build()
26933/// # );
26934/// # let mut hub = Spanner::new(client, auth);
26935/// // As the method needs a request, you would usually fill it with the desired information
26936/// // into the respective structure. Some of the parts shown here might not be applicable !
26937/// // Values shown here are possibly random and not representative !
26938/// let mut req = CreateDatabaseRequest::default();
26939///
26940/// // You can configure optional parameters by calling the respective setters at will, and
26941/// // execute the final call using `doit()`.
26942/// // Values shown here are possibly random and not representative !
26943/// let result = hub.projects().instances_databases_create(req, "parent")
26944///              .doit().await;
26945/// # }
26946/// ```
26947pub struct ProjectInstanceDatabaseCreateCall<'a, C>
26948where
26949    C: 'a,
26950{
26951    hub: &'a Spanner<C>,
26952    _request: CreateDatabaseRequest,
26953    _parent: String,
26954    _delegate: Option<&'a mut dyn common::Delegate>,
26955    _additional_params: HashMap<String, String>,
26956    _scopes: BTreeSet<String>,
26957}
26958
26959impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseCreateCall<'a, C> {}
26960
26961impl<'a, C> ProjectInstanceDatabaseCreateCall<'a, C>
26962where
26963    C: common::Connector,
26964{
26965    /// Perform the operation you have build so far.
26966    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
26967        use std::borrow::Cow;
26968        use std::io::{Read, Seek};
26969
26970        use common::{url::Params, ToParts};
26971        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26972
26973        let mut dd = common::DefaultDelegate;
26974        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26975        dlg.begin(common::MethodInfo {
26976            id: "spanner.projects.instances.databases.create",
26977            http_method: hyper::Method::POST,
26978        });
26979
26980        for &field in ["alt", "parent"].iter() {
26981            if self._additional_params.contains_key(field) {
26982                dlg.finished(false);
26983                return Err(common::Error::FieldClash(field));
26984            }
26985        }
26986
26987        let mut params = Params::with_capacity(4 + self._additional_params.len());
26988        params.push("parent", self._parent);
26989
26990        params.extend(self._additional_params.iter());
26991
26992        params.push("alt", "json");
26993        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases";
26994        if self._scopes.is_empty() {
26995            self._scopes
26996                .insert(Scope::CloudPlatform.as_ref().to_string());
26997        }
26998
26999        #[allow(clippy::single_element_loop)]
27000        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
27001            url = params.uri_replacement(url, param_name, find_this, true);
27002        }
27003        {
27004            let to_remove = ["parent"];
27005            params.remove_params(&to_remove);
27006        }
27007
27008        let url = params.parse_with_url(&url);
27009
27010        let mut json_mime_type = mime::APPLICATION_JSON;
27011        let mut request_value_reader = {
27012            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27013            common::remove_json_null_values(&mut value);
27014            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27015            serde_json::to_writer(&mut dst, &value).unwrap();
27016            dst
27017        };
27018        let request_size = request_value_reader
27019            .seek(std::io::SeekFrom::End(0))
27020            .unwrap();
27021        request_value_reader
27022            .seek(std::io::SeekFrom::Start(0))
27023            .unwrap();
27024
27025        loop {
27026            let token = match self
27027                .hub
27028                .auth
27029                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27030                .await
27031            {
27032                Ok(token) => token,
27033                Err(e) => match dlg.token(e) {
27034                    Ok(token) => token,
27035                    Err(e) => {
27036                        dlg.finished(false);
27037                        return Err(common::Error::MissingToken(e));
27038                    }
27039                },
27040            };
27041            request_value_reader
27042                .seek(std::io::SeekFrom::Start(0))
27043                .unwrap();
27044            let mut req_result = {
27045                let client = &self.hub.client;
27046                dlg.pre_request();
27047                let mut req_builder = hyper::Request::builder()
27048                    .method(hyper::Method::POST)
27049                    .uri(url.as_str())
27050                    .header(USER_AGENT, self.hub._user_agent.clone());
27051
27052                if let Some(token) = token.as_ref() {
27053                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27054                }
27055
27056                let request = req_builder
27057                    .header(CONTENT_TYPE, json_mime_type.to_string())
27058                    .header(CONTENT_LENGTH, request_size as u64)
27059                    .body(common::to_body(
27060                        request_value_reader.get_ref().clone().into(),
27061                    ));
27062
27063                client.request(request.unwrap()).await
27064            };
27065
27066            match req_result {
27067                Err(err) => {
27068                    if let common::Retry::After(d) = dlg.http_error(&err) {
27069                        sleep(d).await;
27070                        continue;
27071                    }
27072                    dlg.finished(false);
27073                    return Err(common::Error::HttpError(err));
27074                }
27075                Ok(res) => {
27076                    let (mut parts, body) = res.into_parts();
27077                    let mut body = common::Body::new(body);
27078                    if !parts.status.is_success() {
27079                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27080                        let error = serde_json::from_str(&common::to_string(&bytes));
27081                        let response = common::to_response(parts, bytes.into());
27082
27083                        if let common::Retry::After(d) =
27084                            dlg.http_failure(&response, error.as_ref().ok())
27085                        {
27086                            sleep(d).await;
27087                            continue;
27088                        }
27089
27090                        dlg.finished(false);
27091
27092                        return Err(match error {
27093                            Ok(value) => common::Error::BadRequest(value),
27094                            _ => common::Error::Failure(response),
27095                        });
27096                    }
27097                    let response = {
27098                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27099                        let encoded = common::to_string(&bytes);
27100                        match serde_json::from_str(&encoded) {
27101                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27102                            Err(error) => {
27103                                dlg.response_json_decode_error(&encoded, &error);
27104                                return Err(common::Error::JsonDecodeError(
27105                                    encoded.to_string(),
27106                                    error,
27107                                ));
27108                            }
27109                        }
27110                    };
27111
27112                    dlg.finished(true);
27113                    return Ok(response);
27114                }
27115            }
27116        }
27117    }
27118
27119    ///
27120    /// Sets the *request* property to the given value.
27121    ///
27122    /// Even though the property as already been set when instantiating this call,
27123    /// we provide this method for API completeness.
27124    pub fn request(
27125        mut self,
27126        new_value: CreateDatabaseRequest,
27127    ) -> ProjectInstanceDatabaseCreateCall<'a, C> {
27128        self._request = new_value;
27129        self
27130    }
27131    /// Required. The name of the instance that will serve the new database. Values are of the form `projects//instances/`.
27132    ///
27133    /// Sets the *parent* path property to the given value.
27134    ///
27135    /// Even though the property as already been set when instantiating this call,
27136    /// we provide this method for API completeness.
27137    pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseCreateCall<'a, C> {
27138        self._parent = new_value.to_string();
27139        self
27140    }
27141    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27142    /// while executing the actual API request.
27143    ///
27144    /// ````text
27145    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27146    /// ````
27147    ///
27148    /// Sets the *delegate* property to the given value.
27149    pub fn delegate(
27150        mut self,
27151        new_value: &'a mut dyn common::Delegate,
27152    ) -> ProjectInstanceDatabaseCreateCall<'a, C> {
27153        self._delegate = Some(new_value);
27154        self
27155    }
27156
27157    /// Set any additional parameter of the query string used in the request.
27158    /// It should be used to set parameters which are not yet available through their own
27159    /// setters.
27160    ///
27161    /// Please note that this method must not be used to set any of the known parameters
27162    /// which have their own setter method. If done anyway, the request will fail.
27163    ///
27164    /// # Additional Parameters
27165    ///
27166    /// * *$.xgafv* (query-string) - V1 error format.
27167    /// * *access_token* (query-string) - OAuth access token.
27168    /// * *alt* (query-string) - Data format for response.
27169    /// * *callback* (query-string) - JSONP
27170    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27171    /// * *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.
27172    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27173    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27174    /// * *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.
27175    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27176    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27177    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseCreateCall<'a, C>
27178    where
27179        T: AsRef<str>,
27180    {
27181        self._additional_params
27182            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27183        self
27184    }
27185
27186    /// Identifies the authorization scope for the method you are building.
27187    ///
27188    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27189    /// [`Scope::CloudPlatform`].
27190    ///
27191    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27192    /// tokens for more than one scope.
27193    ///
27194    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27195    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27196    /// sufficient, a read-write scope will do as well.
27197    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseCreateCall<'a, C>
27198    where
27199        St: AsRef<str>,
27200    {
27201        self._scopes.insert(String::from(scope.as_ref()));
27202        self
27203    }
27204    /// Identifies the authorization scope(s) for the method you are building.
27205    ///
27206    /// See [`Self::add_scope()`] for details.
27207    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseCreateCall<'a, C>
27208    where
27209        I: IntoIterator<Item = St>,
27210        St: AsRef<str>,
27211    {
27212        self._scopes
27213            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27214        self
27215    }
27216
27217    /// Removes all scopes, and no default scope will be used either.
27218    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27219    /// for details).
27220    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseCreateCall<'a, C> {
27221        self._scopes.clear();
27222        self
27223    }
27224}
27225
27226/// Drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be retained according to their `expire_time`. Note: Cloud Spanner might continue to accept requests for a few seconds after the database has been deleted.
27227///
27228/// A builder for the *instances.databases.dropDatabase* method supported by a *project* resource.
27229/// It is not used directly, but through a [`ProjectMethods`] instance.
27230///
27231/// # Example
27232///
27233/// Instantiate a resource method builder
27234///
27235/// ```test_harness,no_run
27236/// # extern crate hyper;
27237/// # extern crate hyper_rustls;
27238/// # extern crate google_spanner1 as spanner1;
27239/// # async fn dox() {
27240/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27241///
27242/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27243/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27244/// #     .with_native_roots()
27245/// #     .unwrap()
27246/// #     .https_only()
27247/// #     .enable_http2()
27248/// #     .build();
27249///
27250/// # let executor = hyper_util::rt::TokioExecutor::new();
27251/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27252/// #     secret,
27253/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27254/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27255/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27256/// #     ),
27257/// # ).build().await.unwrap();
27258///
27259/// # let client = hyper_util::client::legacy::Client::builder(
27260/// #     hyper_util::rt::TokioExecutor::new()
27261/// # )
27262/// # .build(
27263/// #     hyper_rustls::HttpsConnectorBuilder::new()
27264/// #         .with_native_roots()
27265/// #         .unwrap()
27266/// #         .https_or_http()
27267/// #         .enable_http2()
27268/// #         .build()
27269/// # );
27270/// # let mut hub = Spanner::new(client, auth);
27271/// // You can configure optional parameters by calling the respective setters at will, and
27272/// // execute the final call using `doit()`.
27273/// // Values shown here are possibly random and not representative !
27274/// let result = hub.projects().instances_databases_drop_database("database")
27275///              .doit().await;
27276/// # }
27277/// ```
27278pub struct ProjectInstanceDatabaseDropDatabaseCall<'a, C>
27279where
27280    C: 'a,
27281{
27282    hub: &'a Spanner<C>,
27283    _database: String,
27284    _delegate: Option<&'a mut dyn common::Delegate>,
27285    _additional_params: HashMap<String, String>,
27286    _scopes: BTreeSet<String>,
27287}
27288
27289impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseDropDatabaseCall<'a, C> {}
27290
27291impl<'a, C> ProjectInstanceDatabaseDropDatabaseCall<'a, C>
27292where
27293    C: common::Connector,
27294{
27295    /// Perform the operation you have build so far.
27296    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
27297        use std::borrow::Cow;
27298        use std::io::{Read, Seek};
27299
27300        use common::{url::Params, ToParts};
27301        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27302
27303        let mut dd = common::DefaultDelegate;
27304        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27305        dlg.begin(common::MethodInfo {
27306            id: "spanner.projects.instances.databases.dropDatabase",
27307            http_method: hyper::Method::DELETE,
27308        });
27309
27310        for &field in ["alt", "database"].iter() {
27311            if self._additional_params.contains_key(field) {
27312                dlg.finished(false);
27313                return Err(common::Error::FieldClash(field));
27314            }
27315        }
27316
27317        let mut params = Params::with_capacity(3 + self._additional_params.len());
27318        params.push("database", self._database);
27319
27320        params.extend(self._additional_params.iter());
27321
27322        params.push("alt", "json");
27323        let mut url = self.hub._base_url.clone() + "v1/{+database}";
27324        if self._scopes.is_empty() {
27325            self._scopes
27326                .insert(Scope::CloudPlatform.as_ref().to_string());
27327        }
27328
27329        #[allow(clippy::single_element_loop)]
27330        for &(find_this, param_name) in [("{+database}", "database")].iter() {
27331            url = params.uri_replacement(url, param_name, find_this, true);
27332        }
27333        {
27334            let to_remove = ["database"];
27335            params.remove_params(&to_remove);
27336        }
27337
27338        let url = params.parse_with_url(&url);
27339
27340        loop {
27341            let token = match self
27342                .hub
27343                .auth
27344                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27345                .await
27346            {
27347                Ok(token) => token,
27348                Err(e) => match dlg.token(e) {
27349                    Ok(token) => token,
27350                    Err(e) => {
27351                        dlg.finished(false);
27352                        return Err(common::Error::MissingToken(e));
27353                    }
27354                },
27355            };
27356            let mut req_result = {
27357                let client = &self.hub.client;
27358                dlg.pre_request();
27359                let mut req_builder = hyper::Request::builder()
27360                    .method(hyper::Method::DELETE)
27361                    .uri(url.as_str())
27362                    .header(USER_AGENT, self.hub._user_agent.clone());
27363
27364                if let Some(token) = token.as_ref() {
27365                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27366                }
27367
27368                let request = req_builder
27369                    .header(CONTENT_LENGTH, 0_u64)
27370                    .body(common::to_body::<String>(None));
27371
27372                client.request(request.unwrap()).await
27373            };
27374
27375            match req_result {
27376                Err(err) => {
27377                    if let common::Retry::After(d) = dlg.http_error(&err) {
27378                        sleep(d).await;
27379                        continue;
27380                    }
27381                    dlg.finished(false);
27382                    return Err(common::Error::HttpError(err));
27383                }
27384                Ok(res) => {
27385                    let (mut parts, body) = res.into_parts();
27386                    let mut body = common::Body::new(body);
27387                    if !parts.status.is_success() {
27388                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27389                        let error = serde_json::from_str(&common::to_string(&bytes));
27390                        let response = common::to_response(parts, bytes.into());
27391
27392                        if let common::Retry::After(d) =
27393                            dlg.http_failure(&response, error.as_ref().ok())
27394                        {
27395                            sleep(d).await;
27396                            continue;
27397                        }
27398
27399                        dlg.finished(false);
27400
27401                        return Err(match error {
27402                            Ok(value) => common::Error::BadRequest(value),
27403                            _ => common::Error::Failure(response),
27404                        });
27405                    }
27406                    let response = {
27407                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27408                        let encoded = common::to_string(&bytes);
27409                        match serde_json::from_str(&encoded) {
27410                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27411                            Err(error) => {
27412                                dlg.response_json_decode_error(&encoded, &error);
27413                                return Err(common::Error::JsonDecodeError(
27414                                    encoded.to_string(),
27415                                    error,
27416                                ));
27417                            }
27418                        }
27419                    };
27420
27421                    dlg.finished(true);
27422                    return Ok(response);
27423                }
27424            }
27425        }
27426    }
27427
27428    /// Required. The database to be dropped.
27429    ///
27430    /// Sets the *database* path property to the given value.
27431    ///
27432    /// Even though the property as already been set when instantiating this call,
27433    /// we provide this method for API completeness.
27434    pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C> {
27435        self._database = new_value.to_string();
27436        self
27437    }
27438    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27439    /// while executing the actual API request.
27440    ///
27441    /// ````text
27442    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27443    /// ````
27444    ///
27445    /// Sets the *delegate* property to the given value.
27446    pub fn delegate(
27447        mut self,
27448        new_value: &'a mut dyn common::Delegate,
27449    ) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C> {
27450        self._delegate = Some(new_value);
27451        self
27452    }
27453
27454    /// Set any additional parameter of the query string used in the request.
27455    /// It should be used to set parameters which are not yet available through their own
27456    /// setters.
27457    ///
27458    /// Please note that this method must not be used to set any of the known parameters
27459    /// which have their own setter method. If done anyway, the request will fail.
27460    ///
27461    /// # Additional Parameters
27462    ///
27463    /// * *$.xgafv* (query-string) - V1 error format.
27464    /// * *access_token* (query-string) - OAuth access token.
27465    /// * *alt* (query-string) - Data format for response.
27466    /// * *callback* (query-string) - JSONP
27467    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27468    /// * *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.
27469    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27470    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27471    /// * *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.
27472    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27473    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27474    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C>
27475    where
27476        T: AsRef<str>,
27477    {
27478        self._additional_params
27479            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27480        self
27481    }
27482
27483    /// Identifies the authorization scope for the method you are building.
27484    ///
27485    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27486    /// [`Scope::CloudPlatform`].
27487    ///
27488    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27489    /// tokens for more than one scope.
27490    ///
27491    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27492    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27493    /// sufficient, a read-write scope will do as well.
27494    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C>
27495    where
27496        St: AsRef<str>,
27497    {
27498        self._scopes.insert(String::from(scope.as_ref()));
27499        self
27500    }
27501    /// Identifies the authorization scope(s) for the method you are building.
27502    ///
27503    /// See [`Self::add_scope()`] for details.
27504    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C>
27505    where
27506        I: IntoIterator<Item = St>,
27507        St: AsRef<str>,
27508    {
27509        self._scopes
27510            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27511        self
27512    }
27513
27514    /// Removes all scopes, and no default scope will be used either.
27515    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27516    /// for details).
27517    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C> {
27518        self._scopes.clear();
27519        self
27520    }
27521}
27522
27523/// Gets the state of a Cloud Spanner database.
27524///
27525/// A builder for the *instances.databases.get* method supported by a *project* resource.
27526/// It is not used directly, but through a [`ProjectMethods`] instance.
27527///
27528/// # Example
27529///
27530/// Instantiate a resource method builder
27531///
27532/// ```test_harness,no_run
27533/// # extern crate hyper;
27534/// # extern crate hyper_rustls;
27535/// # extern crate google_spanner1 as spanner1;
27536/// # async fn dox() {
27537/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27538///
27539/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27540/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27541/// #     .with_native_roots()
27542/// #     .unwrap()
27543/// #     .https_only()
27544/// #     .enable_http2()
27545/// #     .build();
27546///
27547/// # let executor = hyper_util::rt::TokioExecutor::new();
27548/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27549/// #     secret,
27550/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27551/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27552/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27553/// #     ),
27554/// # ).build().await.unwrap();
27555///
27556/// # let client = hyper_util::client::legacy::Client::builder(
27557/// #     hyper_util::rt::TokioExecutor::new()
27558/// # )
27559/// # .build(
27560/// #     hyper_rustls::HttpsConnectorBuilder::new()
27561/// #         .with_native_roots()
27562/// #         .unwrap()
27563/// #         .https_or_http()
27564/// #         .enable_http2()
27565/// #         .build()
27566/// # );
27567/// # let mut hub = Spanner::new(client, auth);
27568/// // You can configure optional parameters by calling the respective setters at will, and
27569/// // execute the final call using `doit()`.
27570/// // Values shown here are possibly random and not representative !
27571/// let result = hub.projects().instances_databases_get("name")
27572///              .doit().await;
27573/// # }
27574/// ```
27575pub struct ProjectInstanceDatabaseGetCall<'a, C>
27576where
27577    C: 'a,
27578{
27579    hub: &'a Spanner<C>,
27580    _name: String,
27581    _delegate: Option<&'a mut dyn common::Delegate>,
27582    _additional_params: HashMap<String, String>,
27583    _scopes: BTreeSet<String>,
27584}
27585
27586impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseGetCall<'a, C> {}
27587
27588impl<'a, C> ProjectInstanceDatabaseGetCall<'a, C>
27589where
27590    C: common::Connector,
27591{
27592    /// Perform the operation you have build so far.
27593    pub async fn doit(mut self) -> common::Result<(common::Response, Database)> {
27594        use std::borrow::Cow;
27595        use std::io::{Read, Seek};
27596
27597        use common::{url::Params, ToParts};
27598        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27599
27600        let mut dd = common::DefaultDelegate;
27601        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27602        dlg.begin(common::MethodInfo {
27603            id: "spanner.projects.instances.databases.get",
27604            http_method: hyper::Method::GET,
27605        });
27606
27607        for &field in ["alt", "name"].iter() {
27608            if self._additional_params.contains_key(field) {
27609                dlg.finished(false);
27610                return Err(common::Error::FieldClash(field));
27611            }
27612        }
27613
27614        let mut params = Params::with_capacity(3 + self._additional_params.len());
27615        params.push("name", self._name);
27616
27617        params.extend(self._additional_params.iter());
27618
27619        params.push("alt", "json");
27620        let mut url = self.hub._base_url.clone() + "v1/{+name}";
27621        if self._scopes.is_empty() {
27622            self._scopes
27623                .insert(Scope::CloudPlatform.as_ref().to_string());
27624        }
27625
27626        #[allow(clippy::single_element_loop)]
27627        for &(find_this, param_name) in [("{+name}", "name")].iter() {
27628            url = params.uri_replacement(url, param_name, find_this, true);
27629        }
27630        {
27631            let to_remove = ["name"];
27632            params.remove_params(&to_remove);
27633        }
27634
27635        let url = params.parse_with_url(&url);
27636
27637        loop {
27638            let token = match self
27639                .hub
27640                .auth
27641                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27642                .await
27643            {
27644                Ok(token) => token,
27645                Err(e) => match dlg.token(e) {
27646                    Ok(token) => token,
27647                    Err(e) => {
27648                        dlg.finished(false);
27649                        return Err(common::Error::MissingToken(e));
27650                    }
27651                },
27652            };
27653            let mut req_result = {
27654                let client = &self.hub.client;
27655                dlg.pre_request();
27656                let mut req_builder = hyper::Request::builder()
27657                    .method(hyper::Method::GET)
27658                    .uri(url.as_str())
27659                    .header(USER_AGENT, self.hub._user_agent.clone());
27660
27661                if let Some(token) = token.as_ref() {
27662                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27663                }
27664
27665                let request = req_builder
27666                    .header(CONTENT_LENGTH, 0_u64)
27667                    .body(common::to_body::<String>(None));
27668
27669                client.request(request.unwrap()).await
27670            };
27671
27672            match req_result {
27673                Err(err) => {
27674                    if let common::Retry::After(d) = dlg.http_error(&err) {
27675                        sleep(d).await;
27676                        continue;
27677                    }
27678                    dlg.finished(false);
27679                    return Err(common::Error::HttpError(err));
27680                }
27681                Ok(res) => {
27682                    let (mut parts, body) = res.into_parts();
27683                    let mut body = common::Body::new(body);
27684                    if !parts.status.is_success() {
27685                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27686                        let error = serde_json::from_str(&common::to_string(&bytes));
27687                        let response = common::to_response(parts, bytes.into());
27688
27689                        if let common::Retry::After(d) =
27690                            dlg.http_failure(&response, error.as_ref().ok())
27691                        {
27692                            sleep(d).await;
27693                            continue;
27694                        }
27695
27696                        dlg.finished(false);
27697
27698                        return Err(match error {
27699                            Ok(value) => common::Error::BadRequest(value),
27700                            _ => common::Error::Failure(response),
27701                        });
27702                    }
27703                    let response = {
27704                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27705                        let encoded = common::to_string(&bytes);
27706                        match serde_json::from_str(&encoded) {
27707                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27708                            Err(error) => {
27709                                dlg.response_json_decode_error(&encoded, &error);
27710                                return Err(common::Error::JsonDecodeError(
27711                                    encoded.to_string(),
27712                                    error,
27713                                ));
27714                            }
27715                        }
27716                    };
27717
27718                    dlg.finished(true);
27719                    return Ok(response);
27720                }
27721            }
27722        }
27723    }
27724
27725    /// Required. The name of the requested database. Values are of the form `projects//instances//databases/`.
27726    ///
27727    /// Sets the *name* path property to the given value.
27728    ///
27729    /// Even though the property as already been set when instantiating this call,
27730    /// we provide this method for API completeness.
27731    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseGetCall<'a, C> {
27732        self._name = new_value.to_string();
27733        self
27734    }
27735    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27736    /// while executing the actual API request.
27737    ///
27738    /// ````text
27739    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27740    /// ````
27741    ///
27742    /// Sets the *delegate* property to the given value.
27743    pub fn delegate(
27744        mut self,
27745        new_value: &'a mut dyn common::Delegate,
27746    ) -> ProjectInstanceDatabaseGetCall<'a, C> {
27747        self._delegate = Some(new_value);
27748        self
27749    }
27750
27751    /// Set any additional parameter of the query string used in the request.
27752    /// It should be used to set parameters which are not yet available through their own
27753    /// setters.
27754    ///
27755    /// Please note that this method must not be used to set any of the known parameters
27756    /// which have their own setter method. If done anyway, the request will fail.
27757    ///
27758    /// # Additional Parameters
27759    ///
27760    /// * *$.xgafv* (query-string) - V1 error format.
27761    /// * *access_token* (query-string) - OAuth access token.
27762    /// * *alt* (query-string) - Data format for response.
27763    /// * *callback* (query-string) - JSONP
27764    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27765    /// * *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.
27766    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27767    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27768    /// * *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.
27769    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27770    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27771    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseGetCall<'a, C>
27772    where
27773        T: AsRef<str>,
27774    {
27775        self._additional_params
27776            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27777        self
27778    }
27779
27780    /// Identifies the authorization scope for the method you are building.
27781    ///
27782    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27783    /// [`Scope::CloudPlatform`].
27784    ///
27785    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27786    /// tokens for more than one scope.
27787    ///
27788    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27789    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27790    /// sufficient, a read-write scope will do as well.
27791    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseGetCall<'a, C>
27792    where
27793        St: AsRef<str>,
27794    {
27795        self._scopes.insert(String::from(scope.as_ref()));
27796        self
27797    }
27798    /// Identifies the authorization scope(s) for the method you are building.
27799    ///
27800    /// See [`Self::add_scope()`] for details.
27801    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseGetCall<'a, C>
27802    where
27803        I: IntoIterator<Item = St>,
27804        St: AsRef<str>,
27805    {
27806        self._scopes
27807            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27808        self
27809    }
27810
27811    /// Removes all scopes, and no default scope will be used either.
27812    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27813    /// for details).
27814    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseGetCall<'a, C> {
27815        self._scopes.clear();
27816        self
27817    }
27818}
27819
27820/// Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.
27821///
27822/// A builder for the *instances.databases.getDdl* method supported by a *project* resource.
27823/// It is not used directly, but through a [`ProjectMethods`] instance.
27824///
27825/// # Example
27826///
27827/// Instantiate a resource method builder
27828///
27829/// ```test_harness,no_run
27830/// # extern crate hyper;
27831/// # extern crate hyper_rustls;
27832/// # extern crate google_spanner1 as spanner1;
27833/// # async fn dox() {
27834/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27835///
27836/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27837/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27838/// #     .with_native_roots()
27839/// #     .unwrap()
27840/// #     .https_only()
27841/// #     .enable_http2()
27842/// #     .build();
27843///
27844/// # let executor = hyper_util::rt::TokioExecutor::new();
27845/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27846/// #     secret,
27847/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27848/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27849/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27850/// #     ),
27851/// # ).build().await.unwrap();
27852///
27853/// # let client = hyper_util::client::legacy::Client::builder(
27854/// #     hyper_util::rt::TokioExecutor::new()
27855/// # )
27856/// # .build(
27857/// #     hyper_rustls::HttpsConnectorBuilder::new()
27858/// #         .with_native_roots()
27859/// #         .unwrap()
27860/// #         .https_or_http()
27861/// #         .enable_http2()
27862/// #         .build()
27863/// # );
27864/// # let mut hub = Spanner::new(client, auth);
27865/// // You can configure optional parameters by calling the respective setters at will, and
27866/// // execute the final call using `doit()`.
27867/// // Values shown here are possibly random and not representative !
27868/// let result = hub.projects().instances_databases_get_ddl("database")
27869///              .doit().await;
27870/// # }
27871/// ```
27872pub struct ProjectInstanceDatabaseGetDdlCall<'a, C>
27873where
27874    C: 'a,
27875{
27876    hub: &'a Spanner<C>,
27877    _database: String,
27878    _delegate: Option<&'a mut dyn common::Delegate>,
27879    _additional_params: HashMap<String, String>,
27880    _scopes: BTreeSet<String>,
27881}
27882
27883impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseGetDdlCall<'a, C> {}
27884
27885impl<'a, C> ProjectInstanceDatabaseGetDdlCall<'a, C>
27886where
27887    C: common::Connector,
27888{
27889    /// Perform the operation you have build so far.
27890    pub async fn doit(mut self) -> common::Result<(common::Response, GetDatabaseDdlResponse)> {
27891        use std::borrow::Cow;
27892        use std::io::{Read, Seek};
27893
27894        use common::{url::Params, ToParts};
27895        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27896
27897        let mut dd = common::DefaultDelegate;
27898        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27899        dlg.begin(common::MethodInfo {
27900            id: "spanner.projects.instances.databases.getDdl",
27901            http_method: hyper::Method::GET,
27902        });
27903
27904        for &field in ["alt", "database"].iter() {
27905            if self._additional_params.contains_key(field) {
27906                dlg.finished(false);
27907                return Err(common::Error::FieldClash(field));
27908            }
27909        }
27910
27911        let mut params = Params::with_capacity(3 + self._additional_params.len());
27912        params.push("database", self._database);
27913
27914        params.extend(self._additional_params.iter());
27915
27916        params.push("alt", "json");
27917        let mut url = self.hub._base_url.clone() + "v1/{+database}/ddl";
27918        if self._scopes.is_empty() {
27919            self._scopes
27920                .insert(Scope::CloudPlatform.as_ref().to_string());
27921        }
27922
27923        #[allow(clippy::single_element_loop)]
27924        for &(find_this, param_name) in [("{+database}", "database")].iter() {
27925            url = params.uri_replacement(url, param_name, find_this, true);
27926        }
27927        {
27928            let to_remove = ["database"];
27929            params.remove_params(&to_remove);
27930        }
27931
27932        let url = params.parse_with_url(&url);
27933
27934        loop {
27935            let token = match self
27936                .hub
27937                .auth
27938                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27939                .await
27940            {
27941                Ok(token) => token,
27942                Err(e) => match dlg.token(e) {
27943                    Ok(token) => token,
27944                    Err(e) => {
27945                        dlg.finished(false);
27946                        return Err(common::Error::MissingToken(e));
27947                    }
27948                },
27949            };
27950            let mut req_result = {
27951                let client = &self.hub.client;
27952                dlg.pre_request();
27953                let mut req_builder = hyper::Request::builder()
27954                    .method(hyper::Method::GET)
27955                    .uri(url.as_str())
27956                    .header(USER_AGENT, self.hub._user_agent.clone());
27957
27958                if let Some(token) = token.as_ref() {
27959                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27960                }
27961
27962                let request = req_builder
27963                    .header(CONTENT_LENGTH, 0_u64)
27964                    .body(common::to_body::<String>(None));
27965
27966                client.request(request.unwrap()).await
27967            };
27968
27969            match req_result {
27970                Err(err) => {
27971                    if let common::Retry::After(d) = dlg.http_error(&err) {
27972                        sleep(d).await;
27973                        continue;
27974                    }
27975                    dlg.finished(false);
27976                    return Err(common::Error::HttpError(err));
27977                }
27978                Ok(res) => {
27979                    let (mut parts, body) = res.into_parts();
27980                    let mut body = common::Body::new(body);
27981                    if !parts.status.is_success() {
27982                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27983                        let error = serde_json::from_str(&common::to_string(&bytes));
27984                        let response = common::to_response(parts, bytes.into());
27985
27986                        if let common::Retry::After(d) =
27987                            dlg.http_failure(&response, error.as_ref().ok())
27988                        {
27989                            sleep(d).await;
27990                            continue;
27991                        }
27992
27993                        dlg.finished(false);
27994
27995                        return Err(match error {
27996                            Ok(value) => common::Error::BadRequest(value),
27997                            _ => common::Error::Failure(response),
27998                        });
27999                    }
28000                    let response = {
28001                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28002                        let encoded = common::to_string(&bytes);
28003                        match serde_json::from_str(&encoded) {
28004                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28005                            Err(error) => {
28006                                dlg.response_json_decode_error(&encoded, &error);
28007                                return Err(common::Error::JsonDecodeError(
28008                                    encoded.to_string(),
28009                                    error,
28010                                ));
28011                            }
28012                        }
28013                    };
28014
28015                    dlg.finished(true);
28016                    return Ok(response);
28017                }
28018            }
28019        }
28020    }
28021
28022    /// Required. The database whose schema we wish to get. Values are of the form `projects//instances//databases/`
28023    ///
28024    /// Sets the *database* path property to the given value.
28025    ///
28026    /// Even though the property as already been set when instantiating this call,
28027    /// we provide this method for API completeness.
28028    pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseGetDdlCall<'a, C> {
28029        self._database = new_value.to_string();
28030        self
28031    }
28032    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28033    /// while executing the actual API request.
28034    ///
28035    /// ````text
28036    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28037    /// ````
28038    ///
28039    /// Sets the *delegate* property to the given value.
28040    pub fn delegate(
28041        mut self,
28042        new_value: &'a mut dyn common::Delegate,
28043    ) -> ProjectInstanceDatabaseGetDdlCall<'a, C> {
28044        self._delegate = Some(new_value);
28045        self
28046    }
28047
28048    /// Set any additional parameter of the query string used in the request.
28049    /// It should be used to set parameters which are not yet available through their own
28050    /// setters.
28051    ///
28052    /// Please note that this method must not be used to set any of the known parameters
28053    /// which have their own setter method. If done anyway, the request will fail.
28054    ///
28055    /// # Additional Parameters
28056    ///
28057    /// * *$.xgafv* (query-string) - V1 error format.
28058    /// * *access_token* (query-string) - OAuth access token.
28059    /// * *alt* (query-string) - Data format for response.
28060    /// * *callback* (query-string) - JSONP
28061    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28062    /// * *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.
28063    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28064    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28065    /// * *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.
28066    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28067    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28068    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseGetDdlCall<'a, C>
28069    where
28070        T: AsRef<str>,
28071    {
28072        self._additional_params
28073            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28074        self
28075    }
28076
28077    /// Identifies the authorization scope for the method you are building.
28078    ///
28079    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28080    /// [`Scope::CloudPlatform`].
28081    ///
28082    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28083    /// tokens for more than one scope.
28084    ///
28085    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28086    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28087    /// sufficient, a read-write scope will do as well.
28088    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseGetDdlCall<'a, C>
28089    where
28090        St: AsRef<str>,
28091    {
28092        self._scopes.insert(String::from(scope.as_ref()));
28093        self
28094    }
28095    /// Identifies the authorization scope(s) for the method you are building.
28096    ///
28097    /// See [`Self::add_scope()`] for details.
28098    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseGetDdlCall<'a, C>
28099    where
28100        I: IntoIterator<Item = St>,
28101        St: AsRef<str>,
28102    {
28103        self._scopes
28104            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28105        self
28106    }
28107
28108    /// Removes all scopes, and no default scope will be used either.
28109    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28110    /// for details).
28111    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseGetDdlCall<'a, C> {
28112        self._scopes.clear();
28113        self
28114    }
28115}
28116
28117/// Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set. Authorization requires `spanner.databases.getIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.getIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.getIamPolicy` permission on resource.
28118///
28119/// A builder for the *instances.databases.getIamPolicy* method supported by a *project* resource.
28120/// It is not used directly, but through a [`ProjectMethods`] instance.
28121///
28122/// # Example
28123///
28124/// Instantiate a resource method builder
28125///
28126/// ```test_harness,no_run
28127/// # extern crate hyper;
28128/// # extern crate hyper_rustls;
28129/// # extern crate google_spanner1 as spanner1;
28130/// use spanner1::api::GetIamPolicyRequest;
28131/// # async fn dox() {
28132/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28133///
28134/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28135/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28136/// #     .with_native_roots()
28137/// #     .unwrap()
28138/// #     .https_only()
28139/// #     .enable_http2()
28140/// #     .build();
28141///
28142/// # let executor = hyper_util::rt::TokioExecutor::new();
28143/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28144/// #     secret,
28145/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28146/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28147/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28148/// #     ),
28149/// # ).build().await.unwrap();
28150///
28151/// # let client = hyper_util::client::legacy::Client::builder(
28152/// #     hyper_util::rt::TokioExecutor::new()
28153/// # )
28154/// # .build(
28155/// #     hyper_rustls::HttpsConnectorBuilder::new()
28156/// #         .with_native_roots()
28157/// #         .unwrap()
28158/// #         .https_or_http()
28159/// #         .enable_http2()
28160/// #         .build()
28161/// # );
28162/// # let mut hub = Spanner::new(client, auth);
28163/// // As the method needs a request, you would usually fill it with the desired information
28164/// // into the respective structure. Some of the parts shown here might not be applicable !
28165/// // Values shown here are possibly random and not representative !
28166/// let mut req = GetIamPolicyRequest::default();
28167///
28168/// // You can configure optional parameters by calling the respective setters at will, and
28169/// // execute the final call using `doit()`.
28170/// // Values shown here are possibly random and not representative !
28171/// let result = hub.projects().instances_databases_get_iam_policy(req, "resource")
28172///              .doit().await;
28173/// # }
28174/// ```
28175pub struct ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
28176where
28177    C: 'a,
28178{
28179    hub: &'a Spanner<C>,
28180    _request: GetIamPolicyRequest,
28181    _resource: String,
28182    _delegate: Option<&'a mut dyn common::Delegate>,
28183    _additional_params: HashMap<String, String>,
28184    _scopes: BTreeSet<String>,
28185}
28186
28187impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {}
28188
28189impl<'a, C> ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
28190where
28191    C: common::Connector,
28192{
28193    /// Perform the operation you have build so far.
28194    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
28195        use std::borrow::Cow;
28196        use std::io::{Read, Seek};
28197
28198        use common::{url::Params, ToParts};
28199        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28200
28201        let mut dd = common::DefaultDelegate;
28202        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28203        dlg.begin(common::MethodInfo {
28204            id: "spanner.projects.instances.databases.getIamPolicy",
28205            http_method: hyper::Method::POST,
28206        });
28207
28208        for &field in ["alt", "resource"].iter() {
28209            if self._additional_params.contains_key(field) {
28210                dlg.finished(false);
28211                return Err(common::Error::FieldClash(field));
28212            }
28213        }
28214
28215        let mut params = Params::with_capacity(4 + self._additional_params.len());
28216        params.push("resource", self._resource);
28217
28218        params.extend(self._additional_params.iter());
28219
28220        params.push("alt", "json");
28221        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
28222        if self._scopes.is_empty() {
28223            self._scopes
28224                .insert(Scope::CloudPlatform.as_ref().to_string());
28225        }
28226
28227        #[allow(clippy::single_element_loop)]
28228        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
28229            url = params.uri_replacement(url, param_name, find_this, true);
28230        }
28231        {
28232            let to_remove = ["resource"];
28233            params.remove_params(&to_remove);
28234        }
28235
28236        let url = params.parse_with_url(&url);
28237
28238        let mut json_mime_type = mime::APPLICATION_JSON;
28239        let mut request_value_reader = {
28240            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28241            common::remove_json_null_values(&mut value);
28242            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28243            serde_json::to_writer(&mut dst, &value).unwrap();
28244            dst
28245        };
28246        let request_size = request_value_reader
28247            .seek(std::io::SeekFrom::End(0))
28248            .unwrap();
28249        request_value_reader
28250            .seek(std::io::SeekFrom::Start(0))
28251            .unwrap();
28252
28253        loop {
28254            let token = match self
28255                .hub
28256                .auth
28257                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28258                .await
28259            {
28260                Ok(token) => token,
28261                Err(e) => match dlg.token(e) {
28262                    Ok(token) => token,
28263                    Err(e) => {
28264                        dlg.finished(false);
28265                        return Err(common::Error::MissingToken(e));
28266                    }
28267                },
28268            };
28269            request_value_reader
28270                .seek(std::io::SeekFrom::Start(0))
28271                .unwrap();
28272            let mut req_result = {
28273                let client = &self.hub.client;
28274                dlg.pre_request();
28275                let mut req_builder = hyper::Request::builder()
28276                    .method(hyper::Method::POST)
28277                    .uri(url.as_str())
28278                    .header(USER_AGENT, self.hub._user_agent.clone());
28279
28280                if let Some(token) = token.as_ref() {
28281                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28282                }
28283
28284                let request = req_builder
28285                    .header(CONTENT_TYPE, json_mime_type.to_string())
28286                    .header(CONTENT_LENGTH, request_size as u64)
28287                    .body(common::to_body(
28288                        request_value_reader.get_ref().clone().into(),
28289                    ));
28290
28291                client.request(request.unwrap()).await
28292            };
28293
28294            match req_result {
28295                Err(err) => {
28296                    if let common::Retry::After(d) = dlg.http_error(&err) {
28297                        sleep(d).await;
28298                        continue;
28299                    }
28300                    dlg.finished(false);
28301                    return Err(common::Error::HttpError(err));
28302                }
28303                Ok(res) => {
28304                    let (mut parts, body) = res.into_parts();
28305                    let mut body = common::Body::new(body);
28306                    if !parts.status.is_success() {
28307                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28308                        let error = serde_json::from_str(&common::to_string(&bytes));
28309                        let response = common::to_response(parts, bytes.into());
28310
28311                        if let common::Retry::After(d) =
28312                            dlg.http_failure(&response, error.as_ref().ok())
28313                        {
28314                            sleep(d).await;
28315                            continue;
28316                        }
28317
28318                        dlg.finished(false);
28319
28320                        return Err(match error {
28321                            Ok(value) => common::Error::BadRequest(value),
28322                            _ => common::Error::Failure(response),
28323                        });
28324                    }
28325                    let response = {
28326                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28327                        let encoded = common::to_string(&bytes);
28328                        match serde_json::from_str(&encoded) {
28329                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28330                            Err(error) => {
28331                                dlg.response_json_decode_error(&encoded, &error);
28332                                return Err(common::Error::JsonDecodeError(
28333                                    encoded.to_string(),
28334                                    error,
28335                                ));
28336                            }
28337                        }
28338                    };
28339
28340                    dlg.finished(true);
28341                    return Ok(response);
28342                }
28343            }
28344        }
28345    }
28346
28347    ///
28348    /// Sets the *request* property to the given value.
28349    ///
28350    /// Even though the property as already been set when instantiating this call,
28351    /// we provide this method for API completeness.
28352    pub fn request(
28353        mut self,
28354        new_value: GetIamPolicyRequest,
28355    ) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
28356        self._request = new_value;
28357        self
28358    }
28359    /// REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
28360    ///
28361    /// Sets the *resource* path property to the given value.
28362    ///
28363    /// Even though the property as already been set when instantiating this call,
28364    /// we provide this method for API completeness.
28365    pub fn resource(mut self, new_value: &str) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
28366        self._resource = new_value.to_string();
28367        self
28368    }
28369    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28370    /// while executing the actual API request.
28371    ///
28372    /// ````text
28373    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28374    /// ````
28375    ///
28376    /// Sets the *delegate* property to the given value.
28377    pub fn delegate(
28378        mut self,
28379        new_value: &'a mut dyn common::Delegate,
28380    ) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
28381        self._delegate = Some(new_value);
28382        self
28383    }
28384
28385    /// Set any additional parameter of the query string used in the request.
28386    /// It should be used to set parameters which are not yet available through their own
28387    /// setters.
28388    ///
28389    /// Please note that this method must not be used to set any of the known parameters
28390    /// which have their own setter method. If done anyway, the request will fail.
28391    ///
28392    /// # Additional Parameters
28393    ///
28394    /// * *$.xgafv* (query-string) - V1 error format.
28395    /// * *access_token* (query-string) - OAuth access token.
28396    /// * *alt* (query-string) - Data format for response.
28397    /// * *callback* (query-string) - JSONP
28398    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28399    /// * *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.
28400    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28401    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28402    /// * *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.
28403    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28404    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28405    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
28406    where
28407        T: AsRef<str>,
28408    {
28409        self._additional_params
28410            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28411        self
28412    }
28413
28414    /// Identifies the authorization scope for the method you are building.
28415    ///
28416    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28417    /// [`Scope::CloudPlatform`].
28418    ///
28419    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28420    /// tokens for more than one scope.
28421    ///
28422    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28423    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28424    /// sufficient, a read-write scope will do as well.
28425    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
28426    where
28427        St: AsRef<str>,
28428    {
28429        self._scopes.insert(String::from(scope.as_ref()));
28430        self
28431    }
28432    /// Identifies the authorization scope(s) for the method you are building.
28433    ///
28434    /// See [`Self::add_scope()`] for details.
28435    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
28436    where
28437        I: IntoIterator<Item = St>,
28438        St: AsRef<str>,
28439    {
28440        self._scopes
28441            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28442        self
28443    }
28444
28445    /// Removes all scopes, and no default scope will be used either.
28446    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28447    /// for details).
28448    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
28449        self._scopes.clear();
28450        self
28451    }
28452}
28453
28454/// Request a specific scan with Database-specific data for Cloud Key Visualizer.
28455///
28456/// A builder for the *instances.databases.getScans* method supported by a *project* resource.
28457/// It is not used directly, but through a [`ProjectMethods`] instance.
28458///
28459/// # Example
28460///
28461/// Instantiate a resource method builder
28462///
28463/// ```test_harness,no_run
28464/// # extern crate hyper;
28465/// # extern crate hyper_rustls;
28466/// # extern crate google_spanner1 as spanner1;
28467/// # async fn dox() {
28468/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28469///
28470/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28471/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28472/// #     .with_native_roots()
28473/// #     .unwrap()
28474/// #     .https_only()
28475/// #     .enable_http2()
28476/// #     .build();
28477///
28478/// # let executor = hyper_util::rt::TokioExecutor::new();
28479/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28480/// #     secret,
28481/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28482/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28483/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28484/// #     ),
28485/// # ).build().await.unwrap();
28486///
28487/// # let client = hyper_util::client::legacy::Client::builder(
28488/// #     hyper_util::rt::TokioExecutor::new()
28489/// # )
28490/// # .build(
28491/// #     hyper_rustls::HttpsConnectorBuilder::new()
28492/// #         .with_native_roots()
28493/// #         .unwrap()
28494/// #         .https_or_http()
28495/// #         .enable_http2()
28496/// #         .build()
28497/// # );
28498/// # let mut hub = Spanner::new(client, auth);
28499/// // You can configure optional parameters by calling the respective setters at will, and
28500/// // execute the final call using `doit()`.
28501/// // Values shown here are possibly random and not representative !
28502/// let result = hub.projects().instances_databases_get_scans("name")
28503///              .view("consetetur")
28504///              .start_time(chrono::Utc::now())
28505///              .end_time(chrono::Utc::now())
28506///              .doit().await;
28507/// # }
28508/// ```
28509pub struct ProjectInstanceDatabaseGetScanCall<'a, C>
28510where
28511    C: 'a,
28512{
28513    hub: &'a Spanner<C>,
28514    _name: String,
28515    _view: Option<String>,
28516    _start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
28517    _end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
28518    _delegate: Option<&'a mut dyn common::Delegate>,
28519    _additional_params: HashMap<String, String>,
28520    _scopes: BTreeSet<String>,
28521}
28522
28523impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseGetScanCall<'a, C> {}
28524
28525impl<'a, C> ProjectInstanceDatabaseGetScanCall<'a, C>
28526where
28527    C: common::Connector,
28528{
28529    /// Perform the operation you have build so far.
28530    pub async fn doit(mut self) -> common::Result<(common::Response, Scan)> {
28531        use std::borrow::Cow;
28532        use std::io::{Read, Seek};
28533
28534        use common::{url::Params, ToParts};
28535        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28536
28537        let mut dd = common::DefaultDelegate;
28538        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28539        dlg.begin(common::MethodInfo {
28540            id: "spanner.projects.instances.databases.getScans",
28541            http_method: hyper::Method::GET,
28542        });
28543
28544        for &field in ["alt", "name", "view", "startTime", "endTime"].iter() {
28545            if self._additional_params.contains_key(field) {
28546                dlg.finished(false);
28547                return Err(common::Error::FieldClash(field));
28548            }
28549        }
28550
28551        let mut params = Params::with_capacity(6 + self._additional_params.len());
28552        params.push("name", self._name);
28553        if let Some(value) = self._view.as_ref() {
28554            params.push("view", value);
28555        }
28556        if let Some(value) = self._start_time.as_ref() {
28557            params.push("startTime", common::serde::datetime_to_string(&value));
28558        }
28559        if let Some(value) = self._end_time.as_ref() {
28560            params.push("endTime", common::serde::datetime_to_string(&value));
28561        }
28562
28563        params.extend(self._additional_params.iter());
28564
28565        params.push("alt", "json");
28566        let mut url = self.hub._base_url.clone() + "v1/{+name}/scans";
28567        if self._scopes.is_empty() {
28568            self._scopes
28569                .insert(Scope::CloudPlatform.as_ref().to_string());
28570        }
28571
28572        #[allow(clippy::single_element_loop)]
28573        for &(find_this, param_name) in [("{+name}", "name")].iter() {
28574            url = params.uri_replacement(url, param_name, find_this, true);
28575        }
28576        {
28577            let to_remove = ["name"];
28578            params.remove_params(&to_remove);
28579        }
28580
28581        let url = params.parse_with_url(&url);
28582
28583        loop {
28584            let token = match self
28585                .hub
28586                .auth
28587                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28588                .await
28589            {
28590                Ok(token) => token,
28591                Err(e) => match dlg.token(e) {
28592                    Ok(token) => token,
28593                    Err(e) => {
28594                        dlg.finished(false);
28595                        return Err(common::Error::MissingToken(e));
28596                    }
28597                },
28598            };
28599            let mut req_result = {
28600                let client = &self.hub.client;
28601                dlg.pre_request();
28602                let mut req_builder = hyper::Request::builder()
28603                    .method(hyper::Method::GET)
28604                    .uri(url.as_str())
28605                    .header(USER_AGENT, self.hub._user_agent.clone());
28606
28607                if let Some(token) = token.as_ref() {
28608                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28609                }
28610
28611                let request = req_builder
28612                    .header(CONTENT_LENGTH, 0_u64)
28613                    .body(common::to_body::<String>(None));
28614
28615                client.request(request.unwrap()).await
28616            };
28617
28618            match req_result {
28619                Err(err) => {
28620                    if let common::Retry::After(d) = dlg.http_error(&err) {
28621                        sleep(d).await;
28622                        continue;
28623                    }
28624                    dlg.finished(false);
28625                    return Err(common::Error::HttpError(err));
28626                }
28627                Ok(res) => {
28628                    let (mut parts, body) = res.into_parts();
28629                    let mut body = common::Body::new(body);
28630                    if !parts.status.is_success() {
28631                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28632                        let error = serde_json::from_str(&common::to_string(&bytes));
28633                        let response = common::to_response(parts, bytes.into());
28634
28635                        if let common::Retry::After(d) =
28636                            dlg.http_failure(&response, error.as_ref().ok())
28637                        {
28638                            sleep(d).await;
28639                            continue;
28640                        }
28641
28642                        dlg.finished(false);
28643
28644                        return Err(match error {
28645                            Ok(value) => common::Error::BadRequest(value),
28646                            _ => common::Error::Failure(response),
28647                        });
28648                    }
28649                    let response = {
28650                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28651                        let encoded = common::to_string(&bytes);
28652                        match serde_json::from_str(&encoded) {
28653                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28654                            Err(error) => {
28655                                dlg.response_json_decode_error(&encoded, &error);
28656                                return Err(common::Error::JsonDecodeError(
28657                                    encoded.to_string(),
28658                                    error,
28659                                ));
28660                            }
28661                        }
28662                    };
28663
28664                    dlg.finished(true);
28665                    return Ok(response);
28666                }
28667            }
28668        }
28669    }
28670
28671    /// Required. The unique name of the scan containing the requested information, specific to the Database service implementing this interface.
28672    ///
28673    /// Sets the *name* path property to the given value.
28674    ///
28675    /// Even though the property as already been set when instantiating this call,
28676    /// we provide this method for API completeness.
28677    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
28678        self._name = new_value.to_string();
28679        self
28680    }
28681    /// Specifies which parts of the Scan should be returned in the response. Note, if left unspecified, the FULL view is assumed.
28682    ///
28683    /// Sets the *view* query property to the given value.
28684    pub fn view(mut self, new_value: &str) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
28685        self._view = Some(new_value.to_string());
28686        self
28687    }
28688    /// These fields restrict the Database-specific information returned in the `Scan.data` field. If a `View` is provided that does not include the `Scan.data` field, these are ignored. This range of time must be entirely contained within the defined time range of the targeted scan. The lower bound for the time range to retrieve Scan data for.
28689    ///
28690    /// Sets the *start time* query property to the given value.
28691    pub fn start_time(
28692        mut self,
28693        new_value: chrono::DateTime<chrono::offset::Utc>,
28694    ) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
28695        self._start_time = Some(new_value);
28696        self
28697    }
28698    /// The upper bound for the time range to retrieve Scan data for.
28699    ///
28700    /// Sets the *end time* query property to the given value.
28701    pub fn end_time(
28702        mut self,
28703        new_value: chrono::DateTime<chrono::offset::Utc>,
28704    ) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
28705        self._end_time = Some(new_value);
28706        self
28707    }
28708    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28709    /// while executing the actual API request.
28710    ///
28711    /// ````text
28712    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28713    /// ````
28714    ///
28715    /// Sets the *delegate* property to the given value.
28716    pub fn delegate(
28717        mut self,
28718        new_value: &'a mut dyn common::Delegate,
28719    ) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
28720        self._delegate = Some(new_value);
28721        self
28722    }
28723
28724    /// Set any additional parameter of the query string used in the request.
28725    /// It should be used to set parameters which are not yet available through their own
28726    /// setters.
28727    ///
28728    /// Please note that this method must not be used to set any of the known parameters
28729    /// which have their own setter method. If done anyway, the request will fail.
28730    ///
28731    /// # Additional Parameters
28732    ///
28733    /// * *$.xgafv* (query-string) - V1 error format.
28734    /// * *access_token* (query-string) - OAuth access token.
28735    /// * *alt* (query-string) - Data format for response.
28736    /// * *callback* (query-string) - JSONP
28737    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28738    /// * *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.
28739    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28740    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28741    /// * *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.
28742    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28743    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28744    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseGetScanCall<'a, C>
28745    where
28746        T: AsRef<str>,
28747    {
28748        self._additional_params
28749            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28750        self
28751    }
28752
28753    /// Identifies the authorization scope for the method you are building.
28754    ///
28755    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28756    /// [`Scope::CloudPlatform`].
28757    ///
28758    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28759    /// tokens for more than one scope.
28760    ///
28761    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28762    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28763    /// sufficient, a read-write scope will do as well.
28764    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseGetScanCall<'a, C>
28765    where
28766        St: AsRef<str>,
28767    {
28768        self._scopes.insert(String::from(scope.as_ref()));
28769        self
28770    }
28771    /// Identifies the authorization scope(s) for the method you are building.
28772    ///
28773    /// See [`Self::add_scope()`] for details.
28774    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseGetScanCall<'a, C>
28775    where
28776        I: IntoIterator<Item = St>,
28777        St: AsRef<str>,
28778    {
28779        self._scopes
28780            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28781        self
28782    }
28783
28784    /// Removes all scopes, and no default scope will be used either.
28785    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28786    /// for details).
28787    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
28788        self._scopes.clear();
28789        self
28790    }
28791}
28792
28793/// Lists Cloud Spanner databases.
28794///
28795/// A builder for the *instances.databases.list* method supported by a *project* resource.
28796/// It is not used directly, but through a [`ProjectMethods`] instance.
28797///
28798/// # Example
28799///
28800/// Instantiate a resource method builder
28801///
28802/// ```test_harness,no_run
28803/// # extern crate hyper;
28804/// # extern crate hyper_rustls;
28805/// # extern crate google_spanner1 as spanner1;
28806/// # async fn dox() {
28807/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28808///
28809/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28810/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28811/// #     .with_native_roots()
28812/// #     .unwrap()
28813/// #     .https_only()
28814/// #     .enable_http2()
28815/// #     .build();
28816///
28817/// # let executor = hyper_util::rt::TokioExecutor::new();
28818/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28819/// #     secret,
28820/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28821/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28822/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28823/// #     ),
28824/// # ).build().await.unwrap();
28825///
28826/// # let client = hyper_util::client::legacy::Client::builder(
28827/// #     hyper_util::rt::TokioExecutor::new()
28828/// # )
28829/// # .build(
28830/// #     hyper_rustls::HttpsConnectorBuilder::new()
28831/// #         .with_native_roots()
28832/// #         .unwrap()
28833/// #         .https_or_http()
28834/// #         .enable_http2()
28835/// #         .build()
28836/// # );
28837/// # let mut hub = Spanner::new(client, auth);
28838/// // You can configure optional parameters by calling the respective setters at will, and
28839/// // execute the final call using `doit()`.
28840/// // Values shown here are possibly random and not representative !
28841/// let result = hub.projects().instances_databases_list("parent")
28842///              .page_token("Stet")
28843///              .page_size(-7)
28844///              .doit().await;
28845/// # }
28846/// ```
28847pub struct ProjectInstanceDatabaseListCall<'a, C>
28848where
28849    C: 'a,
28850{
28851    hub: &'a Spanner<C>,
28852    _parent: String,
28853    _page_token: Option<String>,
28854    _page_size: Option<i32>,
28855    _delegate: Option<&'a mut dyn common::Delegate>,
28856    _additional_params: HashMap<String, String>,
28857    _scopes: BTreeSet<String>,
28858}
28859
28860impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseListCall<'a, C> {}
28861
28862impl<'a, C> ProjectInstanceDatabaseListCall<'a, C>
28863where
28864    C: common::Connector,
28865{
28866    /// Perform the operation you have build so far.
28867    pub async fn doit(mut self) -> common::Result<(common::Response, ListDatabasesResponse)> {
28868        use std::borrow::Cow;
28869        use std::io::{Read, Seek};
28870
28871        use common::{url::Params, ToParts};
28872        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28873
28874        let mut dd = common::DefaultDelegate;
28875        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28876        dlg.begin(common::MethodInfo {
28877            id: "spanner.projects.instances.databases.list",
28878            http_method: hyper::Method::GET,
28879        });
28880
28881        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
28882            if self._additional_params.contains_key(field) {
28883                dlg.finished(false);
28884                return Err(common::Error::FieldClash(field));
28885            }
28886        }
28887
28888        let mut params = Params::with_capacity(5 + self._additional_params.len());
28889        params.push("parent", self._parent);
28890        if let Some(value) = self._page_token.as_ref() {
28891            params.push("pageToken", value);
28892        }
28893        if let Some(value) = self._page_size.as_ref() {
28894            params.push("pageSize", value.to_string());
28895        }
28896
28897        params.extend(self._additional_params.iter());
28898
28899        params.push("alt", "json");
28900        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases";
28901        if self._scopes.is_empty() {
28902            self._scopes
28903                .insert(Scope::CloudPlatform.as_ref().to_string());
28904        }
28905
28906        #[allow(clippy::single_element_loop)]
28907        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
28908            url = params.uri_replacement(url, param_name, find_this, true);
28909        }
28910        {
28911            let to_remove = ["parent"];
28912            params.remove_params(&to_remove);
28913        }
28914
28915        let url = params.parse_with_url(&url);
28916
28917        loop {
28918            let token = match self
28919                .hub
28920                .auth
28921                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28922                .await
28923            {
28924                Ok(token) => token,
28925                Err(e) => match dlg.token(e) {
28926                    Ok(token) => token,
28927                    Err(e) => {
28928                        dlg.finished(false);
28929                        return Err(common::Error::MissingToken(e));
28930                    }
28931                },
28932            };
28933            let mut req_result = {
28934                let client = &self.hub.client;
28935                dlg.pre_request();
28936                let mut req_builder = hyper::Request::builder()
28937                    .method(hyper::Method::GET)
28938                    .uri(url.as_str())
28939                    .header(USER_AGENT, self.hub._user_agent.clone());
28940
28941                if let Some(token) = token.as_ref() {
28942                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28943                }
28944
28945                let request = req_builder
28946                    .header(CONTENT_LENGTH, 0_u64)
28947                    .body(common::to_body::<String>(None));
28948
28949                client.request(request.unwrap()).await
28950            };
28951
28952            match req_result {
28953                Err(err) => {
28954                    if let common::Retry::After(d) = dlg.http_error(&err) {
28955                        sleep(d).await;
28956                        continue;
28957                    }
28958                    dlg.finished(false);
28959                    return Err(common::Error::HttpError(err));
28960                }
28961                Ok(res) => {
28962                    let (mut parts, body) = res.into_parts();
28963                    let mut body = common::Body::new(body);
28964                    if !parts.status.is_success() {
28965                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28966                        let error = serde_json::from_str(&common::to_string(&bytes));
28967                        let response = common::to_response(parts, bytes.into());
28968
28969                        if let common::Retry::After(d) =
28970                            dlg.http_failure(&response, error.as_ref().ok())
28971                        {
28972                            sleep(d).await;
28973                            continue;
28974                        }
28975
28976                        dlg.finished(false);
28977
28978                        return Err(match error {
28979                            Ok(value) => common::Error::BadRequest(value),
28980                            _ => common::Error::Failure(response),
28981                        });
28982                    }
28983                    let response = {
28984                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28985                        let encoded = common::to_string(&bytes);
28986                        match serde_json::from_str(&encoded) {
28987                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28988                            Err(error) => {
28989                                dlg.response_json_decode_error(&encoded, &error);
28990                                return Err(common::Error::JsonDecodeError(
28991                                    encoded.to_string(),
28992                                    error,
28993                                ));
28994                            }
28995                        }
28996                    };
28997
28998                    dlg.finished(true);
28999                    return Ok(response);
29000                }
29001            }
29002        }
29003    }
29004
29005    /// Required. The instance whose databases should be listed. Values are of the form `projects//instances/`.
29006    ///
29007    /// Sets the *parent* path property to the given value.
29008    ///
29009    /// Even though the property as already been set when instantiating this call,
29010    /// we provide this method for API completeness.
29011    pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseListCall<'a, C> {
29012        self._parent = new_value.to_string();
29013        self
29014    }
29015    /// If non-empty, `page_token` should contain a next_page_token from a previous ListDatabasesResponse.
29016    ///
29017    /// Sets the *page token* query property to the given value.
29018    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceDatabaseListCall<'a, C> {
29019        self._page_token = Some(new_value.to_string());
29020        self
29021    }
29022    /// Number of databases to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
29023    ///
29024    /// Sets the *page size* query property to the given value.
29025    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceDatabaseListCall<'a, C> {
29026        self._page_size = Some(new_value);
29027        self
29028    }
29029    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29030    /// while executing the actual API request.
29031    ///
29032    /// ````text
29033    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29034    /// ````
29035    ///
29036    /// Sets the *delegate* property to the given value.
29037    pub fn delegate(
29038        mut self,
29039        new_value: &'a mut dyn common::Delegate,
29040    ) -> ProjectInstanceDatabaseListCall<'a, C> {
29041        self._delegate = Some(new_value);
29042        self
29043    }
29044
29045    /// Set any additional parameter of the query string used in the request.
29046    /// It should be used to set parameters which are not yet available through their own
29047    /// setters.
29048    ///
29049    /// Please note that this method must not be used to set any of the known parameters
29050    /// which have their own setter method. If done anyway, the request will fail.
29051    ///
29052    /// # Additional Parameters
29053    ///
29054    /// * *$.xgafv* (query-string) - V1 error format.
29055    /// * *access_token* (query-string) - OAuth access token.
29056    /// * *alt* (query-string) - Data format for response.
29057    /// * *callback* (query-string) - JSONP
29058    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29059    /// * *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.
29060    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29061    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29062    /// * *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.
29063    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29064    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29065    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseListCall<'a, C>
29066    where
29067        T: AsRef<str>,
29068    {
29069        self._additional_params
29070            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29071        self
29072    }
29073
29074    /// Identifies the authorization scope for the method you are building.
29075    ///
29076    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29077    /// [`Scope::CloudPlatform`].
29078    ///
29079    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29080    /// tokens for more than one scope.
29081    ///
29082    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29083    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29084    /// sufficient, a read-write scope will do as well.
29085    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseListCall<'a, C>
29086    where
29087        St: AsRef<str>,
29088    {
29089        self._scopes.insert(String::from(scope.as_ref()));
29090        self
29091    }
29092    /// Identifies the authorization scope(s) for the method you are building.
29093    ///
29094    /// See [`Self::add_scope()`] for details.
29095    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseListCall<'a, C>
29096    where
29097        I: IntoIterator<Item = St>,
29098        St: AsRef<str>,
29099    {
29100        self._scopes
29101            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29102        self
29103    }
29104
29105    /// Removes all scopes, and no default scope will be used either.
29106    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29107    /// for details).
29108    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseListCall<'a, C> {
29109        self._scopes.clear();
29110        self
29111    }
29112}
29113
29114/// Updates a Cloud Spanner database. The returned long-running operation can be used to track the progress of updating the database. If the named database does not exist, returns `NOT_FOUND`. While the operation is pending: * The database's reconciling field is set to true. * Cancelling the operation is best-effort. If the cancellation succeeds, the operation metadata's cancel_time is set, the updates are reverted, and the operation terminates with a `CANCELLED` status. * New UpdateDatabase requests will return a `FAILED_PRECONDITION` error until the pending operation is done (returns successfully or with error). * Reading the database via the API continues to give the pre-request values. Upon completion of the returned operation: * The new values are in effect and readable via the API. * The database's reconciling field becomes false. The returned long-running operation will have a name of the format `projects//instances//databases//operations/` and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.
29115///
29116/// A builder for the *instances.databases.patch* method supported by a *project* resource.
29117/// It is not used directly, but through a [`ProjectMethods`] instance.
29118///
29119/// # Example
29120///
29121/// Instantiate a resource method builder
29122///
29123/// ```test_harness,no_run
29124/// # extern crate hyper;
29125/// # extern crate hyper_rustls;
29126/// # extern crate google_spanner1 as spanner1;
29127/// use spanner1::api::Database;
29128/// # async fn dox() {
29129/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29130///
29131/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29132/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29133/// #     .with_native_roots()
29134/// #     .unwrap()
29135/// #     .https_only()
29136/// #     .enable_http2()
29137/// #     .build();
29138///
29139/// # let executor = hyper_util::rt::TokioExecutor::new();
29140/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29141/// #     secret,
29142/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29143/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29144/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29145/// #     ),
29146/// # ).build().await.unwrap();
29147///
29148/// # let client = hyper_util::client::legacy::Client::builder(
29149/// #     hyper_util::rt::TokioExecutor::new()
29150/// # )
29151/// # .build(
29152/// #     hyper_rustls::HttpsConnectorBuilder::new()
29153/// #         .with_native_roots()
29154/// #         .unwrap()
29155/// #         .https_or_http()
29156/// #         .enable_http2()
29157/// #         .build()
29158/// # );
29159/// # let mut hub = Spanner::new(client, auth);
29160/// // As the method needs a request, you would usually fill it with the desired information
29161/// // into the respective structure. Some of the parts shown here might not be applicable !
29162/// // Values shown here are possibly random and not representative !
29163/// let mut req = Database::default();
29164///
29165/// // You can configure optional parameters by calling the respective setters at will, and
29166/// // execute the final call using `doit()`.
29167/// // Values shown here are possibly random and not representative !
29168/// let result = hub.projects().instances_databases_patch(req, "name")
29169///              .update_mask(FieldMask::new::<&str>(&[]))
29170///              .doit().await;
29171/// # }
29172/// ```
29173pub struct ProjectInstanceDatabasePatchCall<'a, C>
29174where
29175    C: 'a,
29176{
29177    hub: &'a Spanner<C>,
29178    _request: Database,
29179    _name: String,
29180    _update_mask: Option<common::FieldMask>,
29181    _delegate: Option<&'a mut dyn common::Delegate>,
29182    _additional_params: HashMap<String, String>,
29183    _scopes: BTreeSet<String>,
29184}
29185
29186impl<'a, C> common::CallBuilder for ProjectInstanceDatabasePatchCall<'a, C> {}
29187
29188impl<'a, C> ProjectInstanceDatabasePatchCall<'a, C>
29189where
29190    C: common::Connector,
29191{
29192    /// Perform the operation you have build so far.
29193    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
29194        use std::borrow::Cow;
29195        use std::io::{Read, Seek};
29196
29197        use common::{url::Params, ToParts};
29198        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29199
29200        let mut dd = common::DefaultDelegate;
29201        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29202        dlg.begin(common::MethodInfo {
29203            id: "spanner.projects.instances.databases.patch",
29204            http_method: hyper::Method::PATCH,
29205        });
29206
29207        for &field in ["alt", "name", "updateMask"].iter() {
29208            if self._additional_params.contains_key(field) {
29209                dlg.finished(false);
29210                return Err(common::Error::FieldClash(field));
29211            }
29212        }
29213
29214        let mut params = Params::with_capacity(5 + self._additional_params.len());
29215        params.push("name", self._name);
29216        if let Some(value) = self._update_mask.as_ref() {
29217            params.push("updateMask", value.to_string());
29218        }
29219
29220        params.extend(self._additional_params.iter());
29221
29222        params.push("alt", "json");
29223        let mut url = self.hub._base_url.clone() + "v1/{+name}";
29224        if self._scopes.is_empty() {
29225            self._scopes
29226                .insert(Scope::CloudPlatform.as_ref().to_string());
29227        }
29228
29229        #[allow(clippy::single_element_loop)]
29230        for &(find_this, param_name) in [("{+name}", "name")].iter() {
29231            url = params.uri_replacement(url, param_name, find_this, true);
29232        }
29233        {
29234            let to_remove = ["name"];
29235            params.remove_params(&to_remove);
29236        }
29237
29238        let url = params.parse_with_url(&url);
29239
29240        let mut json_mime_type = mime::APPLICATION_JSON;
29241        let mut request_value_reader = {
29242            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29243            common::remove_json_null_values(&mut value);
29244            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29245            serde_json::to_writer(&mut dst, &value).unwrap();
29246            dst
29247        };
29248        let request_size = request_value_reader
29249            .seek(std::io::SeekFrom::End(0))
29250            .unwrap();
29251        request_value_reader
29252            .seek(std::io::SeekFrom::Start(0))
29253            .unwrap();
29254
29255        loop {
29256            let token = match self
29257                .hub
29258                .auth
29259                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29260                .await
29261            {
29262                Ok(token) => token,
29263                Err(e) => match dlg.token(e) {
29264                    Ok(token) => token,
29265                    Err(e) => {
29266                        dlg.finished(false);
29267                        return Err(common::Error::MissingToken(e));
29268                    }
29269                },
29270            };
29271            request_value_reader
29272                .seek(std::io::SeekFrom::Start(0))
29273                .unwrap();
29274            let mut req_result = {
29275                let client = &self.hub.client;
29276                dlg.pre_request();
29277                let mut req_builder = hyper::Request::builder()
29278                    .method(hyper::Method::PATCH)
29279                    .uri(url.as_str())
29280                    .header(USER_AGENT, self.hub._user_agent.clone());
29281
29282                if let Some(token) = token.as_ref() {
29283                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29284                }
29285
29286                let request = req_builder
29287                    .header(CONTENT_TYPE, json_mime_type.to_string())
29288                    .header(CONTENT_LENGTH, request_size as u64)
29289                    .body(common::to_body(
29290                        request_value_reader.get_ref().clone().into(),
29291                    ));
29292
29293                client.request(request.unwrap()).await
29294            };
29295
29296            match req_result {
29297                Err(err) => {
29298                    if let common::Retry::After(d) = dlg.http_error(&err) {
29299                        sleep(d).await;
29300                        continue;
29301                    }
29302                    dlg.finished(false);
29303                    return Err(common::Error::HttpError(err));
29304                }
29305                Ok(res) => {
29306                    let (mut parts, body) = res.into_parts();
29307                    let mut body = common::Body::new(body);
29308                    if !parts.status.is_success() {
29309                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29310                        let error = serde_json::from_str(&common::to_string(&bytes));
29311                        let response = common::to_response(parts, bytes.into());
29312
29313                        if let common::Retry::After(d) =
29314                            dlg.http_failure(&response, error.as_ref().ok())
29315                        {
29316                            sleep(d).await;
29317                            continue;
29318                        }
29319
29320                        dlg.finished(false);
29321
29322                        return Err(match error {
29323                            Ok(value) => common::Error::BadRequest(value),
29324                            _ => common::Error::Failure(response),
29325                        });
29326                    }
29327                    let response = {
29328                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29329                        let encoded = common::to_string(&bytes);
29330                        match serde_json::from_str(&encoded) {
29331                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29332                            Err(error) => {
29333                                dlg.response_json_decode_error(&encoded, &error);
29334                                return Err(common::Error::JsonDecodeError(
29335                                    encoded.to_string(),
29336                                    error,
29337                                ));
29338                            }
29339                        }
29340                    };
29341
29342                    dlg.finished(true);
29343                    return Ok(response);
29344                }
29345            }
29346        }
29347    }
29348
29349    ///
29350    /// Sets the *request* property to the given value.
29351    ///
29352    /// Even though the property as already been set when instantiating this call,
29353    /// we provide this method for API completeness.
29354    pub fn request(mut self, new_value: Database) -> ProjectInstanceDatabasePatchCall<'a, C> {
29355        self._request = new_value;
29356        self
29357    }
29358    /// Required. The name of the database. Values are of the form `projects//instances//databases/`, where `` is as specified in the `CREATE DATABASE` statement. This name can be passed to other API methods to identify the database.
29359    ///
29360    /// Sets the *name* path property to the given value.
29361    ///
29362    /// Even though the property as already been set when instantiating this call,
29363    /// we provide this method for API completeness.
29364    pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabasePatchCall<'a, C> {
29365        self._name = new_value.to_string();
29366        self
29367    }
29368    /// Required. The list of fields to update. Currently, only `enable_drop_protection` field can be updated.
29369    ///
29370    /// Sets the *update mask* query property to the given value.
29371    pub fn update_mask(
29372        mut self,
29373        new_value: common::FieldMask,
29374    ) -> ProjectInstanceDatabasePatchCall<'a, C> {
29375        self._update_mask = Some(new_value);
29376        self
29377    }
29378    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29379    /// while executing the actual API request.
29380    ///
29381    /// ````text
29382    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29383    /// ````
29384    ///
29385    /// Sets the *delegate* property to the given value.
29386    pub fn delegate(
29387        mut self,
29388        new_value: &'a mut dyn common::Delegate,
29389    ) -> ProjectInstanceDatabasePatchCall<'a, C> {
29390        self._delegate = Some(new_value);
29391        self
29392    }
29393
29394    /// Set any additional parameter of the query string used in the request.
29395    /// It should be used to set parameters which are not yet available through their own
29396    /// setters.
29397    ///
29398    /// Please note that this method must not be used to set any of the known parameters
29399    /// which have their own setter method. If done anyway, the request will fail.
29400    ///
29401    /// # Additional Parameters
29402    ///
29403    /// * *$.xgafv* (query-string) - V1 error format.
29404    /// * *access_token* (query-string) - OAuth access token.
29405    /// * *alt* (query-string) - Data format for response.
29406    /// * *callback* (query-string) - JSONP
29407    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29408    /// * *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.
29409    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29410    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29411    /// * *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.
29412    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29413    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29414    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabasePatchCall<'a, C>
29415    where
29416        T: AsRef<str>,
29417    {
29418        self._additional_params
29419            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29420        self
29421    }
29422
29423    /// Identifies the authorization scope for the method you are building.
29424    ///
29425    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29426    /// [`Scope::CloudPlatform`].
29427    ///
29428    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29429    /// tokens for more than one scope.
29430    ///
29431    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29432    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29433    /// sufficient, a read-write scope will do as well.
29434    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabasePatchCall<'a, C>
29435    where
29436        St: AsRef<str>,
29437    {
29438        self._scopes.insert(String::from(scope.as_ref()));
29439        self
29440    }
29441    /// Identifies the authorization scope(s) for the method you are building.
29442    ///
29443    /// See [`Self::add_scope()`] for details.
29444    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabasePatchCall<'a, C>
29445    where
29446        I: IntoIterator<Item = St>,
29447        St: AsRef<str>,
29448    {
29449        self._scopes
29450            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29451        self
29452    }
29453
29454    /// Removes all scopes, and no default scope will be used either.
29455    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29456    /// for details).
29457    pub fn clear_scopes(mut self) -> ProjectInstanceDatabasePatchCall<'a, C> {
29458        self._scopes.clear();
29459        self
29460    }
29461}
29462
29463/// Create a new database by restoring from a completed backup. The new database must be in the same project and in an instance with the same instance configuration as the instance containing the backup. The returned database long-running operation has a name of the format `projects//instances//databases//operations/`, and can be used to track the progress of the operation, and to cancel it. The metadata field type is RestoreDatabaseMetadata. The response type is Database, if successful. Cancelling the returned operation will stop the restore and delete the database. There can be only one database being restored into an instance at a time. Once the restore operation completes, a new restore operation can be initiated, without waiting for the optimize operation associated with the first restore to complete.
29464///
29465/// A builder for the *instances.databases.restore* method supported by a *project* resource.
29466/// It is not used directly, but through a [`ProjectMethods`] instance.
29467///
29468/// # Example
29469///
29470/// Instantiate a resource method builder
29471///
29472/// ```test_harness,no_run
29473/// # extern crate hyper;
29474/// # extern crate hyper_rustls;
29475/// # extern crate google_spanner1 as spanner1;
29476/// use spanner1::api::RestoreDatabaseRequest;
29477/// # async fn dox() {
29478/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29479///
29480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29482/// #     .with_native_roots()
29483/// #     .unwrap()
29484/// #     .https_only()
29485/// #     .enable_http2()
29486/// #     .build();
29487///
29488/// # let executor = hyper_util::rt::TokioExecutor::new();
29489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29490/// #     secret,
29491/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29492/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29493/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29494/// #     ),
29495/// # ).build().await.unwrap();
29496///
29497/// # let client = hyper_util::client::legacy::Client::builder(
29498/// #     hyper_util::rt::TokioExecutor::new()
29499/// # )
29500/// # .build(
29501/// #     hyper_rustls::HttpsConnectorBuilder::new()
29502/// #         .with_native_roots()
29503/// #         .unwrap()
29504/// #         .https_or_http()
29505/// #         .enable_http2()
29506/// #         .build()
29507/// # );
29508/// # let mut hub = Spanner::new(client, auth);
29509/// // As the method needs a request, you would usually fill it with the desired information
29510/// // into the respective structure. Some of the parts shown here might not be applicable !
29511/// // Values shown here are possibly random and not representative !
29512/// let mut req = RestoreDatabaseRequest::default();
29513///
29514/// // You can configure optional parameters by calling the respective setters at will, and
29515/// // execute the final call using `doit()`.
29516/// // Values shown here are possibly random and not representative !
29517/// let result = hub.projects().instances_databases_restore(req, "parent")
29518///              .doit().await;
29519/// # }
29520/// ```
29521pub struct ProjectInstanceDatabaseRestoreCall<'a, C>
29522where
29523    C: 'a,
29524{
29525    hub: &'a Spanner<C>,
29526    _request: RestoreDatabaseRequest,
29527    _parent: String,
29528    _delegate: Option<&'a mut dyn common::Delegate>,
29529    _additional_params: HashMap<String, String>,
29530    _scopes: BTreeSet<String>,
29531}
29532
29533impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseRestoreCall<'a, C> {}
29534
29535impl<'a, C> ProjectInstanceDatabaseRestoreCall<'a, C>
29536where
29537    C: common::Connector,
29538{
29539    /// Perform the operation you have build so far.
29540    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
29541        use std::borrow::Cow;
29542        use std::io::{Read, Seek};
29543
29544        use common::{url::Params, ToParts};
29545        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29546
29547        let mut dd = common::DefaultDelegate;
29548        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29549        dlg.begin(common::MethodInfo {
29550            id: "spanner.projects.instances.databases.restore",
29551            http_method: hyper::Method::POST,
29552        });
29553
29554        for &field in ["alt", "parent"].iter() {
29555            if self._additional_params.contains_key(field) {
29556                dlg.finished(false);
29557                return Err(common::Error::FieldClash(field));
29558            }
29559        }
29560
29561        let mut params = Params::with_capacity(4 + self._additional_params.len());
29562        params.push("parent", self._parent);
29563
29564        params.extend(self._additional_params.iter());
29565
29566        params.push("alt", "json");
29567        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases:restore";
29568        if self._scopes.is_empty() {
29569            self._scopes
29570                .insert(Scope::CloudPlatform.as_ref().to_string());
29571        }
29572
29573        #[allow(clippy::single_element_loop)]
29574        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
29575            url = params.uri_replacement(url, param_name, find_this, true);
29576        }
29577        {
29578            let to_remove = ["parent"];
29579            params.remove_params(&to_remove);
29580        }
29581
29582        let url = params.parse_with_url(&url);
29583
29584        let mut json_mime_type = mime::APPLICATION_JSON;
29585        let mut request_value_reader = {
29586            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29587            common::remove_json_null_values(&mut value);
29588            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29589            serde_json::to_writer(&mut dst, &value).unwrap();
29590            dst
29591        };
29592        let request_size = request_value_reader
29593            .seek(std::io::SeekFrom::End(0))
29594            .unwrap();
29595        request_value_reader
29596            .seek(std::io::SeekFrom::Start(0))
29597            .unwrap();
29598
29599        loop {
29600            let token = match self
29601                .hub
29602                .auth
29603                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29604                .await
29605            {
29606                Ok(token) => token,
29607                Err(e) => match dlg.token(e) {
29608                    Ok(token) => token,
29609                    Err(e) => {
29610                        dlg.finished(false);
29611                        return Err(common::Error::MissingToken(e));
29612                    }
29613                },
29614            };
29615            request_value_reader
29616                .seek(std::io::SeekFrom::Start(0))
29617                .unwrap();
29618            let mut req_result = {
29619                let client = &self.hub.client;
29620                dlg.pre_request();
29621                let mut req_builder = hyper::Request::builder()
29622                    .method(hyper::Method::POST)
29623                    .uri(url.as_str())
29624                    .header(USER_AGENT, self.hub._user_agent.clone());
29625
29626                if let Some(token) = token.as_ref() {
29627                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29628                }
29629
29630                let request = req_builder
29631                    .header(CONTENT_TYPE, json_mime_type.to_string())
29632                    .header(CONTENT_LENGTH, request_size as u64)
29633                    .body(common::to_body(
29634                        request_value_reader.get_ref().clone().into(),
29635                    ));
29636
29637                client.request(request.unwrap()).await
29638            };
29639
29640            match req_result {
29641                Err(err) => {
29642                    if let common::Retry::After(d) = dlg.http_error(&err) {
29643                        sleep(d).await;
29644                        continue;
29645                    }
29646                    dlg.finished(false);
29647                    return Err(common::Error::HttpError(err));
29648                }
29649                Ok(res) => {
29650                    let (mut parts, body) = res.into_parts();
29651                    let mut body = common::Body::new(body);
29652                    if !parts.status.is_success() {
29653                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29654                        let error = serde_json::from_str(&common::to_string(&bytes));
29655                        let response = common::to_response(parts, bytes.into());
29656
29657                        if let common::Retry::After(d) =
29658                            dlg.http_failure(&response, error.as_ref().ok())
29659                        {
29660                            sleep(d).await;
29661                            continue;
29662                        }
29663
29664                        dlg.finished(false);
29665
29666                        return Err(match error {
29667                            Ok(value) => common::Error::BadRequest(value),
29668                            _ => common::Error::Failure(response),
29669                        });
29670                    }
29671                    let response = {
29672                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29673                        let encoded = common::to_string(&bytes);
29674                        match serde_json::from_str(&encoded) {
29675                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29676                            Err(error) => {
29677                                dlg.response_json_decode_error(&encoded, &error);
29678                                return Err(common::Error::JsonDecodeError(
29679                                    encoded.to_string(),
29680                                    error,
29681                                ));
29682                            }
29683                        }
29684                    };
29685
29686                    dlg.finished(true);
29687                    return Ok(response);
29688                }
29689            }
29690        }
29691    }
29692
29693    ///
29694    /// Sets the *request* property to the given value.
29695    ///
29696    /// Even though the property as already been set when instantiating this call,
29697    /// we provide this method for API completeness.
29698    pub fn request(
29699        mut self,
29700        new_value: RestoreDatabaseRequest,
29701    ) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
29702        self._request = new_value;
29703        self
29704    }
29705    /// Required. The name of the instance in which to create the restored database. This instance must be in the same project and have the same instance configuration as the instance containing the source backup. Values are of the form `projects//instances/`.
29706    ///
29707    /// Sets the *parent* path property to the given value.
29708    ///
29709    /// Even though the property as already been set when instantiating this call,
29710    /// we provide this method for API completeness.
29711    pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
29712        self._parent = new_value.to_string();
29713        self
29714    }
29715    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29716    /// while executing the actual API request.
29717    ///
29718    /// ````text
29719    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29720    /// ````
29721    ///
29722    /// Sets the *delegate* property to the given value.
29723    pub fn delegate(
29724        mut self,
29725        new_value: &'a mut dyn common::Delegate,
29726    ) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
29727        self._delegate = Some(new_value);
29728        self
29729    }
29730
29731    /// Set any additional parameter of the query string used in the request.
29732    /// It should be used to set parameters which are not yet available through their own
29733    /// setters.
29734    ///
29735    /// Please note that this method must not be used to set any of the known parameters
29736    /// which have their own setter method. If done anyway, the request will fail.
29737    ///
29738    /// # Additional Parameters
29739    ///
29740    /// * *$.xgafv* (query-string) - V1 error format.
29741    /// * *access_token* (query-string) - OAuth access token.
29742    /// * *alt* (query-string) - Data format for response.
29743    /// * *callback* (query-string) - JSONP
29744    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29745    /// * *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.
29746    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29747    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29748    /// * *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.
29749    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29750    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29751    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseRestoreCall<'a, C>
29752    where
29753        T: AsRef<str>,
29754    {
29755        self._additional_params
29756            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29757        self
29758    }
29759
29760    /// Identifies the authorization scope for the method you are building.
29761    ///
29762    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29763    /// [`Scope::CloudPlatform`].
29764    ///
29765    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29766    /// tokens for more than one scope.
29767    ///
29768    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29769    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29770    /// sufficient, a read-write scope will do as well.
29771    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseRestoreCall<'a, C>
29772    where
29773        St: AsRef<str>,
29774    {
29775        self._scopes.insert(String::from(scope.as_ref()));
29776        self
29777    }
29778    /// Identifies the authorization scope(s) for the method you are building.
29779    ///
29780    /// See [`Self::add_scope()`] for details.
29781    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseRestoreCall<'a, C>
29782    where
29783        I: IntoIterator<Item = St>,
29784        St: AsRef<str>,
29785    {
29786        self._scopes
29787            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29788        self
29789    }
29790
29791    /// Removes all scopes, and no default scope will be used either.
29792    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29793    /// for details).
29794    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
29795        self._scopes.clear();
29796        self
29797    }
29798}
29799
29800/// Sets the access control policy on a database or backup resource. Replaces any existing policy. Authorization requires `spanner.databases.setIamPolicy` permission on resource. For backups, authorization requires `spanner.backups.setIamPolicy` permission on resource. For backup schedules, authorization requires `spanner.backupSchedules.setIamPolicy` permission on resource.
29801///
29802/// A builder for the *instances.databases.setIamPolicy* method supported by a *project* resource.
29803/// It is not used directly, but through a [`ProjectMethods`] instance.
29804///
29805/// # Example
29806///
29807/// Instantiate a resource method builder
29808///
29809/// ```test_harness,no_run
29810/// # extern crate hyper;
29811/// # extern crate hyper_rustls;
29812/// # extern crate google_spanner1 as spanner1;
29813/// use spanner1::api::SetIamPolicyRequest;
29814/// # async fn dox() {
29815/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29816///
29817/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29818/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29819/// #     .with_native_roots()
29820/// #     .unwrap()
29821/// #     .https_only()
29822/// #     .enable_http2()
29823/// #     .build();
29824///
29825/// # let executor = hyper_util::rt::TokioExecutor::new();
29826/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29827/// #     secret,
29828/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29829/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29830/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29831/// #     ),
29832/// # ).build().await.unwrap();
29833///
29834/// # let client = hyper_util::client::legacy::Client::builder(
29835/// #     hyper_util::rt::TokioExecutor::new()
29836/// # )
29837/// # .build(
29838/// #     hyper_rustls::HttpsConnectorBuilder::new()
29839/// #         .with_native_roots()
29840/// #         .unwrap()
29841/// #         .https_or_http()
29842/// #         .enable_http2()
29843/// #         .build()
29844/// # );
29845/// # let mut hub = Spanner::new(client, auth);
29846/// // As the method needs a request, you would usually fill it with the desired information
29847/// // into the respective structure. Some of the parts shown here might not be applicable !
29848/// // Values shown here are possibly random and not representative !
29849/// let mut req = SetIamPolicyRequest::default();
29850///
29851/// // You can configure optional parameters by calling the respective setters at will, and
29852/// // execute the final call using `doit()`.
29853/// // Values shown here are possibly random and not representative !
29854/// let result = hub.projects().instances_databases_set_iam_policy(req, "resource")
29855///              .doit().await;
29856/// # }
29857/// ```
29858pub struct ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
29859where
29860    C: 'a,
29861{
29862    hub: &'a Spanner<C>,
29863    _request: SetIamPolicyRequest,
29864    _resource: String,
29865    _delegate: Option<&'a mut dyn common::Delegate>,
29866    _additional_params: HashMap<String, String>,
29867    _scopes: BTreeSet<String>,
29868}
29869
29870impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {}
29871
29872impl<'a, C> ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
29873where
29874    C: common::Connector,
29875{
29876    /// Perform the operation you have build so far.
29877    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
29878        use std::borrow::Cow;
29879        use std::io::{Read, Seek};
29880
29881        use common::{url::Params, ToParts};
29882        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29883
29884        let mut dd = common::DefaultDelegate;
29885        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29886        dlg.begin(common::MethodInfo {
29887            id: "spanner.projects.instances.databases.setIamPolicy",
29888            http_method: hyper::Method::POST,
29889        });
29890
29891        for &field in ["alt", "resource"].iter() {
29892            if self._additional_params.contains_key(field) {
29893                dlg.finished(false);
29894                return Err(common::Error::FieldClash(field));
29895            }
29896        }
29897
29898        let mut params = Params::with_capacity(4 + self._additional_params.len());
29899        params.push("resource", self._resource);
29900
29901        params.extend(self._additional_params.iter());
29902
29903        params.push("alt", "json");
29904        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
29905        if self._scopes.is_empty() {
29906            self._scopes
29907                .insert(Scope::CloudPlatform.as_ref().to_string());
29908        }
29909
29910        #[allow(clippy::single_element_loop)]
29911        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
29912            url = params.uri_replacement(url, param_name, find_this, true);
29913        }
29914        {
29915            let to_remove = ["resource"];
29916            params.remove_params(&to_remove);
29917        }
29918
29919        let url = params.parse_with_url(&url);
29920
29921        let mut json_mime_type = mime::APPLICATION_JSON;
29922        let mut request_value_reader = {
29923            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29924            common::remove_json_null_values(&mut value);
29925            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29926            serde_json::to_writer(&mut dst, &value).unwrap();
29927            dst
29928        };
29929        let request_size = request_value_reader
29930            .seek(std::io::SeekFrom::End(0))
29931            .unwrap();
29932        request_value_reader
29933            .seek(std::io::SeekFrom::Start(0))
29934            .unwrap();
29935
29936        loop {
29937            let token = match self
29938                .hub
29939                .auth
29940                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29941                .await
29942            {
29943                Ok(token) => token,
29944                Err(e) => match dlg.token(e) {
29945                    Ok(token) => token,
29946                    Err(e) => {
29947                        dlg.finished(false);
29948                        return Err(common::Error::MissingToken(e));
29949                    }
29950                },
29951            };
29952            request_value_reader
29953                .seek(std::io::SeekFrom::Start(0))
29954                .unwrap();
29955            let mut req_result = {
29956                let client = &self.hub.client;
29957                dlg.pre_request();
29958                let mut req_builder = hyper::Request::builder()
29959                    .method(hyper::Method::POST)
29960                    .uri(url.as_str())
29961                    .header(USER_AGENT, self.hub._user_agent.clone());
29962
29963                if let Some(token) = token.as_ref() {
29964                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29965                }
29966
29967                let request = req_builder
29968                    .header(CONTENT_TYPE, json_mime_type.to_string())
29969                    .header(CONTENT_LENGTH, request_size as u64)
29970                    .body(common::to_body(
29971                        request_value_reader.get_ref().clone().into(),
29972                    ));
29973
29974                client.request(request.unwrap()).await
29975            };
29976
29977            match req_result {
29978                Err(err) => {
29979                    if let common::Retry::After(d) = dlg.http_error(&err) {
29980                        sleep(d).await;
29981                        continue;
29982                    }
29983                    dlg.finished(false);
29984                    return Err(common::Error::HttpError(err));
29985                }
29986                Ok(res) => {
29987                    let (mut parts, body) = res.into_parts();
29988                    let mut body = common::Body::new(body);
29989                    if !parts.status.is_success() {
29990                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29991                        let error = serde_json::from_str(&common::to_string(&bytes));
29992                        let response = common::to_response(parts, bytes.into());
29993
29994                        if let common::Retry::After(d) =
29995                            dlg.http_failure(&response, error.as_ref().ok())
29996                        {
29997                            sleep(d).await;
29998                            continue;
29999                        }
30000
30001                        dlg.finished(false);
30002
30003                        return Err(match error {
30004                            Ok(value) => common::Error::BadRequest(value),
30005                            _ => common::Error::Failure(response),
30006                        });
30007                    }
30008                    let response = {
30009                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30010                        let encoded = common::to_string(&bytes);
30011                        match serde_json::from_str(&encoded) {
30012                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30013                            Err(error) => {
30014                                dlg.response_json_decode_error(&encoded, &error);
30015                                return Err(common::Error::JsonDecodeError(
30016                                    encoded.to_string(),
30017                                    error,
30018                                ));
30019                            }
30020                        }
30021                    };
30022
30023                    dlg.finished(true);
30024                    return Ok(response);
30025                }
30026            }
30027        }
30028    }
30029
30030    ///
30031    /// Sets the *request* property to the given value.
30032    ///
30033    /// Even though the property as already been set when instantiating this call,
30034    /// we provide this method for API completeness.
30035    pub fn request(
30036        mut self,
30037        new_value: SetIamPolicyRequest,
30038    ) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
30039        self._request = new_value;
30040        self
30041    }
30042    /// REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for databases resources.
30043    ///
30044    /// Sets the *resource* path property to the given value.
30045    ///
30046    /// Even though the property as already been set when instantiating this call,
30047    /// we provide this method for API completeness.
30048    pub fn resource(mut self, new_value: &str) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
30049        self._resource = new_value.to_string();
30050        self
30051    }
30052    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30053    /// while executing the actual API request.
30054    ///
30055    /// ````text
30056    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30057    /// ````
30058    ///
30059    /// Sets the *delegate* property to the given value.
30060    pub fn delegate(
30061        mut self,
30062        new_value: &'a mut dyn common::Delegate,
30063    ) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
30064        self._delegate = Some(new_value);
30065        self
30066    }
30067
30068    /// Set any additional parameter of the query string used in the request.
30069    /// It should be used to set parameters which are not yet available through their own
30070    /// setters.
30071    ///
30072    /// Please note that this method must not be used to set any of the known parameters
30073    /// which have their own setter method. If done anyway, the request will fail.
30074    ///
30075    /// # Additional Parameters
30076    ///
30077    /// * *$.xgafv* (query-string) - V1 error format.
30078    /// * *access_token* (query-string) - OAuth access token.
30079    /// * *alt* (query-string) - Data format for response.
30080    /// * *callback* (query-string) - JSONP
30081    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30082    /// * *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.
30083    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30084    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30085    /// * *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.
30086    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30087    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30088    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
30089    where
30090        T: AsRef<str>,
30091    {
30092        self._additional_params
30093            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30094        self
30095    }
30096
30097    /// Identifies the authorization scope for the method you are building.
30098    ///
30099    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30100    /// [`Scope::CloudPlatform`].
30101    ///
30102    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30103    /// tokens for more than one scope.
30104    ///
30105    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30106    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30107    /// sufficient, a read-write scope will do as well.
30108    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
30109    where
30110        St: AsRef<str>,
30111    {
30112        self._scopes.insert(String::from(scope.as_ref()));
30113        self
30114    }
30115    /// Identifies the authorization scope(s) for the method you are building.
30116    ///
30117    /// See [`Self::add_scope()`] for details.
30118    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
30119    where
30120        I: IntoIterator<Item = St>,
30121        St: AsRef<str>,
30122    {
30123        self._scopes
30124            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30125        self
30126    }
30127
30128    /// Removes all scopes, and no default scope will be used either.
30129    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30130    /// for details).
30131    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
30132        self._scopes.clear();
30133        self
30134    }
30135}
30136
30137/// Returns permissions that the caller has on the specified database or backup resource. Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance. Calling this method on a backup schedule that does not exist will result in a NOT_FOUND error if the user has `spanner.backupSchedules.list` permission on the containing database.
30138///
30139/// A builder for the *instances.databases.testIamPermissions* method supported by a *project* resource.
30140/// It is not used directly, but through a [`ProjectMethods`] instance.
30141///
30142/// # Example
30143///
30144/// Instantiate a resource method builder
30145///
30146/// ```test_harness,no_run
30147/// # extern crate hyper;
30148/// # extern crate hyper_rustls;
30149/// # extern crate google_spanner1 as spanner1;
30150/// use spanner1::api::TestIamPermissionsRequest;
30151/// # async fn dox() {
30152/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30153///
30154/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30155/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30156/// #     .with_native_roots()
30157/// #     .unwrap()
30158/// #     .https_only()
30159/// #     .enable_http2()
30160/// #     .build();
30161///
30162/// # let executor = hyper_util::rt::TokioExecutor::new();
30163/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30164/// #     secret,
30165/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30166/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
30167/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
30168/// #     ),
30169/// # ).build().await.unwrap();
30170///
30171/// # let client = hyper_util::client::legacy::Client::builder(
30172/// #     hyper_util::rt::TokioExecutor::new()
30173/// # )
30174/// # .build(
30175/// #     hyper_rustls::HttpsConnectorBuilder::new()
30176/// #         .with_native_roots()
30177/// #         .unwrap()
30178/// #         .https_or_http()
30179/// #         .enable_http2()
30180/// #         .build()
30181/// # );
30182/// # let mut hub = Spanner::new(client, auth);
30183/// // As the method needs a request, you would usually fill it with the desired information
30184/// // into the respective structure. Some of the parts shown here might not be applicable !
30185/// // Values shown here are possibly random and not representative !
30186/// let mut req = TestIamPermissionsRequest::default();
30187///
30188/// // You can configure optional parameters by calling the respective setters at will, and
30189/// // execute the final call using `doit()`.
30190/// // Values shown here are possibly random and not representative !
30191/// let result = hub.projects().instances_databases_test_iam_permissions(req, "resource")
30192///              .doit().await;
30193/// # }
30194/// ```
30195pub struct ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
30196where
30197    C: 'a,
30198{
30199    hub: &'a Spanner<C>,
30200    _request: TestIamPermissionsRequest,
30201    _resource: String,
30202    _delegate: Option<&'a mut dyn common::Delegate>,
30203    _additional_params: HashMap<String, String>,
30204    _scopes: BTreeSet<String>,
30205}
30206
30207impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {}
30208
30209impl<'a, C> ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
30210where
30211    C: common::Connector,
30212{
30213    /// Perform the operation you have build so far.
30214    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
30215        use std::borrow::Cow;
30216        use std::io::{Read, Seek};
30217
30218        use common::{url::Params, ToParts};
30219        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30220
30221        let mut dd = common::DefaultDelegate;
30222        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30223        dlg.begin(common::MethodInfo {
30224            id: "spanner.projects.instances.databases.testIamPermissions",
30225            http_method: hyper::Method::POST,
30226        });
30227
30228        for &field in ["alt", "resource"].iter() {
30229            if self._additional_params.contains_key(field) {
30230                dlg.finished(false);
30231                return Err(common::Error::FieldClash(field));
30232            }
30233        }
30234
30235        let mut params = Params::with_capacity(4 + self._additional_params.len());
30236        params.push("resource", self._resource);
30237
30238        params.extend(self._additional_params.iter());
30239
30240        params.push("alt", "json");
30241        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
30242        if self._scopes.is_empty() {
30243            self._scopes
30244                .insert(Scope::CloudPlatform.as_ref().to_string());
30245        }
30246
30247        #[allow(clippy::single_element_loop)]
30248        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
30249            url = params.uri_replacement(url, param_name, find_this, true);
30250        }
30251        {
30252            let to_remove = ["resource"];
30253            params.remove_params(&to_remove);
30254        }
30255
30256        let url = params.parse_with_url(&url);
30257
30258        let mut json_mime_type = mime::APPLICATION_JSON;
30259        let mut request_value_reader = {
30260            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30261            common::remove_json_null_values(&mut value);
30262            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30263            serde_json::to_writer(&mut dst, &value).unwrap();
30264            dst
30265        };
30266        let request_size = request_value_reader
30267            .seek(std::io::SeekFrom::End(0))
30268            .unwrap();
30269        request_value_reader
30270            .seek(std::io::SeekFrom::Start(0))
30271            .unwrap();
30272
30273        loop {
30274            let token = match self
30275                .hub
30276                .auth
30277                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30278                .await
30279            {
30280                Ok(token) => token,
30281                Err(e) => match dlg.token(e) {
30282                    Ok(token) => token,
30283                    Err(e) => {
30284                        dlg.finished(false);
30285                        return Err(common::Error::MissingToken(e));
30286                    }
30287                },
30288            };
30289            request_value_reader
30290                .seek(std::io::SeekFrom::Start(0))
30291                .unwrap();
30292            let mut req_result = {
30293                let client = &self.hub.client;
30294                dlg.pre_request();
30295                let mut req_builder = hyper::Request::builder()
30296                    .method(hyper::Method::POST)
30297                    .uri(url.as_str())
30298                    .header(USER_AGENT, self.hub._user_agent.clone());
30299
30300                if let Some(token) = token.as_ref() {
30301                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30302                }
30303
30304                let request = req_builder
30305                    .header(CONTENT_TYPE, json_mime_type.to_string())
30306                    .header(CONTENT_LENGTH, request_size as u64)
30307                    .body(common::to_body(
30308                        request_value_reader.get_ref().clone().into(),
30309                    ));
30310
30311                client.request(request.unwrap()).await
30312            };
30313
30314            match req_result {
30315                Err(err) => {
30316                    if let common::Retry::After(d) = dlg.http_error(&err) {
30317                        sleep(d).await;
30318                        continue;
30319                    }
30320                    dlg.finished(false);
30321                    return Err(common::Error::HttpError(err));
30322                }
30323                Ok(res) => {
30324                    let (mut parts, body) = res.into_parts();
30325                    let mut body = common::Body::new(body);
30326                    if !parts.status.is_success() {
30327                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30328                        let error = serde_json::from_str(&common::to_string(&bytes));
30329                        let response = common::to_response(parts, bytes.into());
30330
30331                        if let common::Retry::After(d) =
30332                            dlg.http_failure(&response, error.as_ref().ok())
30333                        {
30334                            sleep(d).await;
30335                            continue;
30336                        }
30337
30338                        dlg.finished(false);
30339
30340                        return Err(match error {
30341                            Ok(value) => common::Error::BadRequest(value),
30342                            _ => common::Error::Failure(response),
30343                        });
30344                    }
30345                    let response = {
30346                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30347                        let encoded = common::to_string(&bytes);
30348                        match serde_json::from_str(&encoded) {
30349                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30350                            Err(error) => {
30351                                dlg.response_json_decode_error(&encoded, &error);
30352                                return Err(common::Error::JsonDecodeError(
30353                                    encoded.to_string(),
30354                                    error,
30355                                ));
30356                            }
30357                        }
30358                    };
30359
30360                    dlg.finished(true);
30361                    return Ok(response);
30362                }
30363            }
30364        }
30365    }
30366
30367    ///
30368    /// Sets the *request* property to the given value.
30369    ///
30370    /// Even though the property as already been set when instantiating this call,
30371    /// we provide this method for API completeness.
30372    pub fn request(
30373        mut self,
30374        new_value: TestIamPermissionsRequest,
30375    ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
30376        self._request = new_value;
30377        self
30378    }
30379    /// REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
30380    ///
30381    /// Sets the *resource* path property to the given value.
30382    ///
30383    /// Even though the property as already been set when instantiating this call,
30384    /// we provide this method for API completeness.
30385    pub fn resource(
30386        mut self,
30387        new_value: &str,
30388    ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
30389        self._resource = new_value.to_string();
30390        self
30391    }
30392    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30393    /// while executing the actual API request.
30394    ///
30395    /// ````text
30396    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30397    /// ````
30398    ///
30399    /// Sets the *delegate* property to the given value.
30400    pub fn delegate(
30401        mut self,
30402        new_value: &'a mut dyn common::Delegate,
30403    ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
30404        self._delegate = Some(new_value);
30405        self
30406    }
30407
30408    /// Set any additional parameter of the query string used in the request.
30409    /// It should be used to set parameters which are not yet available through their own
30410    /// setters.
30411    ///
30412    /// Please note that this method must not be used to set any of the known parameters
30413    /// which have their own setter method. If done anyway, the request will fail.
30414    ///
30415    /// # Additional Parameters
30416    ///
30417    /// * *$.xgafv* (query-string) - V1 error format.
30418    /// * *access_token* (query-string) - OAuth access token.
30419    /// * *alt* (query-string) - Data format for response.
30420    /// * *callback* (query-string) - JSONP
30421    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30422    /// * *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.
30423    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30424    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30425    /// * *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.
30426    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30427    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30428    pub fn param<T>(
30429        mut self,
30430        name: T,
30431        value: T,
30432    ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
30433    where
30434        T: AsRef<str>,
30435    {
30436        self._additional_params
30437            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30438        self
30439    }
30440
30441    /// Identifies the authorization scope for the method you are building.
30442    ///
30443    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30444    /// [`Scope::CloudPlatform`].
30445    ///
30446    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30447    /// tokens for more than one scope.
30448    ///
30449    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30450    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30451    /// sufficient, a read-write scope will do as well.
30452    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
30453    where
30454        St: AsRef<str>,
30455    {
30456        self._scopes.insert(String::from(scope.as_ref()));
30457        self
30458    }
30459    /// Identifies the authorization scope(s) for the method you are building.
30460    ///
30461    /// See [`Self::add_scope()`] for details.
30462    pub fn add_scopes<I, St>(
30463        mut self,
30464        scopes: I,
30465    ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
30466    where
30467        I: IntoIterator<Item = St>,
30468        St: AsRef<str>,
30469    {
30470        self._scopes
30471            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30472        self
30473    }
30474
30475    /// Removes all scopes, and no default scope will be used either.
30476    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30477    /// for details).
30478    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
30479        self._scopes.clear();
30480        self
30481    }
30482}
30483
30484/// Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns, indexes, etc. The returned long-running operation will have a name of the format `/operations/` and can be used to track execution of the schema changes. The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response.
30485///
30486/// A builder for the *instances.databases.updateDdl* method supported by a *project* resource.
30487/// It is not used directly, but through a [`ProjectMethods`] instance.
30488///
30489/// # Example
30490///
30491/// Instantiate a resource method builder
30492///
30493/// ```test_harness,no_run
30494/// # extern crate hyper;
30495/// # extern crate hyper_rustls;
30496/// # extern crate google_spanner1 as spanner1;
30497/// use spanner1::api::UpdateDatabaseDdlRequest;
30498/// # async fn dox() {
30499/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30500///
30501/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30502/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30503/// #     .with_native_roots()
30504/// #     .unwrap()
30505/// #     .https_only()
30506/// #     .enable_http2()
30507/// #     .build();
30508///
30509/// # let executor = hyper_util::rt::TokioExecutor::new();
30510/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30511/// #     secret,
30512/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30513/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
30514/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
30515/// #     ),
30516/// # ).build().await.unwrap();
30517///
30518/// # let client = hyper_util::client::legacy::Client::builder(
30519/// #     hyper_util::rt::TokioExecutor::new()
30520/// # )
30521/// # .build(
30522/// #     hyper_rustls::HttpsConnectorBuilder::new()
30523/// #         .with_native_roots()
30524/// #         .unwrap()
30525/// #         .https_or_http()
30526/// #         .enable_http2()
30527/// #         .build()
30528/// # );
30529/// # let mut hub = Spanner::new(client, auth);
30530/// // As the method needs a request, you would usually fill it with the desired information
30531/// // into the respective structure. Some of the parts shown here might not be applicable !
30532/// // Values shown here are possibly random and not representative !
30533/// let mut req = UpdateDatabaseDdlRequest::default();
30534///
30535/// // You can configure optional parameters by calling the respective setters at will, and
30536/// // execute the final call using `doit()`.
30537/// // Values shown here are possibly random and not representative !
30538/// let result = hub.projects().instances_databases_update_ddl(req, "database")
30539///              .doit().await;
30540/// # }
30541/// ```
30542pub struct ProjectInstanceDatabaseUpdateDdlCall<'a, C>
30543where
30544    C: 'a,
30545{
30546    hub: &'a Spanner<C>,
30547    _request: UpdateDatabaseDdlRequest,
30548    _database: String,
30549    _delegate: Option<&'a mut dyn common::Delegate>,
30550    _additional_params: HashMap<String, String>,
30551    _scopes: BTreeSet<String>,
30552}
30553
30554impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseUpdateDdlCall<'a, C> {}
30555
30556impl<'a, C> ProjectInstanceDatabaseUpdateDdlCall<'a, C>
30557where
30558    C: common::Connector,
30559{
30560    /// Perform the operation you have build so far.
30561    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
30562        use std::borrow::Cow;
30563        use std::io::{Read, Seek};
30564
30565        use common::{url::Params, ToParts};
30566        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30567
30568        let mut dd = common::DefaultDelegate;
30569        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30570        dlg.begin(common::MethodInfo {
30571            id: "spanner.projects.instances.databases.updateDdl",
30572            http_method: hyper::Method::PATCH,
30573        });
30574
30575        for &field in ["alt", "database"].iter() {
30576            if self._additional_params.contains_key(field) {
30577                dlg.finished(false);
30578                return Err(common::Error::FieldClash(field));
30579            }
30580        }
30581
30582        let mut params = Params::with_capacity(4 + self._additional_params.len());
30583        params.push("database", self._database);
30584
30585        params.extend(self._additional_params.iter());
30586
30587        params.push("alt", "json");
30588        let mut url = self.hub._base_url.clone() + "v1/{+database}/ddl";
30589        if self._scopes.is_empty() {
30590            self._scopes
30591                .insert(Scope::CloudPlatform.as_ref().to_string());
30592        }
30593
30594        #[allow(clippy::single_element_loop)]
30595        for &(find_this, param_name) in [("{+database}", "database")].iter() {
30596            url = params.uri_replacement(url, param_name, find_this, true);
30597        }
30598        {
30599            let to_remove = ["database"];
30600            params.remove_params(&to_remove);
30601        }
30602
30603        let url = params.parse_with_url(&url);
30604
30605        let mut json_mime_type = mime::APPLICATION_JSON;
30606        let mut request_value_reader = {
30607            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30608            common::remove_json_null_values(&mut value);
30609            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30610            serde_json::to_writer(&mut dst, &value).unwrap();
30611            dst
30612        };
30613        let request_size = request_value_reader
30614            .seek(std::io::SeekFrom::End(0))
30615            .unwrap();
30616        request_value_reader
30617            .seek(std::io::SeekFrom::Start(0))
30618            .unwrap();
30619
30620        loop {
30621            let token = match self
30622                .hub
30623                .auth
30624                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30625                .await
30626            {
30627                Ok(token) => token,
30628                Err(e) => match dlg.token(e) {
30629                    Ok(token) => token,
30630                    Err(e) => {
30631                        dlg.finished(false);
30632                        return Err(common::Error::MissingToken(e));
30633                    }
30634                },
30635            };
30636            request_value_reader
30637                .seek(std::io::SeekFrom::Start(0))
30638                .unwrap();
30639            let mut req_result = {
30640                let client = &self.hub.client;
30641                dlg.pre_request();
30642                let mut req_builder = hyper::Request::builder()
30643                    .method(hyper::Method::PATCH)
30644                    .uri(url.as_str())
30645                    .header(USER_AGENT, self.hub._user_agent.clone());
30646
30647                if let Some(token) = token.as_ref() {
30648                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30649                }
30650
30651                let request = req_builder
30652                    .header(CONTENT_TYPE, json_mime_type.to_string())
30653                    .header(CONTENT_LENGTH, request_size as u64)
30654                    .body(common::to_body(
30655                        request_value_reader.get_ref().clone().into(),
30656                    ));
30657
30658                client.request(request.unwrap()).await
30659            };
30660
30661            match req_result {
30662                Err(err) => {
30663                    if let common::Retry::After(d) = dlg.http_error(&err) {
30664                        sleep(d).await;
30665                        continue;
30666                    }
30667                    dlg.finished(false);
30668                    return Err(common::Error::HttpError(err));
30669                }
30670                Ok(res) => {
30671                    let (mut parts, body) = res.into_parts();
30672                    let mut body = common::Body::new(body);
30673                    if !parts.status.is_success() {
30674                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30675                        let error = serde_json::from_str(&common::to_string(&bytes));
30676                        let response = common::to_response(parts, bytes.into());
30677
30678                        if let common::Retry::After(d) =
30679                            dlg.http_failure(&response, error.as_ref().ok())
30680                        {
30681                            sleep(d).await;
30682                            continue;
30683                        }
30684
30685                        dlg.finished(false);
30686
30687                        return Err(match error {
30688                            Ok(value) => common::Error::BadRequest(value),
30689                            _ => common::Error::Failure(response),
30690                        });
30691                    }
30692                    let response = {
30693                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30694                        let encoded = common::to_string(&bytes);
30695                        match serde_json::from_str(&encoded) {
30696                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30697                            Err(error) => {
30698                                dlg.response_json_decode_error(&encoded, &error);
30699                                return Err(common::Error::JsonDecodeError(
30700                                    encoded.to_string(),
30701                                    error,
30702                                ));
30703                            }
30704                        }
30705                    };
30706
30707                    dlg.finished(true);
30708                    return Ok(response);
30709                }
30710            }
30711        }
30712    }
30713
30714    ///
30715    /// Sets the *request* property to the given value.
30716    ///
30717    /// Even though the property as already been set when instantiating this call,
30718    /// we provide this method for API completeness.
30719    pub fn request(
30720        mut self,
30721        new_value: UpdateDatabaseDdlRequest,
30722    ) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
30723        self._request = new_value;
30724        self
30725    }
30726    /// Required. The database to update.
30727    ///
30728    /// Sets the *database* path property to the given value.
30729    ///
30730    /// Even though the property as already been set when instantiating this call,
30731    /// we provide this method for API completeness.
30732    pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
30733        self._database = new_value.to_string();
30734        self
30735    }
30736    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30737    /// while executing the actual API request.
30738    ///
30739    /// ````text
30740    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30741    /// ````
30742    ///
30743    /// Sets the *delegate* property to the given value.
30744    pub fn delegate(
30745        mut self,
30746        new_value: &'a mut dyn common::Delegate,
30747    ) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
30748        self._delegate = Some(new_value);
30749        self
30750    }
30751
30752    /// Set any additional parameter of the query string used in the request.
30753    /// It should be used to set parameters which are not yet available through their own
30754    /// setters.
30755    ///
30756    /// Please note that this method must not be used to set any of the known parameters
30757    /// which have their own setter method. If done anyway, the request will fail.
30758    ///
30759    /// # Additional Parameters
30760    ///
30761    /// * *$.xgafv* (query-string) - V1 error format.
30762    /// * *access_token* (query-string) - OAuth access token.
30763    /// * *alt* (query-string) - Data format for response.
30764    /// * *callback* (query-string) - JSONP
30765    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30766    /// * *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.
30767    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30768    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30769    /// * *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.
30770    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30771    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30772    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C>
30773    where
30774        T: AsRef<str>,
30775    {
30776        self._additional_params
30777            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30778        self
30779    }
30780
30781    /// Identifies the authorization scope for the method you are building.
30782    ///
30783    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30784    /// [`Scope::CloudPlatform`].
30785    ///
30786    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30787    /// tokens for more than one scope.
30788    ///
30789    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30790    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30791    /// sufficient, a read-write scope will do as well.
30792    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C>
30793    where
30794        St: AsRef<str>,
30795    {
30796        self._scopes.insert(String::from(scope.as_ref()));
30797        self
30798    }
30799    /// Identifies the authorization scope(s) for the method you are building.
30800    ///
30801    /// See [`Self::add_scope()`] for details.
30802    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C>
30803    where
30804        I: IntoIterator<Item = St>,
30805        St: AsRef<str>,
30806    {
30807        self._scopes
30808            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30809        self
30810    }
30811
30812    /// Removes all scopes, and no default scope will be used either.
30813    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30814    /// for details).
30815    pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
30816        self._scopes.clear();
30817        self
30818    }
30819}
30820
30821/// Lists instance partition long-running operations in the given instance. An instance partition operation has a name of the form `projects//instances//instancePartitions//operations/`. The long-running operation metadata field type `metadata.type_url` describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by `operation.metadata.value.start_time` in descending order starting from the most recently started operation. Authorization requires `spanner.instancePartitionOperations.list` permission on the resource parent.
30822///
30823/// A builder for the *instances.instancePartitionOperations.list* method supported by a *project* resource.
30824/// It is not used directly, but through a [`ProjectMethods`] instance.
30825///
30826/// # Example
30827///
30828/// Instantiate a resource method builder
30829///
30830/// ```test_harness,no_run
30831/// # extern crate hyper;
30832/// # extern crate hyper_rustls;
30833/// # extern crate google_spanner1 as spanner1;
30834/// # async fn dox() {
30835/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30836///
30837/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30838/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30839/// #     .with_native_roots()
30840/// #     .unwrap()
30841/// #     .https_only()
30842/// #     .enable_http2()
30843/// #     .build();
30844///
30845/// # let executor = hyper_util::rt::TokioExecutor::new();
30846/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30847/// #     secret,
30848/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30849/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
30850/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
30851/// #     ),
30852/// # ).build().await.unwrap();
30853///
30854/// # let client = hyper_util::client::legacy::Client::builder(
30855/// #     hyper_util::rt::TokioExecutor::new()
30856/// # )
30857/// # .build(
30858/// #     hyper_rustls::HttpsConnectorBuilder::new()
30859/// #         .with_native_roots()
30860/// #         .unwrap()
30861/// #         .https_or_http()
30862/// #         .enable_http2()
30863/// #         .build()
30864/// # );
30865/// # let mut hub = Spanner::new(client, auth);
30866/// // You can configure optional parameters by calling the respective setters at will, and
30867/// // execute the final call using `doit()`.
30868/// // Values shown here are possibly random and not representative !
30869/// let result = hub.projects().instances_instance_partition_operations_list("parent")
30870///              .page_token("sed")
30871///              .page_size(-75)
30872///              .instance_partition_deadline(chrono::Utc::now())
30873///              .filter("Lorem")
30874///              .doit().await;
30875/// # }
30876/// ```
30877pub struct ProjectInstanceInstancePartitionOperationListCall<'a, C>
30878where
30879    C: 'a,
30880{
30881    hub: &'a Spanner<C>,
30882    _parent: String,
30883    _page_token: Option<String>,
30884    _page_size: Option<i32>,
30885    _instance_partition_deadline: Option<chrono::DateTime<chrono::offset::Utc>>,
30886    _filter: Option<String>,
30887    _delegate: Option<&'a mut dyn common::Delegate>,
30888    _additional_params: HashMap<String, String>,
30889    _scopes: BTreeSet<String>,
30890}
30891
30892impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationListCall<'a, C> {}
30893
30894impl<'a, C> ProjectInstanceInstancePartitionOperationListCall<'a, C>
30895where
30896    C: common::Connector,
30897{
30898    /// Perform the operation you have build so far.
30899    pub async fn doit(
30900        mut self,
30901    ) -> common::Result<(common::Response, ListInstancePartitionOperationsResponse)> {
30902        use std::borrow::Cow;
30903        use std::io::{Read, Seek};
30904
30905        use common::{url::Params, ToParts};
30906        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30907
30908        let mut dd = common::DefaultDelegate;
30909        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30910        dlg.begin(common::MethodInfo {
30911            id: "spanner.projects.instances.instancePartitionOperations.list",
30912            http_method: hyper::Method::GET,
30913        });
30914
30915        for &field in [
30916            "alt",
30917            "parent",
30918            "pageToken",
30919            "pageSize",
30920            "instancePartitionDeadline",
30921            "filter",
30922        ]
30923        .iter()
30924        {
30925            if self._additional_params.contains_key(field) {
30926                dlg.finished(false);
30927                return Err(common::Error::FieldClash(field));
30928            }
30929        }
30930
30931        let mut params = Params::with_capacity(7 + self._additional_params.len());
30932        params.push("parent", self._parent);
30933        if let Some(value) = self._page_token.as_ref() {
30934            params.push("pageToken", value);
30935        }
30936        if let Some(value) = self._page_size.as_ref() {
30937            params.push("pageSize", value.to_string());
30938        }
30939        if let Some(value) = self._instance_partition_deadline.as_ref() {
30940            params.push(
30941                "instancePartitionDeadline",
30942                common::serde::datetime_to_string(&value),
30943            );
30944        }
30945        if let Some(value) = self._filter.as_ref() {
30946            params.push("filter", value);
30947        }
30948
30949        params.extend(self._additional_params.iter());
30950
30951        params.push("alt", "json");
30952        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instancePartitionOperations";
30953        if self._scopes.is_empty() {
30954            self._scopes
30955                .insert(Scope::CloudPlatform.as_ref().to_string());
30956        }
30957
30958        #[allow(clippy::single_element_loop)]
30959        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
30960            url = params.uri_replacement(url, param_name, find_this, true);
30961        }
30962        {
30963            let to_remove = ["parent"];
30964            params.remove_params(&to_remove);
30965        }
30966
30967        let url = params.parse_with_url(&url);
30968
30969        loop {
30970            let token = match self
30971                .hub
30972                .auth
30973                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30974                .await
30975            {
30976                Ok(token) => token,
30977                Err(e) => match dlg.token(e) {
30978                    Ok(token) => token,
30979                    Err(e) => {
30980                        dlg.finished(false);
30981                        return Err(common::Error::MissingToken(e));
30982                    }
30983                },
30984            };
30985            let mut req_result = {
30986                let client = &self.hub.client;
30987                dlg.pre_request();
30988                let mut req_builder = hyper::Request::builder()
30989                    .method(hyper::Method::GET)
30990                    .uri(url.as_str())
30991                    .header(USER_AGENT, self.hub._user_agent.clone());
30992
30993                if let Some(token) = token.as_ref() {
30994                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30995                }
30996
30997                let request = req_builder
30998                    .header(CONTENT_LENGTH, 0_u64)
30999                    .body(common::to_body::<String>(None));
31000
31001                client.request(request.unwrap()).await
31002            };
31003
31004            match req_result {
31005                Err(err) => {
31006                    if let common::Retry::After(d) = dlg.http_error(&err) {
31007                        sleep(d).await;
31008                        continue;
31009                    }
31010                    dlg.finished(false);
31011                    return Err(common::Error::HttpError(err));
31012                }
31013                Ok(res) => {
31014                    let (mut parts, body) = res.into_parts();
31015                    let mut body = common::Body::new(body);
31016                    if !parts.status.is_success() {
31017                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31018                        let error = serde_json::from_str(&common::to_string(&bytes));
31019                        let response = common::to_response(parts, bytes.into());
31020
31021                        if let common::Retry::After(d) =
31022                            dlg.http_failure(&response, error.as_ref().ok())
31023                        {
31024                            sleep(d).await;
31025                            continue;
31026                        }
31027
31028                        dlg.finished(false);
31029
31030                        return Err(match error {
31031                            Ok(value) => common::Error::BadRequest(value),
31032                            _ => common::Error::Failure(response),
31033                        });
31034                    }
31035                    let response = {
31036                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31037                        let encoded = common::to_string(&bytes);
31038                        match serde_json::from_str(&encoded) {
31039                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31040                            Err(error) => {
31041                                dlg.response_json_decode_error(&encoded, &error);
31042                                return Err(common::Error::JsonDecodeError(
31043                                    encoded.to_string(),
31044                                    error,
31045                                ));
31046                            }
31047                        }
31048                    };
31049
31050                    dlg.finished(true);
31051                    return Ok(response);
31052                }
31053            }
31054        }
31055    }
31056
31057    /// Required. The parent instance of the instance partition operations. Values are of the form `projects//instances/`.
31058    ///
31059    /// Sets the *parent* path property to the given value.
31060    ///
31061    /// Even though the property as already been set when instantiating this call,
31062    /// we provide this method for API completeness.
31063    pub fn parent(
31064        mut self,
31065        new_value: &str,
31066    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
31067        self._parent = new_value.to_string();
31068        self
31069    }
31070    /// Optional. If non-empty, `page_token` should contain a next_page_token from a previous ListInstancePartitionOperationsResponse to the same `parent` and with the same `filter`.
31071    ///
31072    /// Sets the *page token* query property to the given value.
31073    pub fn page_token(
31074        mut self,
31075        new_value: &str,
31076    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
31077        self._page_token = Some(new_value.to_string());
31078        self
31079    }
31080    /// Optional. Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
31081    ///
31082    /// Sets the *page size* query property to the given value.
31083    pub fn page_size(
31084        mut self,
31085        new_value: i32,
31086    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
31087        self._page_size = Some(new_value);
31088        self
31089    }
31090    /// Optional. Deadline used while retrieving metadata for instance partition operations. Instance partitions whose operation metadata cannot be retrieved within this deadline will be added to unreachable_instance_partitions in ListInstancePartitionOperationsResponse.
31091    ///
31092    /// Sets the *instance partition deadline* query property to the given value.
31093    pub fn instance_partition_deadline(
31094        mut self,
31095        new_value: chrono::DateTime<chrono::offset::Utc>,
31096    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
31097        self._instance_partition_deadline = Some(new_value);
31098        self
31099    }
31100    /// Optional. An expression that filters the list of returned operations. A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. Colon `:` is the contains operator. Filter rules are not case sensitive. The following fields in the Operation are eligible for filtering: * `name` - The name of the long-running operation * `done` - False if the operation is in progress, else true. * `metadata.@type` - the type of metadata. For example, the type string for CreateInstancePartitionMetadata is `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata`. * `metadata.` - any field in metadata.value. `metadata.@type` must be specified first, if filtering on metadata fields. * `error` - Error associated with the long-running operation. * `response.@type` - the type of response. * `response.` - any field in response.value. You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly. Here are a few examples: * `done:true` - The operation is complete. * `(metadata.@type=` \ `type.googleapis.com/google.spanner.admin.instance.v1.CreateInstancePartitionMetadata) AND` \ `(metadata.instance_partition.name:custom-instance-partition) AND` \ `(metadata.start_time < \"2021-03-28T14:50:00Z\") AND` \ `(error:*)` - Return operations where: * The operation's metadata type is CreateInstancePartitionMetadata. * The instance partition name contains "custom-instance-partition". * The operation started before 2021-03-28T14:50:00Z. * The operation resulted in an error.
31101    ///
31102    /// Sets the *filter* query property to the given value.
31103    pub fn filter(
31104        mut self,
31105        new_value: &str,
31106    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
31107        self._filter = Some(new_value.to_string());
31108        self
31109    }
31110    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31111    /// while executing the actual API request.
31112    ///
31113    /// ````text
31114    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31115    /// ````
31116    ///
31117    /// Sets the *delegate* property to the given value.
31118    pub fn delegate(
31119        mut self,
31120        new_value: &'a mut dyn common::Delegate,
31121    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
31122        self._delegate = Some(new_value);
31123        self
31124    }
31125
31126    /// Set any additional parameter of the query string used in the request.
31127    /// It should be used to set parameters which are not yet available through their own
31128    /// setters.
31129    ///
31130    /// Please note that this method must not be used to set any of the known parameters
31131    /// which have their own setter method. If done anyway, the request will fail.
31132    ///
31133    /// # Additional Parameters
31134    ///
31135    /// * *$.xgafv* (query-string) - V1 error format.
31136    /// * *access_token* (query-string) - OAuth access token.
31137    /// * *alt* (query-string) - Data format for response.
31138    /// * *callback* (query-string) - JSONP
31139    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31140    /// * *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.
31141    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31142    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31143    /// * *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.
31144    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31145    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31146    pub fn param<T>(
31147        mut self,
31148        name: T,
31149        value: T,
31150    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C>
31151    where
31152        T: AsRef<str>,
31153    {
31154        self._additional_params
31155            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31156        self
31157    }
31158
31159    /// Identifies the authorization scope for the method you are building.
31160    ///
31161    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31162    /// [`Scope::CloudPlatform`].
31163    ///
31164    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31165    /// tokens for more than one scope.
31166    ///
31167    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31168    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31169    /// sufficient, a read-write scope will do as well.
31170    pub fn add_scope<St>(
31171        mut self,
31172        scope: St,
31173    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C>
31174    where
31175        St: AsRef<str>,
31176    {
31177        self._scopes.insert(String::from(scope.as_ref()));
31178        self
31179    }
31180    /// Identifies the authorization scope(s) for the method you are building.
31181    ///
31182    /// See [`Self::add_scope()`] for details.
31183    pub fn add_scopes<I, St>(
31184        mut self,
31185        scopes: I,
31186    ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C>
31187    where
31188        I: IntoIterator<Item = St>,
31189        St: AsRef<str>,
31190    {
31191        self._scopes
31192            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31193        self
31194    }
31195
31196    /// Removes all scopes, and no default scope will be used either.
31197    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31198    /// for details).
31199    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
31200        self._scopes.clear();
31201        self
31202    }
31203}
31204
31205/// 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`.
31206///
31207/// A builder for the *instances.instancePartitions.operations.cancel* method supported by a *project* resource.
31208/// It is not used directly, but through a [`ProjectMethods`] instance.
31209///
31210/// # Example
31211///
31212/// Instantiate a resource method builder
31213///
31214/// ```test_harness,no_run
31215/// # extern crate hyper;
31216/// # extern crate hyper_rustls;
31217/// # extern crate google_spanner1 as spanner1;
31218/// # async fn dox() {
31219/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31220///
31221/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31222/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31223/// #     .with_native_roots()
31224/// #     .unwrap()
31225/// #     .https_only()
31226/// #     .enable_http2()
31227/// #     .build();
31228///
31229/// # let executor = hyper_util::rt::TokioExecutor::new();
31230/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31231/// #     secret,
31232/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31233/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
31234/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
31235/// #     ),
31236/// # ).build().await.unwrap();
31237///
31238/// # let client = hyper_util::client::legacy::Client::builder(
31239/// #     hyper_util::rt::TokioExecutor::new()
31240/// # )
31241/// # .build(
31242/// #     hyper_rustls::HttpsConnectorBuilder::new()
31243/// #         .with_native_roots()
31244/// #         .unwrap()
31245/// #         .https_or_http()
31246/// #         .enable_http2()
31247/// #         .build()
31248/// # );
31249/// # let mut hub = Spanner::new(client, auth);
31250/// // You can configure optional parameters by calling the respective setters at will, and
31251/// // execute the final call using `doit()`.
31252/// // Values shown here are possibly random and not representative !
31253/// let result = hub.projects().instances_instance_partitions_operations_cancel("name")
31254///              .doit().await;
31255/// # }
31256/// ```
31257pub struct ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
31258where
31259    C: 'a,
31260{
31261    hub: &'a Spanner<C>,
31262    _name: String,
31263    _delegate: Option<&'a mut dyn common::Delegate>,
31264    _additional_params: HashMap<String, String>,
31265    _scopes: BTreeSet<String>,
31266}
31267
31268impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {}
31269
31270impl<'a, C> ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
31271where
31272    C: common::Connector,
31273{
31274    /// Perform the operation you have build so far.
31275    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
31276        use std::borrow::Cow;
31277        use std::io::{Read, Seek};
31278
31279        use common::{url::Params, ToParts};
31280        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31281
31282        let mut dd = common::DefaultDelegate;
31283        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31284        dlg.begin(common::MethodInfo {
31285            id: "spanner.projects.instances.instancePartitions.operations.cancel",
31286            http_method: hyper::Method::POST,
31287        });
31288
31289        for &field in ["alt", "name"].iter() {
31290            if self._additional_params.contains_key(field) {
31291                dlg.finished(false);
31292                return Err(common::Error::FieldClash(field));
31293            }
31294        }
31295
31296        let mut params = Params::with_capacity(3 + self._additional_params.len());
31297        params.push("name", self._name);
31298
31299        params.extend(self._additional_params.iter());
31300
31301        params.push("alt", "json");
31302        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
31303        if self._scopes.is_empty() {
31304            self._scopes
31305                .insert(Scope::CloudPlatform.as_ref().to_string());
31306        }
31307
31308        #[allow(clippy::single_element_loop)]
31309        for &(find_this, param_name) in [("{+name}", "name")].iter() {
31310            url = params.uri_replacement(url, param_name, find_this, true);
31311        }
31312        {
31313            let to_remove = ["name"];
31314            params.remove_params(&to_remove);
31315        }
31316
31317        let url = params.parse_with_url(&url);
31318
31319        loop {
31320            let token = match self
31321                .hub
31322                .auth
31323                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31324                .await
31325            {
31326                Ok(token) => token,
31327                Err(e) => match dlg.token(e) {
31328                    Ok(token) => token,
31329                    Err(e) => {
31330                        dlg.finished(false);
31331                        return Err(common::Error::MissingToken(e));
31332                    }
31333                },
31334            };
31335            let mut req_result = {
31336                let client = &self.hub.client;
31337                dlg.pre_request();
31338                let mut req_builder = hyper::Request::builder()
31339                    .method(hyper::Method::POST)
31340                    .uri(url.as_str())
31341                    .header(USER_AGENT, self.hub._user_agent.clone());
31342
31343                if let Some(token) = token.as_ref() {
31344                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31345                }
31346
31347                let request = req_builder
31348                    .header(CONTENT_LENGTH, 0_u64)
31349                    .body(common::to_body::<String>(None));
31350
31351                client.request(request.unwrap()).await
31352            };
31353
31354            match req_result {
31355                Err(err) => {
31356                    if let common::Retry::After(d) = dlg.http_error(&err) {
31357                        sleep(d).await;
31358                        continue;
31359                    }
31360                    dlg.finished(false);
31361                    return Err(common::Error::HttpError(err));
31362                }
31363                Ok(res) => {
31364                    let (mut parts, body) = res.into_parts();
31365                    let mut body = common::Body::new(body);
31366                    if !parts.status.is_success() {
31367                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31368                        let error = serde_json::from_str(&common::to_string(&bytes));
31369                        let response = common::to_response(parts, bytes.into());
31370
31371                        if let common::Retry::After(d) =
31372                            dlg.http_failure(&response, error.as_ref().ok())
31373                        {
31374                            sleep(d).await;
31375                            continue;
31376                        }
31377
31378                        dlg.finished(false);
31379
31380                        return Err(match error {
31381                            Ok(value) => common::Error::BadRequest(value),
31382                            _ => common::Error::Failure(response),
31383                        });
31384                    }
31385                    let response = {
31386                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31387                        let encoded = common::to_string(&bytes);
31388                        match serde_json::from_str(&encoded) {
31389                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31390                            Err(error) => {
31391                                dlg.response_json_decode_error(&encoded, &error);
31392                                return Err(common::Error::JsonDecodeError(
31393                                    encoded.to_string(),
31394                                    error,
31395                                ));
31396                            }
31397                        }
31398                    };
31399
31400                    dlg.finished(true);
31401                    return Ok(response);
31402                }
31403            }
31404        }
31405    }
31406
31407    /// The name of the operation resource to be cancelled.
31408    ///
31409    /// Sets the *name* path property to the given value.
31410    ///
31411    /// Even though the property as already been set when instantiating this call,
31412    /// we provide this method for API completeness.
31413    pub fn name(
31414        mut self,
31415        new_value: &str,
31416    ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {
31417        self._name = new_value.to_string();
31418        self
31419    }
31420    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31421    /// while executing the actual API request.
31422    ///
31423    /// ````text
31424    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31425    /// ````
31426    ///
31427    /// Sets the *delegate* property to the given value.
31428    pub fn delegate(
31429        mut self,
31430        new_value: &'a mut dyn common::Delegate,
31431    ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {
31432        self._delegate = Some(new_value);
31433        self
31434    }
31435
31436    /// Set any additional parameter of the query string used in the request.
31437    /// It should be used to set parameters which are not yet available through their own
31438    /// setters.
31439    ///
31440    /// Please note that this method must not be used to set any of the known parameters
31441    /// which have their own setter method. If done anyway, the request will fail.
31442    ///
31443    /// # Additional Parameters
31444    ///
31445    /// * *$.xgafv* (query-string) - V1 error format.
31446    /// * *access_token* (query-string) - OAuth access token.
31447    /// * *alt* (query-string) - Data format for response.
31448    /// * *callback* (query-string) - JSONP
31449    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31450    /// * *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.
31451    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31452    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31453    /// * *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.
31454    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31455    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31456    pub fn param<T>(
31457        mut self,
31458        name: T,
31459        value: T,
31460    ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
31461    where
31462        T: AsRef<str>,
31463    {
31464        self._additional_params
31465            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31466        self
31467    }
31468
31469    /// Identifies the authorization scope for the method you are building.
31470    ///
31471    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31472    /// [`Scope::CloudPlatform`].
31473    ///
31474    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31475    /// tokens for more than one scope.
31476    ///
31477    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31478    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31479    /// sufficient, a read-write scope will do as well.
31480    pub fn add_scope<St>(
31481        mut self,
31482        scope: St,
31483    ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
31484    where
31485        St: AsRef<str>,
31486    {
31487        self._scopes.insert(String::from(scope.as_ref()));
31488        self
31489    }
31490    /// Identifies the authorization scope(s) for the method you are building.
31491    ///
31492    /// See [`Self::add_scope()`] for details.
31493    pub fn add_scopes<I, St>(
31494        mut self,
31495        scopes: I,
31496    ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
31497    where
31498        I: IntoIterator<Item = St>,
31499        St: AsRef<str>,
31500    {
31501        self._scopes
31502            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31503        self
31504    }
31505
31506    /// Removes all scopes, and no default scope will be used either.
31507    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31508    /// for details).
31509    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {
31510        self._scopes.clear();
31511        self
31512    }
31513}
31514
31515/// 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`.
31516///
31517/// A builder for the *instances.instancePartitions.operations.delete* method supported by a *project* resource.
31518/// It is not used directly, but through a [`ProjectMethods`] instance.
31519///
31520/// # Example
31521///
31522/// Instantiate a resource method builder
31523///
31524/// ```test_harness,no_run
31525/// # extern crate hyper;
31526/// # extern crate hyper_rustls;
31527/// # extern crate google_spanner1 as spanner1;
31528/// # async fn dox() {
31529/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31530///
31531/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31532/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31533/// #     .with_native_roots()
31534/// #     .unwrap()
31535/// #     .https_only()
31536/// #     .enable_http2()
31537/// #     .build();
31538///
31539/// # let executor = hyper_util::rt::TokioExecutor::new();
31540/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31541/// #     secret,
31542/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31543/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
31544/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
31545/// #     ),
31546/// # ).build().await.unwrap();
31547///
31548/// # let client = hyper_util::client::legacy::Client::builder(
31549/// #     hyper_util::rt::TokioExecutor::new()
31550/// # )
31551/// # .build(
31552/// #     hyper_rustls::HttpsConnectorBuilder::new()
31553/// #         .with_native_roots()
31554/// #         .unwrap()
31555/// #         .https_or_http()
31556/// #         .enable_http2()
31557/// #         .build()
31558/// # );
31559/// # let mut hub = Spanner::new(client, auth);
31560/// // You can configure optional parameters by calling the respective setters at will, and
31561/// // execute the final call using `doit()`.
31562/// // Values shown here are possibly random and not representative !
31563/// let result = hub.projects().instances_instance_partitions_operations_delete("name")
31564///              .doit().await;
31565/// # }
31566/// ```
31567pub struct ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
31568where
31569    C: 'a,
31570{
31571    hub: &'a Spanner<C>,
31572    _name: String,
31573    _delegate: Option<&'a mut dyn common::Delegate>,
31574    _additional_params: HashMap<String, String>,
31575    _scopes: BTreeSet<String>,
31576}
31577
31578impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {}
31579
31580impl<'a, C> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
31581where
31582    C: common::Connector,
31583{
31584    /// Perform the operation you have build so far.
31585    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
31586        use std::borrow::Cow;
31587        use std::io::{Read, Seek};
31588
31589        use common::{url::Params, ToParts};
31590        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31591
31592        let mut dd = common::DefaultDelegate;
31593        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31594        dlg.begin(common::MethodInfo {
31595            id: "spanner.projects.instances.instancePartitions.operations.delete",
31596            http_method: hyper::Method::DELETE,
31597        });
31598
31599        for &field in ["alt", "name"].iter() {
31600            if self._additional_params.contains_key(field) {
31601                dlg.finished(false);
31602                return Err(common::Error::FieldClash(field));
31603            }
31604        }
31605
31606        let mut params = Params::with_capacity(3 + self._additional_params.len());
31607        params.push("name", self._name);
31608
31609        params.extend(self._additional_params.iter());
31610
31611        params.push("alt", "json");
31612        let mut url = self.hub._base_url.clone() + "v1/{+name}";
31613        if self._scopes.is_empty() {
31614            self._scopes
31615                .insert(Scope::CloudPlatform.as_ref().to_string());
31616        }
31617
31618        #[allow(clippy::single_element_loop)]
31619        for &(find_this, param_name) in [("{+name}", "name")].iter() {
31620            url = params.uri_replacement(url, param_name, find_this, true);
31621        }
31622        {
31623            let to_remove = ["name"];
31624            params.remove_params(&to_remove);
31625        }
31626
31627        let url = params.parse_with_url(&url);
31628
31629        loop {
31630            let token = match self
31631                .hub
31632                .auth
31633                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31634                .await
31635            {
31636                Ok(token) => token,
31637                Err(e) => match dlg.token(e) {
31638                    Ok(token) => token,
31639                    Err(e) => {
31640                        dlg.finished(false);
31641                        return Err(common::Error::MissingToken(e));
31642                    }
31643                },
31644            };
31645            let mut req_result = {
31646                let client = &self.hub.client;
31647                dlg.pre_request();
31648                let mut req_builder = hyper::Request::builder()
31649                    .method(hyper::Method::DELETE)
31650                    .uri(url.as_str())
31651                    .header(USER_AGENT, self.hub._user_agent.clone());
31652
31653                if let Some(token) = token.as_ref() {
31654                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31655                }
31656
31657                let request = req_builder
31658                    .header(CONTENT_LENGTH, 0_u64)
31659                    .body(common::to_body::<String>(None));
31660
31661                client.request(request.unwrap()).await
31662            };
31663
31664            match req_result {
31665                Err(err) => {
31666                    if let common::Retry::After(d) = dlg.http_error(&err) {
31667                        sleep(d).await;
31668                        continue;
31669                    }
31670                    dlg.finished(false);
31671                    return Err(common::Error::HttpError(err));
31672                }
31673                Ok(res) => {
31674                    let (mut parts, body) = res.into_parts();
31675                    let mut body = common::Body::new(body);
31676                    if !parts.status.is_success() {
31677                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31678                        let error = serde_json::from_str(&common::to_string(&bytes));
31679                        let response = common::to_response(parts, bytes.into());
31680
31681                        if let common::Retry::After(d) =
31682                            dlg.http_failure(&response, error.as_ref().ok())
31683                        {
31684                            sleep(d).await;
31685                            continue;
31686                        }
31687
31688                        dlg.finished(false);
31689
31690                        return Err(match error {
31691                            Ok(value) => common::Error::BadRequest(value),
31692                            _ => common::Error::Failure(response),
31693                        });
31694                    }
31695                    let response = {
31696                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31697                        let encoded = common::to_string(&bytes);
31698                        match serde_json::from_str(&encoded) {
31699                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31700                            Err(error) => {
31701                                dlg.response_json_decode_error(&encoded, &error);
31702                                return Err(common::Error::JsonDecodeError(
31703                                    encoded.to_string(),
31704                                    error,
31705                                ));
31706                            }
31707                        }
31708                    };
31709
31710                    dlg.finished(true);
31711                    return Ok(response);
31712                }
31713            }
31714        }
31715    }
31716
31717    /// The name of the operation resource to be deleted.
31718    ///
31719    /// Sets the *name* path property to the given value.
31720    ///
31721    /// Even though the property as already been set when instantiating this call,
31722    /// we provide this method for API completeness.
31723    pub fn name(
31724        mut self,
31725        new_value: &str,
31726    ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {
31727        self._name = new_value.to_string();
31728        self
31729    }
31730    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31731    /// while executing the actual API request.
31732    ///
31733    /// ````text
31734    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31735    /// ````
31736    ///
31737    /// Sets the *delegate* property to the given value.
31738    pub fn delegate(
31739        mut self,
31740        new_value: &'a mut dyn common::Delegate,
31741    ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {
31742        self._delegate = Some(new_value);
31743        self
31744    }
31745
31746    /// Set any additional parameter of the query string used in the request.
31747    /// It should be used to set parameters which are not yet available through their own
31748    /// setters.
31749    ///
31750    /// Please note that this method must not be used to set any of the known parameters
31751    /// which have their own setter method. If done anyway, the request will fail.
31752    ///
31753    /// # Additional Parameters
31754    ///
31755    /// * *$.xgafv* (query-string) - V1 error format.
31756    /// * *access_token* (query-string) - OAuth access token.
31757    /// * *alt* (query-string) - Data format for response.
31758    /// * *callback* (query-string) - JSONP
31759    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31760    /// * *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.
31761    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31762    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31763    /// * *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.
31764    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31765    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31766    pub fn param<T>(
31767        mut self,
31768        name: T,
31769        value: T,
31770    ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
31771    where
31772        T: AsRef<str>,
31773    {
31774        self._additional_params
31775            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31776        self
31777    }
31778
31779    /// Identifies the authorization scope for the method you are building.
31780    ///
31781    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31782    /// [`Scope::CloudPlatform`].
31783    ///
31784    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31785    /// tokens for more than one scope.
31786    ///
31787    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31788    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31789    /// sufficient, a read-write scope will do as well.
31790    pub fn add_scope<St>(
31791        mut self,
31792        scope: St,
31793    ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
31794    where
31795        St: AsRef<str>,
31796    {
31797        self._scopes.insert(String::from(scope.as_ref()));
31798        self
31799    }
31800    /// Identifies the authorization scope(s) for the method you are building.
31801    ///
31802    /// See [`Self::add_scope()`] for details.
31803    pub fn add_scopes<I, St>(
31804        mut self,
31805        scopes: I,
31806    ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
31807    where
31808        I: IntoIterator<Item = St>,
31809        St: AsRef<str>,
31810    {
31811        self._scopes
31812            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31813        self
31814    }
31815
31816    /// Removes all scopes, and no default scope will be used either.
31817    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31818    /// for details).
31819    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {
31820        self._scopes.clear();
31821        self
31822    }
31823}
31824
31825/// 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.
31826///
31827/// A builder for the *instances.instancePartitions.operations.get* method supported by a *project* resource.
31828/// It is not used directly, but through a [`ProjectMethods`] instance.
31829///
31830/// # Example
31831///
31832/// Instantiate a resource method builder
31833///
31834/// ```test_harness,no_run
31835/// # extern crate hyper;
31836/// # extern crate hyper_rustls;
31837/// # extern crate google_spanner1 as spanner1;
31838/// # async fn dox() {
31839/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31840///
31841/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31842/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31843/// #     .with_native_roots()
31844/// #     .unwrap()
31845/// #     .https_only()
31846/// #     .enable_http2()
31847/// #     .build();
31848///
31849/// # let executor = hyper_util::rt::TokioExecutor::new();
31850/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31851/// #     secret,
31852/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31853/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
31854/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
31855/// #     ),
31856/// # ).build().await.unwrap();
31857///
31858/// # let client = hyper_util::client::legacy::Client::builder(
31859/// #     hyper_util::rt::TokioExecutor::new()
31860/// # )
31861/// # .build(
31862/// #     hyper_rustls::HttpsConnectorBuilder::new()
31863/// #         .with_native_roots()
31864/// #         .unwrap()
31865/// #         .https_or_http()
31866/// #         .enable_http2()
31867/// #         .build()
31868/// # );
31869/// # let mut hub = Spanner::new(client, auth);
31870/// // You can configure optional parameters by calling the respective setters at will, and
31871/// // execute the final call using `doit()`.
31872/// // Values shown here are possibly random and not representative !
31873/// let result = hub.projects().instances_instance_partitions_operations_get("name")
31874///              .doit().await;
31875/// # }
31876/// ```
31877pub struct ProjectInstanceInstancePartitionOperationGetCall<'a, C>
31878where
31879    C: 'a,
31880{
31881    hub: &'a Spanner<C>,
31882    _name: String,
31883    _delegate: Option<&'a mut dyn common::Delegate>,
31884    _additional_params: HashMap<String, String>,
31885    _scopes: BTreeSet<String>,
31886}
31887
31888impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationGetCall<'a, C> {}
31889
31890impl<'a, C> ProjectInstanceInstancePartitionOperationGetCall<'a, C>
31891where
31892    C: common::Connector,
31893{
31894    /// Perform the operation you have build so far.
31895    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
31896        use std::borrow::Cow;
31897        use std::io::{Read, Seek};
31898
31899        use common::{url::Params, ToParts};
31900        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31901
31902        let mut dd = common::DefaultDelegate;
31903        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31904        dlg.begin(common::MethodInfo {
31905            id: "spanner.projects.instances.instancePartitions.operations.get",
31906            http_method: hyper::Method::GET,
31907        });
31908
31909        for &field in ["alt", "name"].iter() {
31910            if self._additional_params.contains_key(field) {
31911                dlg.finished(false);
31912                return Err(common::Error::FieldClash(field));
31913            }
31914        }
31915
31916        let mut params = Params::with_capacity(3 + self._additional_params.len());
31917        params.push("name", self._name);
31918
31919        params.extend(self._additional_params.iter());
31920
31921        params.push("alt", "json");
31922        let mut url = self.hub._base_url.clone() + "v1/{+name}";
31923        if self._scopes.is_empty() {
31924            self._scopes
31925                .insert(Scope::CloudPlatform.as_ref().to_string());
31926        }
31927
31928        #[allow(clippy::single_element_loop)]
31929        for &(find_this, param_name) in [("{+name}", "name")].iter() {
31930            url = params.uri_replacement(url, param_name, find_this, true);
31931        }
31932        {
31933            let to_remove = ["name"];
31934            params.remove_params(&to_remove);
31935        }
31936
31937        let url = params.parse_with_url(&url);
31938
31939        loop {
31940            let token = match self
31941                .hub
31942                .auth
31943                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31944                .await
31945            {
31946                Ok(token) => token,
31947                Err(e) => match dlg.token(e) {
31948                    Ok(token) => token,
31949                    Err(e) => {
31950                        dlg.finished(false);
31951                        return Err(common::Error::MissingToken(e));
31952                    }
31953                },
31954            };
31955            let mut req_result = {
31956                let client = &self.hub.client;
31957                dlg.pre_request();
31958                let mut req_builder = hyper::Request::builder()
31959                    .method(hyper::Method::GET)
31960                    .uri(url.as_str())
31961                    .header(USER_AGENT, self.hub._user_agent.clone());
31962
31963                if let Some(token) = token.as_ref() {
31964                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31965                }
31966
31967                let request = req_builder
31968                    .header(CONTENT_LENGTH, 0_u64)
31969                    .body(common::to_body::<String>(None));
31970
31971                client.request(request.unwrap()).await
31972            };
31973
31974            match req_result {
31975                Err(err) => {
31976                    if let common::Retry::After(d) = dlg.http_error(&err) {
31977                        sleep(d).await;
31978                        continue;
31979                    }
31980                    dlg.finished(false);
31981                    return Err(common::Error::HttpError(err));
31982                }
31983                Ok(res) => {
31984                    let (mut parts, body) = res.into_parts();
31985                    let mut body = common::Body::new(body);
31986                    if !parts.status.is_success() {
31987                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31988                        let error = serde_json::from_str(&common::to_string(&bytes));
31989                        let response = common::to_response(parts, bytes.into());
31990
31991                        if let common::Retry::After(d) =
31992                            dlg.http_failure(&response, error.as_ref().ok())
31993                        {
31994                            sleep(d).await;
31995                            continue;
31996                        }
31997
31998                        dlg.finished(false);
31999
32000                        return Err(match error {
32001                            Ok(value) => common::Error::BadRequest(value),
32002                            _ => common::Error::Failure(response),
32003                        });
32004                    }
32005                    let response = {
32006                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32007                        let encoded = common::to_string(&bytes);
32008                        match serde_json::from_str(&encoded) {
32009                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32010                            Err(error) => {
32011                                dlg.response_json_decode_error(&encoded, &error);
32012                                return Err(common::Error::JsonDecodeError(
32013                                    encoded.to_string(),
32014                                    error,
32015                                ));
32016                            }
32017                        }
32018                    };
32019
32020                    dlg.finished(true);
32021                    return Ok(response);
32022                }
32023            }
32024        }
32025    }
32026
32027    /// The name of the operation resource.
32028    ///
32029    /// Sets the *name* path property to the given value.
32030    ///
32031    /// Even though the property as already been set when instantiating this call,
32032    /// we provide this method for API completeness.
32033    pub fn name(
32034        mut self,
32035        new_value: &str,
32036    ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C> {
32037        self._name = new_value.to_string();
32038        self
32039    }
32040    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32041    /// while executing the actual API request.
32042    ///
32043    /// ````text
32044    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32045    /// ````
32046    ///
32047    /// Sets the *delegate* property to the given value.
32048    pub fn delegate(
32049        mut self,
32050        new_value: &'a mut dyn common::Delegate,
32051    ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C> {
32052        self._delegate = Some(new_value);
32053        self
32054    }
32055
32056    /// Set any additional parameter of the query string used in the request.
32057    /// It should be used to set parameters which are not yet available through their own
32058    /// setters.
32059    ///
32060    /// Please note that this method must not be used to set any of the known parameters
32061    /// which have their own setter method. If done anyway, the request will fail.
32062    ///
32063    /// # Additional Parameters
32064    ///
32065    /// * *$.xgafv* (query-string) - V1 error format.
32066    /// * *access_token* (query-string) - OAuth access token.
32067    /// * *alt* (query-string) - Data format for response.
32068    /// * *callback* (query-string) - JSONP
32069    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32070    /// * *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.
32071    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32072    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32073    /// * *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.
32074    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32075    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32076    pub fn param<T>(
32077        mut self,
32078        name: T,
32079        value: T,
32080    ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C>
32081    where
32082        T: AsRef<str>,
32083    {
32084        self._additional_params
32085            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32086        self
32087    }
32088
32089    /// Identifies the authorization scope for the method you are building.
32090    ///
32091    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32092    /// [`Scope::CloudPlatform`].
32093    ///
32094    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32095    /// tokens for more than one scope.
32096    ///
32097    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32098    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32099    /// sufficient, a read-write scope will do as well.
32100    pub fn add_scope<St>(
32101        mut self,
32102        scope: St,
32103    ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C>
32104    where
32105        St: AsRef<str>,
32106    {
32107        self._scopes.insert(String::from(scope.as_ref()));
32108        self
32109    }
32110    /// Identifies the authorization scope(s) for the method you are building.
32111    ///
32112    /// See [`Self::add_scope()`] for details.
32113    pub fn add_scopes<I, St>(
32114        mut self,
32115        scopes: I,
32116    ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C>
32117    where
32118        I: IntoIterator<Item = St>,
32119        St: AsRef<str>,
32120    {
32121        self._scopes
32122            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32123        self
32124    }
32125
32126    /// Removes all scopes, and no default scope will be used either.
32127    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32128    /// for details).
32129    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C> {
32130        self._scopes.clear();
32131        self
32132    }
32133}
32134
32135/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
32136///
32137/// A builder for the *instances.instancePartitions.operations.list* method supported by a *project* resource.
32138/// It is not used directly, but through a [`ProjectMethods`] instance.
32139///
32140/// # Example
32141///
32142/// Instantiate a resource method builder
32143///
32144/// ```test_harness,no_run
32145/// # extern crate hyper;
32146/// # extern crate hyper_rustls;
32147/// # extern crate google_spanner1 as spanner1;
32148/// # async fn dox() {
32149/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32150///
32151/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32152/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32153/// #     .with_native_roots()
32154/// #     .unwrap()
32155/// #     .https_only()
32156/// #     .enable_http2()
32157/// #     .build();
32158///
32159/// # let executor = hyper_util::rt::TokioExecutor::new();
32160/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32161/// #     secret,
32162/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32163/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
32164/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
32165/// #     ),
32166/// # ).build().await.unwrap();
32167///
32168/// # let client = hyper_util::client::legacy::Client::builder(
32169/// #     hyper_util::rt::TokioExecutor::new()
32170/// # )
32171/// # .build(
32172/// #     hyper_rustls::HttpsConnectorBuilder::new()
32173/// #         .with_native_roots()
32174/// #         .unwrap()
32175/// #         .https_or_http()
32176/// #         .enable_http2()
32177/// #         .build()
32178/// # );
32179/// # let mut hub = Spanner::new(client, auth);
32180/// // You can configure optional parameters by calling the respective setters at will, and
32181/// // execute the final call using `doit()`.
32182/// // Values shown here are possibly random and not representative !
32183/// let result = hub.projects().instances_instance_partitions_operations_list("name")
32184///              .return_partial_success(true)
32185///              .page_token("sea")
32186///              .page_size(-74)
32187///              .filter("At")
32188///              .doit().await;
32189/// # }
32190/// ```
32191pub struct ProjectInstanceInstancePartitionOperationListCall1<'a, C>
32192where
32193    C: 'a,
32194{
32195    hub: &'a Spanner<C>,
32196    _name: String,
32197    _return_partial_success: Option<bool>,
32198    _page_token: Option<String>,
32199    _page_size: Option<i32>,
32200    _filter: Option<String>,
32201    _delegate: Option<&'a mut dyn common::Delegate>,
32202    _additional_params: HashMap<String, String>,
32203    _scopes: BTreeSet<String>,
32204}
32205
32206impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationListCall1<'a, C> {}
32207
32208impl<'a, C> ProjectInstanceInstancePartitionOperationListCall1<'a, C>
32209where
32210    C: common::Connector,
32211{
32212    /// Perform the operation you have build so far.
32213    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
32214        use std::borrow::Cow;
32215        use std::io::{Read, Seek};
32216
32217        use common::{url::Params, ToParts};
32218        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32219
32220        let mut dd = common::DefaultDelegate;
32221        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32222        dlg.begin(common::MethodInfo {
32223            id: "spanner.projects.instances.instancePartitions.operations.list",
32224            http_method: hyper::Method::GET,
32225        });
32226
32227        for &field in [
32228            "alt",
32229            "name",
32230            "returnPartialSuccess",
32231            "pageToken",
32232            "pageSize",
32233            "filter",
32234        ]
32235        .iter()
32236        {
32237            if self._additional_params.contains_key(field) {
32238                dlg.finished(false);
32239                return Err(common::Error::FieldClash(field));
32240            }
32241        }
32242
32243        let mut params = Params::with_capacity(7 + self._additional_params.len());
32244        params.push("name", self._name);
32245        if let Some(value) = self._return_partial_success.as_ref() {
32246            params.push("returnPartialSuccess", value.to_string());
32247        }
32248        if let Some(value) = self._page_token.as_ref() {
32249            params.push("pageToken", value);
32250        }
32251        if let Some(value) = self._page_size.as_ref() {
32252            params.push("pageSize", value.to_string());
32253        }
32254        if let Some(value) = self._filter.as_ref() {
32255            params.push("filter", value);
32256        }
32257
32258        params.extend(self._additional_params.iter());
32259
32260        params.push("alt", "json");
32261        let mut url = self.hub._base_url.clone() + "v1/{+name}";
32262        if self._scopes.is_empty() {
32263            self._scopes
32264                .insert(Scope::CloudPlatform.as_ref().to_string());
32265        }
32266
32267        #[allow(clippy::single_element_loop)]
32268        for &(find_this, param_name) in [("{+name}", "name")].iter() {
32269            url = params.uri_replacement(url, param_name, find_this, true);
32270        }
32271        {
32272            let to_remove = ["name"];
32273            params.remove_params(&to_remove);
32274        }
32275
32276        let url = params.parse_with_url(&url);
32277
32278        loop {
32279            let token = match self
32280                .hub
32281                .auth
32282                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32283                .await
32284            {
32285                Ok(token) => token,
32286                Err(e) => match dlg.token(e) {
32287                    Ok(token) => token,
32288                    Err(e) => {
32289                        dlg.finished(false);
32290                        return Err(common::Error::MissingToken(e));
32291                    }
32292                },
32293            };
32294            let mut req_result = {
32295                let client = &self.hub.client;
32296                dlg.pre_request();
32297                let mut req_builder = hyper::Request::builder()
32298                    .method(hyper::Method::GET)
32299                    .uri(url.as_str())
32300                    .header(USER_AGENT, self.hub._user_agent.clone());
32301
32302                if let Some(token) = token.as_ref() {
32303                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32304                }
32305
32306                let request = req_builder
32307                    .header(CONTENT_LENGTH, 0_u64)
32308                    .body(common::to_body::<String>(None));
32309
32310                client.request(request.unwrap()).await
32311            };
32312
32313            match req_result {
32314                Err(err) => {
32315                    if let common::Retry::After(d) = dlg.http_error(&err) {
32316                        sleep(d).await;
32317                        continue;
32318                    }
32319                    dlg.finished(false);
32320                    return Err(common::Error::HttpError(err));
32321                }
32322                Ok(res) => {
32323                    let (mut parts, body) = res.into_parts();
32324                    let mut body = common::Body::new(body);
32325                    if !parts.status.is_success() {
32326                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32327                        let error = serde_json::from_str(&common::to_string(&bytes));
32328                        let response = common::to_response(parts, bytes.into());
32329
32330                        if let common::Retry::After(d) =
32331                            dlg.http_failure(&response, error.as_ref().ok())
32332                        {
32333                            sleep(d).await;
32334                            continue;
32335                        }
32336
32337                        dlg.finished(false);
32338
32339                        return Err(match error {
32340                            Ok(value) => common::Error::BadRequest(value),
32341                            _ => common::Error::Failure(response),
32342                        });
32343                    }
32344                    let response = {
32345                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32346                        let encoded = common::to_string(&bytes);
32347                        match serde_json::from_str(&encoded) {
32348                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32349                            Err(error) => {
32350                                dlg.response_json_decode_error(&encoded, &error);
32351                                return Err(common::Error::JsonDecodeError(
32352                                    encoded.to_string(),
32353                                    error,
32354                                ));
32355                            }
32356                        }
32357                    };
32358
32359                    dlg.finished(true);
32360                    return Ok(response);
32361                }
32362            }
32363        }
32364    }
32365
32366    /// The name of the operation's parent resource.
32367    ///
32368    /// Sets the *name* path property to the given value.
32369    ///
32370    /// Even though the property as already been set when instantiating this call,
32371    /// we provide this method for API completeness.
32372    pub fn name(
32373        mut self,
32374        new_value: &str,
32375    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
32376        self._name = new_value.to_string();
32377        self
32378    }
32379    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
32380    ///
32381    /// Sets the *return partial success* query property to the given value.
32382    pub fn return_partial_success(
32383        mut self,
32384        new_value: bool,
32385    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
32386        self._return_partial_success = Some(new_value);
32387        self
32388    }
32389    /// The standard list page token.
32390    ///
32391    /// Sets the *page token* query property to the given value.
32392    pub fn page_token(
32393        mut self,
32394        new_value: &str,
32395    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
32396        self._page_token = Some(new_value.to_string());
32397        self
32398    }
32399    /// The standard list page size.
32400    ///
32401    /// Sets the *page size* query property to the given value.
32402    pub fn page_size(
32403        mut self,
32404        new_value: i32,
32405    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
32406        self._page_size = Some(new_value);
32407        self
32408    }
32409    /// The standard list filter.
32410    ///
32411    /// Sets the *filter* query property to the given value.
32412    pub fn filter(
32413        mut self,
32414        new_value: &str,
32415    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
32416        self._filter = Some(new_value.to_string());
32417        self
32418    }
32419    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32420    /// while executing the actual API request.
32421    ///
32422    /// ````text
32423    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32424    /// ````
32425    ///
32426    /// Sets the *delegate* property to the given value.
32427    pub fn delegate(
32428        mut self,
32429        new_value: &'a mut dyn common::Delegate,
32430    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
32431        self._delegate = Some(new_value);
32432        self
32433    }
32434
32435    /// Set any additional parameter of the query string used in the request.
32436    /// It should be used to set parameters which are not yet available through their own
32437    /// setters.
32438    ///
32439    /// Please note that this method must not be used to set any of the known parameters
32440    /// which have their own setter method. If done anyway, the request will fail.
32441    ///
32442    /// # Additional Parameters
32443    ///
32444    /// * *$.xgafv* (query-string) - V1 error format.
32445    /// * *access_token* (query-string) - OAuth access token.
32446    /// * *alt* (query-string) - Data format for response.
32447    /// * *callback* (query-string) - JSONP
32448    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32449    /// * *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.
32450    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32451    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32452    /// * *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.
32453    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32454    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32455    pub fn param<T>(
32456        mut self,
32457        name: T,
32458        value: T,
32459    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C>
32460    where
32461        T: AsRef<str>,
32462    {
32463        self._additional_params
32464            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32465        self
32466    }
32467
32468    /// Identifies the authorization scope for the method you are building.
32469    ///
32470    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32471    /// [`Scope::CloudPlatform`].
32472    ///
32473    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32474    /// tokens for more than one scope.
32475    ///
32476    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32477    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32478    /// sufficient, a read-write scope will do as well.
32479    pub fn add_scope<St>(
32480        mut self,
32481        scope: St,
32482    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C>
32483    where
32484        St: AsRef<str>,
32485    {
32486        self._scopes.insert(String::from(scope.as_ref()));
32487        self
32488    }
32489    /// Identifies the authorization scope(s) for the method you are building.
32490    ///
32491    /// See [`Self::add_scope()`] for details.
32492    pub fn add_scopes<I, St>(
32493        mut self,
32494        scopes: I,
32495    ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C>
32496    where
32497        I: IntoIterator<Item = St>,
32498        St: AsRef<str>,
32499    {
32500        self._scopes
32501            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32502        self
32503    }
32504
32505    /// Removes all scopes, and no default scope will be used either.
32506    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32507    /// for details).
32508    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
32509        self._scopes.clear();
32510        self
32511    }
32512}
32513
32514/// Creates an instance partition and begins preparing it to be used. The returned long-running operation can be used to track the progress of preparing the new instance partition. The instance partition name is assigned by the caller. If the named instance partition already exists, `CreateInstancePartition` returns `ALREADY_EXISTS`. Immediately upon completion of this request: * The instance partition is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`. Until completion of the returned operation: * Cancelling the operation renders the instance partition immediately unreadable via the API. * The instance partition can be deleted. * All other attempts to modify the instance partition are rejected. Upon completion of the returned operation: * Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can start using this instance partition. * The instance partition's allocated resource levels are readable via the API. * The instance partition's state becomes `READY`. The returned long-running operation will have a name of the format `/operations/` and can be used to track creation of the instance partition. The metadata field type is CreateInstancePartitionMetadata. The response field type is InstancePartition, if successful.
32515///
32516/// A builder for the *instances.instancePartitions.create* method supported by a *project* resource.
32517/// It is not used directly, but through a [`ProjectMethods`] instance.
32518///
32519/// # Example
32520///
32521/// Instantiate a resource method builder
32522///
32523/// ```test_harness,no_run
32524/// # extern crate hyper;
32525/// # extern crate hyper_rustls;
32526/// # extern crate google_spanner1 as spanner1;
32527/// use spanner1::api::CreateInstancePartitionRequest;
32528/// # async fn dox() {
32529/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32530///
32531/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32532/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32533/// #     .with_native_roots()
32534/// #     .unwrap()
32535/// #     .https_only()
32536/// #     .enable_http2()
32537/// #     .build();
32538///
32539/// # let executor = hyper_util::rt::TokioExecutor::new();
32540/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32541/// #     secret,
32542/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32543/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
32544/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
32545/// #     ),
32546/// # ).build().await.unwrap();
32547///
32548/// # let client = hyper_util::client::legacy::Client::builder(
32549/// #     hyper_util::rt::TokioExecutor::new()
32550/// # )
32551/// # .build(
32552/// #     hyper_rustls::HttpsConnectorBuilder::new()
32553/// #         .with_native_roots()
32554/// #         .unwrap()
32555/// #         .https_or_http()
32556/// #         .enable_http2()
32557/// #         .build()
32558/// # );
32559/// # let mut hub = Spanner::new(client, auth);
32560/// // As the method needs a request, you would usually fill it with the desired information
32561/// // into the respective structure. Some of the parts shown here might not be applicable !
32562/// // Values shown here are possibly random and not representative !
32563/// let mut req = CreateInstancePartitionRequest::default();
32564///
32565/// // You can configure optional parameters by calling the respective setters at will, and
32566/// // execute the final call using `doit()`.
32567/// // Values shown here are possibly random and not representative !
32568/// let result = hub.projects().instances_instance_partitions_create(req, "parent")
32569///              .doit().await;
32570/// # }
32571/// ```
32572pub struct ProjectInstanceInstancePartitionCreateCall<'a, C>
32573where
32574    C: 'a,
32575{
32576    hub: &'a Spanner<C>,
32577    _request: CreateInstancePartitionRequest,
32578    _parent: String,
32579    _delegate: Option<&'a mut dyn common::Delegate>,
32580    _additional_params: HashMap<String, String>,
32581    _scopes: BTreeSet<String>,
32582}
32583
32584impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionCreateCall<'a, C> {}
32585
32586impl<'a, C> ProjectInstanceInstancePartitionCreateCall<'a, C>
32587where
32588    C: common::Connector,
32589{
32590    /// Perform the operation you have build so far.
32591    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
32592        use std::borrow::Cow;
32593        use std::io::{Read, Seek};
32594
32595        use common::{url::Params, ToParts};
32596        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32597
32598        let mut dd = common::DefaultDelegate;
32599        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32600        dlg.begin(common::MethodInfo {
32601            id: "spanner.projects.instances.instancePartitions.create",
32602            http_method: hyper::Method::POST,
32603        });
32604
32605        for &field in ["alt", "parent"].iter() {
32606            if self._additional_params.contains_key(field) {
32607                dlg.finished(false);
32608                return Err(common::Error::FieldClash(field));
32609            }
32610        }
32611
32612        let mut params = Params::with_capacity(4 + self._additional_params.len());
32613        params.push("parent", self._parent);
32614
32615        params.extend(self._additional_params.iter());
32616
32617        params.push("alt", "json");
32618        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instancePartitions";
32619        if self._scopes.is_empty() {
32620            self._scopes
32621                .insert(Scope::CloudPlatform.as_ref().to_string());
32622        }
32623
32624        #[allow(clippy::single_element_loop)]
32625        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
32626            url = params.uri_replacement(url, param_name, find_this, true);
32627        }
32628        {
32629            let to_remove = ["parent"];
32630            params.remove_params(&to_remove);
32631        }
32632
32633        let url = params.parse_with_url(&url);
32634
32635        let mut json_mime_type = mime::APPLICATION_JSON;
32636        let mut request_value_reader = {
32637            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32638            common::remove_json_null_values(&mut value);
32639            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32640            serde_json::to_writer(&mut dst, &value).unwrap();
32641            dst
32642        };
32643        let request_size = request_value_reader
32644            .seek(std::io::SeekFrom::End(0))
32645            .unwrap();
32646        request_value_reader
32647            .seek(std::io::SeekFrom::Start(0))
32648            .unwrap();
32649
32650        loop {
32651            let token = match self
32652                .hub
32653                .auth
32654                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32655                .await
32656            {
32657                Ok(token) => token,
32658                Err(e) => match dlg.token(e) {
32659                    Ok(token) => token,
32660                    Err(e) => {
32661                        dlg.finished(false);
32662                        return Err(common::Error::MissingToken(e));
32663                    }
32664                },
32665            };
32666            request_value_reader
32667                .seek(std::io::SeekFrom::Start(0))
32668                .unwrap();
32669            let mut req_result = {
32670                let client = &self.hub.client;
32671                dlg.pre_request();
32672                let mut req_builder = hyper::Request::builder()
32673                    .method(hyper::Method::POST)
32674                    .uri(url.as_str())
32675                    .header(USER_AGENT, self.hub._user_agent.clone());
32676
32677                if let Some(token) = token.as_ref() {
32678                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32679                }
32680
32681                let request = req_builder
32682                    .header(CONTENT_TYPE, json_mime_type.to_string())
32683                    .header(CONTENT_LENGTH, request_size as u64)
32684                    .body(common::to_body(
32685                        request_value_reader.get_ref().clone().into(),
32686                    ));
32687
32688                client.request(request.unwrap()).await
32689            };
32690
32691            match req_result {
32692                Err(err) => {
32693                    if let common::Retry::After(d) = dlg.http_error(&err) {
32694                        sleep(d).await;
32695                        continue;
32696                    }
32697                    dlg.finished(false);
32698                    return Err(common::Error::HttpError(err));
32699                }
32700                Ok(res) => {
32701                    let (mut parts, body) = res.into_parts();
32702                    let mut body = common::Body::new(body);
32703                    if !parts.status.is_success() {
32704                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32705                        let error = serde_json::from_str(&common::to_string(&bytes));
32706                        let response = common::to_response(parts, bytes.into());
32707
32708                        if let common::Retry::After(d) =
32709                            dlg.http_failure(&response, error.as_ref().ok())
32710                        {
32711                            sleep(d).await;
32712                            continue;
32713                        }
32714
32715                        dlg.finished(false);
32716
32717                        return Err(match error {
32718                            Ok(value) => common::Error::BadRequest(value),
32719                            _ => common::Error::Failure(response),
32720                        });
32721                    }
32722                    let response = {
32723                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32724                        let encoded = common::to_string(&bytes);
32725                        match serde_json::from_str(&encoded) {
32726                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32727                            Err(error) => {
32728                                dlg.response_json_decode_error(&encoded, &error);
32729                                return Err(common::Error::JsonDecodeError(
32730                                    encoded.to_string(),
32731                                    error,
32732                                ));
32733                            }
32734                        }
32735                    };
32736
32737                    dlg.finished(true);
32738                    return Ok(response);
32739                }
32740            }
32741        }
32742    }
32743
32744    ///
32745    /// Sets the *request* property to the given value.
32746    ///
32747    /// Even though the property as already been set when instantiating this call,
32748    /// we provide this method for API completeness.
32749    pub fn request(
32750        mut self,
32751        new_value: CreateInstancePartitionRequest,
32752    ) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
32753        self._request = new_value;
32754        self
32755    }
32756    /// Required. The name of the instance in which to create the instance partition. Values are of the form `projects//instances/`.
32757    ///
32758    /// Sets the *parent* path property to the given value.
32759    ///
32760    /// Even though the property as already been set when instantiating this call,
32761    /// we provide this method for API completeness.
32762    pub fn parent(mut self, new_value: &str) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
32763        self._parent = new_value.to_string();
32764        self
32765    }
32766    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32767    /// while executing the actual API request.
32768    ///
32769    /// ````text
32770    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32771    /// ````
32772    ///
32773    /// Sets the *delegate* property to the given value.
32774    pub fn delegate(
32775        mut self,
32776        new_value: &'a mut dyn common::Delegate,
32777    ) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
32778        self._delegate = Some(new_value);
32779        self
32780    }
32781
32782    /// Set any additional parameter of the query string used in the request.
32783    /// It should be used to set parameters which are not yet available through their own
32784    /// setters.
32785    ///
32786    /// Please note that this method must not be used to set any of the known parameters
32787    /// which have their own setter method. If done anyway, the request will fail.
32788    ///
32789    /// # Additional Parameters
32790    ///
32791    /// * *$.xgafv* (query-string) - V1 error format.
32792    /// * *access_token* (query-string) - OAuth access token.
32793    /// * *alt* (query-string) - Data format for response.
32794    /// * *callback* (query-string) - JSONP
32795    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32796    /// * *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.
32797    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32798    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32799    /// * *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.
32800    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32801    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32802    pub fn param<T>(
32803        mut self,
32804        name: T,
32805        value: T,
32806    ) -> ProjectInstanceInstancePartitionCreateCall<'a, C>
32807    where
32808        T: AsRef<str>,
32809    {
32810        self._additional_params
32811            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32812        self
32813    }
32814
32815    /// Identifies the authorization scope for the method you are building.
32816    ///
32817    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32818    /// [`Scope::CloudPlatform`].
32819    ///
32820    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32821    /// tokens for more than one scope.
32822    ///
32823    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32824    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32825    /// sufficient, a read-write scope will do as well.
32826    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionCreateCall<'a, C>
32827    where
32828        St: AsRef<str>,
32829    {
32830        self._scopes.insert(String::from(scope.as_ref()));
32831        self
32832    }
32833    /// Identifies the authorization scope(s) for the method you are building.
32834    ///
32835    /// See [`Self::add_scope()`] for details.
32836    pub fn add_scopes<I, St>(
32837        mut self,
32838        scopes: I,
32839    ) -> ProjectInstanceInstancePartitionCreateCall<'a, C>
32840    where
32841        I: IntoIterator<Item = St>,
32842        St: AsRef<str>,
32843    {
32844        self._scopes
32845            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32846        self
32847    }
32848
32849    /// Removes all scopes, and no default scope will be used either.
32850    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32851    /// for details).
32852    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
32853        self._scopes.clear();
32854        self
32855    }
32856}
32857
32858/// Deletes an existing instance partition. Requires that the instance partition is not used by any database or backup and is not the default instance partition of an instance. Authorization requires `spanner.instancePartitions.delete` permission on the resource name.
32859///
32860/// A builder for the *instances.instancePartitions.delete* method supported by a *project* resource.
32861/// It is not used directly, but through a [`ProjectMethods`] instance.
32862///
32863/// # Example
32864///
32865/// Instantiate a resource method builder
32866///
32867/// ```test_harness,no_run
32868/// # extern crate hyper;
32869/// # extern crate hyper_rustls;
32870/// # extern crate google_spanner1 as spanner1;
32871/// # async fn dox() {
32872/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32873///
32874/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32875/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32876/// #     .with_native_roots()
32877/// #     .unwrap()
32878/// #     .https_only()
32879/// #     .enable_http2()
32880/// #     .build();
32881///
32882/// # let executor = hyper_util::rt::TokioExecutor::new();
32883/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32884/// #     secret,
32885/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32886/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
32887/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
32888/// #     ),
32889/// # ).build().await.unwrap();
32890///
32891/// # let client = hyper_util::client::legacy::Client::builder(
32892/// #     hyper_util::rt::TokioExecutor::new()
32893/// # )
32894/// # .build(
32895/// #     hyper_rustls::HttpsConnectorBuilder::new()
32896/// #         .with_native_roots()
32897/// #         .unwrap()
32898/// #         .https_or_http()
32899/// #         .enable_http2()
32900/// #         .build()
32901/// # );
32902/// # let mut hub = Spanner::new(client, auth);
32903/// // You can configure optional parameters by calling the respective setters at will, and
32904/// // execute the final call using `doit()`.
32905/// // Values shown here are possibly random and not representative !
32906/// let result = hub.projects().instances_instance_partitions_delete("name")
32907///              .etag("Lorem")
32908///              .doit().await;
32909/// # }
32910/// ```
32911pub struct ProjectInstanceInstancePartitionDeleteCall<'a, C>
32912where
32913    C: 'a,
32914{
32915    hub: &'a Spanner<C>,
32916    _name: String,
32917    _etag: Option<String>,
32918    _delegate: Option<&'a mut dyn common::Delegate>,
32919    _additional_params: HashMap<String, String>,
32920    _scopes: BTreeSet<String>,
32921}
32922
32923impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionDeleteCall<'a, C> {}
32924
32925impl<'a, C> ProjectInstanceInstancePartitionDeleteCall<'a, C>
32926where
32927    C: common::Connector,
32928{
32929    /// Perform the operation you have build so far.
32930    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
32931        use std::borrow::Cow;
32932        use std::io::{Read, Seek};
32933
32934        use common::{url::Params, ToParts};
32935        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32936
32937        let mut dd = common::DefaultDelegate;
32938        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32939        dlg.begin(common::MethodInfo {
32940            id: "spanner.projects.instances.instancePartitions.delete",
32941            http_method: hyper::Method::DELETE,
32942        });
32943
32944        for &field in ["alt", "name", "etag"].iter() {
32945            if self._additional_params.contains_key(field) {
32946                dlg.finished(false);
32947                return Err(common::Error::FieldClash(field));
32948            }
32949        }
32950
32951        let mut params = Params::with_capacity(4 + self._additional_params.len());
32952        params.push("name", self._name);
32953        if let Some(value) = self._etag.as_ref() {
32954            params.push("etag", value);
32955        }
32956
32957        params.extend(self._additional_params.iter());
32958
32959        params.push("alt", "json");
32960        let mut url = self.hub._base_url.clone() + "v1/{+name}";
32961        if self._scopes.is_empty() {
32962            self._scopes
32963                .insert(Scope::CloudPlatform.as_ref().to_string());
32964        }
32965
32966        #[allow(clippy::single_element_loop)]
32967        for &(find_this, param_name) in [("{+name}", "name")].iter() {
32968            url = params.uri_replacement(url, param_name, find_this, true);
32969        }
32970        {
32971            let to_remove = ["name"];
32972            params.remove_params(&to_remove);
32973        }
32974
32975        let url = params.parse_with_url(&url);
32976
32977        loop {
32978            let token = match self
32979                .hub
32980                .auth
32981                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32982                .await
32983            {
32984                Ok(token) => token,
32985                Err(e) => match dlg.token(e) {
32986                    Ok(token) => token,
32987                    Err(e) => {
32988                        dlg.finished(false);
32989                        return Err(common::Error::MissingToken(e));
32990                    }
32991                },
32992            };
32993            let mut req_result = {
32994                let client = &self.hub.client;
32995                dlg.pre_request();
32996                let mut req_builder = hyper::Request::builder()
32997                    .method(hyper::Method::DELETE)
32998                    .uri(url.as_str())
32999                    .header(USER_AGENT, self.hub._user_agent.clone());
33000
33001                if let Some(token) = token.as_ref() {
33002                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33003                }
33004
33005                let request = req_builder
33006                    .header(CONTENT_LENGTH, 0_u64)
33007                    .body(common::to_body::<String>(None));
33008
33009                client.request(request.unwrap()).await
33010            };
33011
33012            match req_result {
33013                Err(err) => {
33014                    if let common::Retry::After(d) = dlg.http_error(&err) {
33015                        sleep(d).await;
33016                        continue;
33017                    }
33018                    dlg.finished(false);
33019                    return Err(common::Error::HttpError(err));
33020                }
33021                Ok(res) => {
33022                    let (mut parts, body) = res.into_parts();
33023                    let mut body = common::Body::new(body);
33024                    if !parts.status.is_success() {
33025                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33026                        let error = serde_json::from_str(&common::to_string(&bytes));
33027                        let response = common::to_response(parts, bytes.into());
33028
33029                        if let common::Retry::After(d) =
33030                            dlg.http_failure(&response, error.as_ref().ok())
33031                        {
33032                            sleep(d).await;
33033                            continue;
33034                        }
33035
33036                        dlg.finished(false);
33037
33038                        return Err(match error {
33039                            Ok(value) => common::Error::BadRequest(value),
33040                            _ => common::Error::Failure(response),
33041                        });
33042                    }
33043                    let response = {
33044                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33045                        let encoded = common::to_string(&bytes);
33046                        match serde_json::from_str(&encoded) {
33047                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33048                            Err(error) => {
33049                                dlg.response_json_decode_error(&encoded, &error);
33050                                return Err(common::Error::JsonDecodeError(
33051                                    encoded.to_string(),
33052                                    error,
33053                                ));
33054                            }
33055                        }
33056                    };
33057
33058                    dlg.finished(true);
33059                    return Ok(response);
33060                }
33061            }
33062        }
33063    }
33064
33065    /// Required. The name of the instance partition to be deleted. Values are of the form `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`
33066    ///
33067    /// Sets the *name* path property to the given value.
33068    ///
33069    /// Even though the property as already been set when instantiating this call,
33070    /// we provide this method for API completeness.
33071    pub fn name(mut self, new_value: &str) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
33072        self._name = new_value.to_string();
33073        self
33074    }
33075    /// Optional. If not empty, the API only deletes the instance partition when the etag provided matches the current status of the requested instance partition. Otherwise, deletes the instance partition without checking the current status of the requested instance partition.
33076    ///
33077    /// Sets the *etag* query property to the given value.
33078    pub fn etag(mut self, new_value: &str) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
33079        self._etag = Some(new_value.to_string());
33080        self
33081    }
33082    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33083    /// while executing the actual API request.
33084    ///
33085    /// ````text
33086    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33087    /// ````
33088    ///
33089    /// Sets the *delegate* property to the given value.
33090    pub fn delegate(
33091        mut self,
33092        new_value: &'a mut dyn common::Delegate,
33093    ) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
33094        self._delegate = Some(new_value);
33095        self
33096    }
33097
33098    /// Set any additional parameter of the query string used in the request.
33099    /// It should be used to set parameters which are not yet available through their own
33100    /// setters.
33101    ///
33102    /// Please note that this method must not be used to set any of the known parameters
33103    /// which have their own setter method. If done anyway, the request will fail.
33104    ///
33105    /// # Additional Parameters
33106    ///
33107    /// * *$.xgafv* (query-string) - V1 error format.
33108    /// * *access_token* (query-string) - OAuth access token.
33109    /// * *alt* (query-string) - Data format for response.
33110    /// * *callback* (query-string) - JSONP
33111    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33112    /// * *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.
33113    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33114    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33115    /// * *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.
33116    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33117    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33118    pub fn param<T>(
33119        mut self,
33120        name: T,
33121        value: T,
33122    ) -> ProjectInstanceInstancePartitionDeleteCall<'a, C>
33123    where
33124        T: AsRef<str>,
33125    {
33126        self._additional_params
33127            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33128        self
33129    }
33130
33131    /// Identifies the authorization scope for the method you are building.
33132    ///
33133    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33134    /// [`Scope::CloudPlatform`].
33135    ///
33136    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33137    /// tokens for more than one scope.
33138    ///
33139    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33140    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33141    /// sufficient, a read-write scope will do as well.
33142    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionDeleteCall<'a, C>
33143    where
33144        St: AsRef<str>,
33145    {
33146        self._scopes.insert(String::from(scope.as_ref()));
33147        self
33148    }
33149    /// Identifies the authorization scope(s) for the method you are building.
33150    ///
33151    /// See [`Self::add_scope()`] for details.
33152    pub fn add_scopes<I, St>(
33153        mut self,
33154        scopes: I,
33155    ) -> ProjectInstanceInstancePartitionDeleteCall<'a, C>
33156    where
33157        I: IntoIterator<Item = St>,
33158        St: AsRef<str>,
33159    {
33160        self._scopes
33161            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33162        self
33163    }
33164
33165    /// Removes all scopes, and no default scope will be used either.
33166    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33167    /// for details).
33168    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
33169        self._scopes.clear();
33170        self
33171    }
33172}
33173
33174/// Gets information about a particular instance partition.
33175///
33176/// A builder for the *instances.instancePartitions.get* method supported by a *project* resource.
33177/// It is not used directly, but through a [`ProjectMethods`] instance.
33178///
33179/// # Example
33180///
33181/// Instantiate a resource method builder
33182///
33183/// ```test_harness,no_run
33184/// # extern crate hyper;
33185/// # extern crate hyper_rustls;
33186/// # extern crate google_spanner1 as spanner1;
33187/// # async fn dox() {
33188/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33189///
33190/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33191/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33192/// #     .with_native_roots()
33193/// #     .unwrap()
33194/// #     .https_only()
33195/// #     .enable_http2()
33196/// #     .build();
33197///
33198/// # let executor = hyper_util::rt::TokioExecutor::new();
33199/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33200/// #     secret,
33201/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33202/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
33203/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
33204/// #     ),
33205/// # ).build().await.unwrap();
33206///
33207/// # let client = hyper_util::client::legacy::Client::builder(
33208/// #     hyper_util::rt::TokioExecutor::new()
33209/// # )
33210/// # .build(
33211/// #     hyper_rustls::HttpsConnectorBuilder::new()
33212/// #         .with_native_roots()
33213/// #         .unwrap()
33214/// #         .https_or_http()
33215/// #         .enable_http2()
33216/// #         .build()
33217/// # );
33218/// # let mut hub = Spanner::new(client, auth);
33219/// // You can configure optional parameters by calling the respective setters at will, and
33220/// // execute the final call using `doit()`.
33221/// // Values shown here are possibly random and not representative !
33222/// let result = hub.projects().instances_instance_partitions_get("name")
33223///              .doit().await;
33224/// # }
33225/// ```
33226pub struct ProjectInstanceInstancePartitionGetCall<'a, C>
33227where
33228    C: 'a,
33229{
33230    hub: &'a Spanner<C>,
33231    _name: String,
33232    _delegate: Option<&'a mut dyn common::Delegate>,
33233    _additional_params: HashMap<String, String>,
33234    _scopes: BTreeSet<String>,
33235}
33236
33237impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionGetCall<'a, C> {}
33238
33239impl<'a, C> ProjectInstanceInstancePartitionGetCall<'a, C>
33240where
33241    C: common::Connector,
33242{
33243    /// Perform the operation you have build so far.
33244    pub async fn doit(mut self) -> common::Result<(common::Response, InstancePartition)> {
33245        use std::borrow::Cow;
33246        use std::io::{Read, Seek};
33247
33248        use common::{url::Params, ToParts};
33249        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33250
33251        let mut dd = common::DefaultDelegate;
33252        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33253        dlg.begin(common::MethodInfo {
33254            id: "spanner.projects.instances.instancePartitions.get",
33255            http_method: hyper::Method::GET,
33256        });
33257
33258        for &field in ["alt", "name"].iter() {
33259            if self._additional_params.contains_key(field) {
33260                dlg.finished(false);
33261                return Err(common::Error::FieldClash(field));
33262            }
33263        }
33264
33265        let mut params = Params::with_capacity(3 + self._additional_params.len());
33266        params.push("name", self._name);
33267
33268        params.extend(self._additional_params.iter());
33269
33270        params.push("alt", "json");
33271        let mut url = self.hub._base_url.clone() + "v1/{+name}";
33272        if self._scopes.is_empty() {
33273            self._scopes
33274                .insert(Scope::CloudPlatform.as_ref().to_string());
33275        }
33276
33277        #[allow(clippy::single_element_loop)]
33278        for &(find_this, param_name) in [("{+name}", "name")].iter() {
33279            url = params.uri_replacement(url, param_name, find_this, true);
33280        }
33281        {
33282            let to_remove = ["name"];
33283            params.remove_params(&to_remove);
33284        }
33285
33286        let url = params.parse_with_url(&url);
33287
33288        loop {
33289            let token = match self
33290                .hub
33291                .auth
33292                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33293                .await
33294            {
33295                Ok(token) => token,
33296                Err(e) => match dlg.token(e) {
33297                    Ok(token) => token,
33298                    Err(e) => {
33299                        dlg.finished(false);
33300                        return Err(common::Error::MissingToken(e));
33301                    }
33302                },
33303            };
33304            let mut req_result = {
33305                let client = &self.hub.client;
33306                dlg.pre_request();
33307                let mut req_builder = hyper::Request::builder()
33308                    .method(hyper::Method::GET)
33309                    .uri(url.as_str())
33310                    .header(USER_AGENT, self.hub._user_agent.clone());
33311
33312                if let Some(token) = token.as_ref() {
33313                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33314                }
33315
33316                let request = req_builder
33317                    .header(CONTENT_LENGTH, 0_u64)
33318                    .body(common::to_body::<String>(None));
33319
33320                client.request(request.unwrap()).await
33321            };
33322
33323            match req_result {
33324                Err(err) => {
33325                    if let common::Retry::After(d) = dlg.http_error(&err) {
33326                        sleep(d).await;
33327                        continue;
33328                    }
33329                    dlg.finished(false);
33330                    return Err(common::Error::HttpError(err));
33331                }
33332                Ok(res) => {
33333                    let (mut parts, body) = res.into_parts();
33334                    let mut body = common::Body::new(body);
33335                    if !parts.status.is_success() {
33336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33337                        let error = serde_json::from_str(&common::to_string(&bytes));
33338                        let response = common::to_response(parts, bytes.into());
33339
33340                        if let common::Retry::After(d) =
33341                            dlg.http_failure(&response, error.as_ref().ok())
33342                        {
33343                            sleep(d).await;
33344                            continue;
33345                        }
33346
33347                        dlg.finished(false);
33348
33349                        return Err(match error {
33350                            Ok(value) => common::Error::BadRequest(value),
33351                            _ => common::Error::Failure(response),
33352                        });
33353                    }
33354                    let response = {
33355                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33356                        let encoded = common::to_string(&bytes);
33357                        match serde_json::from_str(&encoded) {
33358                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33359                            Err(error) => {
33360                                dlg.response_json_decode_error(&encoded, &error);
33361                                return Err(common::Error::JsonDecodeError(
33362                                    encoded.to_string(),
33363                                    error,
33364                                ));
33365                            }
33366                        }
33367                    };
33368
33369                    dlg.finished(true);
33370                    return Ok(response);
33371                }
33372            }
33373        }
33374    }
33375
33376    /// Required. The name of the requested instance partition. Values are of the form `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`.
33377    ///
33378    /// Sets the *name* path property to the given value.
33379    ///
33380    /// Even though the property as already been set when instantiating this call,
33381    /// we provide this method for API completeness.
33382    pub fn name(mut self, new_value: &str) -> ProjectInstanceInstancePartitionGetCall<'a, C> {
33383        self._name = new_value.to_string();
33384        self
33385    }
33386    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33387    /// while executing the actual API request.
33388    ///
33389    /// ````text
33390    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33391    /// ````
33392    ///
33393    /// Sets the *delegate* property to the given value.
33394    pub fn delegate(
33395        mut self,
33396        new_value: &'a mut dyn common::Delegate,
33397    ) -> ProjectInstanceInstancePartitionGetCall<'a, C> {
33398        self._delegate = Some(new_value);
33399        self
33400    }
33401
33402    /// Set any additional parameter of the query string used in the request.
33403    /// It should be used to set parameters which are not yet available through their own
33404    /// setters.
33405    ///
33406    /// Please note that this method must not be used to set any of the known parameters
33407    /// which have their own setter method. If done anyway, the request will fail.
33408    ///
33409    /// # Additional Parameters
33410    ///
33411    /// * *$.xgafv* (query-string) - V1 error format.
33412    /// * *access_token* (query-string) - OAuth access token.
33413    /// * *alt* (query-string) - Data format for response.
33414    /// * *callback* (query-string) - JSONP
33415    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33416    /// * *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.
33417    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33418    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33419    /// * *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.
33420    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33421    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33422    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceInstancePartitionGetCall<'a, C>
33423    where
33424        T: AsRef<str>,
33425    {
33426        self._additional_params
33427            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33428        self
33429    }
33430
33431    /// Identifies the authorization scope for the method you are building.
33432    ///
33433    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33434    /// [`Scope::CloudPlatform`].
33435    ///
33436    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33437    /// tokens for more than one scope.
33438    ///
33439    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33440    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33441    /// sufficient, a read-write scope will do as well.
33442    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionGetCall<'a, C>
33443    where
33444        St: AsRef<str>,
33445    {
33446        self._scopes.insert(String::from(scope.as_ref()));
33447        self
33448    }
33449    /// Identifies the authorization scope(s) for the method you are building.
33450    ///
33451    /// See [`Self::add_scope()`] for details.
33452    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceInstancePartitionGetCall<'a, C>
33453    where
33454        I: IntoIterator<Item = St>,
33455        St: AsRef<str>,
33456    {
33457        self._scopes
33458            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33459        self
33460    }
33461
33462    /// Removes all scopes, and no default scope will be used either.
33463    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33464    /// for details).
33465    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionGetCall<'a, C> {
33466        self._scopes.clear();
33467        self
33468    }
33469}
33470
33471/// Lists all instance partitions for the given instance.
33472///
33473/// A builder for the *instances.instancePartitions.list* method supported by a *project* resource.
33474/// It is not used directly, but through a [`ProjectMethods`] instance.
33475///
33476/// # Example
33477///
33478/// Instantiate a resource method builder
33479///
33480/// ```test_harness,no_run
33481/// # extern crate hyper;
33482/// # extern crate hyper_rustls;
33483/// # extern crate google_spanner1 as spanner1;
33484/// # async fn dox() {
33485/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33486///
33487/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33488/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33489/// #     .with_native_roots()
33490/// #     .unwrap()
33491/// #     .https_only()
33492/// #     .enable_http2()
33493/// #     .build();
33494///
33495/// # let executor = hyper_util::rt::TokioExecutor::new();
33496/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33497/// #     secret,
33498/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33499/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
33500/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
33501/// #     ),
33502/// # ).build().await.unwrap();
33503///
33504/// # let client = hyper_util::client::legacy::Client::builder(
33505/// #     hyper_util::rt::TokioExecutor::new()
33506/// # )
33507/// # .build(
33508/// #     hyper_rustls::HttpsConnectorBuilder::new()
33509/// #         .with_native_roots()
33510/// #         .unwrap()
33511/// #         .https_or_http()
33512/// #         .enable_http2()
33513/// #         .build()
33514/// # );
33515/// # let mut hub = Spanner::new(client, auth);
33516/// // You can configure optional parameters by calling the respective setters at will, and
33517/// // execute the final call using `doit()`.
33518/// // Values shown here are possibly random and not representative !
33519/// let result = hub.projects().instances_instance_partitions_list("parent")
33520///              .page_token("erat")
33521///              .page_size(-69)
33522///              .instance_partition_deadline(chrono::Utc::now())
33523///              .doit().await;
33524/// # }
33525/// ```
33526pub struct ProjectInstanceInstancePartitionListCall<'a, C>
33527where
33528    C: 'a,
33529{
33530    hub: &'a Spanner<C>,
33531    _parent: String,
33532    _page_token: Option<String>,
33533    _page_size: Option<i32>,
33534    _instance_partition_deadline: Option<chrono::DateTime<chrono::offset::Utc>>,
33535    _delegate: Option<&'a mut dyn common::Delegate>,
33536    _additional_params: HashMap<String, String>,
33537    _scopes: BTreeSet<String>,
33538}
33539
33540impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionListCall<'a, C> {}
33541
33542impl<'a, C> ProjectInstanceInstancePartitionListCall<'a, C>
33543where
33544    C: common::Connector,
33545{
33546    /// Perform the operation you have build so far.
33547    pub async fn doit(
33548        mut self,
33549    ) -> common::Result<(common::Response, ListInstancePartitionsResponse)> {
33550        use std::borrow::Cow;
33551        use std::io::{Read, Seek};
33552
33553        use common::{url::Params, ToParts};
33554        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33555
33556        let mut dd = common::DefaultDelegate;
33557        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33558        dlg.begin(common::MethodInfo {
33559            id: "spanner.projects.instances.instancePartitions.list",
33560            http_method: hyper::Method::GET,
33561        });
33562
33563        for &field in [
33564            "alt",
33565            "parent",
33566            "pageToken",
33567            "pageSize",
33568            "instancePartitionDeadline",
33569        ]
33570        .iter()
33571        {
33572            if self._additional_params.contains_key(field) {
33573                dlg.finished(false);
33574                return Err(common::Error::FieldClash(field));
33575            }
33576        }
33577
33578        let mut params = Params::with_capacity(6 + self._additional_params.len());
33579        params.push("parent", self._parent);
33580        if let Some(value) = self._page_token.as_ref() {
33581            params.push("pageToken", value);
33582        }
33583        if let Some(value) = self._page_size.as_ref() {
33584            params.push("pageSize", value.to_string());
33585        }
33586        if let Some(value) = self._instance_partition_deadline.as_ref() {
33587            params.push(
33588                "instancePartitionDeadline",
33589                common::serde::datetime_to_string(&value),
33590            );
33591        }
33592
33593        params.extend(self._additional_params.iter());
33594
33595        params.push("alt", "json");
33596        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instancePartitions";
33597        if self._scopes.is_empty() {
33598            self._scopes
33599                .insert(Scope::CloudPlatform.as_ref().to_string());
33600        }
33601
33602        #[allow(clippy::single_element_loop)]
33603        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
33604            url = params.uri_replacement(url, param_name, find_this, true);
33605        }
33606        {
33607            let to_remove = ["parent"];
33608            params.remove_params(&to_remove);
33609        }
33610
33611        let url = params.parse_with_url(&url);
33612
33613        loop {
33614            let token = match self
33615                .hub
33616                .auth
33617                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33618                .await
33619            {
33620                Ok(token) => token,
33621                Err(e) => match dlg.token(e) {
33622                    Ok(token) => token,
33623                    Err(e) => {
33624                        dlg.finished(false);
33625                        return Err(common::Error::MissingToken(e));
33626                    }
33627                },
33628            };
33629            let mut req_result = {
33630                let client = &self.hub.client;
33631                dlg.pre_request();
33632                let mut req_builder = hyper::Request::builder()
33633                    .method(hyper::Method::GET)
33634                    .uri(url.as_str())
33635                    .header(USER_AGENT, self.hub._user_agent.clone());
33636
33637                if let Some(token) = token.as_ref() {
33638                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33639                }
33640
33641                let request = req_builder
33642                    .header(CONTENT_LENGTH, 0_u64)
33643                    .body(common::to_body::<String>(None));
33644
33645                client.request(request.unwrap()).await
33646            };
33647
33648            match req_result {
33649                Err(err) => {
33650                    if let common::Retry::After(d) = dlg.http_error(&err) {
33651                        sleep(d).await;
33652                        continue;
33653                    }
33654                    dlg.finished(false);
33655                    return Err(common::Error::HttpError(err));
33656                }
33657                Ok(res) => {
33658                    let (mut parts, body) = res.into_parts();
33659                    let mut body = common::Body::new(body);
33660                    if !parts.status.is_success() {
33661                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33662                        let error = serde_json::from_str(&common::to_string(&bytes));
33663                        let response = common::to_response(parts, bytes.into());
33664
33665                        if let common::Retry::After(d) =
33666                            dlg.http_failure(&response, error.as_ref().ok())
33667                        {
33668                            sleep(d).await;
33669                            continue;
33670                        }
33671
33672                        dlg.finished(false);
33673
33674                        return Err(match error {
33675                            Ok(value) => common::Error::BadRequest(value),
33676                            _ => common::Error::Failure(response),
33677                        });
33678                    }
33679                    let response = {
33680                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33681                        let encoded = common::to_string(&bytes);
33682                        match serde_json::from_str(&encoded) {
33683                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33684                            Err(error) => {
33685                                dlg.response_json_decode_error(&encoded, &error);
33686                                return Err(common::Error::JsonDecodeError(
33687                                    encoded.to_string(),
33688                                    error,
33689                                ));
33690                            }
33691                        }
33692                    };
33693
33694                    dlg.finished(true);
33695                    return Ok(response);
33696                }
33697            }
33698        }
33699    }
33700
33701    /// Required. The instance whose instance partitions should be listed. Values are of the form `projects//instances/`. Use `{instance} = '-'` to list instance partitions for all Instances in a project, e.g., `projects/myproject/instances/-`.
33702    ///
33703    /// Sets the *parent* path property to the given value.
33704    ///
33705    /// Even though the property as already been set when instantiating this call,
33706    /// we provide this method for API completeness.
33707    pub fn parent(mut self, new_value: &str) -> ProjectInstanceInstancePartitionListCall<'a, C> {
33708        self._parent = new_value.to_string();
33709        self
33710    }
33711    /// If non-empty, `page_token` should contain a next_page_token from a previous ListInstancePartitionsResponse.
33712    ///
33713    /// Sets the *page token* query property to the given value.
33714    pub fn page_token(
33715        mut self,
33716        new_value: &str,
33717    ) -> ProjectInstanceInstancePartitionListCall<'a, C> {
33718        self._page_token = Some(new_value.to_string());
33719        self
33720    }
33721    /// Number of instance partitions to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
33722    ///
33723    /// Sets the *page size* query property to the given value.
33724    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceInstancePartitionListCall<'a, C> {
33725        self._page_size = Some(new_value);
33726        self
33727    }
33728    /// Optional. Deadline used while retrieving metadata for instance partitions. Instance partitions whose metadata cannot be retrieved within this deadline will be added to unreachable in ListInstancePartitionsResponse.
33729    ///
33730    /// Sets the *instance partition deadline* query property to the given value.
33731    pub fn instance_partition_deadline(
33732        mut self,
33733        new_value: chrono::DateTime<chrono::offset::Utc>,
33734    ) -> ProjectInstanceInstancePartitionListCall<'a, C> {
33735        self._instance_partition_deadline = Some(new_value);
33736        self
33737    }
33738    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33739    /// while executing the actual API request.
33740    ///
33741    /// ````text
33742    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33743    /// ````
33744    ///
33745    /// Sets the *delegate* property to the given value.
33746    pub fn delegate(
33747        mut self,
33748        new_value: &'a mut dyn common::Delegate,
33749    ) -> ProjectInstanceInstancePartitionListCall<'a, C> {
33750        self._delegate = Some(new_value);
33751        self
33752    }
33753
33754    /// Set any additional parameter of the query string used in the request.
33755    /// It should be used to set parameters which are not yet available through their own
33756    /// setters.
33757    ///
33758    /// Please note that this method must not be used to set any of the known parameters
33759    /// which have their own setter method. If done anyway, the request will fail.
33760    ///
33761    /// # Additional Parameters
33762    ///
33763    /// * *$.xgafv* (query-string) - V1 error format.
33764    /// * *access_token* (query-string) - OAuth access token.
33765    /// * *alt* (query-string) - Data format for response.
33766    /// * *callback* (query-string) - JSONP
33767    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33768    /// * *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.
33769    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33770    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33771    /// * *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.
33772    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33773    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33774    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceInstancePartitionListCall<'a, C>
33775    where
33776        T: AsRef<str>,
33777    {
33778        self._additional_params
33779            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33780        self
33781    }
33782
33783    /// Identifies the authorization scope for the method you are building.
33784    ///
33785    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33786    /// [`Scope::CloudPlatform`].
33787    ///
33788    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33789    /// tokens for more than one scope.
33790    ///
33791    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33792    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33793    /// sufficient, a read-write scope will do as well.
33794    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionListCall<'a, C>
33795    where
33796        St: AsRef<str>,
33797    {
33798        self._scopes.insert(String::from(scope.as_ref()));
33799        self
33800    }
33801    /// Identifies the authorization scope(s) for the method you are building.
33802    ///
33803    /// See [`Self::add_scope()`] for details.
33804    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceInstancePartitionListCall<'a, C>
33805    where
33806        I: IntoIterator<Item = St>,
33807        St: AsRef<str>,
33808    {
33809        self._scopes
33810            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33811        self
33812    }
33813
33814    /// Removes all scopes, and no default scope will be used either.
33815    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33816    /// for details).
33817    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionListCall<'a, C> {
33818        self._scopes.clear();
33819        self
33820    }
33821}
33822
33823/// Updates an instance partition, and begins allocating or releasing resources as requested. The returned long-running operation can be used to track the progress of updating the instance partition. If the named instance partition does not exist, returns `NOT_FOUND`. Immediately upon completion of this request: * For resource types for which a decrease in the instance partition's allocation has been requested, billing is based on the newly-requested level. Until completion of the returned operation: * Cancelling the operation sets its metadata's cancel_time, and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance partition are rejected. * Reading the instance partition via the API continues to give the pre-request resource levels. Upon completion of the returned operation: * Billing begins for all successfully-allocated resources (some types may have lower than the requested levels). * All newly-reserved resources are available for serving the instance partition's tables. * The instance partition's new resource levels are readable via the API. The returned long-running operation will have a name of the format `/operations/` and can be used to track the instance partition modification. The metadata field type is UpdateInstancePartitionMetadata. The response field type is InstancePartition, if successful. Authorization requires `spanner.instancePartitions.update` permission on the resource name.
33824///
33825/// A builder for the *instances.instancePartitions.patch* method supported by a *project* resource.
33826/// It is not used directly, but through a [`ProjectMethods`] instance.
33827///
33828/// # Example
33829///
33830/// Instantiate a resource method builder
33831///
33832/// ```test_harness,no_run
33833/// # extern crate hyper;
33834/// # extern crate hyper_rustls;
33835/// # extern crate google_spanner1 as spanner1;
33836/// use spanner1::api::UpdateInstancePartitionRequest;
33837/// # async fn dox() {
33838/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33839///
33840/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33841/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33842/// #     .with_native_roots()
33843/// #     .unwrap()
33844/// #     .https_only()
33845/// #     .enable_http2()
33846/// #     .build();
33847///
33848/// # let executor = hyper_util::rt::TokioExecutor::new();
33849/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33850/// #     secret,
33851/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33852/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
33853/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
33854/// #     ),
33855/// # ).build().await.unwrap();
33856///
33857/// # let client = hyper_util::client::legacy::Client::builder(
33858/// #     hyper_util::rt::TokioExecutor::new()
33859/// # )
33860/// # .build(
33861/// #     hyper_rustls::HttpsConnectorBuilder::new()
33862/// #         .with_native_roots()
33863/// #         .unwrap()
33864/// #         .https_or_http()
33865/// #         .enable_http2()
33866/// #         .build()
33867/// # );
33868/// # let mut hub = Spanner::new(client, auth);
33869/// // As the method needs a request, you would usually fill it with the desired information
33870/// // into the respective structure. Some of the parts shown here might not be applicable !
33871/// // Values shown here are possibly random and not representative !
33872/// let mut req = UpdateInstancePartitionRequest::default();
33873///
33874/// // You can configure optional parameters by calling the respective setters at will, and
33875/// // execute the final call using `doit()`.
33876/// // Values shown here are possibly random and not representative !
33877/// let result = hub.projects().instances_instance_partitions_patch(req, "name")
33878///              .doit().await;
33879/// # }
33880/// ```
33881pub struct ProjectInstanceInstancePartitionPatchCall<'a, C>
33882where
33883    C: 'a,
33884{
33885    hub: &'a Spanner<C>,
33886    _request: UpdateInstancePartitionRequest,
33887    _name: String,
33888    _delegate: Option<&'a mut dyn common::Delegate>,
33889    _additional_params: HashMap<String, String>,
33890    _scopes: BTreeSet<String>,
33891}
33892
33893impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionPatchCall<'a, C> {}
33894
33895impl<'a, C> ProjectInstanceInstancePartitionPatchCall<'a, C>
33896where
33897    C: common::Connector,
33898{
33899    /// Perform the operation you have build so far.
33900    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
33901        use std::borrow::Cow;
33902        use std::io::{Read, Seek};
33903
33904        use common::{url::Params, ToParts};
33905        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33906
33907        let mut dd = common::DefaultDelegate;
33908        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33909        dlg.begin(common::MethodInfo {
33910            id: "spanner.projects.instances.instancePartitions.patch",
33911            http_method: hyper::Method::PATCH,
33912        });
33913
33914        for &field in ["alt", "name"].iter() {
33915            if self._additional_params.contains_key(field) {
33916                dlg.finished(false);
33917                return Err(common::Error::FieldClash(field));
33918            }
33919        }
33920
33921        let mut params = Params::with_capacity(4 + self._additional_params.len());
33922        params.push("name", self._name);
33923
33924        params.extend(self._additional_params.iter());
33925
33926        params.push("alt", "json");
33927        let mut url = self.hub._base_url.clone() + "v1/{+name}";
33928        if self._scopes.is_empty() {
33929            self._scopes
33930                .insert(Scope::CloudPlatform.as_ref().to_string());
33931        }
33932
33933        #[allow(clippy::single_element_loop)]
33934        for &(find_this, param_name) in [("{+name}", "name")].iter() {
33935            url = params.uri_replacement(url, param_name, find_this, true);
33936        }
33937        {
33938            let to_remove = ["name"];
33939            params.remove_params(&to_remove);
33940        }
33941
33942        let url = params.parse_with_url(&url);
33943
33944        let mut json_mime_type = mime::APPLICATION_JSON;
33945        let mut request_value_reader = {
33946            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33947            common::remove_json_null_values(&mut value);
33948            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33949            serde_json::to_writer(&mut dst, &value).unwrap();
33950            dst
33951        };
33952        let request_size = request_value_reader
33953            .seek(std::io::SeekFrom::End(0))
33954            .unwrap();
33955        request_value_reader
33956            .seek(std::io::SeekFrom::Start(0))
33957            .unwrap();
33958
33959        loop {
33960            let token = match self
33961                .hub
33962                .auth
33963                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33964                .await
33965            {
33966                Ok(token) => token,
33967                Err(e) => match dlg.token(e) {
33968                    Ok(token) => token,
33969                    Err(e) => {
33970                        dlg.finished(false);
33971                        return Err(common::Error::MissingToken(e));
33972                    }
33973                },
33974            };
33975            request_value_reader
33976                .seek(std::io::SeekFrom::Start(0))
33977                .unwrap();
33978            let mut req_result = {
33979                let client = &self.hub.client;
33980                dlg.pre_request();
33981                let mut req_builder = hyper::Request::builder()
33982                    .method(hyper::Method::PATCH)
33983                    .uri(url.as_str())
33984                    .header(USER_AGENT, self.hub._user_agent.clone());
33985
33986                if let Some(token) = token.as_ref() {
33987                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33988                }
33989
33990                let request = req_builder
33991                    .header(CONTENT_TYPE, json_mime_type.to_string())
33992                    .header(CONTENT_LENGTH, request_size as u64)
33993                    .body(common::to_body(
33994                        request_value_reader.get_ref().clone().into(),
33995                    ));
33996
33997                client.request(request.unwrap()).await
33998            };
33999
34000            match req_result {
34001                Err(err) => {
34002                    if let common::Retry::After(d) = dlg.http_error(&err) {
34003                        sleep(d).await;
34004                        continue;
34005                    }
34006                    dlg.finished(false);
34007                    return Err(common::Error::HttpError(err));
34008                }
34009                Ok(res) => {
34010                    let (mut parts, body) = res.into_parts();
34011                    let mut body = common::Body::new(body);
34012                    if !parts.status.is_success() {
34013                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34014                        let error = serde_json::from_str(&common::to_string(&bytes));
34015                        let response = common::to_response(parts, bytes.into());
34016
34017                        if let common::Retry::After(d) =
34018                            dlg.http_failure(&response, error.as_ref().ok())
34019                        {
34020                            sleep(d).await;
34021                            continue;
34022                        }
34023
34024                        dlg.finished(false);
34025
34026                        return Err(match error {
34027                            Ok(value) => common::Error::BadRequest(value),
34028                            _ => common::Error::Failure(response),
34029                        });
34030                    }
34031                    let response = {
34032                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34033                        let encoded = common::to_string(&bytes);
34034                        match serde_json::from_str(&encoded) {
34035                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34036                            Err(error) => {
34037                                dlg.response_json_decode_error(&encoded, &error);
34038                                return Err(common::Error::JsonDecodeError(
34039                                    encoded.to_string(),
34040                                    error,
34041                                ));
34042                            }
34043                        }
34044                    };
34045
34046                    dlg.finished(true);
34047                    return Ok(response);
34048                }
34049            }
34050        }
34051    }
34052
34053    ///
34054    /// Sets the *request* property to the given value.
34055    ///
34056    /// Even though the property as already been set when instantiating this call,
34057    /// we provide this method for API completeness.
34058    pub fn request(
34059        mut self,
34060        new_value: UpdateInstancePartitionRequest,
34061    ) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
34062        self._request = new_value;
34063        self
34064    }
34065    /// Required. A unique identifier for the instance partition. Values are of the form `projects//instances//instancePartitions/a-z*[a-z0-9]`. The final segment of the name must be between 2 and 64 characters in length. An instance partition's name cannot be changed after the instance partition is created.
34066    ///
34067    /// Sets the *name* path property to the given value.
34068    ///
34069    /// Even though the property as already been set when instantiating this call,
34070    /// we provide this method for API completeness.
34071    pub fn name(mut self, new_value: &str) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
34072        self._name = new_value.to_string();
34073        self
34074    }
34075    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34076    /// while executing the actual API request.
34077    ///
34078    /// ````text
34079    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34080    /// ````
34081    ///
34082    /// Sets the *delegate* property to the given value.
34083    pub fn delegate(
34084        mut self,
34085        new_value: &'a mut dyn common::Delegate,
34086    ) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
34087        self._delegate = Some(new_value);
34088        self
34089    }
34090
34091    /// Set any additional parameter of the query string used in the request.
34092    /// It should be used to set parameters which are not yet available through their own
34093    /// setters.
34094    ///
34095    /// Please note that this method must not be used to set any of the known parameters
34096    /// which have their own setter method. If done anyway, the request will fail.
34097    ///
34098    /// # Additional Parameters
34099    ///
34100    /// * *$.xgafv* (query-string) - V1 error format.
34101    /// * *access_token* (query-string) - OAuth access token.
34102    /// * *alt* (query-string) - Data format for response.
34103    /// * *callback* (query-string) - JSONP
34104    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34105    /// * *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.
34106    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34107    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34108    /// * *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.
34109    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34110    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34111    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceInstancePartitionPatchCall<'a, C>
34112    where
34113        T: AsRef<str>,
34114    {
34115        self._additional_params
34116            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34117        self
34118    }
34119
34120    /// Identifies the authorization scope for the method you are building.
34121    ///
34122    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34123    /// [`Scope::CloudPlatform`].
34124    ///
34125    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34126    /// tokens for more than one scope.
34127    ///
34128    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34129    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34130    /// sufficient, a read-write scope will do as well.
34131    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionPatchCall<'a, C>
34132    where
34133        St: AsRef<str>,
34134    {
34135        self._scopes.insert(String::from(scope.as_ref()));
34136        self
34137    }
34138    /// Identifies the authorization scope(s) for the method you are building.
34139    ///
34140    /// See [`Self::add_scope()`] for details.
34141    pub fn add_scopes<I, St>(
34142        mut self,
34143        scopes: I,
34144    ) -> ProjectInstanceInstancePartitionPatchCall<'a, C>
34145    where
34146        I: IntoIterator<Item = St>,
34147        St: AsRef<str>,
34148    {
34149        self._scopes
34150            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34151        self
34152    }
34153
34154    /// Removes all scopes, and no default scope will be used either.
34155    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34156    /// for details).
34157    pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
34158        self._scopes.clear();
34159        self
34160    }
34161}
34162
34163/// 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`.
34164///
34165/// A builder for the *instances.operations.cancel* method supported by a *project* resource.
34166/// It is not used directly, but through a [`ProjectMethods`] instance.
34167///
34168/// # Example
34169///
34170/// Instantiate a resource method builder
34171///
34172/// ```test_harness,no_run
34173/// # extern crate hyper;
34174/// # extern crate hyper_rustls;
34175/// # extern crate google_spanner1 as spanner1;
34176/// # async fn dox() {
34177/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34178///
34179/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34180/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34181/// #     .with_native_roots()
34182/// #     .unwrap()
34183/// #     .https_only()
34184/// #     .enable_http2()
34185/// #     .build();
34186///
34187/// # let executor = hyper_util::rt::TokioExecutor::new();
34188/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34189/// #     secret,
34190/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34191/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
34192/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
34193/// #     ),
34194/// # ).build().await.unwrap();
34195///
34196/// # let client = hyper_util::client::legacy::Client::builder(
34197/// #     hyper_util::rt::TokioExecutor::new()
34198/// # )
34199/// # .build(
34200/// #     hyper_rustls::HttpsConnectorBuilder::new()
34201/// #         .with_native_roots()
34202/// #         .unwrap()
34203/// #         .https_or_http()
34204/// #         .enable_http2()
34205/// #         .build()
34206/// # );
34207/// # let mut hub = Spanner::new(client, auth);
34208/// // You can configure optional parameters by calling the respective setters at will, and
34209/// // execute the final call using `doit()`.
34210/// // Values shown here are possibly random and not representative !
34211/// let result = hub.projects().instances_operations_cancel("name")
34212///              .doit().await;
34213/// # }
34214/// ```
34215pub struct ProjectInstanceOperationCancelCall<'a, C>
34216where
34217    C: 'a,
34218{
34219    hub: &'a Spanner<C>,
34220    _name: String,
34221    _delegate: Option<&'a mut dyn common::Delegate>,
34222    _additional_params: HashMap<String, String>,
34223    _scopes: BTreeSet<String>,
34224}
34225
34226impl<'a, C> common::CallBuilder for ProjectInstanceOperationCancelCall<'a, C> {}
34227
34228impl<'a, C> ProjectInstanceOperationCancelCall<'a, C>
34229where
34230    C: common::Connector,
34231{
34232    /// Perform the operation you have build so far.
34233    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
34234        use std::borrow::Cow;
34235        use std::io::{Read, Seek};
34236
34237        use common::{url::Params, ToParts};
34238        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34239
34240        let mut dd = common::DefaultDelegate;
34241        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34242        dlg.begin(common::MethodInfo {
34243            id: "spanner.projects.instances.operations.cancel",
34244            http_method: hyper::Method::POST,
34245        });
34246
34247        for &field in ["alt", "name"].iter() {
34248            if self._additional_params.contains_key(field) {
34249                dlg.finished(false);
34250                return Err(common::Error::FieldClash(field));
34251            }
34252        }
34253
34254        let mut params = Params::with_capacity(3 + self._additional_params.len());
34255        params.push("name", self._name);
34256
34257        params.extend(self._additional_params.iter());
34258
34259        params.push("alt", "json");
34260        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
34261        if self._scopes.is_empty() {
34262            self._scopes
34263                .insert(Scope::CloudPlatform.as_ref().to_string());
34264        }
34265
34266        #[allow(clippy::single_element_loop)]
34267        for &(find_this, param_name) in [("{+name}", "name")].iter() {
34268            url = params.uri_replacement(url, param_name, find_this, true);
34269        }
34270        {
34271            let to_remove = ["name"];
34272            params.remove_params(&to_remove);
34273        }
34274
34275        let url = params.parse_with_url(&url);
34276
34277        loop {
34278            let token = match self
34279                .hub
34280                .auth
34281                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34282                .await
34283            {
34284                Ok(token) => token,
34285                Err(e) => match dlg.token(e) {
34286                    Ok(token) => token,
34287                    Err(e) => {
34288                        dlg.finished(false);
34289                        return Err(common::Error::MissingToken(e));
34290                    }
34291                },
34292            };
34293            let mut req_result = {
34294                let client = &self.hub.client;
34295                dlg.pre_request();
34296                let mut req_builder = hyper::Request::builder()
34297                    .method(hyper::Method::POST)
34298                    .uri(url.as_str())
34299                    .header(USER_AGENT, self.hub._user_agent.clone());
34300
34301                if let Some(token) = token.as_ref() {
34302                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34303                }
34304
34305                let request = req_builder
34306                    .header(CONTENT_LENGTH, 0_u64)
34307                    .body(common::to_body::<String>(None));
34308
34309                client.request(request.unwrap()).await
34310            };
34311
34312            match req_result {
34313                Err(err) => {
34314                    if let common::Retry::After(d) = dlg.http_error(&err) {
34315                        sleep(d).await;
34316                        continue;
34317                    }
34318                    dlg.finished(false);
34319                    return Err(common::Error::HttpError(err));
34320                }
34321                Ok(res) => {
34322                    let (mut parts, body) = res.into_parts();
34323                    let mut body = common::Body::new(body);
34324                    if !parts.status.is_success() {
34325                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34326                        let error = serde_json::from_str(&common::to_string(&bytes));
34327                        let response = common::to_response(parts, bytes.into());
34328
34329                        if let common::Retry::After(d) =
34330                            dlg.http_failure(&response, error.as_ref().ok())
34331                        {
34332                            sleep(d).await;
34333                            continue;
34334                        }
34335
34336                        dlg.finished(false);
34337
34338                        return Err(match error {
34339                            Ok(value) => common::Error::BadRequest(value),
34340                            _ => common::Error::Failure(response),
34341                        });
34342                    }
34343                    let response = {
34344                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34345                        let encoded = common::to_string(&bytes);
34346                        match serde_json::from_str(&encoded) {
34347                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34348                            Err(error) => {
34349                                dlg.response_json_decode_error(&encoded, &error);
34350                                return Err(common::Error::JsonDecodeError(
34351                                    encoded.to_string(),
34352                                    error,
34353                                ));
34354                            }
34355                        }
34356                    };
34357
34358                    dlg.finished(true);
34359                    return Ok(response);
34360                }
34361            }
34362        }
34363    }
34364
34365    /// The name of the operation resource to be cancelled.
34366    ///
34367    /// Sets the *name* path property to the given value.
34368    ///
34369    /// Even though the property as already been set when instantiating this call,
34370    /// we provide this method for API completeness.
34371    pub fn name(mut self, new_value: &str) -> ProjectInstanceOperationCancelCall<'a, C> {
34372        self._name = new_value.to_string();
34373        self
34374    }
34375    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34376    /// while executing the actual API request.
34377    ///
34378    /// ````text
34379    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34380    /// ````
34381    ///
34382    /// Sets the *delegate* property to the given value.
34383    pub fn delegate(
34384        mut self,
34385        new_value: &'a mut dyn common::Delegate,
34386    ) -> ProjectInstanceOperationCancelCall<'a, C> {
34387        self._delegate = Some(new_value);
34388        self
34389    }
34390
34391    /// Set any additional parameter of the query string used in the request.
34392    /// It should be used to set parameters which are not yet available through their own
34393    /// setters.
34394    ///
34395    /// Please note that this method must not be used to set any of the known parameters
34396    /// which have their own setter method. If done anyway, the request will fail.
34397    ///
34398    /// # Additional Parameters
34399    ///
34400    /// * *$.xgafv* (query-string) - V1 error format.
34401    /// * *access_token* (query-string) - OAuth access token.
34402    /// * *alt* (query-string) - Data format for response.
34403    /// * *callback* (query-string) - JSONP
34404    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34405    /// * *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.
34406    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34407    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34408    /// * *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.
34409    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34410    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34411    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceOperationCancelCall<'a, C>
34412    where
34413        T: AsRef<str>,
34414    {
34415        self._additional_params
34416            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34417        self
34418    }
34419
34420    /// Identifies the authorization scope for the method you are building.
34421    ///
34422    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34423    /// [`Scope::CloudPlatform`].
34424    ///
34425    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34426    /// tokens for more than one scope.
34427    ///
34428    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34429    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34430    /// sufficient, a read-write scope will do as well.
34431    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceOperationCancelCall<'a, C>
34432    where
34433        St: AsRef<str>,
34434    {
34435        self._scopes.insert(String::from(scope.as_ref()));
34436        self
34437    }
34438    /// Identifies the authorization scope(s) for the method you are building.
34439    ///
34440    /// See [`Self::add_scope()`] for details.
34441    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceOperationCancelCall<'a, C>
34442    where
34443        I: IntoIterator<Item = St>,
34444        St: AsRef<str>,
34445    {
34446        self._scopes
34447            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34448        self
34449    }
34450
34451    /// Removes all scopes, and no default scope will be used either.
34452    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34453    /// for details).
34454    pub fn clear_scopes(mut self) -> ProjectInstanceOperationCancelCall<'a, C> {
34455        self._scopes.clear();
34456        self
34457    }
34458}
34459
34460/// 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`.
34461///
34462/// A builder for the *instances.operations.delete* method supported by a *project* resource.
34463/// It is not used directly, but through a [`ProjectMethods`] instance.
34464///
34465/// # Example
34466///
34467/// Instantiate a resource method builder
34468///
34469/// ```test_harness,no_run
34470/// # extern crate hyper;
34471/// # extern crate hyper_rustls;
34472/// # extern crate google_spanner1 as spanner1;
34473/// # async fn dox() {
34474/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34475///
34476/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34477/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34478/// #     .with_native_roots()
34479/// #     .unwrap()
34480/// #     .https_only()
34481/// #     .enable_http2()
34482/// #     .build();
34483///
34484/// # let executor = hyper_util::rt::TokioExecutor::new();
34485/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34486/// #     secret,
34487/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34488/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
34489/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
34490/// #     ),
34491/// # ).build().await.unwrap();
34492///
34493/// # let client = hyper_util::client::legacy::Client::builder(
34494/// #     hyper_util::rt::TokioExecutor::new()
34495/// # )
34496/// # .build(
34497/// #     hyper_rustls::HttpsConnectorBuilder::new()
34498/// #         .with_native_roots()
34499/// #         .unwrap()
34500/// #         .https_or_http()
34501/// #         .enable_http2()
34502/// #         .build()
34503/// # );
34504/// # let mut hub = Spanner::new(client, auth);
34505/// // You can configure optional parameters by calling the respective setters at will, and
34506/// // execute the final call using `doit()`.
34507/// // Values shown here are possibly random and not representative !
34508/// let result = hub.projects().instances_operations_delete("name")
34509///              .doit().await;
34510/// # }
34511/// ```
34512pub struct ProjectInstanceOperationDeleteCall<'a, C>
34513where
34514    C: 'a,
34515{
34516    hub: &'a Spanner<C>,
34517    _name: String,
34518    _delegate: Option<&'a mut dyn common::Delegate>,
34519    _additional_params: HashMap<String, String>,
34520    _scopes: BTreeSet<String>,
34521}
34522
34523impl<'a, C> common::CallBuilder for ProjectInstanceOperationDeleteCall<'a, C> {}
34524
34525impl<'a, C> ProjectInstanceOperationDeleteCall<'a, C>
34526where
34527    C: common::Connector,
34528{
34529    /// Perform the operation you have build so far.
34530    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
34531        use std::borrow::Cow;
34532        use std::io::{Read, Seek};
34533
34534        use common::{url::Params, ToParts};
34535        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34536
34537        let mut dd = common::DefaultDelegate;
34538        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34539        dlg.begin(common::MethodInfo {
34540            id: "spanner.projects.instances.operations.delete",
34541            http_method: hyper::Method::DELETE,
34542        });
34543
34544        for &field in ["alt", "name"].iter() {
34545            if self._additional_params.contains_key(field) {
34546                dlg.finished(false);
34547                return Err(common::Error::FieldClash(field));
34548            }
34549        }
34550
34551        let mut params = Params::with_capacity(3 + self._additional_params.len());
34552        params.push("name", self._name);
34553
34554        params.extend(self._additional_params.iter());
34555
34556        params.push("alt", "json");
34557        let mut url = self.hub._base_url.clone() + "v1/{+name}";
34558        if self._scopes.is_empty() {
34559            self._scopes
34560                .insert(Scope::CloudPlatform.as_ref().to_string());
34561        }
34562
34563        #[allow(clippy::single_element_loop)]
34564        for &(find_this, param_name) in [("{+name}", "name")].iter() {
34565            url = params.uri_replacement(url, param_name, find_this, true);
34566        }
34567        {
34568            let to_remove = ["name"];
34569            params.remove_params(&to_remove);
34570        }
34571
34572        let url = params.parse_with_url(&url);
34573
34574        loop {
34575            let token = match self
34576                .hub
34577                .auth
34578                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34579                .await
34580            {
34581                Ok(token) => token,
34582                Err(e) => match dlg.token(e) {
34583                    Ok(token) => token,
34584                    Err(e) => {
34585                        dlg.finished(false);
34586                        return Err(common::Error::MissingToken(e));
34587                    }
34588                },
34589            };
34590            let mut req_result = {
34591                let client = &self.hub.client;
34592                dlg.pre_request();
34593                let mut req_builder = hyper::Request::builder()
34594                    .method(hyper::Method::DELETE)
34595                    .uri(url.as_str())
34596                    .header(USER_AGENT, self.hub._user_agent.clone());
34597
34598                if let Some(token) = token.as_ref() {
34599                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34600                }
34601
34602                let request = req_builder
34603                    .header(CONTENT_LENGTH, 0_u64)
34604                    .body(common::to_body::<String>(None));
34605
34606                client.request(request.unwrap()).await
34607            };
34608
34609            match req_result {
34610                Err(err) => {
34611                    if let common::Retry::After(d) = dlg.http_error(&err) {
34612                        sleep(d).await;
34613                        continue;
34614                    }
34615                    dlg.finished(false);
34616                    return Err(common::Error::HttpError(err));
34617                }
34618                Ok(res) => {
34619                    let (mut parts, body) = res.into_parts();
34620                    let mut body = common::Body::new(body);
34621                    if !parts.status.is_success() {
34622                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34623                        let error = serde_json::from_str(&common::to_string(&bytes));
34624                        let response = common::to_response(parts, bytes.into());
34625
34626                        if let common::Retry::After(d) =
34627                            dlg.http_failure(&response, error.as_ref().ok())
34628                        {
34629                            sleep(d).await;
34630                            continue;
34631                        }
34632
34633                        dlg.finished(false);
34634
34635                        return Err(match error {
34636                            Ok(value) => common::Error::BadRequest(value),
34637                            _ => common::Error::Failure(response),
34638                        });
34639                    }
34640                    let response = {
34641                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34642                        let encoded = common::to_string(&bytes);
34643                        match serde_json::from_str(&encoded) {
34644                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34645                            Err(error) => {
34646                                dlg.response_json_decode_error(&encoded, &error);
34647                                return Err(common::Error::JsonDecodeError(
34648                                    encoded.to_string(),
34649                                    error,
34650                                ));
34651                            }
34652                        }
34653                    };
34654
34655                    dlg.finished(true);
34656                    return Ok(response);
34657                }
34658            }
34659        }
34660    }
34661
34662    /// The name of the operation resource to be deleted.
34663    ///
34664    /// Sets the *name* path property to the given value.
34665    ///
34666    /// Even though the property as already been set when instantiating this call,
34667    /// we provide this method for API completeness.
34668    pub fn name(mut self, new_value: &str) -> ProjectInstanceOperationDeleteCall<'a, C> {
34669        self._name = new_value.to_string();
34670        self
34671    }
34672    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34673    /// while executing the actual API request.
34674    ///
34675    /// ````text
34676    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34677    /// ````
34678    ///
34679    /// Sets the *delegate* property to the given value.
34680    pub fn delegate(
34681        mut self,
34682        new_value: &'a mut dyn common::Delegate,
34683    ) -> ProjectInstanceOperationDeleteCall<'a, C> {
34684        self._delegate = Some(new_value);
34685        self
34686    }
34687
34688    /// Set any additional parameter of the query string used in the request.
34689    /// It should be used to set parameters which are not yet available through their own
34690    /// setters.
34691    ///
34692    /// Please note that this method must not be used to set any of the known parameters
34693    /// which have their own setter method. If done anyway, the request will fail.
34694    ///
34695    /// # Additional Parameters
34696    ///
34697    /// * *$.xgafv* (query-string) - V1 error format.
34698    /// * *access_token* (query-string) - OAuth access token.
34699    /// * *alt* (query-string) - Data format for response.
34700    /// * *callback* (query-string) - JSONP
34701    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34702    /// * *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.
34703    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34704    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34705    /// * *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.
34706    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34707    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34708    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceOperationDeleteCall<'a, C>
34709    where
34710        T: AsRef<str>,
34711    {
34712        self._additional_params
34713            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34714        self
34715    }
34716
34717    /// Identifies the authorization scope for the method you are building.
34718    ///
34719    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34720    /// [`Scope::CloudPlatform`].
34721    ///
34722    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34723    /// tokens for more than one scope.
34724    ///
34725    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34726    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34727    /// sufficient, a read-write scope will do as well.
34728    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceOperationDeleteCall<'a, C>
34729    where
34730        St: AsRef<str>,
34731    {
34732        self._scopes.insert(String::from(scope.as_ref()));
34733        self
34734    }
34735    /// Identifies the authorization scope(s) for the method you are building.
34736    ///
34737    /// See [`Self::add_scope()`] for details.
34738    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceOperationDeleteCall<'a, C>
34739    where
34740        I: IntoIterator<Item = St>,
34741        St: AsRef<str>,
34742    {
34743        self._scopes
34744            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34745        self
34746    }
34747
34748    /// Removes all scopes, and no default scope will be used either.
34749    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34750    /// for details).
34751    pub fn clear_scopes(mut self) -> ProjectInstanceOperationDeleteCall<'a, C> {
34752        self._scopes.clear();
34753        self
34754    }
34755}
34756
34757/// 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.
34758///
34759/// A builder for the *instances.operations.get* method supported by a *project* resource.
34760/// It is not used directly, but through a [`ProjectMethods`] instance.
34761///
34762/// # Example
34763///
34764/// Instantiate a resource method builder
34765///
34766/// ```test_harness,no_run
34767/// # extern crate hyper;
34768/// # extern crate hyper_rustls;
34769/// # extern crate google_spanner1 as spanner1;
34770/// # async fn dox() {
34771/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34772///
34773/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34774/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34775/// #     .with_native_roots()
34776/// #     .unwrap()
34777/// #     .https_only()
34778/// #     .enable_http2()
34779/// #     .build();
34780///
34781/// # let executor = hyper_util::rt::TokioExecutor::new();
34782/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34783/// #     secret,
34784/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34785/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
34786/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
34787/// #     ),
34788/// # ).build().await.unwrap();
34789///
34790/// # let client = hyper_util::client::legacy::Client::builder(
34791/// #     hyper_util::rt::TokioExecutor::new()
34792/// # )
34793/// # .build(
34794/// #     hyper_rustls::HttpsConnectorBuilder::new()
34795/// #         .with_native_roots()
34796/// #         .unwrap()
34797/// #         .https_or_http()
34798/// #         .enable_http2()
34799/// #         .build()
34800/// # );
34801/// # let mut hub = Spanner::new(client, auth);
34802/// // You can configure optional parameters by calling the respective setters at will, and
34803/// // execute the final call using `doit()`.
34804/// // Values shown here are possibly random and not representative !
34805/// let result = hub.projects().instances_operations_get("name")
34806///              .doit().await;
34807/// # }
34808/// ```
34809pub struct ProjectInstanceOperationGetCall<'a, C>
34810where
34811    C: 'a,
34812{
34813    hub: &'a Spanner<C>,
34814    _name: String,
34815    _delegate: Option<&'a mut dyn common::Delegate>,
34816    _additional_params: HashMap<String, String>,
34817    _scopes: BTreeSet<String>,
34818}
34819
34820impl<'a, C> common::CallBuilder for ProjectInstanceOperationGetCall<'a, C> {}
34821
34822impl<'a, C> ProjectInstanceOperationGetCall<'a, C>
34823where
34824    C: common::Connector,
34825{
34826    /// Perform the operation you have build so far.
34827    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
34828        use std::borrow::Cow;
34829        use std::io::{Read, Seek};
34830
34831        use common::{url::Params, ToParts};
34832        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34833
34834        let mut dd = common::DefaultDelegate;
34835        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34836        dlg.begin(common::MethodInfo {
34837            id: "spanner.projects.instances.operations.get",
34838            http_method: hyper::Method::GET,
34839        });
34840
34841        for &field in ["alt", "name"].iter() {
34842            if self._additional_params.contains_key(field) {
34843                dlg.finished(false);
34844                return Err(common::Error::FieldClash(field));
34845            }
34846        }
34847
34848        let mut params = Params::with_capacity(3 + self._additional_params.len());
34849        params.push("name", self._name);
34850
34851        params.extend(self._additional_params.iter());
34852
34853        params.push("alt", "json");
34854        let mut url = self.hub._base_url.clone() + "v1/{+name}";
34855        if self._scopes.is_empty() {
34856            self._scopes
34857                .insert(Scope::CloudPlatform.as_ref().to_string());
34858        }
34859
34860        #[allow(clippy::single_element_loop)]
34861        for &(find_this, param_name) in [("{+name}", "name")].iter() {
34862            url = params.uri_replacement(url, param_name, find_this, true);
34863        }
34864        {
34865            let to_remove = ["name"];
34866            params.remove_params(&to_remove);
34867        }
34868
34869        let url = params.parse_with_url(&url);
34870
34871        loop {
34872            let token = match self
34873                .hub
34874                .auth
34875                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34876                .await
34877            {
34878                Ok(token) => token,
34879                Err(e) => match dlg.token(e) {
34880                    Ok(token) => token,
34881                    Err(e) => {
34882                        dlg.finished(false);
34883                        return Err(common::Error::MissingToken(e));
34884                    }
34885                },
34886            };
34887            let mut req_result = {
34888                let client = &self.hub.client;
34889                dlg.pre_request();
34890                let mut req_builder = hyper::Request::builder()
34891                    .method(hyper::Method::GET)
34892                    .uri(url.as_str())
34893                    .header(USER_AGENT, self.hub._user_agent.clone());
34894
34895                if let Some(token) = token.as_ref() {
34896                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34897                }
34898
34899                let request = req_builder
34900                    .header(CONTENT_LENGTH, 0_u64)
34901                    .body(common::to_body::<String>(None));
34902
34903                client.request(request.unwrap()).await
34904            };
34905
34906            match req_result {
34907                Err(err) => {
34908                    if let common::Retry::After(d) = dlg.http_error(&err) {
34909                        sleep(d).await;
34910                        continue;
34911                    }
34912                    dlg.finished(false);
34913                    return Err(common::Error::HttpError(err));
34914                }
34915                Ok(res) => {
34916                    let (mut parts, body) = res.into_parts();
34917                    let mut body = common::Body::new(body);
34918                    if !parts.status.is_success() {
34919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34920                        let error = serde_json::from_str(&common::to_string(&bytes));
34921                        let response = common::to_response(parts, bytes.into());
34922
34923                        if let common::Retry::After(d) =
34924                            dlg.http_failure(&response, error.as_ref().ok())
34925                        {
34926                            sleep(d).await;
34927                            continue;
34928                        }
34929
34930                        dlg.finished(false);
34931
34932                        return Err(match error {
34933                            Ok(value) => common::Error::BadRequest(value),
34934                            _ => common::Error::Failure(response),
34935                        });
34936                    }
34937                    let response = {
34938                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34939                        let encoded = common::to_string(&bytes);
34940                        match serde_json::from_str(&encoded) {
34941                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34942                            Err(error) => {
34943                                dlg.response_json_decode_error(&encoded, &error);
34944                                return Err(common::Error::JsonDecodeError(
34945                                    encoded.to_string(),
34946                                    error,
34947                                ));
34948                            }
34949                        }
34950                    };
34951
34952                    dlg.finished(true);
34953                    return Ok(response);
34954                }
34955            }
34956        }
34957    }
34958
34959    /// The name of the operation resource.
34960    ///
34961    /// Sets the *name* path property to the given value.
34962    ///
34963    /// Even though the property as already been set when instantiating this call,
34964    /// we provide this method for API completeness.
34965    pub fn name(mut self, new_value: &str) -> ProjectInstanceOperationGetCall<'a, C> {
34966        self._name = new_value.to_string();
34967        self
34968    }
34969    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34970    /// while executing the actual API request.
34971    ///
34972    /// ````text
34973    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34974    /// ````
34975    ///
34976    /// Sets the *delegate* property to the given value.
34977    pub fn delegate(
34978        mut self,
34979        new_value: &'a mut dyn common::Delegate,
34980    ) -> ProjectInstanceOperationGetCall<'a, C> {
34981        self._delegate = Some(new_value);
34982        self
34983    }
34984
34985    /// Set any additional parameter of the query string used in the request.
34986    /// It should be used to set parameters which are not yet available through their own
34987    /// setters.
34988    ///
34989    /// Please note that this method must not be used to set any of the known parameters
34990    /// which have their own setter method. If done anyway, the request will fail.
34991    ///
34992    /// # Additional Parameters
34993    ///
34994    /// * *$.xgafv* (query-string) - V1 error format.
34995    /// * *access_token* (query-string) - OAuth access token.
34996    /// * *alt* (query-string) - Data format for response.
34997    /// * *callback* (query-string) - JSONP
34998    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34999    /// * *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.
35000    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35001    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35002    /// * *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.
35003    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35004    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35005    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceOperationGetCall<'a, C>
35006    where
35007        T: AsRef<str>,
35008    {
35009        self._additional_params
35010            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35011        self
35012    }
35013
35014    /// Identifies the authorization scope for the method you are building.
35015    ///
35016    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35017    /// [`Scope::CloudPlatform`].
35018    ///
35019    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35020    /// tokens for more than one scope.
35021    ///
35022    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35023    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35024    /// sufficient, a read-write scope will do as well.
35025    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceOperationGetCall<'a, C>
35026    where
35027        St: AsRef<str>,
35028    {
35029        self._scopes.insert(String::from(scope.as_ref()));
35030        self
35031    }
35032    /// Identifies the authorization scope(s) for the method you are building.
35033    ///
35034    /// See [`Self::add_scope()`] for details.
35035    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceOperationGetCall<'a, C>
35036    where
35037        I: IntoIterator<Item = St>,
35038        St: AsRef<str>,
35039    {
35040        self._scopes
35041            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35042        self
35043    }
35044
35045    /// Removes all scopes, and no default scope will be used either.
35046    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35047    /// for details).
35048    pub fn clear_scopes(mut self) -> ProjectInstanceOperationGetCall<'a, C> {
35049        self._scopes.clear();
35050        self
35051    }
35052}
35053
35054/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
35055///
35056/// A builder for the *instances.operations.list* method supported by a *project* resource.
35057/// It is not used directly, but through a [`ProjectMethods`] instance.
35058///
35059/// # Example
35060///
35061/// Instantiate a resource method builder
35062///
35063/// ```test_harness,no_run
35064/// # extern crate hyper;
35065/// # extern crate hyper_rustls;
35066/// # extern crate google_spanner1 as spanner1;
35067/// # async fn dox() {
35068/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35069///
35070/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35071/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35072/// #     .with_native_roots()
35073/// #     .unwrap()
35074/// #     .https_only()
35075/// #     .enable_http2()
35076/// #     .build();
35077///
35078/// # let executor = hyper_util::rt::TokioExecutor::new();
35079/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35080/// #     secret,
35081/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35082/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
35083/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
35084/// #     ),
35085/// # ).build().await.unwrap();
35086///
35087/// # let client = hyper_util::client::legacy::Client::builder(
35088/// #     hyper_util::rt::TokioExecutor::new()
35089/// # )
35090/// # .build(
35091/// #     hyper_rustls::HttpsConnectorBuilder::new()
35092/// #         .with_native_roots()
35093/// #         .unwrap()
35094/// #         .https_or_http()
35095/// #         .enable_http2()
35096/// #         .build()
35097/// # );
35098/// # let mut hub = Spanner::new(client, auth);
35099/// // You can configure optional parameters by calling the respective setters at will, and
35100/// // execute the final call using `doit()`.
35101/// // Values shown here are possibly random and not representative !
35102/// let result = hub.projects().instances_operations_list("name")
35103///              .return_partial_success(false)
35104///              .page_token("dolor")
35105///              .page_size(-22)
35106///              .filter("sit")
35107///              .doit().await;
35108/// # }
35109/// ```
35110pub struct ProjectInstanceOperationListCall<'a, C>
35111where
35112    C: 'a,
35113{
35114    hub: &'a Spanner<C>,
35115    _name: String,
35116    _return_partial_success: Option<bool>,
35117    _page_token: Option<String>,
35118    _page_size: Option<i32>,
35119    _filter: Option<String>,
35120    _delegate: Option<&'a mut dyn common::Delegate>,
35121    _additional_params: HashMap<String, String>,
35122    _scopes: BTreeSet<String>,
35123}
35124
35125impl<'a, C> common::CallBuilder for ProjectInstanceOperationListCall<'a, C> {}
35126
35127impl<'a, C> ProjectInstanceOperationListCall<'a, C>
35128where
35129    C: common::Connector,
35130{
35131    /// Perform the operation you have build so far.
35132    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
35133        use std::borrow::Cow;
35134        use std::io::{Read, Seek};
35135
35136        use common::{url::Params, ToParts};
35137        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35138
35139        let mut dd = common::DefaultDelegate;
35140        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35141        dlg.begin(common::MethodInfo {
35142            id: "spanner.projects.instances.operations.list",
35143            http_method: hyper::Method::GET,
35144        });
35145
35146        for &field in [
35147            "alt",
35148            "name",
35149            "returnPartialSuccess",
35150            "pageToken",
35151            "pageSize",
35152            "filter",
35153        ]
35154        .iter()
35155        {
35156            if self._additional_params.contains_key(field) {
35157                dlg.finished(false);
35158                return Err(common::Error::FieldClash(field));
35159            }
35160        }
35161
35162        let mut params = Params::with_capacity(7 + self._additional_params.len());
35163        params.push("name", self._name);
35164        if let Some(value) = self._return_partial_success.as_ref() {
35165            params.push("returnPartialSuccess", value.to_string());
35166        }
35167        if let Some(value) = self._page_token.as_ref() {
35168            params.push("pageToken", value);
35169        }
35170        if let Some(value) = self._page_size.as_ref() {
35171            params.push("pageSize", value.to_string());
35172        }
35173        if let Some(value) = self._filter.as_ref() {
35174            params.push("filter", value);
35175        }
35176
35177        params.extend(self._additional_params.iter());
35178
35179        params.push("alt", "json");
35180        let mut url = self.hub._base_url.clone() + "v1/{+name}";
35181        if self._scopes.is_empty() {
35182            self._scopes
35183                .insert(Scope::CloudPlatform.as_ref().to_string());
35184        }
35185
35186        #[allow(clippy::single_element_loop)]
35187        for &(find_this, param_name) in [("{+name}", "name")].iter() {
35188            url = params.uri_replacement(url, param_name, find_this, true);
35189        }
35190        {
35191            let to_remove = ["name"];
35192            params.remove_params(&to_remove);
35193        }
35194
35195        let url = params.parse_with_url(&url);
35196
35197        loop {
35198            let token = match self
35199                .hub
35200                .auth
35201                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35202                .await
35203            {
35204                Ok(token) => token,
35205                Err(e) => match dlg.token(e) {
35206                    Ok(token) => token,
35207                    Err(e) => {
35208                        dlg.finished(false);
35209                        return Err(common::Error::MissingToken(e));
35210                    }
35211                },
35212            };
35213            let mut req_result = {
35214                let client = &self.hub.client;
35215                dlg.pre_request();
35216                let mut req_builder = hyper::Request::builder()
35217                    .method(hyper::Method::GET)
35218                    .uri(url.as_str())
35219                    .header(USER_AGENT, self.hub._user_agent.clone());
35220
35221                if let Some(token) = token.as_ref() {
35222                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35223                }
35224
35225                let request = req_builder
35226                    .header(CONTENT_LENGTH, 0_u64)
35227                    .body(common::to_body::<String>(None));
35228
35229                client.request(request.unwrap()).await
35230            };
35231
35232            match req_result {
35233                Err(err) => {
35234                    if let common::Retry::After(d) = dlg.http_error(&err) {
35235                        sleep(d).await;
35236                        continue;
35237                    }
35238                    dlg.finished(false);
35239                    return Err(common::Error::HttpError(err));
35240                }
35241                Ok(res) => {
35242                    let (mut parts, body) = res.into_parts();
35243                    let mut body = common::Body::new(body);
35244                    if !parts.status.is_success() {
35245                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35246                        let error = serde_json::from_str(&common::to_string(&bytes));
35247                        let response = common::to_response(parts, bytes.into());
35248
35249                        if let common::Retry::After(d) =
35250                            dlg.http_failure(&response, error.as_ref().ok())
35251                        {
35252                            sleep(d).await;
35253                            continue;
35254                        }
35255
35256                        dlg.finished(false);
35257
35258                        return Err(match error {
35259                            Ok(value) => common::Error::BadRequest(value),
35260                            _ => common::Error::Failure(response),
35261                        });
35262                    }
35263                    let response = {
35264                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35265                        let encoded = common::to_string(&bytes);
35266                        match serde_json::from_str(&encoded) {
35267                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35268                            Err(error) => {
35269                                dlg.response_json_decode_error(&encoded, &error);
35270                                return Err(common::Error::JsonDecodeError(
35271                                    encoded.to_string(),
35272                                    error,
35273                                ));
35274                            }
35275                        }
35276                    };
35277
35278                    dlg.finished(true);
35279                    return Ok(response);
35280                }
35281            }
35282        }
35283    }
35284
35285    /// The name of the operation's parent resource.
35286    ///
35287    /// Sets the *name* path property to the given value.
35288    ///
35289    /// Even though the property as already been set when instantiating this call,
35290    /// we provide this method for API completeness.
35291    pub fn name(mut self, new_value: &str) -> ProjectInstanceOperationListCall<'a, C> {
35292        self._name = new_value.to_string();
35293        self
35294    }
35295    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
35296    ///
35297    /// Sets the *return partial success* query property to the given value.
35298    pub fn return_partial_success(
35299        mut self,
35300        new_value: bool,
35301    ) -> ProjectInstanceOperationListCall<'a, C> {
35302        self._return_partial_success = Some(new_value);
35303        self
35304    }
35305    /// The standard list page token.
35306    ///
35307    /// Sets the *page token* query property to the given value.
35308    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceOperationListCall<'a, C> {
35309        self._page_token = Some(new_value.to_string());
35310        self
35311    }
35312    /// The standard list page size.
35313    ///
35314    /// Sets the *page size* query property to the given value.
35315    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceOperationListCall<'a, C> {
35316        self._page_size = Some(new_value);
35317        self
35318    }
35319    /// The standard list filter.
35320    ///
35321    /// Sets the *filter* query property to the given value.
35322    pub fn filter(mut self, new_value: &str) -> ProjectInstanceOperationListCall<'a, C> {
35323        self._filter = Some(new_value.to_string());
35324        self
35325    }
35326    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35327    /// while executing the actual API request.
35328    ///
35329    /// ````text
35330    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35331    /// ````
35332    ///
35333    /// Sets the *delegate* property to the given value.
35334    pub fn delegate(
35335        mut self,
35336        new_value: &'a mut dyn common::Delegate,
35337    ) -> ProjectInstanceOperationListCall<'a, C> {
35338        self._delegate = Some(new_value);
35339        self
35340    }
35341
35342    /// Set any additional parameter of the query string used in the request.
35343    /// It should be used to set parameters which are not yet available through their own
35344    /// setters.
35345    ///
35346    /// Please note that this method must not be used to set any of the known parameters
35347    /// which have their own setter method. If done anyway, the request will fail.
35348    ///
35349    /// # Additional Parameters
35350    ///
35351    /// * *$.xgafv* (query-string) - V1 error format.
35352    /// * *access_token* (query-string) - OAuth access token.
35353    /// * *alt* (query-string) - Data format for response.
35354    /// * *callback* (query-string) - JSONP
35355    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35356    /// * *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.
35357    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35358    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35359    /// * *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.
35360    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35361    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35362    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceOperationListCall<'a, C>
35363    where
35364        T: AsRef<str>,
35365    {
35366        self._additional_params
35367            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35368        self
35369    }
35370
35371    /// Identifies the authorization scope for the method you are building.
35372    ///
35373    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35374    /// [`Scope::CloudPlatform`].
35375    ///
35376    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35377    /// tokens for more than one scope.
35378    ///
35379    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35380    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35381    /// sufficient, a read-write scope will do as well.
35382    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceOperationListCall<'a, C>
35383    where
35384        St: AsRef<str>,
35385    {
35386        self._scopes.insert(String::from(scope.as_ref()));
35387        self
35388    }
35389    /// Identifies the authorization scope(s) for the method you are building.
35390    ///
35391    /// See [`Self::add_scope()`] for details.
35392    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceOperationListCall<'a, C>
35393    where
35394        I: IntoIterator<Item = St>,
35395        St: AsRef<str>,
35396    {
35397        self._scopes
35398            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35399        self
35400    }
35401
35402    /// Removes all scopes, and no default scope will be used either.
35403    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35404    /// for details).
35405    pub fn clear_scopes(mut self) -> ProjectInstanceOperationListCall<'a, C> {
35406        self._scopes.clear();
35407        self
35408    }
35409}
35410
35411/// Creates an instance and begins preparing it to begin serving. The returned long-running operation can be used to track the progress of preparing the new instance. The instance name is assigned by the caller. If the named instance already exists, `CreateInstance` returns `ALREADY_EXISTS`. Immediately upon completion of this request: * The instance is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`. Until completion of the returned operation: * Cancelling the operation renders the instance immediately unreadable via the API. * The instance can be deleted. * All other attempts to modify the instance are rejected. Upon completion of the returned operation: * Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can be created in the instance. * The instance's allocated resource levels are readable via the API. * The instance's state becomes `READY`. The returned long-running operation will have a name of the format `/operations/` and can be used to track creation of the instance. The metadata field type is CreateInstanceMetadata. The response field type is Instance, if successful.
35412///
35413/// A builder for the *instances.create* method supported by a *project* resource.
35414/// It is not used directly, but through a [`ProjectMethods`] instance.
35415///
35416/// # Example
35417///
35418/// Instantiate a resource method builder
35419///
35420/// ```test_harness,no_run
35421/// # extern crate hyper;
35422/// # extern crate hyper_rustls;
35423/// # extern crate google_spanner1 as spanner1;
35424/// use spanner1::api::CreateInstanceRequest;
35425/// # async fn dox() {
35426/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35427///
35428/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35429/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35430/// #     .with_native_roots()
35431/// #     .unwrap()
35432/// #     .https_only()
35433/// #     .enable_http2()
35434/// #     .build();
35435///
35436/// # let executor = hyper_util::rt::TokioExecutor::new();
35437/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35438/// #     secret,
35439/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35440/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
35441/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
35442/// #     ),
35443/// # ).build().await.unwrap();
35444///
35445/// # let client = hyper_util::client::legacy::Client::builder(
35446/// #     hyper_util::rt::TokioExecutor::new()
35447/// # )
35448/// # .build(
35449/// #     hyper_rustls::HttpsConnectorBuilder::new()
35450/// #         .with_native_roots()
35451/// #         .unwrap()
35452/// #         .https_or_http()
35453/// #         .enable_http2()
35454/// #         .build()
35455/// # );
35456/// # let mut hub = Spanner::new(client, auth);
35457/// // As the method needs a request, you would usually fill it with the desired information
35458/// // into the respective structure. Some of the parts shown here might not be applicable !
35459/// // Values shown here are possibly random and not representative !
35460/// let mut req = CreateInstanceRequest::default();
35461///
35462/// // You can configure optional parameters by calling the respective setters at will, and
35463/// // execute the final call using `doit()`.
35464/// // Values shown here are possibly random and not representative !
35465/// let result = hub.projects().instances_create(req, "parent")
35466///              .doit().await;
35467/// # }
35468/// ```
35469pub struct ProjectInstanceCreateCall<'a, C>
35470where
35471    C: 'a,
35472{
35473    hub: &'a Spanner<C>,
35474    _request: CreateInstanceRequest,
35475    _parent: String,
35476    _delegate: Option<&'a mut dyn common::Delegate>,
35477    _additional_params: HashMap<String, String>,
35478    _scopes: BTreeSet<String>,
35479}
35480
35481impl<'a, C> common::CallBuilder for ProjectInstanceCreateCall<'a, C> {}
35482
35483impl<'a, C> ProjectInstanceCreateCall<'a, C>
35484where
35485    C: common::Connector,
35486{
35487    /// Perform the operation you have build so far.
35488    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
35489        use std::borrow::Cow;
35490        use std::io::{Read, Seek};
35491
35492        use common::{url::Params, ToParts};
35493        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35494
35495        let mut dd = common::DefaultDelegate;
35496        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35497        dlg.begin(common::MethodInfo {
35498            id: "spanner.projects.instances.create",
35499            http_method: hyper::Method::POST,
35500        });
35501
35502        for &field in ["alt", "parent"].iter() {
35503            if self._additional_params.contains_key(field) {
35504                dlg.finished(false);
35505                return Err(common::Error::FieldClash(field));
35506            }
35507        }
35508
35509        let mut params = Params::with_capacity(4 + self._additional_params.len());
35510        params.push("parent", self._parent);
35511
35512        params.extend(self._additional_params.iter());
35513
35514        params.push("alt", "json");
35515        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
35516        if self._scopes.is_empty() {
35517            self._scopes
35518                .insert(Scope::CloudPlatform.as_ref().to_string());
35519        }
35520
35521        #[allow(clippy::single_element_loop)]
35522        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
35523            url = params.uri_replacement(url, param_name, find_this, true);
35524        }
35525        {
35526            let to_remove = ["parent"];
35527            params.remove_params(&to_remove);
35528        }
35529
35530        let url = params.parse_with_url(&url);
35531
35532        let mut json_mime_type = mime::APPLICATION_JSON;
35533        let mut request_value_reader = {
35534            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
35535            common::remove_json_null_values(&mut value);
35536            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
35537            serde_json::to_writer(&mut dst, &value).unwrap();
35538            dst
35539        };
35540        let request_size = request_value_reader
35541            .seek(std::io::SeekFrom::End(0))
35542            .unwrap();
35543        request_value_reader
35544            .seek(std::io::SeekFrom::Start(0))
35545            .unwrap();
35546
35547        loop {
35548            let token = match self
35549                .hub
35550                .auth
35551                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35552                .await
35553            {
35554                Ok(token) => token,
35555                Err(e) => match dlg.token(e) {
35556                    Ok(token) => token,
35557                    Err(e) => {
35558                        dlg.finished(false);
35559                        return Err(common::Error::MissingToken(e));
35560                    }
35561                },
35562            };
35563            request_value_reader
35564                .seek(std::io::SeekFrom::Start(0))
35565                .unwrap();
35566            let mut req_result = {
35567                let client = &self.hub.client;
35568                dlg.pre_request();
35569                let mut req_builder = hyper::Request::builder()
35570                    .method(hyper::Method::POST)
35571                    .uri(url.as_str())
35572                    .header(USER_AGENT, self.hub._user_agent.clone());
35573
35574                if let Some(token) = token.as_ref() {
35575                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35576                }
35577
35578                let request = req_builder
35579                    .header(CONTENT_TYPE, json_mime_type.to_string())
35580                    .header(CONTENT_LENGTH, request_size as u64)
35581                    .body(common::to_body(
35582                        request_value_reader.get_ref().clone().into(),
35583                    ));
35584
35585                client.request(request.unwrap()).await
35586            };
35587
35588            match req_result {
35589                Err(err) => {
35590                    if let common::Retry::After(d) = dlg.http_error(&err) {
35591                        sleep(d).await;
35592                        continue;
35593                    }
35594                    dlg.finished(false);
35595                    return Err(common::Error::HttpError(err));
35596                }
35597                Ok(res) => {
35598                    let (mut parts, body) = res.into_parts();
35599                    let mut body = common::Body::new(body);
35600                    if !parts.status.is_success() {
35601                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35602                        let error = serde_json::from_str(&common::to_string(&bytes));
35603                        let response = common::to_response(parts, bytes.into());
35604
35605                        if let common::Retry::After(d) =
35606                            dlg.http_failure(&response, error.as_ref().ok())
35607                        {
35608                            sleep(d).await;
35609                            continue;
35610                        }
35611
35612                        dlg.finished(false);
35613
35614                        return Err(match error {
35615                            Ok(value) => common::Error::BadRequest(value),
35616                            _ => common::Error::Failure(response),
35617                        });
35618                    }
35619                    let response = {
35620                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35621                        let encoded = common::to_string(&bytes);
35622                        match serde_json::from_str(&encoded) {
35623                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35624                            Err(error) => {
35625                                dlg.response_json_decode_error(&encoded, &error);
35626                                return Err(common::Error::JsonDecodeError(
35627                                    encoded.to_string(),
35628                                    error,
35629                                ));
35630                            }
35631                        }
35632                    };
35633
35634                    dlg.finished(true);
35635                    return Ok(response);
35636                }
35637            }
35638        }
35639    }
35640
35641    ///
35642    /// Sets the *request* property to the given value.
35643    ///
35644    /// Even though the property as already been set when instantiating this call,
35645    /// we provide this method for API completeness.
35646    pub fn request(mut self, new_value: CreateInstanceRequest) -> ProjectInstanceCreateCall<'a, C> {
35647        self._request = new_value;
35648        self
35649    }
35650    /// Required. The name of the project in which to create the instance. Values are of the form `projects/`.
35651    ///
35652    /// Sets the *parent* path property to the given value.
35653    ///
35654    /// Even though the property as already been set when instantiating this call,
35655    /// we provide this method for API completeness.
35656    pub fn parent(mut self, new_value: &str) -> ProjectInstanceCreateCall<'a, C> {
35657        self._parent = new_value.to_string();
35658        self
35659    }
35660    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35661    /// while executing the actual API request.
35662    ///
35663    /// ````text
35664    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35665    /// ````
35666    ///
35667    /// Sets the *delegate* property to the given value.
35668    pub fn delegate(
35669        mut self,
35670        new_value: &'a mut dyn common::Delegate,
35671    ) -> ProjectInstanceCreateCall<'a, C> {
35672        self._delegate = Some(new_value);
35673        self
35674    }
35675
35676    /// Set any additional parameter of the query string used in the request.
35677    /// It should be used to set parameters which are not yet available through their own
35678    /// setters.
35679    ///
35680    /// Please note that this method must not be used to set any of the known parameters
35681    /// which have their own setter method. If done anyway, the request will fail.
35682    ///
35683    /// # Additional Parameters
35684    ///
35685    /// * *$.xgafv* (query-string) - V1 error format.
35686    /// * *access_token* (query-string) - OAuth access token.
35687    /// * *alt* (query-string) - Data format for response.
35688    /// * *callback* (query-string) - JSONP
35689    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35690    /// * *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.
35691    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35692    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35693    /// * *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.
35694    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35695    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35696    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceCreateCall<'a, C>
35697    where
35698        T: AsRef<str>,
35699    {
35700        self._additional_params
35701            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35702        self
35703    }
35704
35705    /// Identifies the authorization scope for the method you are building.
35706    ///
35707    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35708    /// [`Scope::CloudPlatform`].
35709    ///
35710    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35711    /// tokens for more than one scope.
35712    ///
35713    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35714    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35715    /// sufficient, a read-write scope will do as well.
35716    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceCreateCall<'a, C>
35717    where
35718        St: AsRef<str>,
35719    {
35720        self._scopes.insert(String::from(scope.as_ref()));
35721        self
35722    }
35723    /// Identifies the authorization scope(s) for the method you are building.
35724    ///
35725    /// See [`Self::add_scope()`] for details.
35726    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceCreateCall<'a, C>
35727    where
35728        I: IntoIterator<Item = St>,
35729        St: AsRef<str>,
35730    {
35731        self._scopes
35732            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35733        self
35734    }
35735
35736    /// Removes all scopes, and no default scope will be used either.
35737    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35738    /// for details).
35739    pub fn clear_scopes(mut self) -> ProjectInstanceCreateCall<'a, C> {
35740        self._scopes.clear();
35741        self
35742    }
35743}
35744
35745/// Deletes an instance. Immediately upon completion of the request: * Billing ceases for all of the instance's reserved resources. Soon afterward: * The instance and *all of its databases* immediately and irrevocably disappear from the API. All data in the databases is permanently deleted.
35746///
35747/// A builder for the *instances.delete* method supported by a *project* resource.
35748/// It is not used directly, but through a [`ProjectMethods`] instance.
35749///
35750/// # Example
35751///
35752/// Instantiate a resource method builder
35753///
35754/// ```test_harness,no_run
35755/// # extern crate hyper;
35756/// # extern crate hyper_rustls;
35757/// # extern crate google_spanner1 as spanner1;
35758/// # async fn dox() {
35759/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35760///
35761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35762/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35763/// #     .with_native_roots()
35764/// #     .unwrap()
35765/// #     .https_only()
35766/// #     .enable_http2()
35767/// #     .build();
35768///
35769/// # let executor = hyper_util::rt::TokioExecutor::new();
35770/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35771/// #     secret,
35772/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35773/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
35774/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
35775/// #     ),
35776/// # ).build().await.unwrap();
35777///
35778/// # let client = hyper_util::client::legacy::Client::builder(
35779/// #     hyper_util::rt::TokioExecutor::new()
35780/// # )
35781/// # .build(
35782/// #     hyper_rustls::HttpsConnectorBuilder::new()
35783/// #         .with_native_roots()
35784/// #         .unwrap()
35785/// #         .https_or_http()
35786/// #         .enable_http2()
35787/// #         .build()
35788/// # );
35789/// # let mut hub = Spanner::new(client, auth);
35790/// // You can configure optional parameters by calling the respective setters at will, and
35791/// // execute the final call using `doit()`.
35792/// // Values shown here are possibly random and not representative !
35793/// let result = hub.projects().instances_delete("name")
35794///              .doit().await;
35795/// # }
35796/// ```
35797pub struct ProjectInstanceDeleteCall<'a, C>
35798where
35799    C: 'a,
35800{
35801    hub: &'a Spanner<C>,
35802    _name: String,
35803    _delegate: Option<&'a mut dyn common::Delegate>,
35804    _additional_params: HashMap<String, String>,
35805    _scopes: BTreeSet<String>,
35806}
35807
35808impl<'a, C> common::CallBuilder for ProjectInstanceDeleteCall<'a, C> {}
35809
35810impl<'a, C> ProjectInstanceDeleteCall<'a, C>
35811where
35812    C: common::Connector,
35813{
35814    /// Perform the operation you have build so far.
35815    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
35816        use std::borrow::Cow;
35817        use std::io::{Read, Seek};
35818
35819        use common::{url::Params, ToParts};
35820        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35821
35822        let mut dd = common::DefaultDelegate;
35823        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35824        dlg.begin(common::MethodInfo {
35825            id: "spanner.projects.instances.delete",
35826            http_method: hyper::Method::DELETE,
35827        });
35828
35829        for &field in ["alt", "name"].iter() {
35830            if self._additional_params.contains_key(field) {
35831                dlg.finished(false);
35832                return Err(common::Error::FieldClash(field));
35833            }
35834        }
35835
35836        let mut params = Params::with_capacity(3 + self._additional_params.len());
35837        params.push("name", self._name);
35838
35839        params.extend(self._additional_params.iter());
35840
35841        params.push("alt", "json");
35842        let mut url = self.hub._base_url.clone() + "v1/{+name}";
35843        if self._scopes.is_empty() {
35844            self._scopes
35845                .insert(Scope::CloudPlatform.as_ref().to_string());
35846        }
35847
35848        #[allow(clippy::single_element_loop)]
35849        for &(find_this, param_name) in [("{+name}", "name")].iter() {
35850            url = params.uri_replacement(url, param_name, find_this, true);
35851        }
35852        {
35853            let to_remove = ["name"];
35854            params.remove_params(&to_remove);
35855        }
35856
35857        let url = params.parse_with_url(&url);
35858
35859        loop {
35860            let token = match self
35861                .hub
35862                .auth
35863                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35864                .await
35865            {
35866                Ok(token) => token,
35867                Err(e) => match dlg.token(e) {
35868                    Ok(token) => token,
35869                    Err(e) => {
35870                        dlg.finished(false);
35871                        return Err(common::Error::MissingToken(e));
35872                    }
35873                },
35874            };
35875            let mut req_result = {
35876                let client = &self.hub.client;
35877                dlg.pre_request();
35878                let mut req_builder = hyper::Request::builder()
35879                    .method(hyper::Method::DELETE)
35880                    .uri(url.as_str())
35881                    .header(USER_AGENT, self.hub._user_agent.clone());
35882
35883                if let Some(token) = token.as_ref() {
35884                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35885                }
35886
35887                let request = req_builder
35888                    .header(CONTENT_LENGTH, 0_u64)
35889                    .body(common::to_body::<String>(None));
35890
35891                client.request(request.unwrap()).await
35892            };
35893
35894            match req_result {
35895                Err(err) => {
35896                    if let common::Retry::After(d) = dlg.http_error(&err) {
35897                        sleep(d).await;
35898                        continue;
35899                    }
35900                    dlg.finished(false);
35901                    return Err(common::Error::HttpError(err));
35902                }
35903                Ok(res) => {
35904                    let (mut parts, body) = res.into_parts();
35905                    let mut body = common::Body::new(body);
35906                    if !parts.status.is_success() {
35907                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35908                        let error = serde_json::from_str(&common::to_string(&bytes));
35909                        let response = common::to_response(parts, bytes.into());
35910
35911                        if let common::Retry::After(d) =
35912                            dlg.http_failure(&response, error.as_ref().ok())
35913                        {
35914                            sleep(d).await;
35915                            continue;
35916                        }
35917
35918                        dlg.finished(false);
35919
35920                        return Err(match error {
35921                            Ok(value) => common::Error::BadRequest(value),
35922                            _ => common::Error::Failure(response),
35923                        });
35924                    }
35925                    let response = {
35926                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35927                        let encoded = common::to_string(&bytes);
35928                        match serde_json::from_str(&encoded) {
35929                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35930                            Err(error) => {
35931                                dlg.response_json_decode_error(&encoded, &error);
35932                                return Err(common::Error::JsonDecodeError(
35933                                    encoded.to_string(),
35934                                    error,
35935                                ));
35936                            }
35937                        }
35938                    };
35939
35940                    dlg.finished(true);
35941                    return Ok(response);
35942                }
35943            }
35944        }
35945    }
35946
35947    /// Required. The name of the instance to be deleted. Values are of the form `projects//instances/`
35948    ///
35949    /// Sets the *name* path property to the given value.
35950    ///
35951    /// Even though the property as already been set when instantiating this call,
35952    /// we provide this method for API completeness.
35953    pub fn name(mut self, new_value: &str) -> ProjectInstanceDeleteCall<'a, C> {
35954        self._name = new_value.to_string();
35955        self
35956    }
35957    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35958    /// while executing the actual API request.
35959    ///
35960    /// ````text
35961    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35962    /// ````
35963    ///
35964    /// Sets the *delegate* property to the given value.
35965    pub fn delegate(
35966        mut self,
35967        new_value: &'a mut dyn common::Delegate,
35968    ) -> ProjectInstanceDeleteCall<'a, C> {
35969        self._delegate = Some(new_value);
35970        self
35971    }
35972
35973    /// Set any additional parameter of the query string used in the request.
35974    /// It should be used to set parameters which are not yet available through their own
35975    /// setters.
35976    ///
35977    /// Please note that this method must not be used to set any of the known parameters
35978    /// which have their own setter method. If done anyway, the request will fail.
35979    ///
35980    /// # Additional Parameters
35981    ///
35982    /// * *$.xgafv* (query-string) - V1 error format.
35983    /// * *access_token* (query-string) - OAuth access token.
35984    /// * *alt* (query-string) - Data format for response.
35985    /// * *callback* (query-string) - JSONP
35986    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35987    /// * *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.
35988    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35989    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35990    /// * *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.
35991    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35992    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35993    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDeleteCall<'a, C>
35994    where
35995        T: AsRef<str>,
35996    {
35997        self._additional_params
35998            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35999        self
36000    }
36001
36002    /// Identifies the authorization scope for the method you are building.
36003    ///
36004    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36005    /// [`Scope::CloudPlatform`].
36006    ///
36007    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36008    /// tokens for more than one scope.
36009    ///
36010    /// Usually there is more than one suitable scope to authorize an operation, some of which may
36011    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36012    /// sufficient, a read-write scope will do as well.
36013    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDeleteCall<'a, C>
36014    where
36015        St: AsRef<str>,
36016    {
36017        self._scopes.insert(String::from(scope.as_ref()));
36018        self
36019    }
36020    /// Identifies the authorization scope(s) for the method you are building.
36021    ///
36022    /// See [`Self::add_scope()`] for details.
36023    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDeleteCall<'a, C>
36024    where
36025        I: IntoIterator<Item = St>,
36026        St: AsRef<str>,
36027    {
36028        self._scopes
36029            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36030        self
36031    }
36032
36033    /// Removes all scopes, and no default scope will be used either.
36034    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36035    /// for details).
36036    pub fn clear_scopes(mut self) -> ProjectInstanceDeleteCall<'a, C> {
36037        self._scopes.clear();
36038        self
36039    }
36040}
36041
36042/// Gets information about a particular instance.
36043///
36044/// A builder for the *instances.get* method supported by a *project* resource.
36045/// It is not used directly, but through a [`ProjectMethods`] instance.
36046///
36047/// # Example
36048///
36049/// Instantiate a resource method builder
36050///
36051/// ```test_harness,no_run
36052/// # extern crate hyper;
36053/// # extern crate hyper_rustls;
36054/// # extern crate google_spanner1 as spanner1;
36055/// # async fn dox() {
36056/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36057///
36058/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36059/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
36060/// #     .with_native_roots()
36061/// #     .unwrap()
36062/// #     .https_only()
36063/// #     .enable_http2()
36064/// #     .build();
36065///
36066/// # let executor = hyper_util::rt::TokioExecutor::new();
36067/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
36068/// #     secret,
36069/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36070/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
36071/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
36072/// #     ),
36073/// # ).build().await.unwrap();
36074///
36075/// # let client = hyper_util::client::legacy::Client::builder(
36076/// #     hyper_util::rt::TokioExecutor::new()
36077/// # )
36078/// # .build(
36079/// #     hyper_rustls::HttpsConnectorBuilder::new()
36080/// #         .with_native_roots()
36081/// #         .unwrap()
36082/// #         .https_or_http()
36083/// #         .enable_http2()
36084/// #         .build()
36085/// # );
36086/// # let mut hub = Spanner::new(client, auth);
36087/// // You can configure optional parameters by calling the respective setters at will, and
36088/// // execute the final call using `doit()`.
36089/// // Values shown here are possibly random and not representative !
36090/// let result = hub.projects().instances_get("name")
36091///              .field_mask(FieldMask::new::<&str>(&[]))
36092///              .doit().await;
36093/// # }
36094/// ```
36095pub struct ProjectInstanceGetCall<'a, C>
36096where
36097    C: 'a,
36098{
36099    hub: &'a Spanner<C>,
36100    _name: String,
36101    _field_mask: Option<common::FieldMask>,
36102    _delegate: Option<&'a mut dyn common::Delegate>,
36103    _additional_params: HashMap<String, String>,
36104    _scopes: BTreeSet<String>,
36105}
36106
36107impl<'a, C> common::CallBuilder for ProjectInstanceGetCall<'a, C> {}
36108
36109impl<'a, C> ProjectInstanceGetCall<'a, C>
36110where
36111    C: common::Connector,
36112{
36113    /// Perform the operation you have build so far.
36114    pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
36115        use std::borrow::Cow;
36116        use std::io::{Read, Seek};
36117
36118        use common::{url::Params, ToParts};
36119        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36120
36121        let mut dd = common::DefaultDelegate;
36122        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36123        dlg.begin(common::MethodInfo {
36124            id: "spanner.projects.instances.get",
36125            http_method: hyper::Method::GET,
36126        });
36127
36128        for &field in ["alt", "name", "fieldMask"].iter() {
36129            if self._additional_params.contains_key(field) {
36130                dlg.finished(false);
36131                return Err(common::Error::FieldClash(field));
36132            }
36133        }
36134
36135        let mut params = Params::with_capacity(4 + self._additional_params.len());
36136        params.push("name", self._name);
36137        if let Some(value) = self._field_mask.as_ref() {
36138            params.push("fieldMask", value.to_string());
36139        }
36140
36141        params.extend(self._additional_params.iter());
36142
36143        params.push("alt", "json");
36144        let mut url = self.hub._base_url.clone() + "v1/{+name}";
36145        if self._scopes.is_empty() {
36146            self._scopes
36147                .insert(Scope::CloudPlatform.as_ref().to_string());
36148        }
36149
36150        #[allow(clippy::single_element_loop)]
36151        for &(find_this, param_name) in [("{+name}", "name")].iter() {
36152            url = params.uri_replacement(url, param_name, find_this, true);
36153        }
36154        {
36155            let to_remove = ["name"];
36156            params.remove_params(&to_remove);
36157        }
36158
36159        let url = params.parse_with_url(&url);
36160
36161        loop {
36162            let token = match self
36163                .hub
36164                .auth
36165                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36166                .await
36167            {
36168                Ok(token) => token,
36169                Err(e) => match dlg.token(e) {
36170                    Ok(token) => token,
36171                    Err(e) => {
36172                        dlg.finished(false);
36173                        return Err(common::Error::MissingToken(e));
36174                    }
36175                },
36176            };
36177            let mut req_result = {
36178                let client = &self.hub.client;
36179                dlg.pre_request();
36180                let mut req_builder = hyper::Request::builder()
36181                    .method(hyper::Method::GET)
36182                    .uri(url.as_str())
36183                    .header(USER_AGENT, self.hub._user_agent.clone());
36184
36185                if let Some(token) = token.as_ref() {
36186                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36187                }
36188
36189                let request = req_builder
36190                    .header(CONTENT_LENGTH, 0_u64)
36191                    .body(common::to_body::<String>(None));
36192
36193                client.request(request.unwrap()).await
36194            };
36195
36196            match req_result {
36197                Err(err) => {
36198                    if let common::Retry::After(d) = dlg.http_error(&err) {
36199                        sleep(d).await;
36200                        continue;
36201                    }
36202                    dlg.finished(false);
36203                    return Err(common::Error::HttpError(err));
36204                }
36205                Ok(res) => {
36206                    let (mut parts, body) = res.into_parts();
36207                    let mut body = common::Body::new(body);
36208                    if !parts.status.is_success() {
36209                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36210                        let error = serde_json::from_str(&common::to_string(&bytes));
36211                        let response = common::to_response(parts, bytes.into());
36212
36213                        if let common::Retry::After(d) =
36214                            dlg.http_failure(&response, error.as_ref().ok())
36215                        {
36216                            sleep(d).await;
36217                            continue;
36218                        }
36219
36220                        dlg.finished(false);
36221
36222                        return Err(match error {
36223                            Ok(value) => common::Error::BadRequest(value),
36224                            _ => common::Error::Failure(response),
36225                        });
36226                    }
36227                    let response = {
36228                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36229                        let encoded = common::to_string(&bytes);
36230                        match serde_json::from_str(&encoded) {
36231                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36232                            Err(error) => {
36233                                dlg.response_json_decode_error(&encoded, &error);
36234                                return Err(common::Error::JsonDecodeError(
36235                                    encoded.to_string(),
36236                                    error,
36237                                ));
36238                            }
36239                        }
36240                    };
36241
36242                    dlg.finished(true);
36243                    return Ok(response);
36244                }
36245            }
36246        }
36247    }
36248
36249    /// Required. The name of the requested instance. Values are of the form `projects//instances/`.
36250    ///
36251    /// Sets the *name* path property to the given value.
36252    ///
36253    /// Even though the property as already been set when instantiating this call,
36254    /// we provide this method for API completeness.
36255    pub fn name(mut self, new_value: &str) -> ProjectInstanceGetCall<'a, C> {
36256        self._name = new_value.to_string();
36257        self
36258    }
36259    /// If field_mask is present, specifies the subset of Instance fields that should be returned. If absent, all Instance fields are returned.
36260    ///
36261    /// Sets the *field mask* query property to the given value.
36262    pub fn field_mask(mut self, new_value: common::FieldMask) -> ProjectInstanceGetCall<'a, C> {
36263        self._field_mask = Some(new_value);
36264        self
36265    }
36266    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36267    /// while executing the actual API request.
36268    ///
36269    /// ````text
36270    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36271    /// ````
36272    ///
36273    /// Sets the *delegate* property to the given value.
36274    pub fn delegate(
36275        mut self,
36276        new_value: &'a mut dyn common::Delegate,
36277    ) -> ProjectInstanceGetCall<'a, C> {
36278        self._delegate = Some(new_value);
36279        self
36280    }
36281
36282    /// Set any additional parameter of the query string used in the request.
36283    /// It should be used to set parameters which are not yet available through their own
36284    /// setters.
36285    ///
36286    /// Please note that this method must not be used to set any of the known parameters
36287    /// which have their own setter method. If done anyway, the request will fail.
36288    ///
36289    /// # Additional Parameters
36290    ///
36291    /// * *$.xgafv* (query-string) - V1 error format.
36292    /// * *access_token* (query-string) - OAuth access token.
36293    /// * *alt* (query-string) - Data format for response.
36294    /// * *callback* (query-string) - JSONP
36295    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36296    /// * *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.
36297    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36298    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36299    /// * *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.
36300    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
36301    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
36302    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceGetCall<'a, C>
36303    where
36304        T: AsRef<str>,
36305    {
36306        self._additional_params
36307            .insert(name.as_ref().to_string(), value.as_ref().to_string());
36308        self
36309    }
36310
36311    /// Identifies the authorization scope for the method you are building.
36312    ///
36313    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36314    /// [`Scope::CloudPlatform`].
36315    ///
36316    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36317    /// tokens for more than one scope.
36318    ///
36319    /// Usually there is more than one suitable scope to authorize an operation, some of which may
36320    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36321    /// sufficient, a read-write scope will do as well.
36322    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceGetCall<'a, C>
36323    where
36324        St: AsRef<str>,
36325    {
36326        self._scopes.insert(String::from(scope.as_ref()));
36327        self
36328    }
36329    /// Identifies the authorization scope(s) for the method you are building.
36330    ///
36331    /// See [`Self::add_scope()`] for details.
36332    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceGetCall<'a, C>
36333    where
36334        I: IntoIterator<Item = St>,
36335        St: AsRef<str>,
36336    {
36337        self._scopes
36338            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36339        self
36340    }
36341
36342    /// Removes all scopes, and no default scope will be used either.
36343    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36344    /// for details).
36345    pub fn clear_scopes(mut self) -> ProjectInstanceGetCall<'a, C> {
36346        self._scopes.clear();
36347        self
36348    }
36349}
36350
36351/// Gets the access control policy for an instance resource. Returns an empty policy if an instance exists but does not have a policy set. Authorization requires `spanner.instances.getIamPolicy` on resource.
36352///
36353/// A builder for the *instances.getIamPolicy* method supported by a *project* resource.
36354/// It is not used directly, but through a [`ProjectMethods`] instance.
36355///
36356/// # Example
36357///
36358/// Instantiate a resource method builder
36359///
36360/// ```test_harness,no_run
36361/// # extern crate hyper;
36362/// # extern crate hyper_rustls;
36363/// # extern crate google_spanner1 as spanner1;
36364/// use spanner1::api::GetIamPolicyRequest;
36365/// # async fn dox() {
36366/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36367///
36368/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36369/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
36370/// #     .with_native_roots()
36371/// #     .unwrap()
36372/// #     .https_only()
36373/// #     .enable_http2()
36374/// #     .build();
36375///
36376/// # let executor = hyper_util::rt::TokioExecutor::new();
36377/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
36378/// #     secret,
36379/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36380/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
36381/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
36382/// #     ),
36383/// # ).build().await.unwrap();
36384///
36385/// # let client = hyper_util::client::legacy::Client::builder(
36386/// #     hyper_util::rt::TokioExecutor::new()
36387/// # )
36388/// # .build(
36389/// #     hyper_rustls::HttpsConnectorBuilder::new()
36390/// #         .with_native_roots()
36391/// #         .unwrap()
36392/// #         .https_or_http()
36393/// #         .enable_http2()
36394/// #         .build()
36395/// # );
36396/// # let mut hub = Spanner::new(client, auth);
36397/// // As the method needs a request, you would usually fill it with the desired information
36398/// // into the respective structure. Some of the parts shown here might not be applicable !
36399/// // Values shown here are possibly random and not representative !
36400/// let mut req = GetIamPolicyRequest::default();
36401///
36402/// // You can configure optional parameters by calling the respective setters at will, and
36403/// // execute the final call using `doit()`.
36404/// // Values shown here are possibly random and not representative !
36405/// let result = hub.projects().instances_get_iam_policy(req, "resource")
36406///              .doit().await;
36407/// # }
36408/// ```
36409pub struct ProjectInstanceGetIamPolicyCall<'a, C>
36410where
36411    C: 'a,
36412{
36413    hub: &'a Spanner<C>,
36414    _request: GetIamPolicyRequest,
36415    _resource: String,
36416    _delegate: Option<&'a mut dyn common::Delegate>,
36417    _additional_params: HashMap<String, String>,
36418    _scopes: BTreeSet<String>,
36419}
36420
36421impl<'a, C> common::CallBuilder for ProjectInstanceGetIamPolicyCall<'a, C> {}
36422
36423impl<'a, C> ProjectInstanceGetIamPolicyCall<'a, C>
36424where
36425    C: common::Connector,
36426{
36427    /// Perform the operation you have build so far.
36428    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
36429        use std::borrow::Cow;
36430        use std::io::{Read, Seek};
36431
36432        use common::{url::Params, ToParts};
36433        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36434
36435        let mut dd = common::DefaultDelegate;
36436        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36437        dlg.begin(common::MethodInfo {
36438            id: "spanner.projects.instances.getIamPolicy",
36439            http_method: hyper::Method::POST,
36440        });
36441
36442        for &field in ["alt", "resource"].iter() {
36443            if self._additional_params.contains_key(field) {
36444                dlg.finished(false);
36445                return Err(common::Error::FieldClash(field));
36446            }
36447        }
36448
36449        let mut params = Params::with_capacity(4 + self._additional_params.len());
36450        params.push("resource", self._resource);
36451
36452        params.extend(self._additional_params.iter());
36453
36454        params.push("alt", "json");
36455        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
36456        if self._scopes.is_empty() {
36457            self._scopes
36458                .insert(Scope::CloudPlatform.as_ref().to_string());
36459        }
36460
36461        #[allow(clippy::single_element_loop)]
36462        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
36463            url = params.uri_replacement(url, param_name, find_this, true);
36464        }
36465        {
36466            let to_remove = ["resource"];
36467            params.remove_params(&to_remove);
36468        }
36469
36470        let url = params.parse_with_url(&url);
36471
36472        let mut json_mime_type = mime::APPLICATION_JSON;
36473        let mut request_value_reader = {
36474            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
36475            common::remove_json_null_values(&mut value);
36476            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
36477            serde_json::to_writer(&mut dst, &value).unwrap();
36478            dst
36479        };
36480        let request_size = request_value_reader
36481            .seek(std::io::SeekFrom::End(0))
36482            .unwrap();
36483        request_value_reader
36484            .seek(std::io::SeekFrom::Start(0))
36485            .unwrap();
36486
36487        loop {
36488            let token = match self
36489                .hub
36490                .auth
36491                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36492                .await
36493            {
36494                Ok(token) => token,
36495                Err(e) => match dlg.token(e) {
36496                    Ok(token) => token,
36497                    Err(e) => {
36498                        dlg.finished(false);
36499                        return Err(common::Error::MissingToken(e));
36500                    }
36501                },
36502            };
36503            request_value_reader
36504                .seek(std::io::SeekFrom::Start(0))
36505                .unwrap();
36506            let mut req_result = {
36507                let client = &self.hub.client;
36508                dlg.pre_request();
36509                let mut req_builder = hyper::Request::builder()
36510                    .method(hyper::Method::POST)
36511                    .uri(url.as_str())
36512                    .header(USER_AGENT, self.hub._user_agent.clone());
36513
36514                if let Some(token) = token.as_ref() {
36515                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36516                }
36517
36518                let request = req_builder
36519                    .header(CONTENT_TYPE, json_mime_type.to_string())
36520                    .header(CONTENT_LENGTH, request_size as u64)
36521                    .body(common::to_body(
36522                        request_value_reader.get_ref().clone().into(),
36523                    ));
36524
36525                client.request(request.unwrap()).await
36526            };
36527
36528            match req_result {
36529                Err(err) => {
36530                    if let common::Retry::After(d) = dlg.http_error(&err) {
36531                        sleep(d).await;
36532                        continue;
36533                    }
36534                    dlg.finished(false);
36535                    return Err(common::Error::HttpError(err));
36536                }
36537                Ok(res) => {
36538                    let (mut parts, body) = res.into_parts();
36539                    let mut body = common::Body::new(body);
36540                    if !parts.status.is_success() {
36541                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36542                        let error = serde_json::from_str(&common::to_string(&bytes));
36543                        let response = common::to_response(parts, bytes.into());
36544
36545                        if let common::Retry::After(d) =
36546                            dlg.http_failure(&response, error.as_ref().ok())
36547                        {
36548                            sleep(d).await;
36549                            continue;
36550                        }
36551
36552                        dlg.finished(false);
36553
36554                        return Err(match error {
36555                            Ok(value) => common::Error::BadRequest(value),
36556                            _ => common::Error::Failure(response),
36557                        });
36558                    }
36559                    let response = {
36560                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36561                        let encoded = common::to_string(&bytes);
36562                        match serde_json::from_str(&encoded) {
36563                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36564                            Err(error) => {
36565                                dlg.response_json_decode_error(&encoded, &error);
36566                                return Err(common::Error::JsonDecodeError(
36567                                    encoded.to_string(),
36568                                    error,
36569                                ));
36570                            }
36571                        }
36572                    };
36573
36574                    dlg.finished(true);
36575                    return Ok(response);
36576                }
36577            }
36578        }
36579    }
36580
36581    ///
36582    /// Sets the *request* property to the given value.
36583    ///
36584    /// Even though the property as already been set when instantiating this call,
36585    /// we provide this method for API completeness.
36586    pub fn request(
36587        mut self,
36588        new_value: GetIamPolicyRequest,
36589    ) -> ProjectInstanceGetIamPolicyCall<'a, C> {
36590        self._request = new_value;
36591        self
36592    }
36593    /// REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
36594    ///
36595    /// Sets the *resource* path property to the given value.
36596    ///
36597    /// Even though the property as already been set when instantiating this call,
36598    /// we provide this method for API completeness.
36599    pub fn resource(mut self, new_value: &str) -> ProjectInstanceGetIamPolicyCall<'a, C> {
36600        self._resource = new_value.to_string();
36601        self
36602    }
36603    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36604    /// while executing the actual API request.
36605    ///
36606    /// ````text
36607    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36608    /// ````
36609    ///
36610    /// Sets the *delegate* property to the given value.
36611    pub fn delegate(
36612        mut self,
36613        new_value: &'a mut dyn common::Delegate,
36614    ) -> ProjectInstanceGetIamPolicyCall<'a, C> {
36615        self._delegate = Some(new_value);
36616        self
36617    }
36618
36619    /// Set any additional parameter of the query string used in the request.
36620    /// It should be used to set parameters which are not yet available through their own
36621    /// setters.
36622    ///
36623    /// Please note that this method must not be used to set any of the known parameters
36624    /// which have their own setter method. If done anyway, the request will fail.
36625    ///
36626    /// # Additional Parameters
36627    ///
36628    /// * *$.xgafv* (query-string) - V1 error format.
36629    /// * *access_token* (query-string) - OAuth access token.
36630    /// * *alt* (query-string) - Data format for response.
36631    /// * *callback* (query-string) - JSONP
36632    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36633    /// * *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.
36634    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36635    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36636    /// * *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.
36637    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
36638    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
36639    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceGetIamPolicyCall<'a, C>
36640    where
36641        T: AsRef<str>,
36642    {
36643        self._additional_params
36644            .insert(name.as_ref().to_string(), value.as_ref().to_string());
36645        self
36646    }
36647
36648    /// Identifies the authorization scope for the method you are building.
36649    ///
36650    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36651    /// [`Scope::CloudPlatform`].
36652    ///
36653    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36654    /// tokens for more than one scope.
36655    ///
36656    /// Usually there is more than one suitable scope to authorize an operation, some of which may
36657    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36658    /// sufficient, a read-write scope will do as well.
36659    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceGetIamPolicyCall<'a, C>
36660    where
36661        St: AsRef<str>,
36662    {
36663        self._scopes.insert(String::from(scope.as_ref()));
36664        self
36665    }
36666    /// Identifies the authorization scope(s) for the method you are building.
36667    ///
36668    /// See [`Self::add_scope()`] for details.
36669    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceGetIamPolicyCall<'a, C>
36670    where
36671        I: IntoIterator<Item = St>,
36672        St: AsRef<str>,
36673    {
36674        self._scopes
36675            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36676        self
36677    }
36678
36679    /// Removes all scopes, and no default scope will be used either.
36680    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36681    /// for details).
36682    pub fn clear_scopes(mut self) -> ProjectInstanceGetIamPolicyCall<'a, C> {
36683        self._scopes.clear();
36684        self
36685    }
36686}
36687
36688/// Lists all instances in the given project.
36689///
36690/// A builder for the *instances.list* method supported by a *project* resource.
36691/// It is not used directly, but through a [`ProjectMethods`] instance.
36692///
36693/// # Example
36694///
36695/// Instantiate a resource method builder
36696///
36697/// ```test_harness,no_run
36698/// # extern crate hyper;
36699/// # extern crate hyper_rustls;
36700/// # extern crate google_spanner1 as spanner1;
36701/// # async fn dox() {
36702/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36703///
36704/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36705/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
36706/// #     .with_native_roots()
36707/// #     .unwrap()
36708/// #     .https_only()
36709/// #     .enable_http2()
36710/// #     .build();
36711///
36712/// # let executor = hyper_util::rt::TokioExecutor::new();
36713/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
36714/// #     secret,
36715/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36716/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
36717/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
36718/// #     ),
36719/// # ).build().await.unwrap();
36720///
36721/// # let client = hyper_util::client::legacy::Client::builder(
36722/// #     hyper_util::rt::TokioExecutor::new()
36723/// # )
36724/// # .build(
36725/// #     hyper_rustls::HttpsConnectorBuilder::new()
36726/// #         .with_native_roots()
36727/// #         .unwrap()
36728/// #         .https_or_http()
36729/// #         .enable_http2()
36730/// #         .build()
36731/// # );
36732/// # let mut hub = Spanner::new(client, auth);
36733/// // You can configure optional parameters by calling the respective setters at will, and
36734/// // execute the final call using `doit()`.
36735/// // Values shown here are possibly random and not representative !
36736/// let result = hub.projects().instances_list("parent")
36737///              .page_token("justo")
36738///              .page_size(-60)
36739///              .instance_deadline(chrono::Utc::now())
36740///              .filter("consetetur")
36741///              .doit().await;
36742/// # }
36743/// ```
36744pub struct ProjectInstanceListCall<'a, C>
36745where
36746    C: 'a,
36747{
36748    hub: &'a Spanner<C>,
36749    _parent: String,
36750    _page_token: Option<String>,
36751    _page_size: Option<i32>,
36752    _instance_deadline: Option<chrono::DateTime<chrono::offset::Utc>>,
36753    _filter: Option<String>,
36754    _delegate: Option<&'a mut dyn common::Delegate>,
36755    _additional_params: HashMap<String, String>,
36756    _scopes: BTreeSet<String>,
36757}
36758
36759impl<'a, C> common::CallBuilder for ProjectInstanceListCall<'a, C> {}
36760
36761impl<'a, C> ProjectInstanceListCall<'a, C>
36762where
36763    C: common::Connector,
36764{
36765    /// Perform the operation you have build so far.
36766    pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
36767        use std::borrow::Cow;
36768        use std::io::{Read, Seek};
36769
36770        use common::{url::Params, ToParts};
36771        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36772
36773        let mut dd = common::DefaultDelegate;
36774        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36775        dlg.begin(common::MethodInfo {
36776            id: "spanner.projects.instances.list",
36777            http_method: hyper::Method::GET,
36778        });
36779
36780        for &field in [
36781            "alt",
36782            "parent",
36783            "pageToken",
36784            "pageSize",
36785            "instanceDeadline",
36786            "filter",
36787        ]
36788        .iter()
36789        {
36790            if self._additional_params.contains_key(field) {
36791                dlg.finished(false);
36792                return Err(common::Error::FieldClash(field));
36793            }
36794        }
36795
36796        let mut params = Params::with_capacity(7 + self._additional_params.len());
36797        params.push("parent", self._parent);
36798        if let Some(value) = self._page_token.as_ref() {
36799            params.push("pageToken", value);
36800        }
36801        if let Some(value) = self._page_size.as_ref() {
36802            params.push("pageSize", value.to_string());
36803        }
36804        if let Some(value) = self._instance_deadline.as_ref() {
36805            params.push(
36806                "instanceDeadline",
36807                common::serde::datetime_to_string(&value),
36808            );
36809        }
36810        if let Some(value) = self._filter.as_ref() {
36811            params.push("filter", value);
36812        }
36813
36814        params.extend(self._additional_params.iter());
36815
36816        params.push("alt", "json");
36817        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
36818        if self._scopes.is_empty() {
36819            self._scopes
36820                .insert(Scope::CloudPlatform.as_ref().to_string());
36821        }
36822
36823        #[allow(clippy::single_element_loop)]
36824        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
36825            url = params.uri_replacement(url, param_name, find_this, true);
36826        }
36827        {
36828            let to_remove = ["parent"];
36829            params.remove_params(&to_remove);
36830        }
36831
36832        let url = params.parse_with_url(&url);
36833
36834        loop {
36835            let token = match self
36836                .hub
36837                .auth
36838                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36839                .await
36840            {
36841                Ok(token) => token,
36842                Err(e) => match dlg.token(e) {
36843                    Ok(token) => token,
36844                    Err(e) => {
36845                        dlg.finished(false);
36846                        return Err(common::Error::MissingToken(e));
36847                    }
36848                },
36849            };
36850            let mut req_result = {
36851                let client = &self.hub.client;
36852                dlg.pre_request();
36853                let mut req_builder = hyper::Request::builder()
36854                    .method(hyper::Method::GET)
36855                    .uri(url.as_str())
36856                    .header(USER_AGENT, self.hub._user_agent.clone());
36857
36858                if let Some(token) = token.as_ref() {
36859                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36860                }
36861
36862                let request = req_builder
36863                    .header(CONTENT_LENGTH, 0_u64)
36864                    .body(common::to_body::<String>(None));
36865
36866                client.request(request.unwrap()).await
36867            };
36868
36869            match req_result {
36870                Err(err) => {
36871                    if let common::Retry::After(d) = dlg.http_error(&err) {
36872                        sleep(d).await;
36873                        continue;
36874                    }
36875                    dlg.finished(false);
36876                    return Err(common::Error::HttpError(err));
36877                }
36878                Ok(res) => {
36879                    let (mut parts, body) = res.into_parts();
36880                    let mut body = common::Body::new(body);
36881                    if !parts.status.is_success() {
36882                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36883                        let error = serde_json::from_str(&common::to_string(&bytes));
36884                        let response = common::to_response(parts, bytes.into());
36885
36886                        if let common::Retry::After(d) =
36887                            dlg.http_failure(&response, error.as_ref().ok())
36888                        {
36889                            sleep(d).await;
36890                            continue;
36891                        }
36892
36893                        dlg.finished(false);
36894
36895                        return Err(match error {
36896                            Ok(value) => common::Error::BadRequest(value),
36897                            _ => common::Error::Failure(response),
36898                        });
36899                    }
36900                    let response = {
36901                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36902                        let encoded = common::to_string(&bytes);
36903                        match serde_json::from_str(&encoded) {
36904                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36905                            Err(error) => {
36906                                dlg.response_json_decode_error(&encoded, &error);
36907                                return Err(common::Error::JsonDecodeError(
36908                                    encoded.to_string(),
36909                                    error,
36910                                ));
36911                            }
36912                        }
36913                    };
36914
36915                    dlg.finished(true);
36916                    return Ok(response);
36917                }
36918            }
36919        }
36920    }
36921
36922    /// Required. The name of the project for which a list of instances is requested. Values are of the form `projects/`.
36923    ///
36924    /// Sets the *parent* path property to the given value.
36925    ///
36926    /// Even though the property as already been set when instantiating this call,
36927    /// we provide this method for API completeness.
36928    pub fn parent(mut self, new_value: &str) -> ProjectInstanceListCall<'a, C> {
36929        self._parent = new_value.to_string();
36930        self
36931    }
36932    /// If non-empty, `page_token` should contain a next_page_token from a previous ListInstancesResponse.
36933    ///
36934    /// Sets the *page token* query property to the given value.
36935    pub fn page_token(mut self, new_value: &str) -> ProjectInstanceListCall<'a, C> {
36936        self._page_token = Some(new_value.to_string());
36937        self
36938    }
36939    /// Number of instances to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
36940    ///
36941    /// Sets the *page size* query property to the given value.
36942    pub fn page_size(mut self, new_value: i32) -> ProjectInstanceListCall<'a, C> {
36943        self._page_size = Some(new_value);
36944        self
36945    }
36946    /// Deadline used while retrieving metadata for instances. Instances whose metadata cannot be retrieved within this deadline will be added to unreachable in ListInstancesResponse.
36947    ///
36948    /// Sets the *instance deadline* query property to the given value.
36949    pub fn instance_deadline(
36950        mut self,
36951        new_value: chrono::DateTime<chrono::offset::Utc>,
36952    ) -> ProjectInstanceListCall<'a, C> {
36953        self._instance_deadline = Some(new_value);
36954        self
36955    }
36956    /// An expression for filtering the results of the request. Filter rules are case insensitive. The fields eligible for filtering are: * `name` * `display_name` * `labels.key` where key is the name of a label Some examples of using filters are: * `name:*` --> The instance has a name. * `name:Howl` --> The instance's name contains the string "howl". * `name:HOWL` --> Equivalent to above. * `NAME:howl` --> Equivalent to above. * `labels.env:*` --> The instance has the label "env". * `labels.env:dev` --> The instance has the label "env" and the value of the label contains the string "dev". * `name:howl labels.env:dev` --> The instance's name contains "howl" and it has the label "env" with its value containing "dev".
36957    ///
36958    /// Sets the *filter* query property to the given value.
36959    pub fn filter(mut self, new_value: &str) -> ProjectInstanceListCall<'a, C> {
36960        self._filter = Some(new_value.to_string());
36961        self
36962    }
36963    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36964    /// while executing the actual API request.
36965    ///
36966    /// ````text
36967    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36968    /// ````
36969    ///
36970    /// Sets the *delegate* property to the given value.
36971    pub fn delegate(
36972        mut self,
36973        new_value: &'a mut dyn common::Delegate,
36974    ) -> ProjectInstanceListCall<'a, C> {
36975        self._delegate = Some(new_value);
36976        self
36977    }
36978
36979    /// Set any additional parameter of the query string used in the request.
36980    /// It should be used to set parameters which are not yet available through their own
36981    /// setters.
36982    ///
36983    /// Please note that this method must not be used to set any of the known parameters
36984    /// which have their own setter method. If done anyway, the request will fail.
36985    ///
36986    /// # Additional Parameters
36987    ///
36988    /// * *$.xgafv* (query-string) - V1 error format.
36989    /// * *access_token* (query-string) - OAuth access token.
36990    /// * *alt* (query-string) - Data format for response.
36991    /// * *callback* (query-string) - JSONP
36992    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36993    /// * *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.
36994    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36995    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36996    /// * *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.
36997    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
36998    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
36999    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceListCall<'a, C>
37000    where
37001        T: AsRef<str>,
37002    {
37003        self._additional_params
37004            .insert(name.as_ref().to_string(), value.as_ref().to_string());
37005        self
37006    }
37007
37008    /// Identifies the authorization scope for the method you are building.
37009    ///
37010    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37011    /// [`Scope::CloudPlatform`].
37012    ///
37013    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37014    /// tokens for more than one scope.
37015    ///
37016    /// Usually there is more than one suitable scope to authorize an operation, some of which may
37017    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37018    /// sufficient, a read-write scope will do as well.
37019    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceListCall<'a, C>
37020    where
37021        St: AsRef<str>,
37022    {
37023        self._scopes.insert(String::from(scope.as_ref()));
37024        self
37025    }
37026    /// Identifies the authorization scope(s) for the method you are building.
37027    ///
37028    /// See [`Self::add_scope()`] for details.
37029    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceListCall<'a, C>
37030    where
37031        I: IntoIterator<Item = St>,
37032        St: AsRef<str>,
37033    {
37034        self._scopes
37035            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37036        self
37037    }
37038
37039    /// Removes all scopes, and no default scope will be used either.
37040    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37041    /// for details).
37042    pub fn clear_scopes(mut self) -> ProjectInstanceListCall<'a, C> {
37043        self._scopes.clear();
37044        self
37045    }
37046}
37047
37048/// Moves an instance to the target instance configuration. You can use the returned long-running operation to track the progress of moving the instance. `MoveInstance` returns `FAILED_PRECONDITION` if the instance meets any of the following criteria: * Is undergoing a move to a different instance configuration * Has backups * Has an ongoing update * Contains any CMEK-enabled databases * Is a free trial instance While the operation is pending: * All other attempts to modify the instance, including changes to its compute capacity, are rejected. * The following database and backup admin operations are rejected: * `DatabaseAdmin.CreateDatabase` * `DatabaseAdmin.UpdateDatabaseDdl` (disabled if default_leader is specified in the request.) * `DatabaseAdmin.RestoreDatabase` * `DatabaseAdmin.CreateBackup` * `DatabaseAdmin.CopyBackup` * Both the source and target instance configurations are subject to hourly compute and storage charges. * The instance might experience higher read-write latencies and a higher transaction abort rate. However, moving an instance doesn't cause any downtime. The returned long-running operation has a name of the format `/operations/` and can be used to track the move instance operation. The metadata field type is MoveInstanceMetadata. The response field type is Instance, if successful. Cancelling the operation sets its metadata's cancel_time. Cancellation is not immediate because it involves moving any data previously moved to the target instance configuration back to the original instance configuration. You can use this operation to track the progress of the cancellation. Upon successful completion of the cancellation, the operation terminates with `CANCELLED` status. If not cancelled, upon completion of the returned operation: * The instance successfully moves to the target instance configuration. * You are billed for compute and storage in target instance configuration. Authorization requires the `spanner.instances.update` permission on the resource instance. For more details, see [Move an instance](https://cloud.google.com/spanner/docs/move-instance).
37049///
37050/// A builder for the *instances.move* method supported by a *project* resource.
37051/// It is not used directly, but through a [`ProjectMethods`] instance.
37052///
37053/// # Example
37054///
37055/// Instantiate a resource method builder
37056///
37057/// ```test_harness,no_run
37058/// # extern crate hyper;
37059/// # extern crate hyper_rustls;
37060/// # extern crate google_spanner1 as spanner1;
37061/// use spanner1::api::MoveInstanceRequest;
37062/// # async fn dox() {
37063/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37064///
37065/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37066/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
37067/// #     .with_native_roots()
37068/// #     .unwrap()
37069/// #     .https_only()
37070/// #     .enable_http2()
37071/// #     .build();
37072///
37073/// # let executor = hyper_util::rt::TokioExecutor::new();
37074/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
37075/// #     secret,
37076/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37077/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
37078/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
37079/// #     ),
37080/// # ).build().await.unwrap();
37081///
37082/// # let client = hyper_util::client::legacy::Client::builder(
37083/// #     hyper_util::rt::TokioExecutor::new()
37084/// # )
37085/// # .build(
37086/// #     hyper_rustls::HttpsConnectorBuilder::new()
37087/// #         .with_native_roots()
37088/// #         .unwrap()
37089/// #         .https_or_http()
37090/// #         .enable_http2()
37091/// #         .build()
37092/// # );
37093/// # let mut hub = Spanner::new(client, auth);
37094/// // As the method needs a request, you would usually fill it with the desired information
37095/// // into the respective structure. Some of the parts shown here might not be applicable !
37096/// // Values shown here are possibly random and not representative !
37097/// let mut req = MoveInstanceRequest::default();
37098///
37099/// // You can configure optional parameters by calling the respective setters at will, and
37100/// // execute the final call using `doit()`.
37101/// // Values shown here are possibly random and not representative !
37102/// let result = hub.projects().instances_move(req, "name")
37103///              .doit().await;
37104/// # }
37105/// ```
37106pub struct ProjectInstanceMoveCall<'a, C>
37107where
37108    C: 'a,
37109{
37110    hub: &'a Spanner<C>,
37111    _request: MoveInstanceRequest,
37112    _name: String,
37113    _delegate: Option<&'a mut dyn common::Delegate>,
37114    _additional_params: HashMap<String, String>,
37115    _scopes: BTreeSet<String>,
37116}
37117
37118impl<'a, C> common::CallBuilder for ProjectInstanceMoveCall<'a, C> {}
37119
37120impl<'a, C> ProjectInstanceMoveCall<'a, C>
37121where
37122    C: common::Connector,
37123{
37124    /// Perform the operation you have build so far.
37125    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
37126        use std::borrow::Cow;
37127        use std::io::{Read, Seek};
37128
37129        use common::{url::Params, ToParts};
37130        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37131
37132        let mut dd = common::DefaultDelegate;
37133        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37134        dlg.begin(common::MethodInfo {
37135            id: "spanner.projects.instances.move",
37136            http_method: hyper::Method::POST,
37137        });
37138
37139        for &field in ["alt", "name"].iter() {
37140            if self._additional_params.contains_key(field) {
37141                dlg.finished(false);
37142                return Err(common::Error::FieldClash(field));
37143            }
37144        }
37145
37146        let mut params = Params::with_capacity(4 + self._additional_params.len());
37147        params.push("name", self._name);
37148
37149        params.extend(self._additional_params.iter());
37150
37151        params.push("alt", "json");
37152        let mut url = self.hub._base_url.clone() + "v1/{+name}:move";
37153        if self._scopes.is_empty() {
37154            self._scopes
37155                .insert(Scope::CloudPlatform.as_ref().to_string());
37156        }
37157
37158        #[allow(clippy::single_element_loop)]
37159        for &(find_this, param_name) in [("{+name}", "name")].iter() {
37160            url = params.uri_replacement(url, param_name, find_this, true);
37161        }
37162        {
37163            let to_remove = ["name"];
37164            params.remove_params(&to_remove);
37165        }
37166
37167        let url = params.parse_with_url(&url);
37168
37169        let mut json_mime_type = mime::APPLICATION_JSON;
37170        let mut request_value_reader = {
37171            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
37172            common::remove_json_null_values(&mut value);
37173            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
37174            serde_json::to_writer(&mut dst, &value).unwrap();
37175            dst
37176        };
37177        let request_size = request_value_reader
37178            .seek(std::io::SeekFrom::End(0))
37179            .unwrap();
37180        request_value_reader
37181            .seek(std::io::SeekFrom::Start(0))
37182            .unwrap();
37183
37184        loop {
37185            let token = match self
37186                .hub
37187                .auth
37188                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37189                .await
37190            {
37191                Ok(token) => token,
37192                Err(e) => match dlg.token(e) {
37193                    Ok(token) => token,
37194                    Err(e) => {
37195                        dlg.finished(false);
37196                        return Err(common::Error::MissingToken(e));
37197                    }
37198                },
37199            };
37200            request_value_reader
37201                .seek(std::io::SeekFrom::Start(0))
37202                .unwrap();
37203            let mut req_result = {
37204                let client = &self.hub.client;
37205                dlg.pre_request();
37206                let mut req_builder = hyper::Request::builder()
37207                    .method(hyper::Method::POST)
37208                    .uri(url.as_str())
37209                    .header(USER_AGENT, self.hub._user_agent.clone());
37210
37211                if let Some(token) = token.as_ref() {
37212                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37213                }
37214
37215                let request = req_builder
37216                    .header(CONTENT_TYPE, json_mime_type.to_string())
37217                    .header(CONTENT_LENGTH, request_size as u64)
37218                    .body(common::to_body(
37219                        request_value_reader.get_ref().clone().into(),
37220                    ));
37221
37222                client.request(request.unwrap()).await
37223            };
37224
37225            match req_result {
37226                Err(err) => {
37227                    if let common::Retry::After(d) = dlg.http_error(&err) {
37228                        sleep(d).await;
37229                        continue;
37230                    }
37231                    dlg.finished(false);
37232                    return Err(common::Error::HttpError(err));
37233                }
37234                Ok(res) => {
37235                    let (mut parts, body) = res.into_parts();
37236                    let mut body = common::Body::new(body);
37237                    if !parts.status.is_success() {
37238                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37239                        let error = serde_json::from_str(&common::to_string(&bytes));
37240                        let response = common::to_response(parts, bytes.into());
37241
37242                        if let common::Retry::After(d) =
37243                            dlg.http_failure(&response, error.as_ref().ok())
37244                        {
37245                            sleep(d).await;
37246                            continue;
37247                        }
37248
37249                        dlg.finished(false);
37250
37251                        return Err(match error {
37252                            Ok(value) => common::Error::BadRequest(value),
37253                            _ => common::Error::Failure(response),
37254                        });
37255                    }
37256                    let response = {
37257                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37258                        let encoded = common::to_string(&bytes);
37259                        match serde_json::from_str(&encoded) {
37260                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
37261                            Err(error) => {
37262                                dlg.response_json_decode_error(&encoded, &error);
37263                                return Err(common::Error::JsonDecodeError(
37264                                    encoded.to_string(),
37265                                    error,
37266                                ));
37267                            }
37268                        }
37269                    };
37270
37271                    dlg.finished(true);
37272                    return Ok(response);
37273                }
37274            }
37275        }
37276    }
37277
37278    ///
37279    /// Sets the *request* property to the given value.
37280    ///
37281    /// Even though the property as already been set when instantiating this call,
37282    /// we provide this method for API completeness.
37283    pub fn request(mut self, new_value: MoveInstanceRequest) -> ProjectInstanceMoveCall<'a, C> {
37284        self._request = new_value;
37285        self
37286    }
37287    /// Required. The instance to move. Values are of the form `projects//instances/`.
37288    ///
37289    /// Sets the *name* path property to the given value.
37290    ///
37291    /// Even though the property as already been set when instantiating this call,
37292    /// we provide this method for API completeness.
37293    pub fn name(mut self, new_value: &str) -> ProjectInstanceMoveCall<'a, C> {
37294        self._name = new_value.to_string();
37295        self
37296    }
37297    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37298    /// while executing the actual API request.
37299    ///
37300    /// ````text
37301    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
37302    /// ````
37303    ///
37304    /// Sets the *delegate* property to the given value.
37305    pub fn delegate(
37306        mut self,
37307        new_value: &'a mut dyn common::Delegate,
37308    ) -> ProjectInstanceMoveCall<'a, C> {
37309        self._delegate = Some(new_value);
37310        self
37311    }
37312
37313    /// Set any additional parameter of the query string used in the request.
37314    /// It should be used to set parameters which are not yet available through their own
37315    /// setters.
37316    ///
37317    /// Please note that this method must not be used to set any of the known parameters
37318    /// which have their own setter method. If done anyway, the request will fail.
37319    ///
37320    /// # Additional Parameters
37321    ///
37322    /// * *$.xgafv* (query-string) - V1 error format.
37323    /// * *access_token* (query-string) - OAuth access token.
37324    /// * *alt* (query-string) - Data format for response.
37325    /// * *callback* (query-string) - JSONP
37326    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37327    /// * *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.
37328    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
37329    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
37330    /// * *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.
37331    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
37332    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
37333    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceMoveCall<'a, C>
37334    where
37335        T: AsRef<str>,
37336    {
37337        self._additional_params
37338            .insert(name.as_ref().to_string(), value.as_ref().to_string());
37339        self
37340    }
37341
37342    /// Identifies the authorization scope for the method you are building.
37343    ///
37344    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37345    /// [`Scope::CloudPlatform`].
37346    ///
37347    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37348    /// tokens for more than one scope.
37349    ///
37350    /// Usually there is more than one suitable scope to authorize an operation, some of which may
37351    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37352    /// sufficient, a read-write scope will do as well.
37353    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceMoveCall<'a, C>
37354    where
37355        St: AsRef<str>,
37356    {
37357        self._scopes.insert(String::from(scope.as_ref()));
37358        self
37359    }
37360    /// Identifies the authorization scope(s) for the method you are building.
37361    ///
37362    /// See [`Self::add_scope()`] for details.
37363    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceMoveCall<'a, C>
37364    where
37365        I: IntoIterator<Item = St>,
37366        St: AsRef<str>,
37367    {
37368        self._scopes
37369            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37370        self
37371    }
37372
37373    /// Removes all scopes, and no default scope will be used either.
37374    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37375    /// for details).
37376    pub fn clear_scopes(mut self) -> ProjectInstanceMoveCall<'a, C> {
37377        self._scopes.clear();
37378        self
37379    }
37380}
37381
37382/// Updates an instance, and begins allocating or releasing resources as requested. The returned long-running operation can be used to track the progress of updating the instance. If the named instance does not exist, returns `NOT_FOUND`. Immediately upon completion of this request: * For resource types for which a decrease in the instance's allocation has been requested, billing is based on the newly-requested level. Until completion of the returned operation: * Cancelling the operation sets its metadata's cancel_time, and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance are rejected. * Reading the instance via the API continues to give the pre-request resource levels. Upon completion of the returned operation: * Billing begins for all successfully-allocated resources (some types may have lower than the requested levels). * All newly-reserved resources are available for serving the instance's tables. * The instance's new resource levels are readable via the API. The returned long-running operation will have a name of the format `/operations/` and can be used to track the instance modification. The metadata field type is UpdateInstanceMetadata. The response field type is Instance, if successful. Authorization requires `spanner.instances.update` permission on the resource name.
37383///
37384/// A builder for the *instances.patch* method supported by a *project* resource.
37385/// It is not used directly, but through a [`ProjectMethods`] instance.
37386///
37387/// # Example
37388///
37389/// Instantiate a resource method builder
37390///
37391/// ```test_harness,no_run
37392/// # extern crate hyper;
37393/// # extern crate hyper_rustls;
37394/// # extern crate google_spanner1 as spanner1;
37395/// use spanner1::api::UpdateInstanceRequest;
37396/// # async fn dox() {
37397/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37398///
37399/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37400/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
37401/// #     .with_native_roots()
37402/// #     .unwrap()
37403/// #     .https_only()
37404/// #     .enable_http2()
37405/// #     .build();
37406///
37407/// # let executor = hyper_util::rt::TokioExecutor::new();
37408/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
37409/// #     secret,
37410/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37411/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
37412/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
37413/// #     ),
37414/// # ).build().await.unwrap();
37415///
37416/// # let client = hyper_util::client::legacy::Client::builder(
37417/// #     hyper_util::rt::TokioExecutor::new()
37418/// # )
37419/// # .build(
37420/// #     hyper_rustls::HttpsConnectorBuilder::new()
37421/// #         .with_native_roots()
37422/// #         .unwrap()
37423/// #         .https_or_http()
37424/// #         .enable_http2()
37425/// #         .build()
37426/// # );
37427/// # let mut hub = Spanner::new(client, auth);
37428/// // As the method needs a request, you would usually fill it with the desired information
37429/// // into the respective structure. Some of the parts shown here might not be applicable !
37430/// // Values shown here are possibly random and not representative !
37431/// let mut req = UpdateInstanceRequest::default();
37432///
37433/// // You can configure optional parameters by calling the respective setters at will, and
37434/// // execute the final call using `doit()`.
37435/// // Values shown here are possibly random and not representative !
37436/// let result = hub.projects().instances_patch(req, "name")
37437///              .doit().await;
37438/// # }
37439/// ```
37440pub struct ProjectInstancePatchCall<'a, C>
37441where
37442    C: 'a,
37443{
37444    hub: &'a Spanner<C>,
37445    _request: UpdateInstanceRequest,
37446    _name: String,
37447    _delegate: Option<&'a mut dyn common::Delegate>,
37448    _additional_params: HashMap<String, String>,
37449    _scopes: BTreeSet<String>,
37450}
37451
37452impl<'a, C> common::CallBuilder for ProjectInstancePatchCall<'a, C> {}
37453
37454impl<'a, C> ProjectInstancePatchCall<'a, C>
37455where
37456    C: common::Connector,
37457{
37458    /// Perform the operation you have build so far.
37459    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
37460        use std::borrow::Cow;
37461        use std::io::{Read, Seek};
37462
37463        use common::{url::Params, ToParts};
37464        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37465
37466        let mut dd = common::DefaultDelegate;
37467        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37468        dlg.begin(common::MethodInfo {
37469            id: "spanner.projects.instances.patch",
37470            http_method: hyper::Method::PATCH,
37471        });
37472
37473        for &field in ["alt", "name"].iter() {
37474            if self._additional_params.contains_key(field) {
37475                dlg.finished(false);
37476                return Err(common::Error::FieldClash(field));
37477            }
37478        }
37479
37480        let mut params = Params::with_capacity(4 + self._additional_params.len());
37481        params.push("name", self._name);
37482
37483        params.extend(self._additional_params.iter());
37484
37485        params.push("alt", "json");
37486        let mut url = self.hub._base_url.clone() + "v1/{+name}";
37487        if self._scopes.is_empty() {
37488            self._scopes
37489                .insert(Scope::CloudPlatform.as_ref().to_string());
37490        }
37491
37492        #[allow(clippy::single_element_loop)]
37493        for &(find_this, param_name) in [("{+name}", "name")].iter() {
37494            url = params.uri_replacement(url, param_name, find_this, true);
37495        }
37496        {
37497            let to_remove = ["name"];
37498            params.remove_params(&to_remove);
37499        }
37500
37501        let url = params.parse_with_url(&url);
37502
37503        let mut json_mime_type = mime::APPLICATION_JSON;
37504        let mut request_value_reader = {
37505            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
37506            common::remove_json_null_values(&mut value);
37507            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
37508            serde_json::to_writer(&mut dst, &value).unwrap();
37509            dst
37510        };
37511        let request_size = request_value_reader
37512            .seek(std::io::SeekFrom::End(0))
37513            .unwrap();
37514        request_value_reader
37515            .seek(std::io::SeekFrom::Start(0))
37516            .unwrap();
37517
37518        loop {
37519            let token = match self
37520                .hub
37521                .auth
37522                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37523                .await
37524            {
37525                Ok(token) => token,
37526                Err(e) => match dlg.token(e) {
37527                    Ok(token) => token,
37528                    Err(e) => {
37529                        dlg.finished(false);
37530                        return Err(common::Error::MissingToken(e));
37531                    }
37532                },
37533            };
37534            request_value_reader
37535                .seek(std::io::SeekFrom::Start(0))
37536                .unwrap();
37537            let mut req_result = {
37538                let client = &self.hub.client;
37539                dlg.pre_request();
37540                let mut req_builder = hyper::Request::builder()
37541                    .method(hyper::Method::PATCH)
37542                    .uri(url.as_str())
37543                    .header(USER_AGENT, self.hub._user_agent.clone());
37544
37545                if let Some(token) = token.as_ref() {
37546                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37547                }
37548
37549                let request = req_builder
37550                    .header(CONTENT_TYPE, json_mime_type.to_string())
37551                    .header(CONTENT_LENGTH, request_size as u64)
37552                    .body(common::to_body(
37553                        request_value_reader.get_ref().clone().into(),
37554                    ));
37555
37556                client.request(request.unwrap()).await
37557            };
37558
37559            match req_result {
37560                Err(err) => {
37561                    if let common::Retry::After(d) = dlg.http_error(&err) {
37562                        sleep(d).await;
37563                        continue;
37564                    }
37565                    dlg.finished(false);
37566                    return Err(common::Error::HttpError(err));
37567                }
37568                Ok(res) => {
37569                    let (mut parts, body) = res.into_parts();
37570                    let mut body = common::Body::new(body);
37571                    if !parts.status.is_success() {
37572                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37573                        let error = serde_json::from_str(&common::to_string(&bytes));
37574                        let response = common::to_response(parts, bytes.into());
37575
37576                        if let common::Retry::After(d) =
37577                            dlg.http_failure(&response, error.as_ref().ok())
37578                        {
37579                            sleep(d).await;
37580                            continue;
37581                        }
37582
37583                        dlg.finished(false);
37584
37585                        return Err(match error {
37586                            Ok(value) => common::Error::BadRequest(value),
37587                            _ => common::Error::Failure(response),
37588                        });
37589                    }
37590                    let response = {
37591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37592                        let encoded = common::to_string(&bytes);
37593                        match serde_json::from_str(&encoded) {
37594                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
37595                            Err(error) => {
37596                                dlg.response_json_decode_error(&encoded, &error);
37597                                return Err(common::Error::JsonDecodeError(
37598                                    encoded.to_string(),
37599                                    error,
37600                                ));
37601                            }
37602                        }
37603                    };
37604
37605                    dlg.finished(true);
37606                    return Ok(response);
37607                }
37608            }
37609        }
37610    }
37611
37612    ///
37613    /// Sets the *request* property to the given value.
37614    ///
37615    /// Even though the property as already been set when instantiating this call,
37616    /// we provide this method for API completeness.
37617    pub fn request(mut self, new_value: UpdateInstanceRequest) -> ProjectInstancePatchCall<'a, C> {
37618        self._request = new_value;
37619        self
37620    }
37621    /// Required. A unique identifier for the instance, which cannot be changed after the instance is created. Values are of the form `projects//instances/a-z*[a-z0-9]`. The final segment of the name must be between 2 and 64 characters in length.
37622    ///
37623    /// Sets the *name* path property to the given value.
37624    ///
37625    /// Even though the property as already been set when instantiating this call,
37626    /// we provide this method for API completeness.
37627    pub fn name(mut self, new_value: &str) -> ProjectInstancePatchCall<'a, C> {
37628        self._name = new_value.to_string();
37629        self
37630    }
37631    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37632    /// while executing the actual API request.
37633    ///
37634    /// ````text
37635    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
37636    /// ````
37637    ///
37638    /// Sets the *delegate* property to the given value.
37639    pub fn delegate(
37640        mut self,
37641        new_value: &'a mut dyn common::Delegate,
37642    ) -> ProjectInstancePatchCall<'a, C> {
37643        self._delegate = Some(new_value);
37644        self
37645    }
37646
37647    /// Set any additional parameter of the query string used in the request.
37648    /// It should be used to set parameters which are not yet available through their own
37649    /// setters.
37650    ///
37651    /// Please note that this method must not be used to set any of the known parameters
37652    /// which have their own setter method. If done anyway, the request will fail.
37653    ///
37654    /// # Additional Parameters
37655    ///
37656    /// * *$.xgafv* (query-string) - V1 error format.
37657    /// * *access_token* (query-string) - OAuth access token.
37658    /// * *alt* (query-string) - Data format for response.
37659    /// * *callback* (query-string) - JSONP
37660    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37661    /// * *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.
37662    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
37663    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
37664    /// * *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.
37665    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
37666    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
37667    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstancePatchCall<'a, C>
37668    where
37669        T: AsRef<str>,
37670    {
37671        self._additional_params
37672            .insert(name.as_ref().to_string(), value.as_ref().to_string());
37673        self
37674    }
37675
37676    /// Identifies the authorization scope for the method you are building.
37677    ///
37678    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37679    /// [`Scope::CloudPlatform`].
37680    ///
37681    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37682    /// tokens for more than one scope.
37683    ///
37684    /// Usually there is more than one suitable scope to authorize an operation, some of which may
37685    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37686    /// sufficient, a read-write scope will do as well.
37687    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstancePatchCall<'a, C>
37688    where
37689        St: AsRef<str>,
37690    {
37691        self._scopes.insert(String::from(scope.as_ref()));
37692        self
37693    }
37694    /// Identifies the authorization scope(s) for the method you are building.
37695    ///
37696    /// See [`Self::add_scope()`] for details.
37697    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstancePatchCall<'a, C>
37698    where
37699        I: IntoIterator<Item = St>,
37700        St: AsRef<str>,
37701    {
37702        self._scopes
37703            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37704        self
37705    }
37706
37707    /// Removes all scopes, and no default scope will be used either.
37708    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37709    /// for details).
37710    pub fn clear_scopes(mut self) -> ProjectInstancePatchCall<'a, C> {
37711        self._scopes.clear();
37712        self
37713    }
37714}
37715
37716/// Sets the access control policy on an instance resource. Replaces any existing policy. Authorization requires `spanner.instances.setIamPolicy` on resource.
37717///
37718/// A builder for the *instances.setIamPolicy* method supported by a *project* resource.
37719/// It is not used directly, but through a [`ProjectMethods`] instance.
37720///
37721/// # Example
37722///
37723/// Instantiate a resource method builder
37724///
37725/// ```test_harness,no_run
37726/// # extern crate hyper;
37727/// # extern crate hyper_rustls;
37728/// # extern crate google_spanner1 as spanner1;
37729/// use spanner1::api::SetIamPolicyRequest;
37730/// # async fn dox() {
37731/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37732///
37733/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37734/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
37735/// #     .with_native_roots()
37736/// #     .unwrap()
37737/// #     .https_only()
37738/// #     .enable_http2()
37739/// #     .build();
37740///
37741/// # let executor = hyper_util::rt::TokioExecutor::new();
37742/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
37743/// #     secret,
37744/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37745/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
37746/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
37747/// #     ),
37748/// # ).build().await.unwrap();
37749///
37750/// # let client = hyper_util::client::legacy::Client::builder(
37751/// #     hyper_util::rt::TokioExecutor::new()
37752/// # )
37753/// # .build(
37754/// #     hyper_rustls::HttpsConnectorBuilder::new()
37755/// #         .with_native_roots()
37756/// #         .unwrap()
37757/// #         .https_or_http()
37758/// #         .enable_http2()
37759/// #         .build()
37760/// # );
37761/// # let mut hub = Spanner::new(client, auth);
37762/// // As the method needs a request, you would usually fill it with the desired information
37763/// // into the respective structure. Some of the parts shown here might not be applicable !
37764/// // Values shown here are possibly random and not representative !
37765/// let mut req = SetIamPolicyRequest::default();
37766///
37767/// // You can configure optional parameters by calling the respective setters at will, and
37768/// // execute the final call using `doit()`.
37769/// // Values shown here are possibly random and not representative !
37770/// let result = hub.projects().instances_set_iam_policy(req, "resource")
37771///              .doit().await;
37772/// # }
37773/// ```
37774pub struct ProjectInstanceSetIamPolicyCall<'a, C>
37775where
37776    C: 'a,
37777{
37778    hub: &'a Spanner<C>,
37779    _request: SetIamPolicyRequest,
37780    _resource: String,
37781    _delegate: Option<&'a mut dyn common::Delegate>,
37782    _additional_params: HashMap<String, String>,
37783    _scopes: BTreeSet<String>,
37784}
37785
37786impl<'a, C> common::CallBuilder for ProjectInstanceSetIamPolicyCall<'a, C> {}
37787
37788impl<'a, C> ProjectInstanceSetIamPolicyCall<'a, C>
37789where
37790    C: common::Connector,
37791{
37792    /// Perform the operation you have build so far.
37793    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
37794        use std::borrow::Cow;
37795        use std::io::{Read, Seek};
37796
37797        use common::{url::Params, ToParts};
37798        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37799
37800        let mut dd = common::DefaultDelegate;
37801        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37802        dlg.begin(common::MethodInfo {
37803            id: "spanner.projects.instances.setIamPolicy",
37804            http_method: hyper::Method::POST,
37805        });
37806
37807        for &field in ["alt", "resource"].iter() {
37808            if self._additional_params.contains_key(field) {
37809                dlg.finished(false);
37810                return Err(common::Error::FieldClash(field));
37811            }
37812        }
37813
37814        let mut params = Params::with_capacity(4 + self._additional_params.len());
37815        params.push("resource", self._resource);
37816
37817        params.extend(self._additional_params.iter());
37818
37819        params.push("alt", "json");
37820        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
37821        if self._scopes.is_empty() {
37822            self._scopes
37823                .insert(Scope::CloudPlatform.as_ref().to_string());
37824        }
37825
37826        #[allow(clippy::single_element_loop)]
37827        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
37828            url = params.uri_replacement(url, param_name, find_this, true);
37829        }
37830        {
37831            let to_remove = ["resource"];
37832            params.remove_params(&to_remove);
37833        }
37834
37835        let url = params.parse_with_url(&url);
37836
37837        let mut json_mime_type = mime::APPLICATION_JSON;
37838        let mut request_value_reader = {
37839            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
37840            common::remove_json_null_values(&mut value);
37841            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
37842            serde_json::to_writer(&mut dst, &value).unwrap();
37843            dst
37844        };
37845        let request_size = request_value_reader
37846            .seek(std::io::SeekFrom::End(0))
37847            .unwrap();
37848        request_value_reader
37849            .seek(std::io::SeekFrom::Start(0))
37850            .unwrap();
37851
37852        loop {
37853            let token = match self
37854                .hub
37855                .auth
37856                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37857                .await
37858            {
37859                Ok(token) => token,
37860                Err(e) => match dlg.token(e) {
37861                    Ok(token) => token,
37862                    Err(e) => {
37863                        dlg.finished(false);
37864                        return Err(common::Error::MissingToken(e));
37865                    }
37866                },
37867            };
37868            request_value_reader
37869                .seek(std::io::SeekFrom::Start(0))
37870                .unwrap();
37871            let mut req_result = {
37872                let client = &self.hub.client;
37873                dlg.pre_request();
37874                let mut req_builder = hyper::Request::builder()
37875                    .method(hyper::Method::POST)
37876                    .uri(url.as_str())
37877                    .header(USER_AGENT, self.hub._user_agent.clone());
37878
37879                if let Some(token) = token.as_ref() {
37880                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37881                }
37882
37883                let request = req_builder
37884                    .header(CONTENT_TYPE, json_mime_type.to_string())
37885                    .header(CONTENT_LENGTH, request_size as u64)
37886                    .body(common::to_body(
37887                        request_value_reader.get_ref().clone().into(),
37888                    ));
37889
37890                client.request(request.unwrap()).await
37891            };
37892
37893            match req_result {
37894                Err(err) => {
37895                    if let common::Retry::After(d) = dlg.http_error(&err) {
37896                        sleep(d).await;
37897                        continue;
37898                    }
37899                    dlg.finished(false);
37900                    return Err(common::Error::HttpError(err));
37901                }
37902                Ok(res) => {
37903                    let (mut parts, body) = res.into_parts();
37904                    let mut body = common::Body::new(body);
37905                    if !parts.status.is_success() {
37906                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37907                        let error = serde_json::from_str(&common::to_string(&bytes));
37908                        let response = common::to_response(parts, bytes.into());
37909
37910                        if let common::Retry::After(d) =
37911                            dlg.http_failure(&response, error.as_ref().ok())
37912                        {
37913                            sleep(d).await;
37914                            continue;
37915                        }
37916
37917                        dlg.finished(false);
37918
37919                        return Err(match error {
37920                            Ok(value) => common::Error::BadRequest(value),
37921                            _ => common::Error::Failure(response),
37922                        });
37923                    }
37924                    let response = {
37925                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37926                        let encoded = common::to_string(&bytes);
37927                        match serde_json::from_str(&encoded) {
37928                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
37929                            Err(error) => {
37930                                dlg.response_json_decode_error(&encoded, &error);
37931                                return Err(common::Error::JsonDecodeError(
37932                                    encoded.to_string(),
37933                                    error,
37934                                ));
37935                            }
37936                        }
37937                    };
37938
37939                    dlg.finished(true);
37940                    return Ok(response);
37941                }
37942            }
37943        }
37944    }
37945
37946    ///
37947    /// Sets the *request* property to the given value.
37948    ///
37949    /// Even though the property as already been set when instantiating this call,
37950    /// we provide this method for API completeness.
37951    pub fn request(
37952        mut self,
37953        new_value: SetIamPolicyRequest,
37954    ) -> ProjectInstanceSetIamPolicyCall<'a, C> {
37955        self._request = new_value;
37956        self
37957    }
37958    /// REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for databases resources.
37959    ///
37960    /// Sets the *resource* path property to the given value.
37961    ///
37962    /// Even though the property as already been set when instantiating this call,
37963    /// we provide this method for API completeness.
37964    pub fn resource(mut self, new_value: &str) -> ProjectInstanceSetIamPolicyCall<'a, C> {
37965        self._resource = new_value.to_string();
37966        self
37967    }
37968    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37969    /// while executing the actual API request.
37970    ///
37971    /// ````text
37972    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
37973    /// ````
37974    ///
37975    /// Sets the *delegate* property to the given value.
37976    pub fn delegate(
37977        mut self,
37978        new_value: &'a mut dyn common::Delegate,
37979    ) -> ProjectInstanceSetIamPolicyCall<'a, C> {
37980        self._delegate = Some(new_value);
37981        self
37982    }
37983
37984    /// Set any additional parameter of the query string used in the request.
37985    /// It should be used to set parameters which are not yet available through their own
37986    /// setters.
37987    ///
37988    /// Please note that this method must not be used to set any of the known parameters
37989    /// which have their own setter method. If done anyway, the request will fail.
37990    ///
37991    /// # Additional Parameters
37992    ///
37993    /// * *$.xgafv* (query-string) - V1 error format.
37994    /// * *access_token* (query-string) - OAuth access token.
37995    /// * *alt* (query-string) - Data format for response.
37996    /// * *callback* (query-string) - JSONP
37997    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37998    /// * *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.
37999    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
38000    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
38001    /// * *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.
38002    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
38003    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
38004    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceSetIamPolicyCall<'a, C>
38005    where
38006        T: AsRef<str>,
38007    {
38008        self._additional_params
38009            .insert(name.as_ref().to_string(), value.as_ref().to_string());
38010        self
38011    }
38012
38013    /// Identifies the authorization scope for the method you are building.
38014    ///
38015    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
38016    /// [`Scope::CloudPlatform`].
38017    ///
38018    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
38019    /// tokens for more than one scope.
38020    ///
38021    /// Usually there is more than one suitable scope to authorize an operation, some of which may
38022    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
38023    /// sufficient, a read-write scope will do as well.
38024    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceSetIamPolicyCall<'a, C>
38025    where
38026        St: AsRef<str>,
38027    {
38028        self._scopes.insert(String::from(scope.as_ref()));
38029        self
38030    }
38031    /// Identifies the authorization scope(s) for the method you are building.
38032    ///
38033    /// See [`Self::add_scope()`] for details.
38034    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceSetIamPolicyCall<'a, C>
38035    where
38036        I: IntoIterator<Item = St>,
38037        St: AsRef<str>,
38038    {
38039        self._scopes
38040            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
38041        self
38042    }
38043
38044    /// Removes all scopes, and no default scope will be used either.
38045    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
38046    /// for details).
38047    pub fn clear_scopes(mut self) -> ProjectInstanceSetIamPolicyCall<'a, C> {
38048        self._scopes.clear();
38049        self
38050    }
38051}
38052
38053/// Returns permissions that the caller has on the specified instance resource. Attempting this RPC on a non-existent Cloud Spanner instance resource will result in a NOT_FOUND error if the user has `spanner.instances.list` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions.
38054///
38055/// A builder for the *instances.testIamPermissions* method supported by a *project* resource.
38056/// It is not used directly, but through a [`ProjectMethods`] instance.
38057///
38058/// # Example
38059///
38060/// Instantiate a resource method builder
38061///
38062/// ```test_harness,no_run
38063/// # extern crate hyper;
38064/// # extern crate hyper_rustls;
38065/// # extern crate google_spanner1 as spanner1;
38066/// use spanner1::api::TestIamPermissionsRequest;
38067/// # async fn dox() {
38068/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
38069///
38070/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
38071/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
38072/// #     .with_native_roots()
38073/// #     .unwrap()
38074/// #     .https_only()
38075/// #     .enable_http2()
38076/// #     .build();
38077///
38078/// # let executor = hyper_util::rt::TokioExecutor::new();
38079/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
38080/// #     secret,
38081/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
38082/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
38083/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
38084/// #     ),
38085/// # ).build().await.unwrap();
38086///
38087/// # let client = hyper_util::client::legacy::Client::builder(
38088/// #     hyper_util::rt::TokioExecutor::new()
38089/// # )
38090/// # .build(
38091/// #     hyper_rustls::HttpsConnectorBuilder::new()
38092/// #         .with_native_roots()
38093/// #         .unwrap()
38094/// #         .https_or_http()
38095/// #         .enable_http2()
38096/// #         .build()
38097/// # );
38098/// # let mut hub = Spanner::new(client, auth);
38099/// // As the method needs a request, you would usually fill it with the desired information
38100/// // into the respective structure. Some of the parts shown here might not be applicable !
38101/// // Values shown here are possibly random and not representative !
38102/// let mut req = TestIamPermissionsRequest::default();
38103///
38104/// // You can configure optional parameters by calling the respective setters at will, and
38105/// // execute the final call using `doit()`.
38106/// // Values shown here are possibly random and not representative !
38107/// let result = hub.projects().instances_test_iam_permissions(req, "resource")
38108///              .doit().await;
38109/// # }
38110/// ```
38111pub struct ProjectInstanceTestIamPermissionCall<'a, C>
38112where
38113    C: 'a,
38114{
38115    hub: &'a Spanner<C>,
38116    _request: TestIamPermissionsRequest,
38117    _resource: String,
38118    _delegate: Option<&'a mut dyn common::Delegate>,
38119    _additional_params: HashMap<String, String>,
38120    _scopes: BTreeSet<String>,
38121}
38122
38123impl<'a, C> common::CallBuilder for ProjectInstanceTestIamPermissionCall<'a, C> {}
38124
38125impl<'a, C> ProjectInstanceTestIamPermissionCall<'a, C>
38126where
38127    C: common::Connector,
38128{
38129    /// Perform the operation you have build so far.
38130    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
38131        use std::borrow::Cow;
38132        use std::io::{Read, Seek};
38133
38134        use common::{url::Params, ToParts};
38135        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
38136
38137        let mut dd = common::DefaultDelegate;
38138        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
38139        dlg.begin(common::MethodInfo {
38140            id: "spanner.projects.instances.testIamPermissions",
38141            http_method: hyper::Method::POST,
38142        });
38143
38144        for &field in ["alt", "resource"].iter() {
38145            if self._additional_params.contains_key(field) {
38146                dlg.finished(false);
38147                return Err(common::Error::FieldClash(field));
38148            }
38149        }
38150
38151        let mut params = Params::with_capacity(4 + self._additional_params.len());
38152        params.push("resource", self._resource);
38153
38154        params.extend(self._additional_params.iter());
38155
38156        params.push("alt", "json");
38157        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
38158        if self._scopes.is_empty() {
38159            self._scopes
38160                .insert(Scope::CloudPlatform.as_ref().to_string());
38161        }
38162
38163        #[allow(clippy::single_element_loop)]
38164        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
38165            url = params.uri_replacement(url, param_name, find_this, true);
38166        }
38167        {
38168            let to_remove = ["resource"];
38169            params.remove_params(&to_remove);
38170        }
38171
38172        let url = params.parse_with_url(&url);
38173
38174        let mut json_mime_type = mime::APPLICATION_JSON;
38175        let mut request_value_reader = {
38176            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
38177            common::remove_json_null_values(&mut value);
38178            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
38179            serde_json::to_writer(&mut dst, &value).unwrap();
38180            dst
38181        };
38182        let request_size = request_value_reader
38183            .seek(std::io::SeekFrom::End(0))
38184            .unwrap();
38185        request_value_reader
38186            .seek(std::io::SeekFrom::Start(0))
38187            .unwrap();
38188
38189        loop {
38190            let token = match self
38191                .hub
38192                .auth
38193                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
38194                .await
38195            {
38196                Ok(token) => token,
38197                Err(e) => match dlg.token(e) {
38198                    Ok(token) => token,
38199                    Err(e) => {
38200                        dlg.finished(false);
38201                        return Err(common::Error::MissingToken(e));
38202                    }
38203                },
38204            };
38205            request_value_reader
38206                .seek(std::io::SeekFrom::Start(0))
38207                .unwrap();
38208            let mut req_result = {
38209                let client = &self.hub.client;
38210                dlg.pre_request();
38211                let mut req_builder = hyper::Request::builder()
38212                    .method(hyper::Method::POST)
38213                    .uri(url.as_str())
38214                    .header(USER_AGENT, self.hub._user_agent.clone());
38215
38216                if let Some(token) = token.as_ref() {
38217                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
38218                }
38219
38220                let request = req_builder
38221                    .header(CONTENT_TYPE, json_mime_type.to_string())
38222                    .header(CONTENT_LENGTH, request_size as u64)
38223                    .body(common::to_body(
38224                        request_value_reader.get_ref().clone().into(),
38225                    ));
38226
38227                client.request(request.unwrap()).await
38228            };
38229
38230            match req_result {
38231                Err(err) => {
38232                    if let common::Retry::After(d) = dlg.http_error(&err) {
38233                        sleep(d).await;
38234                        continue;
38235                    }
38236                    dlg.finished(false);
38237                    return Err(common::Error::HttpError(err));
38238                }
38239                Ok(res) => {
38240                    let (mut parts, body) = res.into_parts();
38241                    let mut body = common::Body::new(body);
38242                    if !parts.status.is_success() {
38243                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38244                        let error = serde_json::from_str(&common::to_string(&bytes));
38245                        let response = common::to_response(parts, bytes.into());
38246
38247                        if let common::Retry::After(d) =
38248                            dlg.http_failure(&response, error.as_ref().ok())
38249                        {
38250                            sleep(d).await;
38251                            continue;
38252                        }
38253
38254                        dlg.finished(false);
38255
38256                        return Err(match error {
38257                            Ok(value) => common::Error::BadRequest(value),
38258                            _ => common::Error::Failure(response),
38259                        });
38260                    }
38261                    let response = {
38262                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38263                        let encoded = common::to_string(&bytes);
38264                        match serde_json::from_str(&encoded) {
38265                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
38266                            Err(error) => {
38267                                dlg.response_json_decode_error(&encoded, &error);
38268                                return Err(common::Error::JsonDecodeError(
38269                                    encoded.to_string(),
38270                                    error,
38271                                ));
38272                            }
38273                        }
38274                    };
38275
38276                    dlg.finished(true);
38277                    return Ok(response);
38278                }
38279            }
38280        }
38281    }
38282
38283    ///
38284    /// Sets the *request* property to the given value.
38285    ///
38286    /// Even though the property as already been set when instantiating this call,
38287    /// we provide this method for API completeness.
38288    pub fn request(
38289        mut self,
38290        new_value: TestIamPermissionsRequest,
38291    ) -> ProjectInstanceTestIamPermissionCall<'a, C> {
38292        self._request = new_value;
38293        self
38294    }
38295    /// REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is `projects//instances/` for instance resources and `projects//instances//databases/` for database resources.
38296    ///
38297    /// Sets the *resource* path property to the given value.
38298    ///
38299    /// Even though the property as already been set when instantiating this call,
38300    /// we provide this method for API completeness.
38301    pub fn resource(mut self, new_value: &str) -> ProjectInstanceTestIamPermissionCall<'a, C> {
38302        self._resource = new_value.to_string();
38303        self
38304    }
38305    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
38306    /// while executing the actual API request.
38307    ///
38308    /// ````text
38309    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
38310    /// ````
38311    ///
38312    /// Sets the *delegate* property to the given value.
38313    pub fn delegate(
38314        mut self,
38315        new_value: &'a mut dyn common::Delegate,
38316    ) -> ProjectInstanceTestIamPermissionCall<'a, C> {
38317        self._delegate = Some(new_value);
38318        self
38319    }
38320
38321    /// Set any additional parameter of the query string used in the request.
38322    /// It should be used to set parameters which are not yet available through their own
38323    /// setters.
38324    ///
38325    /// Please note that this method must not be used to set any of the known parameters
38326    /// which have their own setter method. If done anyway, the request will fail.
38327    ///
38328    /// # Additional Parameters
38329    ///
38330    /// * *$.xgafv* (query-string) - V1 error format.
38331    /// * *access_token* (query-string) - OAuth access token.
38332    /// * *alt* (query-string) - Data format for response.
38333    /// * *callback* (query-string) - JSONP
38334    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
38335    /// * *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.
38336    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
38337    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
38338    /// * *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.
38339    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
38340    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
38341    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceTestIamPermissionCall<'a, C>
38342    where
38343        T: AsRef<str>,
38344    {
38345        self._additional_params
38346            .insert(name.as_ref().to_string(), value.as_ref().to_string());
38347        self
38348    }
38349
38350    /// Identifies the authorization scope for the method you are building.
38351    ///
38352    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
38353    /// [`Scope::CloudPlatform`].
38354    ///
38355    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
38356    /// tokens for more than one scope.
38357    ///
38358    /// Usually there is more than one suitable scope to authorize an operation, some of which may
38359    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
38360    /// sufficient, a read-write scope will do as well.
38361    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceTestIamPermissionCall<'a, C>
38362    where
38363        St: AsRef<str>,
38364    {
38365        self._scopes.insert(String::from(scope.as_ref()));
38366        self
38367    }
38368    /// Identifies the authorization scope(s) for the method you are building.
38369    ///
38370    /// See [`Self::add_scope()`] for details.
38371    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceTestIamPermissionCall<'a, C>
38372    where
38373        I: IntoIterator<Item = St>,
38374        St: AsRef<str>,
38375    {
38376        self._scopes
38377            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
38378        self
38379    }
38380
38381    /// Removes all scopes, and no default scope will be used either.
38382    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
38383    /// for details).
38384    pub fn clear_scopes(mut self) -> ProjectInstanceTestIamPermissionCall<'a, C> {
38385        self._scopes.clear();
38386        self
38387    }
38388}
38389
38390/// Return available scans given a Database-specific resource name.
38391///
38392/// A builder for the *list* method supported by a *scan* resource.
38393/// It is not used directly, but through a [`ScanMethods`] instance.
38394///
38395/// # Example
38396///
38397/// Instantiate a resource method builder
38398///
38399/// ```test_harness,no_run
38400/// # extern crate hyper;
38401/// # extern crate hyper_rustls;
38402/// # extern crate google_spanner1 as spanner1;
38403/// # async fn dox() {
38404/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
38405///
38406/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
38407/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
38408/// #     .with_native_roots()
38409/// #     .unwrap()
38410/// #     .https_only()
38411/// #     .enable_http2()
38412/// #     .build();
38413///
38414/// # let executor = hyper_util::rt::TokioExecutor::new();
38415/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
38416/// #     secret,
38417/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
38418/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
38419/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
38420/// #     ),
38421/// # ).build().await.unwrap();
38422///
38423/// # let client = hyper_util::client::legacy::Client::builder(
38424/// #     hyper_util::rt::TokioExecutor::new()
38425/// # )
38426/// # .build(
38427/// #     hyper_rustls::HttpsConnectorBuilder::new()
38428/// #         .with_native_roots()
38429/// #         .unwrap()
38430/// #         .https_or_http()
38431/// #         .enable_http2()
38432/// #         .build()
38433/// # );
38434/// # let mut hub = Spanner::new(client, auth);
38435/// // You can configure optional parameters by calling the respective setters at will, and
38436/// // execute the final call using `doit()`.
38437/// // Values shown here are possibly random and not representative !
38438/// let result = hub.scans().list("parent")
38439///              .view("consetetur")
38440///              .page_token("gubergren")
38441///              .page_size(-4)
38442///              .filter("aliquyam")
38443///              .doit().await;
38444/// # }
38445/// ```
38446pub struct ScanListCall<'a, C>
38447where
38448    C: 'a,
38449{
38450    hub: &'a Spanner<C>,
38451    _parent: String,
38452    _view: Option<String>,
38453    _page_token: Option<String>,
38454    _page_size: Option<i32>,
38455    _filter: Option<String>,
38456    _delegate: Option<&'a mut dyn common::Delegate>,
38457    _additional_params: HashMap<String, String>,
38458    _scopes: BTreeSet<String>,
38459}
38460
38461impl<'a, C> common::CallBuilder for ScanListCall<'a, C> {}
38462
38463impl<'a, C> ScanListCall<'a, C>
38464where
38465    C: common::Connector,
38466{
38467    /// Perform the operation you have build so far.
38468    pub async fn doit(mut self) -> common::Result<(common::Response, ListScansResponse)> {
38469        use std::borrow::Cow;
38470        use std::io::{Read, Seek};
38471
38472        use common::{url::Params, ToParts};
38473        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
38474
38475        let mut dd = common::DefaultDelegate;
38476        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
38477        dlg.begin(common::MethodInfo {
38478            id: "spanner.scans.list",
38479            http_method: hyper::Method::GET,
38480        });
38481
38482        for &field in ["alt", "parent", "view", "pageToken", "pageSize", "filter"].iter() {
38483            if self._additional_params.contains_key(field) {
38484                dlg.finished(false);
38485                return Err(common::Error::FieldClash(field));
38486            }
38487        }
38488
38489        let mut params = Params::with_capacity(7 + self._additional_params.len());
38490        params.push("parent", self._parent);
38491        if let Some(value) = self._view.as_ref() {
38492            params.push("view", value);
38493        }
38494        if let Some(value) = self._page_token.as_ref() {
38495            params.push("pageToken", value);
38496        }
38497        if let Some(value) = self._page_size.as_ref() {
38498            params.push("pageSize", value.to_string());
38499        }
38500        if let Some(value) = self._filter.as_ref() {
38501            params.push("filter", value);
38502        }
38503
38504        params.extend(self._additional_params.iter());
38505
38506        params.push("alt", "json");
38507        let mut url = self.hub._base_url.clone() + "v1/{+parent}";
38508        if self._scopes.is_empty() {
38509            self._scopes
38510                .insert(Scope::CloudPlatform.as_ref().to_string());
38511        }
38512
38513        #[allow(clippy::single_element_loop)]
38514        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
38515            url = params.uri_replacement(url, param_name, find_this, true);
38516        }
38517        {
38518            let to_remove = ["parent"];
38519            params.remove_params(&to_remove);
38520        }
38521
38522        let url = params.parse_with_url(&url);
38523
38524        loop {
38525            let token = match self
38526                .hub
38527                .auth
38528                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
38529                .await
38530            {
38531                Ok(token) => token,
38532                Err(e) => match dlg.token(e) {
38533                    Ok(token) => token,
38534                    Err(e) => {
38535                        dlg.finished(false);
38536                        return Err(common::Error::MissingToken(e));
38537                    }
38538                },
38539            };
38540            let mut req_result = {
38541                let client = &self.hub.client;
38542                dlg.pre_request();
38543                let mut req_builder = hyper::Request::builder()
38544                    .method(hyper::Method::GET)
38545                    .uri(url.as_str())
38546                    .header(USER_AGENT, self.hub._user_agent.clone());
38547
38548                if let Some(token) = token.as_ref() {
38549                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
38550                }
38551
38552                let request = req_builder
38553                    .header(CONTENT_LENGTH, 0_u64)
38554                    .body(common::to_body::<String>(None));
38555
38556                client.request(request.unwrap()).await
38557            };
38558
38559            match req_result {
38560                Err(err) => {
38561                    if let common::Retry::After(d) = dlg.http_error(&err) {
38562                        sleep(d).await;
38563                        continue;
38564                    }
38565                    dlg.finished(false);
38566                    return Err(common::Error::HttpError(err));
38567                }
38568                Ok(res) => {
38569                    let (mut parts, body) = res.into_parts();
38570                    let mut body = common::Body::new(body);
38571                    if !parts.status.is_success() {
38572                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38573                        let error = serde_json::from_str(&common::to_string(&bytes));
38574                        let response = common::to_response(parts, bytes.into());
38575
38576                        if let common::Retry::After(d) =
38577                            dlg.http_failure(&response, error.as_ref().ok())
38578                        {
38579                            sleep(d).await;
38580                            continue;
38581                        }
38582
38583                        dlg.finished(false);
38584
38585                        return Err(match error {
38586                            Ok(value) => common::Error::BadRequest(value),
38587                            _ => common::Error::Failure(response),
38588                        });
38589                    }
38590                    let response = {
38591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38592                        let encoded = common::to_string(&bytes);
38593                        match serde_json::from_str(&encoded) {
38594                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
38595                            Err(error) => {
38596                                dlg.response_json_decode_error(&encoded, &error);
38597                                return Err(common::Error::JsonDecodeError(
38598                                    encoded.to_string(),
38599                                    error,
38600                                ));
38601                            }
38602                        }
38603                    };
38604
38605                    dlg.finished(true);
38606                    return Ok(response);
38607                }
38608            }
38609        }
38610    }
38611
38612    /// Required. The unique name of the parent resource, specific to the Database service implementing this interface.
38613    ///
38614    /// Sets the *parent* path property to the given value.
38615    ///
38616    /// Even though the property as already been set when instantiating this call,
38617    /// we provide this method for API completeness.
38618    pub fn parent(mut self, new_value: &str) -> ScanListCall<'a, C> {
38619        self._parent = new_value.to_string();
38620        self
38621    }
38622    /// Specifies which parts of the Scan should be returned in the response. Note, only the SUMMARY view (the default) is currently supported for ListScans.
38623    ///
38624    /// Sets the *view* query property to the given value.
38625    pub fn view(mut self, new_value: &str) -> ScanListCall<'a, C> {
38626        self._view = Some(new_value.to_string());
38627        self
38628    }
38629    /// The next_page_token value returned from a previous List request, if any.
38630    ///
38631    /// Sets the *page token* query property to the given value.
38632    pub fn page_token(mut self, new_value: &str) -> ScanListCall<'a, C> {
38633        self._page_token = Some(new_value.to_string());
38634        self
38635    }
38636    /// The maximum number of items to return.
38637    ///
38638    /// Sets the *page size* query property to the given value.
38639    pub fn page_size(mut self, new_value: i32) -> ScanListCall<'a, C> {
38640        self._page_size = Some(new_value);
38641        self
38642    }
38643    /// A filter expression to restrict the results based on information present in the available Scan collection. The filter applies to all fields within the Scan message except for `data`.
38644    ///
38645    /// Sets the *filter* query property to the given value.
38646    pub fn filter(mut self, new_value: &str) -> ScanListCall<'a, C> {
38647        self._filter = Some(new_value.to_string());
38648        self
38649    }
38650    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
38651    /// while executing the actual API request.
38652    ///
38653    /// ````text
38654    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
38655    /// ````
38656    ///
38657    /// Sets the *delegate* property to the given value.
38658    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ScanListCall<'a, C> {
38659        self._delegate = Some(new_value);
38660        self
38661    }
38662
38663    /// Set any additional parameter of the query string used in the request.
38664    /// It should be used to set parameters which are not yet available through their own
38665    /// setters.
38666    ///
38667    /// Please note that this method must not be used to set any of the known parameters
38668    /// which have their own setter method. If done anyway, the request will fail.
38669    ///
38670    /// # Additional Parameters
38671    ///
38672    /// * *$.xgafv* (query-string) - V1 error format.
38673    /// * *access_token* (query-string) - OAuth access token.
38674    /// * *alt* (query-string) - Data format for response.
38675    /// * *callback* (query-string) - JSONP
38676    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
38677    /// * *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.
38678    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
38679    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
38680    /// * *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.
38681    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
38682    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
38683    pub fn param<T>(mut self, name: T, value: T) -> ScanListCall<'a, C>
38684    where
38685        T: AsRef<str>,
38686    {
38687        self._additional_params
38688            .insert(name.as_ref().to_string(), value.as_ref().to_string());
38689        self
38690    }
38691
38692    /// Identifies the authorization scope for the method you are building.
38693    ///
38694    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
38695    /// [`Scope::CloudPlatform`].
38696    ///
38697    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
38698    /// tokens for more than one scope.
38699    ///
38700    /// Usually there is more than one suitable scope to authorize an operation, some of which may
38701    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
38702    /// sufficient, a read-write scope will do as well.
38703    pub fn add_scope<St>(mut self, scope: St) -> ScanListCall<'a, C>
38704    where
38705        St: AsRef<str>,
38706    {
38707        self._scopes.insert(String::from(scope.as_ref()));
38708        self
38709    }
38710    /// Identifies the authorization scope(s) for the method you are building.
38711    ///
38712    /// See [`Self::add_scope()`] for details.
38713    pub fn add_scopes<I, St>(mut self, scopes: I) -> ScanListCall<'a, C>
38714    where
38715        I: IntoIterator<Item = St>,
38716        St: AsRef<str>,
38717    {
38718        self._scopes
38719            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
38720        self
38721    }
38722
38723    /// Removes all scopes, and no default scope will be used either.
38724    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
38725    /// for details).
38726    pub fn clear_scopes(mut self) -> ScanListCall<'a, C> {
38727        self._scopes.clear();
38728        self
38729    }
38730}