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 /// View and manage the contents of your Spanner databases
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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// ).build().await.unwrap();
74///
75/// let client = hyper_util::client::legacy::Client::builder(
76/// hyper_util::rt::TokioExecutor::new()
77/// )
78/// .build(
79/// hyper_rustls::HttpsConnectorBuilder::new()
80/// .with_native_roots()
81/// .unwrap()
82/// .https_or_http()
83/// .enable_http1()
84/// .build()
85/// );
86/// let mut hub = Spanner::new(client, auth);
87/// // As the method needs a request, you would usually fill it with the desired information
88/// // into the respective structure. Some of the parts shown here might not be applicable !
89/// // Values shown here are possibly random and not representative !
90/// let mut req = Backup::default();
91///
92/// // You can configure optional parameters by calling the respective setters at will, and
93/// // execute the final call using `doit()`.
94/// // Values shown here are possibly random and not representative !
95/// let result = hub.projects().instances_backups_create(req, "parent")
96/// .add_encryption_config_kms_key_names("duo")
97/// .encryption_config_kms_key_name("ipsum")
98/// .encryption_config_encryption_type("gubergren")
99/// .backup_id("Lorem")
100/// .doit().await;
101///
102/// match result {
103/// Err(e) => match e {
104/// // The Error enum provides details about what exactly happened.
105/// // You can also just use its `Debug`, `Display` or `Error` traits
106/// Error::HttpError(_)
107/// |Error::Io(_)
108/// |Error::MissingAPIKey
109/// |Error::MissingToken(_)
110/// |Error::Cancelled
111/// |Error::UploadSizeLimitExceeded(_, _)
112/// |Error::Failure(_)
113/// |Error::BadRequest(_)
114/// |Error::FieldClash(_)
115/// |Error::JsonDecodeError(_, _) => println!("{}", e),
116/// },
117/// Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct Spanner<C> {
123 pub client: common::Client<C>,
124 pub auth: Box<dyn common::GetToken>,
125 _user_agent: String,
126 _base_url: String,
127 _root_url: String,
128}
129
130impl<C> common::Hub for Spanner<C> {}
131
132impl<'a, C> Spanner<C> {
133 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Spanner<C> {
134 Spanner {
135 client,
136 auth: Box::new(auth),
137 _user_agent: "google-api-rust-client/6.0.0".to_string(),
138 _base_url: "https://spanner.googleapis.com/".to_string(),
139 _root_url: "https://spanner.googleapis.com/".to_string(),
140 }
141 }
142
143 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
144 ProjectMethods { hub: self }
145 }
146 pub fn scans(&'a self) -> ScanMethods<'a, C> {
147 ScanMethods { hub: self }
148 }
149
150 /// Set the user-agent header field to use in all requests to the server.
151 /// It defaults to `google-api-rust-client/6.0.0`.
152 ///
153 /// Returns the previously set user-agent.
154 pub fn user_agent(&mut self, agent_name: String) -> String {
155 std::mem::replace(&mut self._user_agent, agent_name)
156 }
157
158 /// Set the base url to use in all requests to the server.
159 /// It defaults to `https://spanner.googleapis.com/`.
160 ///
161 /// Returns the previously set base url.
162 pub fn base_url(&mut self, new_base_url: String) -> String {
163 std::mem::replace(&mut self._base_url, new_base_url)
164 }
165
166 /// Set the root url to use in all requests to the server.
167 /// It defaults to `https://spanner.googleapis.com/`.
168 ///
169 /// Returns the previously set root url.
170 pub fn root_url(&mut self, new_root_url: String) -> String {
171 std::mem::replace(&mut self._root_url, new_root_url)
172 }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// Autoscaling config for an instance.
179///
180/// This type is not used in any activity, and only used as *part* of another schema.
181///
182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
183#[serde_with::serde_as]
184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
185pub struct AutoscalingConfig {
186 /// Required. Autoscaling limits for an instance.
187 #[serde(rename = "autoscalingLimits")]
188 pub autoscaling_limits: Option<AutoscalingLimits>,
189 /// Required. The autoscaling targets for an instance.
190 #[serde(rename = "autoscalingTargets")]
191 pub autoscaling_targets: Option<AutoscalingTargets>,
192}
193
194impl common::Part for AutoscalingConfig {}
195
196/// 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.
197///
198/// This type is not used in any activity, and only used as *part* of another schema.
199///
200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
201#[serde_with::serde_as]
202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
203pub struct AutoscalingLimits {
204 /// Maximum number of nodes allocated to the instance. If set, this number should be greater than or equal to min_nodes.
205 #[serde(rename = "maxNodes")]
206 pub max_nodes: Option<i32>,
207 /// 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.
208 #[serde(rename = "maxProcessingUnits")]
209 pub max_processing_units: Option<i32>,
210 /// Minimum number of nodes allocated to the instance. If set, this number should be greater than or equal to 1.
211 #[serde(rename = "minNodes")]
212 pub min_nodes: Option<i32>,
213 /// Minimum number of processing units allocated to the instance. If set, this number should be multiples of 1000.
214 #[serde(rename = "minProcessingUnits")]
215 pub min_processing_units: Option<i32>,
216}
217
218impl common::Part for AutoscalingLimits {}
219
220/// The autoscaling targets for an instance.
221///
222/// This type is not used in any activity, and only used as *part* of another schema.
223///
224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
225#[serde_with::serde_as]
226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
227pub struct AutoscalingTargets {
228 /// 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.
229 #[serde(rename = "highPriorityCpuUtilizationPercent")]
230 pub high_priority_cpu_utilization_percent: Option<i32>,
231 /// 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.
232 #[serde(rename = "storageUtilizationPercent")]
233 pub storage_utilization_percent: Option<i32>,
234}
235
236impl common::Part for AutoscalingTargets {}
237
238/// A backup of a Cloud Spanner database.
239///
240/// # Activities
241///
242/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
243/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
244///
245/// * [instances backups create projects](ProjectInstanceBackupCreateCall) (request)
246/// * [instances backups get projects](ProjectInstanceBackupGetCall) (response)
247/// * [instances backups patch projects](ProjectInstanceBackupPatchCall) (request|response)
248#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
249#[serde_with::serde_as]
250#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
251pub struct Backup {
252 /// 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`.
253 #[serde(rename = "createTime")]
254 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
255 /// 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/`.
256 pub database: Option<String>,
257 /// Output only. The database dialect information for the backup.
258 #[serde(rename = "databaseDialect")]
259 pub database_dialect: Option<String>,
260 /// Output only. The encryption information for the backup.
261 #[serde(rename = "encryptionInfo")]
262 pub encryption_info: Option<EncryptionInfo>,
263 /// 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.
264 #[serde(rename = "encryptionInformation")]
265 pub encryption_information: Option<Vec<EncryptionInfo>>,
266 /// 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.
267 #[serde(rename = "expireTime")]
268 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
269 /// 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`.
270 #[serde(rename = "maxExpireTime")]
271 pub max_expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
272 /// 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/`.
273 pub name: Option<String>,
274 /// 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.
275 #[serde(rename = "referencingBackups")]
276 pub referencing_backups: Option<Vec<String>>,
277 /// 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.
278 #[serde(rename = "referencingDatabases")]
279 pub referencing_databases: Option<Vec<String>>,
280 /// Output only. Size of the backup in bytes.
281 #[serde(rename = "sizeBytes")]
282 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
283 pub size_bytes: Option<i64>,
284 /// Output only. The current state of the backup.
285 pub state: Option<String>,
286 /// 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.
287 #[serde(rename = "versionTime")]
288 pub version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
289}
290
291impl common::RequestValue for Backup {}
292impl common::ResponseResult for Backup {}
293
294/// Information about a backup.
295///
296/// This type is not used in any activity, and only used as *part* of another schema.
297///
298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
299#[serde_with::serde_as]
300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
301pub struct BackupInfo {
302 /// Name of the backup.
303 pub backup: Option<String>,
304 /// The time the CreateBackup request was received.
305 #[serde(rename = "createTime")]
306 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
307 /// Name of the database the backup was created from.
308 #[serde(rename = "sourceDatabase")]
309 pub source_database: Option<String>,
310 /// 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`.
311 #[serde(rename = "versionTime")]
312 pub version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
313}
314
315impl common::Part for BackupInfo {}
316
317/// The request for BatchCreateSessions.
318///
319/// # Activities
320///
321/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
322/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
323///
324/// * [instances databases sessions batch create projects](ProjectInstanceDatabaseSessionBatchCreateCall) (request)
325#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
326#[serde_with::serde_as]
327#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
328pub struct BatchCreateSessionsRequest {
329 /// Required. The number of sessions to be created in this batch call. The API may 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).
330 #[serde(rename = "sessionCount")]
331 pub session_count: Option<i32>,
332 /// Parameters to be applied to each created session.
333 #[serde(rename = "sessionTemplate")]
334 pub session_template: Option<Session>,
335}
336
337impl common::RequestValue for BatchCreateSessionsRequest {}
338
339/// The response for BatchCreateSessions.
340///
341/// # Activities
342///
343/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
344/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
345///
346/// * [instances databases sessions batch create projects](ProjectInstanceDatabaseSessionBatchCreateCall) (response)
347#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
348#[serde_with::serde_as]
349#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
350pub struct BatchCreateSessionsResponse {
351 /// The freshly created sessions.
352 pub session: Option<Vec<Session>>,
353}
354
355impl common::ResponseResult for BatchCreateSessionsResponse {}
356
357/// The request for BatchWrite.
358///
359/// # Activities
360///
361/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
362/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
363///
364/// * [instances databases sessions batch write projects](ProjectInstanceDatabaseSessionBatchWriteCall) (request)
365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
366#[serde_with::serde_as]
367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
368pub struct BatchWriteRequest {
369 /// Optional. When `exclude_txn_from_change_streams` is set to `true`: * Modifications from all transactions in this batch write operation will not be recorded in change streams with DDL option `allow_txn_exclusion=true` that are tracking columns modified by these transactions. * Modifications from all transactions in this batch write operation will be recorded in change streams with DDL option `allow_txn_exclusion=false or not set` that are tracking columns modified by these transactions. When `exclude_txn_from_change_streams` is set to `false` or not set, Modifications from all transactions in this batch write operation will be recorded in all change streams that are tracking columns modified by these transactions.
370 #[serde(rename = "excludeTxnFromChangeStreams")]
371 pub exclude_txn_from_change_streams: Option<bool>,
372 /// Required. The groups of mutations to be applied.
373 #[serde(rename = "mutationGroups")]
374 pub mutation_groups: Option<Vec<MutationGroup>>,
375 /// Common options for this request.
376 #[serde(rename = "requestOptions")]
377 pub request_options: Option<RequestOptions>,
378}
379
380impl common::RequestValue for BatchWriteRequest {}
381
382/// The result of applying a batch of mutations.
383///
384/// # Activities
385///
386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
388///
389/// * [instances databases sessions batch write projects](ProjectInstanceDatabaseSessionBatchWriteCall) (response)
390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
391#[serde_with::serde_as]
392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
393pub struct BatchWriteResponse {
394 /// The commit timestamp of the transaction that applied this batch. Present if `status` is `OK`, absent otherwise.
395 #[serde(rename = "commitTimestamp")]
396 pub commit_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
397 /// The mutation groups applied in this batch. The values index into the `mutation_groups` field in the corresponding `BatchWriteRequest`.
398 pub indexes: Option<Vec<i32>>,
399 /// An `OK` status indicates success. Any other status indicates a failure.
400 pub status: Option<Status>,
401}
402
403impl common::ResponseResult for BatchWriteResponse {}
404
405/// The request for BeginTransaction.
406///
407/// # Activities
408///
409/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
410/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
411///
412/// * [instances databases sessions begin transaction projects](ProjectInstanceDatabaseSessionBeginTransactionCall) (request)
413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
414#[serde_with::serde_as]
415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
416pub struct BeginTransactionRequest {
417 /// Required. Options for the new transaction.
418 pub options: Option<TransactionOptions>,
419 /// Common options for this request. Priority is ignored for this request. Setting the priority in this request_options struct will not do anything. To set the priority for a transaction, set it on the reads and writes that are part of this transaction instead.
420 #[serde(rename = "requestOptions")]
421 pub request_options: Option<RequestOptions>,
422}
423
424impl common::RequestValue for BeginTransactionRequest {}
425
426/// Associates `members`, or principals, with a `role`.
427///
428/// This type is not used in any activity, and only used as *part* of another schema.
429///
430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
431#[serde_with::serde_as]
432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
433pub struct Binding {
434 /// 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).
435 pub condition: Option<Expr>,
436 /// 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`.
437 pub members: Option<Vec<String>>,
438 /// 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).
439 pub role: Option<String>,
440}
441
442impl common::Part for Binding {}
443
444/// The request for ChangeQuorum.
445///
446/// # Activities
447///
448/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
449/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
450///
451/// * [instances databases changequorum projects](ProjectInstanceDatabaseChangequorumCall) (request)
452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
453#[serde_with::serde_as]
454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
455pub struct ChangeQuorumRequest {
456 /// Optional. The etag is the hash of the QuorumInfo. The ChangeQuorum operation will only be performed if the etag matches that of the QuorumInfo in the current database resource. Otherwise the API will return 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.
457 pub etag: Option<String>,
458 /// Required. Name of the database in which to apply the ChangeQuorum. Values are of the form `projects//instances//databases/`.
459 pub name: Option<String>,
460 /// Required. The type of this Quorum.
461 #[serde(rename = "quorumType")]
462 pub quorum_type: Option<QuorumType>,
463}
464
465impl common::RequestValue for ChangeQuorumRequest {}
466
467/// Metadata associated with a parent-child relationship appearing in a PlanNode.
468///
469/// This type is not used in any activity, and only used as *part* of another schema.
470///
471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
472#[serde_with::serde_as]
473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
474pub struct ChildLink {
475 /// The node to which the link points.
476 #[serde(rename = "childIndex")]
477 pub child_index: Option<i32>,
478 /// 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.
479 #[serde(rename = "type")]
480 pub type_: Option<String>,
481 /// 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.
482 pub variable: Option<String>,
483}
484
485impl common::Part for ChildLink {}
486
487/// The request for Commit.
488///
489/// # Activities
490///
491/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
492/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
493///
494/// * [instances databases sessions commit projects](ProjectInstanceDatabaseSessionCommitCall) (request)
495#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
496#[serde_with::serde_as]
497#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
498pub struct CommitRequest {
499 /// Optional. The amount of latency this request is configured to incur in order to improve throughput. If this field is not 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.
500 #[serde(rename = "maxCommitDelay")]
501 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
502 pub max_commit_delay: Option<chrono::Duration>,
503 /// The mutations to be executed when this transaction commits. All mutations are applied atomically, in the order they appear in this list.
504 pub mutations: Option<Vec<Mutation>>,
505 /// Common options for this request.
506 #[serde(rename = "requestOptions")]
507 pub request_options: Option<RequestOptions>,
508 /// If `true`, then statistics related to the transaction will be included in the CommitResponse. Default value is `false`.
509 #[serde(rename = "returnCommitStats")]
510 pub return_commit_stats: Option<bool>,
511 /// 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 is possible that the mutations are executed more than once. If this is undesirable, use BeginTransaction and Commit instead.
512 #[serde(rename = "singleUseTransaction")]
513 pub single_use_transaction: Option<TransactionOptions>,
514 /// Commit a previously-started transaction.
515 #[serde(rename = "transactionId")]
516 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
517 pub transaction_id: Option<Vec<u8>>,
518}
519
520impl common::RequestValue for CommitRequest {}
521
522/// The response for Commit.
523///
524/// # Activities
525///
526/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
527/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
528///
529/// * [instances databases sessions commit projects](ProjectInstanceDatabaseSessionCommitCall) (response)
530#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
531#[serde_with::serde_as]
532#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
533pub struct CommitResponse {
534 /// The statistics about this Commit. Not returned by default. For more information, see CommitRequest.return_commit_stats.
535 #[serde(rename = "commitStats")]
536 pub commit_stats: Option<CommitStats>,
537 /// The Cloud Spanner timestamp at which the transaction committed.
538 #[serde(rename = "commitTimestamp")]
539 pub commit_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
540}
541
542impl common::ResponseResult for CommitResponse {}
543
544/// Additional statistics about a commit.
545///
546/// This type is not used in any activity, and only used as *part* of another schema.
547///
548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
549#[serde_with::serde_as]
550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
551pub struct CommitStats {
552 /// 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).
553 #[serde(rename = "mutationCount")]
554 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
555 pub mutation_count: Option<i64>,
556}
557
558impl common::Part for CommitStats {}
559
560/// A message representing context for a KeyRangeInfo, including a label, value, unit, and severity.
561///
562/// This type is not used in any activity, and only used as *part* of another schema.
563///
564#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
565#[serde_with::serde_as]
566#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
567pub struct ContextValue {
568 /// The label for the context value. e.g. "latency".
569 pub label: Option<LocalizedString>,
570 /// The severity of this context.
571 pub severity: Option<String>,
572 /// The unit of the context value.
573 pub unit: Option<String>,
574 /// The value for the context.
575 pub value: Option<f32>,
576}
577
578impl common::Part for ContextValue {}
579
580/// Encryption configuration for the copied backup.
581///
582/// This type is not used in any activity, and only used as *part* of another schema.
583///
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct CopyBackupEncryptionConfig {
588 /// Required. The encryption type of the backup.
589 #[serde(rename = "encryptionType")]
590 pub encryption_type: Option<String>,
591 /// Optional. The Cloud KMS key that will be used to protect the backup. This field should be set only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
592 #[serde(rename = "kmsKeyName")]
593 pub kms_key_name: Option<String>,
594 /// 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 single region instance configs, specify a single regional location KMS key. * For multi-regional instance configs of type GOOGLE_MANAGED, either specify a multi-regional location KMS key or multiple regional location KMS keys that cover all regions in the instance config. * For an instance config of type USER_MANAGED, please specify only regional location KMS keys to cover each region in the instance config. Multi-regional location KMS keys are not supported for USER_MANAGED instance configs.
595 #[serde(rename = "kmsKeyNames")]
596 pub kms_key_names: Option<Vec<String>>,
597}
598
599impl common::Part for CopyBackupEncryptionConfig {}
600
601/// The request for CopyBackup.
602///
603/// # Activities
604///
605/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
606/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
607///
608/// * [instances backups copy projects](ProjectInstanceBackupCopyCall) (request)
609#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
610#[serde_with::serde_as]
611#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
612pub struct CopyBackupRequest {
613 /// Required. The id of the backup copy. The `backup_id` appended to `parent` forms the full backup_uri of the form `projects//instances//backups/`.
614 #[serde(rename = "backupId")]
615 pub backup_id: Option<String>,
616 /// 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`.
617 #[serde(rename = "encryptionConfig")]
618 pub encryption_config: Option<CopyBackupEncryptionConfig>,
619 /// 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.
620 #[serde(rename = "expireTime")]
621 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
622 /// 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/`.
623 #[serde(rename = "sourceBackup")]
624 pub source_backup: Option<String>,
625}
626
627impl common::RequestValue for CopyBackupRequest {}
628
629/// The request for CreateDatabase.
630///
631/// # Activities
632///
633/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
634/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
635///
636/// * [instances databases create projects](ProjectInstanceDatabaseCreateCall) (request)
637#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
638#[serde_with::serde_as]
639#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
640pub struct CreateDatabaseRequest {
641 /// 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 (`` ` ``).
642 #[serde(rename = "createStatement")]
643 pub create_statement: Option<String>,
644 /// Optional. The dialect of the Cloud Spanner Database.
645 #[serde(rename = "databaseDialect")]
646 pub database_dialect: Option<String>,
647 /// 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.
648 #[serde(rename = "encryptionConfig")]
649 pub encryption_config: Option<EncryptionConfig>,
650 /// 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.
651 #[serde(rename = "extraStatements")]
652 pub extra_statements: Option<Vec<String>>,
653 /// Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in 'extra_statements' above. 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).
654 #[serde(rename = "protoDescriptors")]
655 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
656 pub proto_descriptors: Option<Vec<u8>>,
657}
658
659impl common::RequestValue for CreateDatabaseRequest {}
660
661/// The request for CreateInstanceConfigRequest.
662///
663/// # Activities
664///
665/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
666/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
667///
668/// * [instance configs create projects](ProjectInstanceConfigCreateCall) (request)
669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
670#[serde_with::serde_as]
671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
672pub struct CreateInstanceConfigRequest {
673 /// 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.
674 #[serde(rename = "instanceConfig")]
675 pub instance_config: Option<InstanceConfig>,
676 /// Required. The ID of the instance config 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.
677 #[serde(rename = "instanceConfigId")]
678 pub instance_config_id: Option<String>,
679 /// An option to validate, but not actually execute, a request, and provide the same response.
680 #[serde(rename = "validateOnly")]
681 pub validate_only: Option<bool>,
682}
683
684impl common::RequestValue for CreateInstanceConfigRequest {}
685
686/// The request for CreateInstancePartition.
687///
688/// # Activities
689///
690/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
691/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
692///
693/// * [instances instance partitions create projects](ProjectInstanceInstancePartitionCreateCall) (request)
694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
695#[serde_with::serde_as]
696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
697pub struct CreateInstancePartitionRequest {
698 /// Required. The instance partition to create. The instance_partition.name may be omitted, but if specified must be `/instancePartitions/`.
699 #[serde(rename = "instancePartition")]
700 pub instance_partition: Option<InstancePartition>,
701 /// 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.
702 #[serde(rename = "instancePartitionId")]
703 pub instance_partition_id: Option<String>,
704}
705
706impl common::RequestValue for CreateInstancePartitionRequest {}
707
708/// The request for CreateInstance.
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 create projects](ProjectInstanceCreateCall) (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 CreateInstanceRequest {
720 /// Required. The instance to create. The name may be omitted, but if specified must be `/instances/`.
721 pub instance: Option<Instance>,
722 /// 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.
723 #[serde(rename = "instanceId")]
724 pub instance_id: Option<String>,
725}
726
727impl common::RequestValue for CreateInstanceRequest {}
728
729/// The request for CreateSession.
730///
731/// # Activities
732///
733/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
734/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
735///
736/// * [instances databases sessions create projects](ProjectInstanceDatabaseSessionCreateCall) (request)
737#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
738#[serde_with::serde_as]
739#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
740pub struct CreateSessionRequest {
741 /// Required. The session to create.
742 pub session: Option<Session>,
743}
744
745impl common::RequestValue for CreateSessionRequest {}
746
747/// A Cloud Spanner database.
748///
749/// # Activities
750///
751/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
752/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
753///
754/// * [instances databases get projects](ProjectInstanceDatabaseGetCall) (response)
755/// * [instances databases patch projects](ProjectInstanceDatabasePatchCall) (request)
756#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
757#[serde_with::serde_as]
758#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
759pub struct Database {
760 /// Output only. If exists, the time at which the database creation started.
761 #[serde(rename = "createTime")]
762 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
763 /// Output only. The dialect of the Cloud Spanner Database.
764 #[serde(rename = "databaseDialect")]
765 pub database_dialect: Option<String>,
766 /// 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.
767 #[serde(rename = "defaultLeader")]
768 pub default_leader: Option<String>,
769 /// 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.
770 #[serde(rename = "earliestVersionTime")]
771 pub earliest_version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
772 /// 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).
773 #[serde(rename = "enableDropProtection")]
774 pub enable_drop_protection: Option<bool>,
775 /// 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.
776 #[serde(rename = "encryptionConfig")]
777 pub encryption_config: Option<EncryptionConfig>,
778 /// 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.
779 #[serde(rename = "encryptionInfo")]
780 pub encryption_info: Option<Vec<EncryptionInfo>>,
781 /// 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.
782 pub name: Option<String>,
783 /// Output only. Applicable only for databases that use dual region instance configurations. Contains information about the quorum.
784 #[serde(rename = "quorumInfo")]
785 pub quorum_info: Option<QuorumInfo>,
786 /// Output only. If true, the database is being updated. If false, there are no ongoing update operations for the database.
787 pub reconciling: Option<bool>,
788 /// Output only. Applicable only for restored databases. Contains information about the restore source.
789 #[serde(rename = "restoreInfo")]
790 pub restore_info: Option<RestoreInfo>,
791 /// Output only. The current database state.
792 pub state: Option<String>,
793 /// 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.
794 #[serde(rename = "versionRetentionPeriod")]
795 pub version_retention_period: Option<String>,
796}
797
798impl common::RequestValue for Database {}
799impl common::ResponseResult for Database {}
800
801/// A Cloud Spanner database role.
802///
803/// This type is not used in any activity, and only used as *part* of another schema.
804///
805#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
806#[serde_with::serde_as]
807#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
808pub struct DatabaseRole {
809 /// 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.
810 pub name: Option<String>,
811}
812
813impl common::Part for DatabaseRole {}
814
815/// Arguments to delete operations.
816///
817/// This type is not used in any activity, and only used as *part* of another schema.
818///
819#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
820#[serde_with::serde_as]
821#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
822pub struct Delete {
823 /// 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.
824 #[serde(rename = "keySet")]
825 pub key_set: Option<KeySet>,
826 /// Required. The table whose rows will be deleted.
827 pub table: Option<String>,
828}
829
830impl common::Part for Delete {}
831
832/// A message representing a derived metric.
833///
834/// This type is not used in any activity, and only used as *part* of another schema.
835///
836#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
837#[serde_with::serde_as]
838#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
839pub struct DerivedMetric {
840 /// The name of the denominator metric. e.g. "rows".
841 pub denominator: Option<LocalizedString>,
842 /// The name of the numerator metric. e.g. "latency".
843 pub numerator: Option<LocalizedString>,
844}
845
846impl common::Part for DerivedMetric {}
847
848/// A message representing the key visualizer diagnostic messages.
849///
850/// This type is not used in any activity, and only used as *part* of another schema.
851///
852#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
853#[serde_with::serde_as]
854#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
855pub struct DiagnosticMessage {
856 /// Information about this diagnostic information.
857 pub info: Option<LocalizedString>,
858 /// The metric.
859 pub metric: Option<LocalizedString>,
860 /// 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.
861 #[serde(rename = "metricSpecific")]
862 pub metric_specific: Option<bool>,
863 /// The severity of the diagnostic message.
864 pub severity: Option<String>,
865 /// The short message.
866 #[serde(rename = "shortMessage")]
867 pub short_message: Option<LocalizedString>,
868}
869
870impl common::Part for DiagnosticMessage {}
871
872/// The DirectedReadOptions can be used to indicate which replicas or regions should be used for non-transactional reads or queries. DirectedReadOptions may only be specified for a read-only transaction, otherwise the API will return an `INVALID_ARGUMENT` error.
873///
874/// This type is not used in any activity, and only used as *part* of another schema.
875///
876#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
877#[serde_with::serde_as]
878#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
879pub struct DirectedReadOptions {
880 /// Exclude_replicas indicates that specified replicas should be excluded from serving requests. Spanner will not route requests to the replicas in this list.
881 #[serde(rename = "excludeReplicas")]
882 pub exclude_replicas: Option<ExcludeReplicas>,
883 /// 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 will wait for a replica in the list to become available, requests may fail due to `DEADLINE_EXCEEDED` errors.
884 #[serde(rename = "includeReplicas")]
885 pub include_replicas: Option<IncludeReplicas>,
886}
887
888impl common::Part for DirectedReadOptions {}
889
890/// Message type for a dual-region quorum. Currently this type has no options.
891///
892/// This type is not used in any activity, and only used as *part* of another schema.
893///
894#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
895#[serde_with::serde_as]
896#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
897pub struct DualRegionQuorum {
898 _never_set: Option<bool>,
899}
900
901impl common::Part for DualRegionQuorum {}
902
903/// 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); }
904///
905/// # Activities
906///
907/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
908/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
909///
910/// * [instance configs operations cancel projects](ProjectInstanceConfigOperationCancelCall) (response)
911/// * [instance configs operations delete projects](ProjectInstanceConfigOperationDeleteCall) (response)
912/// * [instance configs ssd caches operations cancel projects](ProjectInstanceConfigSsdCachOperationCancelCall) (response)
913/// * [instance configs ssd caches operations delete projects](ProjectInstanceConfigSsdCachOperationDeleteCall) (response)
914/// * [instance configs delete projects](ProjectInstanceConfigDeleteCall) (response)
915/// * [instances backups operations cancel projects](ProjectInstanceBackupOperationCancelCall) (response)
916/// * [instances backups operations delete projects](ProjectInstanceBackupOperationDeleteCall) (response)
917/// * [instances backups delete projects](ProjectInstanceBackupDeleteCall) (response)
918/// * [instances databases operations cancel projects](ProjectInstanceDatabaseOperationCancelCall) (response)
919/// * [instances databases operations delete projects](ProjectInstanceDatabaseOperationDeleteCall) (response)
920/// * [instances databases sessions delete projects](ProjectInstanceDatabaseSessionDeleteCall) (response)
921/// * [instances databases sessions rollback projects](ProjectInstanceDatabaseSessionRollbackCall) (response)
922/// * [instances databases drop database projects](ProjectInstanceDatabaseDropDatabaseCall) (response)
923/// * [instances instance partitions operations cancel projects](ProjectInstanceInstancePartitionOperationCancelCall) (response)
924/// * [instances instance partitions operations delete projects](ProjectInstanceInstancePartitionOperationDeleteCall) (response)
925/// * [instances instance partitions delete projects](ProjectInstanceInstancePartitionDeleteCall) (response)
926/// * [instances operations cancel projects](ProjectInstanceOperationCancelCall) (response)
927/// * [instances operations delete projects](ProjectInstanceOperationDeleteCall) (response)
928/// * [instances delete projects](ProjectInstanceDeleteCall) (response)
929#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
930#[serde_with::serde_as]
931#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
932pub struct Empty {
933 _never_set: Option<bool>,
934}
935
936impl common::ResponseResult for Empty {}
937
938/// Encryption configuration for a Cloud Spanner database.
939///
940/// This type is not used in any activity, and only used as *part* of another schema.
941///
942#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
943#[serde_with::serde_as]
944#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
945pub struct EncryptionConfig {
946 /// The Cloud KMS key to be used for encrypting and decrypting the database. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
947 #[serde(rename = "kmsKeyName")]
948 pub kms_key_name: Option<String>,
949 /// Specifies the KMS configuration for the 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 instance configuration. Some examples: * For single region database instance configs, specify a single regional location KMS key. * For multi-regional database instance configs of type GOOGLE_MANAGED, either specify a multi-regional location KMS key or multiple regional location KMS keys that cover all regions in the instance config. * For a database instance config of type USER_MANAGED, please specify only regional location KMS keys to cover each region in the instance config. Multi-regional location KMS keys are not supported for USER_MANAGED instance configs.
950 #[serde(rename = "kmsKeyNames")]
951 pub kms_key_names: Option<Vec<String>>,
952}
953
954impl common::Part for EncryptionConfig {}
955
956/// Encryption information for a Cloud Spanner database or backup.
957///
958/// This type is not used in any activity, and only used as *part* of another schema.
959///
960#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
961#[serde_with::serde_as]
962#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
963pub struct EncryptionInfo {
964 /// 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.
965 #[serde(rename = "encryptionStatus")]
966 pub encryption_status: Option<Status>,
967 /// Output only. The type of encryption.
968 #[serde(rename = "encryptionType")]
969 pub encryption_type: Option<String>,
970 /// Output only. A Cloud KMS key version that is being used to protect the database or backup.
971 #[serde(rename = "kmsKeyVersion")]
972 pub kms_key_version: Option<String>,
973}
974
975impl common::Part for EncryptionInfo {}
976
977/// An ExcludeReplicas contains a repeated set of ReplicaSelection that should be excluded from serving requests.
978///
979/// This type is not used in any activity, and only used as *part* of another schema.
980///
981#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
982#[serde_with::serde_as]
983#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
984pub struct ExcludeReplicas {
985 /// The directed read replica selector.
986 #[serde(rename = "replicaSelections")]
987 pub replica_selections: Option<Vec<ReplicaSelection>>,
988}
989
990impl common::Part for ExcludeReplicas {}
991
992/// The request for ExecuteBatchDml.
993///
994/// # Activities
995///
996/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
997/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
998///
999/// * [instances databases sessions execute batch dml projects](ProjectInstanceDatabaseSessionExecuteBatchDmlCall) (request)
1000#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1001#[serde_with::serde_as]
1002#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1003pub struct ExecuteBatchDmlRequest {
1004 /// Common options for this request.
1005 #[serde(rename = "requestOptions")]
1006 pub request_options: Option<RequestOptions>,
1007 /// 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 will succeed. 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 may be aborted. Replays of previously handled requests will yield the same response as the first execution.
1008 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1009 pub seqno: Option<i64>,
1010 /// 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.
1011 pub statements: Option<Vec<Statement>>,
1012 /// 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.
1013 pub transaction: Option<TransactionSelector>,
1014}
1015
1016impl common::RequestValue for ExecuteBatchDmlRequest {}
1017
1018/// 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.
1019///
1020/// # Activities
1021///
1022/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1023/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1024///
1025/// * [instances databases sessions execute batch dml projects](ProjectInstanceDatabaseSessionExecuteBatchDmlCall) (response)
1026#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1027#[serde_with::serde_as]
1028#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1029pub struct ExecuteBatchDmlResponse {
1030 /// 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.
1031 #[serde(rename = "resultSets")]
1032 pub result_sets: Option<Vec<ResultSet>>,
1033 /// If all DML statements are executed successfully, the status is `OK`. Otherwise, the error status of the first failed statement.
1034 pub status: Option<Status>,
1035}
1036
1037impl common::ResponseResult for ExecuteBatchDmlResponse {}
1038
1039/// The request for ExecuteSql and ExecuteStreamingSql.
1040///
1041/// # Activities
1042///
1043/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1044/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1045///
1046/// * [instances databases sessions execute sql projects](ProjectInstanceDatabaseSessionExecuteSqlCall) (request)
1047/// * [instances databases sessions execute streaming sql projects](ProjectInstanceDatabaseSessionExecuteStreamingSqlCall) (request)
1048#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1049#[serde_with::serde_as]
1050#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1051pub struct ExecuteSqlRequest {
1052 /// 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 does not set `partition_token`, the API returns an `INVALID_ARGUMENT` error.
1053 #[serde(rename = "dataBoostEnabled")]
1054 pub data_boost_enabled: Option<bool>,
1055 /// Directed read options for this request.
1056 #[serde(rename = "directedReadOptions")]
1057 pub directed_read_options: Option<DirectedReadOptions>,
1058 /// It is not 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.
1059 #[serde(rename = "paramTypes")]
1060 pub param_types: Option<HashMap<String, Type>>,
1061 /// 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 is an error to execute a SQL statement with unbound parameters.
1062 pub params: Option<HashMap<String, serde_json::Value>>,
1063 /// If present, results will be 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.
1064 #[serde(rename = "partitionToken")]
1065 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1066 pub partition_token: Option<Vec<u8>>,
1067 /// 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.
1068 #[serde(rename = "queryMode")]
1069 pub query_mode: Option<String>,
1070 /// Query optimizer configuration to use for the given query.
1071 #[serde(rename = "queryOptions")]
1072 pub query_options: Option<QueryOptions>,
1073 /// Common options for this request.
1074 #[serde(rename = "requestOptions")]
1075 pub request_options: Option<RequestOptions>,
1076 /// 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.
1077 #[serde(rename = "resumeToken")]
1078 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1079 pub resume_token: Option<Vec<u8>>,
1080 /// 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 will succeed. 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 may be aborted. Replays of previously handled requests will yield the same response as the first execution. Required for DML statements. Ignored for queries.
1081 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1082 pub seqno: Option<i64>,
1083 /// Required. The SQL string.
1084 pub sql: Option<String>,
1085 /// 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.
1086 pub transaction: Option<TransactionSelector>,
1087}
1088
1089impl common::RequestValue for ExecuteSqlRequest {}
1090
1091/// 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.
1092///
1093/// This type is not used in any activity, and only used as *part* of another schema.
1094///
1095#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1096#[serde_with::serde_as]
1097#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1098pub struct Expr {
1099 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
1100 pub description: Option<String>,
1101 /// Textual representation of an expression in Common Expression Language syntax.
1102 pub expression: Option<String>,
1103 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
1104 pub location: Option<String>,
1105 /// 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.
1106 pub title: Option<String>,
1107}
1108
1109impl common::Part for Expr {}
1110
1111/// Message representing a single field of a struct.
1112///
1113/// This type is not used in any activity, and only used as *part* of another schema.
1114///
1115#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1116#[serde_with::serde_as]
1117#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1118pub struct Field {
1119 /// 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.
1120 pub name: Option<String>,
1121 /// The type of the field.
1122 #[serde(rename = "type")]
1123 pub type_: Option<Type>,
1124}
1125
1126impl common::Part for Field {}
1127
1128/// Free instance specific metadata that is kept even after an instance has been upgraded for tracking purposes.
1129///
1130/// This type is not used in any activity, and only used as *part* of another schema.
1131///
1132#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1133#[serde_with::serde_as]
1134#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1135pub struct FreeInstanceMetadata {
1136 /// 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.
1137 #[serde(rename = "expireBehavior")]
1138 pub expire_behavior: Option<String>,
1139 /// 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.
1140 #[serde(rename = "expireTime")]
1141 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1142 /// Output only. If present, the timestamp at which the free instance was upgraded to a provisioned instance.
1143 #[serde(rename = "upgradeTime")]
1144 pub upgrade_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1145}
1146
1147impl common::Part for FreeInstanceMetadata {}
1148
1149/// The response for GetDatabaseDdl.
1150///
1151/// # Activities
1152///
1153/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1154/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1155///
1156/// * [instances databases get ddl projects](ProjectInstanceDatabaseGetDdlCall) (response)
1157#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1158#[serde_with::serde_as]
1159#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1160pub struct GetDatabaseDdlResponse {
1161 /// 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).
1162 #[serde(rename = "protoDescriptors")]
1163 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1164 pub proto_descriptors: Option<Vec<u8>>,
1165 /// A list of formatted DDL statements defining the schema of the database specified in the request.
1166 pub statements: Option<Vec<String>>,
1167}
1168
1169impl common::ResponseResult for GetDatabaseDdlResponse {}
1170
1171/// Request message for `GetIamPolicy` method.
1172///
1173/// # Activities
1174///
1175/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1176/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1177///
1178/// * [instances backups get iam policy projects](ProjectInstanceBackupGetIamPolicyCall) (request)
1179/// * [instances databases get iam policy projects](ProjectInstanceDatabaseGetIamPolicyCall) (request)
1180/// * [instances get iam policy projects](ProjectInstanceGetIamPolicyCall) (request)
1181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1182#[serde_with::serde_as]
1183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1184pub struct GetIamPolicyRequest {
1185 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
1186 pub options: Option<GetPolicyOptions>,
1187}
1188
1189impl common::RequestValue for GetIamPolicyRequest {}
1190
1191/// Encapsulates settings provided to GetIamPolicy.
1192///
1193/// This type is not used in any activity, and only used as *part* of another schema.
1194///
1195#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1196#[serde_with::serde_as]
1197#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1198pub struct GetPolicyOptions {
1199 /// 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).
1200 #[serde(rename = "requestedPolicyVersion")]
1201 pub requested_policy_version: Option<i32>,
1202}
1203
1204impl common::Part for GetPolicyOptions {}
1205
1206/// An IncludeReplicas contains a repeated set of ReplicaSelection which indicates the order in which replicas should be considered.
1207///
1208/// This type is not used in any activity, and only used as *part* of another schema.
1209///
1210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1211#[serde_with::serde_as]
1212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1213pub struct IncludeReplicas {
1214 /// If true, Spanner will not route requests to a replica outside the include_replicas list when all of the specified replicas are unavailable or unhealthy. Default value is `false`.
1215 #[serde(rename = "autoFailoverDisabled")]
1216 pub auto_failover_disabled: Option<bool>,
1217 /// The directed read replica selector.
1218 #[serde(rename = "replicaSelections")]
1219 pub replica_selections: Option<Vec<ReplicaSelection>>,
1220}
1221
1222impl common::Part for IncludeReplicas {}
1223
1224/// Recommendation to add new indexes to run queries more efficiently.
1225///
1226/// This type is not used in any activity, and only used as *part* of another schema.
1227///
1228#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1229#[serde_with::serde_as]
1230#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1231pub struct IndexAdvice {
1232 /// Optional. DDL statements to add new indexes that will improve the query.
1233 pub ddl: Option<Vec<String>>,
1234 /// 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.
1235 #[serde(rename = "improvementFactor")]
1236 pub improvement_factor: Option<f64>,
1237}
1238
1239impl common::Part for IndexAdvice {}
1240
1241/// A message representing a (sparse) collection of hot keys for specific key buckets.
1242///
1243/// This type is not used in any activity, and only used as *part* of another schema.
1244///
1245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1246#[serde_with::serde_as]
1247#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1248pub struct IndexedHotKey {
1249 /// 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.
1250 #[serde(rename = "sparseHotKeys")]
1251 pub sparse_hot_keys: Option<HashMap<String, i32>>,
1252}
1253
1254impl common::Part for IndexedHotKey {}
1255
1256/// A message representing a (sparse) collection of KeyRangeInfos for specific key buckets.
1257///
1258/// This type is not used in any activity, and only used as *part* of another schema.
1259///
1260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1261#[serde_with::serde_as]
1262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1263pub struct IndexedKeyRangeInfos {
1264 /// A (sparse) mapping from key bucket index to the KeyRangeInfos for that key bucket.
1265 #[serde(rename = "keyRangeInfos")]
1266 pub key_range_infos: Option<HashMap<String, KeyRangeInfos>>,
1267}
1268
1269impl common::Part for IndexedKeyRangeInfos {}
1270
1271/// An isolated set of Cloud Spanner resources on which databases can be hosted.
1272///
1273/// # Activities
1274///
1275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1277///
1278/// * [instances get projects](ProjectInstanceGetCall) (response)
1279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1280#[serde_with::serde_as]
1281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1282pub struct Instance {
1283 /// 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.
1284 #[serde(rename = "autoscalingConfig")]
1285 pub autoscaling_config: Option<AutoscalingConfig>,
1286 /// Required. The name of the instance's configuration. Values are of the form `projects//instanceConfigs/`. See also InstanceConfig and ListInstanceConfigs.
1287 pub config: Option<String>,
1288 /// Output only. The time at which the instance was created.
1289 #[serde(rename = "createTime")]
1290 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1291 /// 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.
1292 #[serde(rename = "displayName")]
1293 pub display_name: Option<String>,
1294 /// Deprecated. This field is not populated.
1295 #[serde(rename = "endpointUris")]
1296 pub endpoint_uris: Option<Vec<String>>,
1297 /// Free instance metadata. Only populated for free instances.
1298 #[serde(rename = "freeInstanceMetadata")]
1299 pub free_instance_metadata: Option<FreeInstanceMetadata>,
1300 /// The `InstanceType` of the current instance.
1301 #[serde(rename = "instanceType")]
1302 pub instance_type: Option<String>,
1303 /// 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.
1304 pub labels: Option<HashMap<String, String>>,
1305 /// 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.
1306 pub name: Option<String>,
1307 /// 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 may be zero in API responses for instances that are not yet in state `READY`. See [the documentation](https://cloud.google.com/spanner/docs/compute-capacity) for more information about nodes and processing units.
1308 #[serde(rename = "nodeCount")]
1309 pub node_count: Option<i32>,
1310 /// The number of processing units allocated to this instance. At most one of 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 may be zero in API responses for instances that are not yet in state `READY`. See [the documentation](https://cloud.google.com/spanner/docs/compute-capacity) for more information about nodes and processing units.
1311 #[serde(rename = "processingUnits")]
1312 pub processing_units: Option<i32>,
1313 /// 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`.
1314 pub state: Option<String>,
1315 /// Output only. The time at which the instance was most recently updated.
1316 #[serde(rename = "updateTime")]
1317 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1318}
1319
1320impl common::ResponseResult for Instance {}
1321
1322/// A possible configuration for a Cloud Spanner instance. Configurations define the geographic placement of nodes and their replication.
1323///
1324/// # Activities
1325///
1326/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1327/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1328///
1329/// * [instance configs get projects](ProjectInstanceConfigGetCall) (response)
1330#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1331#[serde_with::serde_as]
1332#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1333pub struct InstanceConfig {
1334 /// 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.
1335 #[serde(rename = "baseConfig")]
1336 pub base_config: Option<String>,
1337 /// Output only. Whether this instance config is a Google or User Managed Configuration.
1338 #[serde(rename = "configType")]
1339 pub config_type: Option<String>,
1340 /// The name of this instance configuration as it appears in UIs.
1341 #[serde(rename = "displayName")]
1342 pub display_name: Option<String>,
1343 /// etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a instance config from overwriting each other. It is strongly suggested that systems make use of the etag in the read-modify-write cycle to perform instance config updates in order to avoid race conditions: An etag is returned in the response which contains instance configs, and systems are expected to put that etag in the request to update instance config to ensure that their change will be applied to the same version of the instance config. If no etag is provided in the call to update instance config, then the existing instance config is overwritten blindly.
1344 pub etag: Option<String>,
1345 /// Output only. Describes whether free instances are available to be created in this instance config.
1346 #[serde(rename = "freeInstanceAvailability")]
1347 pub free_instance_availability: Option<String>,
1348 /// 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.
1349 pub labels: Option<HashMap<String, String>>,
1350 /// Allowed values of the "default_leader" schema option for databases in instances that use this instance configuration.
1351 #[serde(rename = "leaderOptions")]
1352 pub leader_options: Option<Vec<String>>,
1353 /// A unique identifier for the instance configuration. Values are of the form `projects//instanceConfigs/a-z*`. User instance config must start with `custom-`.
1354 pub name: Option<String>,
1355 /// Output only. The available optional replicas to choose from for user managed configurations. Populated for Google managed configurations.
1356 #[serde(rename = "optionalReplicas")]
1357 pub optional_replicas: Option<Vec<ReplicaInfo>>,
1358 /// Output only. The `QuorumType` of the instance configuration.
1359 #[serde(rename = "quorumType")]
1360 pub quorum_type: Option<String>,
1361 /// Output only. If true, the instance config is being created or updated. If false, there are no ongoing operations for the instance config.
1362 pub reconciling: Option<bool>,
1363 /// 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`.
1364 pub replicas: Option<Vec<ReplicaInfo>>,
1365 /// Output only. The current instance config state. Applicable only for USER_MANAGED configs.
1366 pub state: Option<String>,
1367 /// Output only. The storage limit in bytes per processing unit.
1368 #[serde(rename = "storageLimitPerProcessingUnit")]
1369 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1370 pub storage_limit_per_processing_unit: Option<i64>,
1371}
1372
1373impl common::ResponseResult for InstanceConfig {}
1374
1375/// An isolated set of Cloud Spanner resources that databases can define placements on.
1376///
1377/// # Activities
1378///
1379/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1380/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1381///
1382/// * [instances instance partitions get projects](ProjectInstanceInstancePartitionGetCall) (response)
1383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1384#[serde_with::serde_as]
1385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1386pub struct InstancePartition {
1387 /// Required. The name of the instance partition's configuration. Values are of the form `projects//instanceConfigs/`. See also InstanceConfig and ListInstanceConfigs.
1388 pub config: Option<String>,
1389 /// Output only. The time at which the instance partition was created.
1390 #[serde(rename = "createTime")]
1391 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1392 /// 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.
1393 #[serde(rename = "displayName")]
1394 pub display_name: Option<String>,
1395 /// 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.
1396 pub etag: Option<String>,
1397 /// 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.
1398 pub name: Option<String>,
1399 /// 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`.
1400 #[serde(rename = "nodeCount")]
1401 pub node_count: Option<i32>,
1402 /// 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 may be zero in API responses for instance partitions that are not yet in state `READY`.
1403 #[serde(rename = "processingUnits")]
1404 pub processing_units: Option<i32>,
1405 /// 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.
1406 #[serde(rename = "referencingBackups")]
1407 pub referencing_backups: Option<Vec<String>>,
1408 /// 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.
1409 #[serde(rename = "referencingDatabases")]
1410 pub referencing_databases: Option<Vec<String>>,
1411 /// Output only. The current instance partition state.
1412 pub state: Option<String>,
1413 /// Output only. The time at which the instance partition was most recently updated.
1414 #[serde(rename = "updateTime")]
1415 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1416}
1417
1418impl common::ResponseResult for InstancePartition {}
1419
1420/// 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.
1421///
1422/// This type is not used in any activity, and only used as *part* of another schema.
1423///
1424#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1425#[serde_with::serde_as]
1426#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1427pub struct KeyRange {
1428 /// If the end is closed, then the range includes all rows whose first `len(end_closed)` key columns exactly match `end_closed`.
1429 #[serde(rename = "endClosed")]
1430 pub end_closed: Option<Vec<serde_json::Value>>,
1431 /// If the end is open, then the range excludes rows whose first `len(end_open)` key columns exactly match `end_open`.
1432 #[serde(rename = "endOpen")]
1433 pub end_open: Option<Vec<serde_json::Value>>,
1434 /// If the start is closed, then the range includes all rows whose first `len(start_closed)` key columns exactly match `start_closed`.
1435 #[serde(rename = "startClosed")]
1436 pub start_closed: Option<Vec<serde_json::Value>>,
1437 /// If the start is open, then the range excludes rows whose first `len(start_open)` key columns exactly match `start_open`.
1438 #[serde(rename = "startOpen")]
1439 pub start_open: Option<Vec<serde_json::Value>>,
1440}
1441
1442impl common::Part for KeyRange {}
1443
1444/// A message representing information for a key range (possibly one key).
1445///
1446/// This type is not used in any activity, and only used as *part* of another schema.
1447///
1448#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1449#[serde_with::serde_as]
1450#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1451pub struct KeyRangeInfo {
1452 /// The list of context values for this key range.
1453 #[serde(rename = "contextValues")]
1454 pub context_values: Option<Vec<ContextValue>>,
1455 /// The index of the end key in indexed_keys.
1456 #[serde(rename = "endKeyIndex")]
1457 pub end_key_index: Option<i32>,
1458 /// Information about this key range, for all metrics.
1459 pub info: Option<LocalizedString>,
1460 /// The number of keys this range covers.
1461 #[serde(rename = "keysCount")]
1462 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1463 pub keys_count: Option<i64>,
1464 /// The name of the metric. e.g. "latency".
1465 pub metric: Option<LocalizedString>,
1466 /// The index of the start key in indexed_keys.
1467 #[serde(rename = "startKeyIndex")]
1468 pub start_key_index: Option<i32>,
1469 /// The time offset. This is the time since the start of the time interval.
1470 #[serde(rename = "timeOffset")]
1471 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1472 pub time_offset: Option<chrono::Duration>,
1473 /// The unit of the metric. This is an unstructured field and will be mapped as is to the user.
1474 pub unit: Option<LocalizedString>,
1475 /// The value of the metric.
1476 pub value: Option<f32>,
1477}
1478
1479impl common::Part for KeyRangeInfo {}
1480
1481/// A message representing a list of specific information for multiple key ranges.
1482///
1483/// This type is not used in any activity, and only used as *part* of another schema.
1484///
1485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1486#[serde_with::serde_as]
1487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1488pub struct KeyRangeInfos {
1489 /// The list individual KeyRangeInfos.
1490 pub infos: Option<Vec<KeyRangeInfo>>,
1491 /// 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.
1492 #[serde(rename = "totalSize")]
1493 pub total_size: Option<i32>,
1494}
1495
1496impl common::Part for KeyRangeInfos {}
1497
1498/// `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.
1499///
1500/// This type is not used in any activity, and only used as *part* of another schema.
1501///
1502#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1503#[serde_with::serde_as]
1504#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1505pub struct KeySet {
1506 /// 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.
1507 pub all: Option<bool>,
1508 /// 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.
1509 pub keys: Option<Vec<Vec<serde_json::Value>>>,
1510 /// A list of key ranges. See KeyRange for more information about key range specifications.
1511 pub ranges: Option<Vec<KeyRange>>,
1512}
1513
1514impl common::Part for KeySet {}
1515
1516/// The response for ListBackupOperations.
1517///
1518/// # Activities
1519///
1520/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1521/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1522///
1523/// * [instances backup operations list projects](ProjectInstanceBackupOperationListCall) (response)
1524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1525#[serde_with::serde_as]
1526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1527pub struct ListBackupOperationsResponse {
1528 /// `next_page_token` can be sent in a subsequent ListBackupOperations call to fetch more of the matching metadata.
1529 #[serde(rename = "nextPageToken")]
1530 pub next_page_token: Option<String>,
1531 /// 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.
1532 pub operations: Option<Vec<Operation>>,
1533}
1534
1535impl common::ResponseResult for ListBackupOperationsResponse {}
1536
1537/// The response for ListBackups.
1538///
1539/// # Activities
1540///
1541/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1542/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1543///
1544/// * [instances backups list projects](ProjectInstanceBackupListCall) (response)
1545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1546#[serde_with::serde_as]
1547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1548pub struct ListBackupsResponse {
1549 /// The list of matching backups. Backups returned are ordered by `create_time` in descending order, starting from the most recent `create_time`.
1550 pub backups: Option<Vec<Backup>>,
1551 /// `next_page_token` can be sent in a subsequent ListBackups call to fetch more of the matching backups.
1552 #[serde(rename = "nextPageToken")]
1553 pub next_page_token: Option<String>,
1554}
1555
1556impl common::ResponseResult for ListBackupsResponse {}
1557
1558/// The response for ListDatabaseOperations.
1559///
1560/// # Activities
1561///
1562/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1563/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1564///
1565/// * [instances database operations list projects](ProjectInstanceDatabaseOperationListCall) (response)
1566#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1567#[serde_with::serde_as]
1568#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1569pub struct ListDatabaseOperationsResponse {
1570 /// `next_page_token` can be sent in a subsequent ListDatabaseOperations call to fetch more of the matching metadata.
1571 #[serde(rename = "nextPageToken")]
1572 pub next_page_token: Option<String>,
1573 /// 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.
1574 pub operations: Option<Vec<Operation>>,
1575}
1576
1577impl common::ResponseResult for ListDatabaseOperationsResponse {}
1578
1579/// The response for ListDatabaseRoles.
1580///
1581/// # Activities
1582///
1583/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1584/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1585///
1586/// * [instances databases database roles list projects](ProjectInstanceDatabaseDatabaseRoleListCall) (response)
1587#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1588#[serde_with::serde_as]
1589#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1590pub struct ListDatabaseRolesResponse {
1591 /// Database roles that matched the request.
1592 #[serde(rename = "databaseRoles")]
1593 pub database_roles: Option<Vec<DatabaseRole>>,
1594 /// `next_page_token` can be sent in a subsequent ListDatabaseRoles call to fetch more of the matching roles.
1595 #[serde(rename = "nextPageToken")]
1596 pub next_page_token: Option<String>,
1597}
1598
1599impl common::ResponseResult for ListDatabaseRolesResponse {}
1600
1601/// The response for ListDatabases.
1602///
1603/// # Activities
1604///
1605/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1606/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1607///
1608/// * [instances databases list projects](ProjectInstanceDatabaseListCall) (response)
1609#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1610#[serde_with::serde_as]
1611#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1612pub struct ListDatabasesResponse {
1613 /// Databases that matched the request.
1614 pub databases: Option<Vec<Database>>,
1615 /// `next_page_token` can be sent in a subsequent ListDatabases call to fetch more of the matching databases.
1616 #[serde(rename = "nextPageToken")]
1617 pub next_page_token: Option<String>,
1618}
1619
1620impl common::ResponseResult for ListDatabasesResponse {}
1621
1622/// The response for ListInstanceConfigOperations.
1623///
1624/// # Activities
1625///
1626/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1627/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1628///
1629/// * [instance config operations list projects](ProjectInstanceConfigOperationListCall) (response)
1630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1631#[serde_with::serde_as]
1632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1633pub struct ListInstanceConfigOperationsResponse {
1634 /// `next_page_token` can be sent in a subsequent ListInstanceConfigOperations call to fetch more of the matching metadata.
1635 #[serde(rename = "nextPageToken")]
1636 pub next_page_token: Option<String>,
1637 /// The list of matching instance config long-running operations. Each operation's name will be prefixed by the instance config's name. The operation's metadata field type `metadata.type_url` describes the type of the metadata.
1638 pub operations: Option<Vec<Operation>>,
1639}
1640
1641impl common::ResponseResult for ListInstanceConfigOperationsResponse {}
1642
1643/// The response for ListInstanceConfigs.
1644///
1645/// # Activities
1646///
1647/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1648/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1649///
1650/// * [instance configs list projects](ProjectInstanceConfigListCall) (response)
1651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1652#[serde_with::serde_as]
1653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1654pub struct ListInstanceConfigsResponse {
1655 /// The list of requested instance configurations.
1656 #[serde(rename = "instanceConfigs")]
1657 pub instance_configs: Option<Vec<InstanceConfig>>,
1658 /// `next_page_token` can be sent in a subsequent ListInstanceConfigs call to fetch more of the matching instance configurations.
1659 #[serde(rename = "nextPageToken")]
1660 pub next_page_token: Option<String>,
1661}
1662
1663impl common::ResponseResult for ListInstanceConfigsResponse {}
1664
1665/// The response for ListInstancePartitionOperations.
1666///
1667/// # Activities
1668///
1669/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1670/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1671///
1672/// * [instances instance partition operations list projects](ProjectInstanceInstancePartitionOperationListCall) (response)
1673#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1674#[serde_with::serde_as]
1675#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1676pub struct ListInstancePartitionOperationsResponse {
1677 /// `next_page_token` can be sent in a subsequent ListInstancePartitionOperations call to fetch more of the matching metadata.
1678 #[serde(rename = "nextPageToken")]
1679 pub next_page_token: Option<String>,
1680 /// 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.
1681 pub operations: Option<Vec<Operation>>,
1682 /// The list of unreachable instance partitions. It includes the names of instance partitions whose operation metadata could not be retrieved within instance_partition_deadline.
1683 #[serde(rename = "unreachableInstancePartitions")]
1684 pub unreachable_instance_partitions: Option<Vec<String>>,
1685}
1686
1687impl common::ResponseResult for ListInstancePartitionOperationsResponse {}
1688
1689/// The response for ListInstancePartitions.
1690///
1691/// # Activities
1692///
1693/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1694/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1695///
1696/// * [instances instance partitions list projects](ProjectInstanceInstancePartitionListCall) (response)
1697#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1698#[serde_with::serde_as]
1699#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1700pub struct ListInstancePartitionsResponse {
1701 /// The list of requested instancePartitions.
1702 #[serde(rename = "instancePartitions")]
1703 pub instance_partitions: Option<Vec<InstancePartition>>,
1704 /// `next_page_token` can be sent in a subsequent ListInstancePartitions call to fetch more of the matching instance partitions.
1705 #[serde(rename = "nextPageToken")]
1706 pub next_page_token: Option<String>,
1707 /// 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.
1708 pub unreachable: Option<Vec<String>>,
1709}
1710
1711impl common::ResponseResult for ListInstancePartitionsResponse {}
1712
1713/// The response for ListInstances.
1714///
1715/// # Activities
1716///
1717/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1718/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1719///
1720/// * [instances list projects](ProjectInstanceListCall) (response)
1721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1722#[serde_with::serde_as]
1723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1724pub struct ListInstancesResponse {
1725 /// The list of requested instances.
1726 pub instances: Option<Vec<Instance>>,
1727 /// `next_page_token` can be sent in a subsequent ListInstances call to fetch more of the matching instances.
1728 #[serde(rename = "nextPageToken")]
1729 pub next_page_token: Option<String>,
1730 /// The list of unreachable instances. It includes the names of instances whose metadata could not be retrieved within instance_deadline.
1731 pub unreachable: Option<Vec<String>>,
1732}
1733
1734impl common::ResponseResult for ListInstancesResponse {}
1735
1736/// The response message for Operations.ListOperations.
1737///
1738/// # Activities
1739///
1740/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1741/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1742///
1743/// * [instance configs operations list projects](ProjectInstanceConfigOperationListCall1) (response)
1744/// * [instance configs ssd caches operations list projects](ProjectInstanceConfigSsdCachOperationListCall) (response)
1745/// * [instances backups operations list projects](ProjectInstanceBackupOperationListCall1) (response)
1746/// * [instances databases operations list projects](ProjectInstanceDatabaseOperationListCall1) (response)
1747/// * [instances instance partitions operations list projects](ProjectInstanceInstancePartitionOperationListCall1) (response)
1748/// * [instances operations list projects](ProjectInstanceOperationListCall) (response)
1749#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1750#[serde_with::serde_as]
1751#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1752pub struct ListOperationsResponse {
1753 /// The standard List next-page token.
1754 #[serde(rename = "nextPageToken")]
1755 pub next_page_token: Option<String>,
1756 /// A list of operations that matches the specified filter in the request.
1757 pub operations: Option<Vec<Operation>>,
1758}
1759
1760impl common::ResponseResult for ListOperationsResponse {}
1761
1762/// Response method from the ListScans method.
1763///
1764/// # Activities
1765///
1766/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1767/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1768///
1769/// * [list scans](ScanListCall) (response)
1770#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1771#[serde_with::serde_as]
1772#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1773pub struct ListScansResponse {
1774 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
1775 #[serde(rename = "nextPageToken")]
1776 pub next_page_token: Option<String>,
1777 /// Available scans based on the list query parameters.
1778 pub scans: Option<Vec<Scan>>,
1779}
1780
1781impl common::ResponseResult for ListScansResponse {}
1782
1783/// The response for ListSessions.
1784///
1785/// # Activities
1786///
1787/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1788/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1789///
1790/// * [instances databases sessions list projects](ProjectInstanceDatabaseSessionListCall) (response)
1791#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1792#[serde_with::serde_as]
1793#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1794pub struct ListSessionsResponse {
1795 /// `next_page_token` can be sent in a subsequent ListSessions call to fetch more of the matching sessions.
1796 #[serde(rename = "nextPageToken")]
1797 pub next_page_token: Option<String>,
1798 /// The list of requested sessions.
1799 pub sessions: Option<Vec<Session>>,
1800}
1801
1802impl common::ResponseResult for ListSessionsResponse {}
1803
1804/// A message representing a user-facing string whose value may need to be translated before being displayed.
1805///
1806/// This type is not used in any activity, and only used as *part* of another schema.
1807///
1808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1809#[serde_with::serde_as]
1810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1811pub struct LocalizedString {
1812 /// 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.
1813 pub args: Option<HashMap<String, String>>,
1814 /// 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.
1815 pub message: Option<String>,
1816 /// The token identifying the message, e.g. 'METRIC_READ_CPU'. This should be unique within the service.
1817 pub token: Option<String>,
1818}
1819
1820impl common::Part for LocalizedString {}
1821
1822/// A message representing the actual monitoring data, values for each key bucket over time, of a metric.
1823///
1824/// This type is not used in any activity, and only used as *part* of another schema.
1825///
1826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1827#[serde_with::serde_as]
1828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1829pub struct Metric {
1830 /// The aggregation function used to aggregate each key bucket
1831 pub aggregation: Option<String>,
1832 /// The category of the metric, e.g. "Activity", "Alerts", "Reads", etc.
1833 pub category: Option<LocalizedString>,
1834 /// The references to numerator and denominator metrics for a derived metric.
1835 pub derived: Option<DerivedMetric>,
1836 /// The displayed label of the metric.
1837 #[serde(rename = "displayLabel")]
1838 pub display_label: Option<LocalizedString>,
1839 /// Whether the metric has any non-zero data.
1840 #[serde(rename = "hasNonzeroData")]
1841 pub has_nonzero_data: Option<bool>,
1842 /// 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.
1843 #[serde(rename = "hotValue")]
1844 pub hot_value: Option<f32>,
1845 /// The (sparse) mapping from time index to an IndexedHotKey message, representing those time intervals for which there are hot keys.
1846 #[serde(rename = "indexedHotKeys")]
1847 pub indexed_hot_keys: Option<HashMap<String, IndexedHotKey>>,
1848 /// The (sparse) mapping from time interval index to an IndexedKeyRangeInfos message, representing those time intervals for which there are informational messages concerning key ranges.
1849 #[serde(rename = "indexedKeyRangeInfos")]
1850 pub indexed_key_range_infos: Option<HashMap<String, IndexedKeyRangeInfos>>,
1851 /// Information about the metric.
1852 pub info: Option<LocalizedString>,
1853 /// The data for the metric as a matrix.
1854 pub matrix: Option<MetricMatrix>,
1855 /// The unit of the metric.
1856 pub unit: Option<LocalizedString>,
1857 /// Whether the metric is visible to the end user.
1858 pub visible: Option<bool>,
1859}
1860
1861impl common::Part for Metric {}
1862
1863/// A message representing a matrix of floats.
1864///
1865/// This type is not used in any activity, and only used as *part* of another schema.
1866///
1867#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1868#[serde_with::serde_as]
1869#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1870pub struct MetricMatrix {
1871 /// The rows of the matrix.
1872 pub rows: Option<Vec<MetricMatrixRow>>,
1873}
1874
1875impl common::Part for MetricMatrix {}
1876
1877/// A message representing a row of a matrix of floats.
1878///
1879/// This type is not used in any activity, and only used as *part* of another schema.
1880///
1881#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1882#[serde_with::serde_as]
1883#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1884pub struct MetricMatrixRow {
1885 /// The columns of the row.
1886 pub cols: Option<Vec<f32>>,
1887}
1888
1889impl common::Part for MetricMatrixRow {}
1890
1891/// The request for MoveInstance.
1892///
1893/// # Activities
1894///
1895/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1896/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1897///
1898/// * [instances move projects](ProjectInstanceMoveCall) (request)
1899#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1900#[serde_with::serde_as]
1901#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1902pub struct MoveInstanceRequest {
1903 /// Required. The target instance config for the instance to move. Values are of the form `projects//instanceConfigs/`.
1904 #[serde(rename = "targetConfig")]
1905 pub target_config: Option<String>,
1906}
1907
1908impl common::RequestValue for MoveInstanceRequest {}
1909
1910/// 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.
1911///
1912/// This type is not used in any activity, and only used as *part* of another schema.
1913///
1914#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1915#[serde_with::serde_as]
1916#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1917pub struct Mutation {
1918 /// Delete rows from a table. Succeeds whether or not the named rows were present.
1919 pub delete: Option<Delete>,
1920 /// Insert new rows in a table. If any of the rows already exist, the write or transaction fails with error `ALREADY_EXISTS`.
1921 pub insert: Option<Write>,
1922 /// 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.
1923 #[serde(rename = "insertOrUpdate")]
1924 pub insert_or_update: Option<Write>,
1925 /// 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.
1926 pub replace: Option<Write>,
1927 /// Update existing rows in a table. If any of the rows does not already exist, the transaction fails with error `NOT_FOUND`.
1928 pub update: Option<Write>,
1929}
1930
1931impl common::Part for Mutation {}
1932
1933/// 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.
1934///
1935/// This type is not used in any activity, and only used as *part* of another schema.
1936///
1937#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1938#[serde_with::serde_as]
1939#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1940pub struct MutationGroup {
1941 /// Required. The mutations in this group.
1942 pub mutations: Option<Vec<Mutation>>,
1943}
1944
1945impl common::Part for MutationGroup {}
1946
1947/// This resource represents a long-running operation that is the result of a network API call.
1948///
1949/// # Activities
1950///
1951/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1952/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1953///
1954/// * [instance configs operations get projects](ProjectInstanceConfigOperationGetCall) (response)
1955/// * [instance configs ssd caches operations get projects](ProjectInstanceConfigSsdCachOperationGetCall) (response)
1956/// * [instance configs create projects](ProjectInstanceConfigCreateCall) (response)
1957/// * [instance configs patch projects](ProjectInstanceConfigPatchCall) (response)
1958/// * [instances backups operations get projects](ProjectInstanceBackupOperationGetCall) (response)
1959/// * [instances backups copy projects](ProjectInstanceBackupCopyCall) (response)
1960/// * [instances backups create projects](ProjectInstanceBackupCreateCall) (response)
1961/// * [instances databases operations get projects](ProjectInstanceDatabaseOperationGetCall) (response)
1962/// * [instances databases changequorum projects](ProjectInstanceDatabaseChangequorumCall) (response)
1963/// * [instances databases create projects](ProjectInstanceDatabaseCreateCall) (response)
1964/// * [instances databases patch projects](ProjectInstanceDatabasePatchCall) (response)
1965/// * [instances databases restore projects](ProjectInstanceDatabaseRestoreCall) (response)
1966/// * [instances databases update ddl projects](ProjectInstanceDatabaseUpdateDdlCall) (response)
1967/// * [instances instance partitions operations get projects](ProjectInstanceInstancePartitionOperationGetCall) (response)
1968/// * [instances instance partitions create projects](ProjectInstanceInstancePartitionCreateCall) (response)
1969/// * [instances instance partitions patch projects](ProjectInstanceInstancePartitionPatchCall) (response)
1970/// * [instances operations get projects](ProjectInstanceOperationGetCall) (response)
1971/// * [instances create projects](ProjectInstanceCreateCall) (response)
1972/// * [instances move projects](ProjectInstanceMoveCall) (response)
1973/// * [instances patch projects](ProjectInstancePatchCall) (response)
1974#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1975#[serde_with::serde_as]
1976#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1977pub struct Operation {
1978 /// 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.
1979 pub done: Option<bool>,
1980 /// The error result of the operation in case of failure or cancellation.
1981 pub error: Option<Status>,
1982 /// 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.
1983 pub metadata: Option<HashMap<String, serde_json::Value>>,
1984 /// 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}`.
1985 pub name: Option<String>,
1986 /// 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`.
1987 pub response: Option<HashMap<String, serde_json::Value>>,
1988}
1989
1990impl common::ResponseResult for Operation {}
1991
1992/// 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.
1993///
1994/// # Activities
1995///
1996/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1997/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1998///
1999/// * [instances databases sessions execute streaming sql projects](ProjectInstanceDatabaseSessionExecuteStreamingSqlCall) (response)
2000/// * [instances databases sessions streaming read projects](ProjectInstanceDatabaseSessionStreamingReadCall) (response)
2001#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2002#[serde_with::serde_as]
2003#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2004pub struct PartialResultSet {
2005 /// 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.
2006 #[serde(rename = "chunkedValue")]
2007 pub chunked_value: Option<bool>,
2008 /// Metadata about the result set, such as row type information. Only present in the first response.
2009 pub metadata: Option<ResultSetMetadata>,
2010 /// 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.
2011 #[serde(rename = "resumeToken")]
2012 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2013 pub resume_token: Option<Vec<u8>>,
2014 /// 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 will also be present in the last response for DML statements.
2015 pub stats: Option<ResultSetStats>,
2016 /// 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 is 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`: cannot 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..."` will yield results from the `PartialResultSet` with value `["orl"]`.
2017 pub values: Option<Vec<serde_json::Value>>,
2018}
2019
2020impl common::ResponseResult for PartialResultSet {}
2021
2022/// Information returned for each partition returned in a PartitionResponse.
2023///
2024/// This type is not used in any activity, and only used as *part* of another schema.
2025///
2026#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2027#[serde_with::serde_as]
2028#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2029pub struct Partition {
2030 /// This token can be passed to Read, StreamingRead, ExecuteSql, or ExecuteStreamingSql requests to restrict the results to those identified by this partition token.
2031 #[serde(rename = "partitionToken")]
2032 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2033 pub partition_token: Option<Vec<u8>>,
2034}
2035
2036impl common::Part for Partition {}
2037
2038/// Options for a PartitionQueryRequest and PartitionReadRequest.
2039///
2040/// This type is not used in any activity, and only used as *part* of another schema.
2041///
2042#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2043#[serde_with::serde_as]
2044#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2045pub struct PartitionOptions {
2046 /// **Note:** This hint is currently ignored by PartitionQuery and PartitionRead requests. The desired maximum number of partitions to return. For example, this may 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 may be smaller or larger than this maximum count request.
2047 #[serde(rename = "maxPartitions")]
2048 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2049 pub max_partitions: Option<i64>,
2050 /// **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 may be smaller or larger than this size request.
2051 #[serde(rename = "partitionSizeBytes")]
2052 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2053 pub partition_size_bytes: Option<i64>,
2054}
2055
2056impl common::Part for PartitionOptions {}
2057
2058/// The request for PartitionQuery
2059///
2060/// # Activities
2061///
2062/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2063/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2064///
2065/// * [instances databases sessions partition query projects](ProjectInstanceDatabaseSessionPartitionQueryCall) (request)
2066#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2067#[serde_with::serde_as]
2068#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2069pub struct PartitionQueryRequest {
2070 /// It is not 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.
2071 #[serde(rename = "paramTypes")]
2072 pub param_types: Option<HashMap<String, Type>>,
2073 /// 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 is an error to execute a SQL statement with unbound parameters.
2074 pub params: Option<HashMap<String, serde_json::Value>>,
2075 /// Additional options that affect how many partitions are created.
2076 #[serde(rename = "partitionOptions")]
2077 pub partition_options: Option<PartitionOptions>,
2078 /// Required. The query request to generate partitions for. The request will fail if the query is not 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.
2079 pub sql: Option<String>,
2080 /// Read only snapshot transactions are supported, read/write and single use transactions are not.
2081 pub transaction: Option<TransactionSelector>,
2082}
2083
2084impl common::RequestValue for PartitionQueryRequest {}
2085
2086/// The request for PartitionRead
2087///
2088/// # Activities
2089///
2090/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2091/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2092///
2093/// * [instances databases sessions partition read projects](ProjectInstanceDatabaseSessionPartitionReadCall) (request)
2094#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2095#[serde_with::serde_as]
2096#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2097pub struct PartitionReadRequest {
2098 /// The columns of table to be returned for each row matching this request.
2099 pub columns: Option<Vec<String>>,
2100 /// 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.
2101 pub index: Option<String>,
2102 /// 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 is not an error for the `key_set` to name rows that do not exist in the database. Read yields nothing for nonexistent rows.
2103 #[serde(rename = "keySet")]
2104 pub key_set: Option<KeySet>,
2105 /// Additional options that affect how many partitions are created.
2106 #[serde(rename = "partitionOptions")]
2107 pub partition_options: Option<PartitionOptions>,
2108 /// Required. The name of the table in the database to be read.
2109 pub table: Option<String>,
2110 /// Read only snapshot transactions are supported, read/write and single use transactions are not.
2111 pub transaction: Option<TransactionSelector>,
2112}
2113
2114impl common::RequestValue for PartitionReadRequest {}
2115
2116/// The response for PartitionQuery or PartitionRead
2117///
2118/// # Activities
2119///
2120/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2121/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2122///
2123/// * [instances databases sessions partition query projects](ProjectInstanceDatabaseSessionPartitionQueryCall) (response)
2124/// * [instances databases sessions partition read projects](ProjectInstanceDatabaseSessionPartitionReadCall) (response)
2125#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2126#[serde_with::serde_as]
2127#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2128pub struct PartitionResponse {
2129 /// Partitions created by this request.
2130 pub partitions: Option<Vec<Partition>>,
2131 /// Transaction created by this request.
2132 pub transaction: Option<Transaction>,
2133}
2134
2135impl common::ResponseResult for PartitionResponse {}
2136
2137/// Message type to initiate a Partitioned DML transaction.
2138///
2139/// This type is not used in any activity, and only used as *part* of another schema.
2140///
2141#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2142#[serde_with::serde_as]
2143#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2144pub struct PartitionedDml {
2145 _never_set: Option<bool>,
2146}
2147
2148impl common::Part for PartitionedDml {}
2149
2150/// Node information for nodes appearing in a QueryPlan.plan_nodes.
2151///
2152/// This type is not used in any activity, and only used as *part* of another schema.
2153///
2154#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2155#[serde_with::serde_as]
2156#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2157pub struct PlanNode {
2158 /// List of child node `index`es and their relationship to this parent.
2159 #[serde(rename = "childLinks")]
2160 pub child_links: Option<Vec<ChildLink>>,
2161 /// The display name for the node.
2162 #[serde(rename = "displayName")]
2163 pub display_name: Option<String>,
2164 /// 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.
2165 #[serde(rename = "executionStats")]
2166 pub execution_stats: Option<HashMap<String, serde_json::Value>>,
2167 /// The `PlanNode`'s index in node list.
2168 pub index: Option<i32>,
2169 /// 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.
2170 pub kind: Option<String>,
2171 /// 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" }
2172 pub metadata: Option<HashMap<String, serde_json::Value>>,
2173 /// Condensed representation for SCALAR nodes.
2174 #[serde(rename = "shortRepresentation")]
2175 pub short_representation: Option<ShortRepresentation>,
2176}
2177
2178impl common::Part for PlanNode {}
2179
2180/// 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/).
2181///
2182/// # Activities
2183///
2184/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2185/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2186///
2187/// * [instances backups get iam policy projects](ProjectInstanceBackupGetIamPolicyCall) (response)
2188/// * [instances backups set iam policy projects](ProjectInstanceBackupSetIamPolicyCall) (response)
2189/// * [instances databases get iam policy projects](ProjectInstanceDatabaseGetIamPolicyCall) (response)
2190/// * [instances databases set iam policy projects](ProjectInstanceDatabaseSetIamPolicyCall) (response)
2191/// * [instances get iam policy projects](ProjectInstanceGetIamPolicyCall) (response)
2192/// * [instances set iam policy projects](ProjectInstanceSetIamPolicyCall) (response)
2193#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2194#[serde_with::serde_as]
2195#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2196pub struct Policy {
2197 /// 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`.
2198 pub bindings: Option<Vec<Binding>>,
2199 /// `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.
2200 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2201 pub etag: Option<Vec<u8>>,
2202 /// 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).
2203 pub version: Option<i32>,
2204}
2205
2206impl common::ResponseResult for Policy {}
2207
2208/// 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.
2209///
2210/// This type is not used in any activity, and only used as *part* of another schema.
2211///
2212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2213#[serde_with::serde_as]
2214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2215pub struct PrefixNode {
2216 /// Whether this corresponds to a data_source name.
2217 #[serde(rename = "dataSourceNode")]
2218 pub data_source_node: Option<bool>,
2219 /// The depth in the prefix hierarchy.
2220 pub depth: Option<i32>,
2221 /// The index of the end key bucket of the range that this node spans.
2222 #[serde(rename = "endIndex")]
2223 pub end_index: Option<i32>,
2224 /// The index of the start key bucket of the range that this node spans.
2225 #[serde(rename = "startIndex")]
2226 pub start_index: Option<i32>,
2227 /// The string represented by the prefix node.
2228 pub word: Option<String>,
2229}
2230
2231impl common::Part for PrefixNode {}
2232
2233/// Output of query advisor analysis.
2234///
2235/// This type is not used in any activity, and only used as *part* of another schema.
2236///
2237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2238#[serde_with::serde_as]
2239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2240pub struct QueryAdvisorResult {
2241 /// 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.
2242 #[serde(rename = "indexAdvice")]
2243 pub index_advice: Option<Vec<IndexAdvice>>,
2244}
2245
2246impl common::Part for QueryAdvisorResult {}
2247
2248/// Query optimizer configuration.
2249///
2250/// This type is not used in any activity, and only used as *part* of another schema.
2251///
2252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2253#[serde_with::serde_as]
2254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2255pub struct QueryOptions {
2256 /// 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 is not set. The statistics package requested by the query has to be exempt from garbage collection. This can be achieved with the following DDL statement: ``` 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.
2257 #[serde(rename = "optimizerStatisticsPackage")]
2258 pub optimizer_statistics_package: Option<String>,
2259 /// 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.
2260 #[serde(rename = "optimizerVersion")]
2261 pub optimizer_version: Option<String>,
2262}
2263
2264impl common::Part for QueryOptions {}
2265
2266/// Contains an ordered list of nodes appearing in the query plan.
2267///
2268/// This type is not used in any activity, and only used as *part* of another schema.
2269///
2270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2271#[serde_with::serde_as]
2272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2273pub struct QueryPlan {
2274 /// 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`.
2275 #[serde(rename = "planNodes")]
2276 pub plan_nodes: Option<Vec<PlanNode>>,
2277 /// Optional. The advices/recommendations for a query. Currently this field will be serving index recommendations for a query.
2278 #[serde(rename = "queryAdvice")]
2279 pub query_advice: Option<QueryAdvisorResult>,
2280}
2281
2282impl common::Part for QueryPlan {}
2283
2284/// Information about the dual region quorum.
2285///
2286/// This type is not used in any activity, and only used as *part* of another schema.
2287///
2288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2289#[serde_with::serde_as]
2290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2291pub struct QuorumInfo {
2292 /// Output only. The etag is used for optimistic concurrency control as a way to help prevent simultaneous ChangeQuorum requests that could create a race condition.
2293 pub etag: Option<String>,
2294 /// Output only. Whether this ChangeQuorum is a Google or User initiated.
2295 pub initiator: Option<String>,
2296 /// Output only. The type of this quorum. See QuorumType for more information about quorum type specifications.
2297 #[serde(rename = "quorumType")]
2298 pub quorum_type: Option<QuorumType>,
2299 /// Output only. The timestamp when the request was triggered.
2300 #[serde(rename = "startTime")]
2301 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2302}
2303
2304impl common::Part for QuorumInfo {}
2305
2306/// Information about the database quorum type. this applies only for dual region instance configs.
2307///
2308/// This type is not used in any activity, and only used as *part* of another schema.
2309///
2310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2311#[serde_with::serde_as]
2312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2313pub struct QuorumType {
2314 /// Dual region quorum type.
2315 #[serde(rename = "dualRegion")]
2316 pub dual_region: Option<DualRegionQuorum>,
2317 /// Single region quorum type.
2318 #[serde(rename = "singleRegion")]
2319 pub single_region: Option<SingleRegionQuorum>,
2320}
2321
2322impl common::Part for QuorumType {}
2323
2324/// Message type to initiate a read-only transaction.
2325///
2326/// This type is not used in any activity, and only used as *part* of another schema.
2327///
2328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2329#[serde_with::serde_as]
2330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2331pub struct ReadOnly {
2332 /// 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`.
2333 #[serde(rename = "exactStaleness")]
2334 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2335 pub exact_staleness: Option<chrono::Duration>,
2336 /// 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.
2337 #[serde(rename = "maxStaleness")]
2338 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2339 pub max_staleness: Option<chrono::Duration>,
2340 /// 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"`.
2341 #[serde(rename = "minReadTimestamp")]
2342 pub min_read_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
2343 /// 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 will block 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"`.
2344 #[serde(rename = "readTimestamp")]
2345 pub read_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
2346 /// If true, the Cloud Spanner-selected read timestamp is included in the Transaction message that describes the transaction.
2347 #[serde(rename = "returnReadTimestamp")]
2348 pub return_read_timestamp: Option<bool>,
2349 /// Read at a timestamp where all previously committed transactions are visible.
2350 pub strong: Option<bool>,
2351}
2352
2353impl common::Part for ReadOnly {}
2354
2355/// The request for Read and StreamingRead.
2356///
2357/// # Activities
2358///
2359/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2360/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2361///
2362/// * [instances databases sessions read projects](ProjectInstanceDatabaseSessionReadCall) (request)
2363/// * [instances databases sessions streaming read projects](ProjectInstanceDatabaseSessionStreamingReadCall) (request)
2364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2365#[serde_with::serde_as]
2366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2367pub struct ReadRequest {
2368 /// Required. The columns of table to be returned for each row matching this request.
2369 pub columns: Option<Vec<String>>,
2370 /// 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 does not set `partition_token`, the API returns an `INVALID_ARGUMENT` error.
2371 #[serde(rename = "dataBoostEnabled")]
2372 pub data_boost_enabled: Option<bool>,
2373 /// Directed read options for this request.
2374 #[serde(rename = "directedReadOptions")]
2375 pub directed_read_options: Option<DirectedReadOptions>,
2376 /// 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.
2377 pub index: Option<String>,
2378 /// 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 is not empty, rows will be yielded in an unspecified order. It is not an error for the `key_set` to name rows that do not exist in the database. Read yields nothing for nonexistent rows.
2379 #[serde(rename = "keySet")]
2380 pub key_set: Option<KeySet>,
2381 /// If greater than zero, only the first `limit` rows are yielded. If `limit` is zero, the default is no limit. A limit cannot be specified if `partition_token` is set.
2382 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2383 pub limit: Option<i64>,
2384 /// Optional. Lock Hint for the request, it can only be used with read-write transactions.
2385 #[serde(rename = "lockHint")]
2386 pub lock_hint: Option<String>,
2387 /// Optional. Order for the returned rows. By default, Spanner will return result rows in primary key order except for PartitionRead requests. For applications that do not 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 (e.g. bulk point lookups).
2388 #[serde(rename = "orderBy")]
2389 pub order_by: Option<String>,
2390 /// If present, results will be 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.
2391 #[serde(rename = "partitionToken")]
2392 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2393 pub partition_token: Option<Vec<u8>>,
2394 /// Common options for this request.
2395 #[serde(rename = "requestOptions")]
2396 pub request_options: Option<RequestOptions>,
2397 /// 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.
2398 #[serde(rename = "resumeToken")]
2399 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2400 pub resume_token: Option<Vec<u8>>,
2401 /// Required. The name of the table in the database to be read.
2402 pub table: Option<String>,
2403 /// The transaction to use. If none is provided, the default is a temporary read-only transaction with strong concurrency.
2404 pub transaction: Option<TransactionSelector>,
2405}
2406
2407impl common::RequestValue for ReadRequest {}
2408
2409/// Message type to initiate a read-write transaction. Currently this transaction type has no options.
2410///
2411/// This type is not used in any activity, and only used as *part* of another schema.
2412///
2413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2414#[serde_with::serde_as]
2415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2416pub struct ReadWrite {
2417 /// Read lock mode for the transaction.
2418 #[serde(rename = "readLockMode")]
2419 pub read_lock_mode: Option<String>,
2420}
2421
2422impl common::Part for ReadWrite {}
2423
2424/// There is no detailed description.
2425///
2426/// This type is not used in any activity, and only used as *part* of another schema.
2427///
2428#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2429#[serde_with::serde_as]
2430#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2431pub struct ReplicaInfo {
2432 /// 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.
2433 #[serde(rename = "defaultLeaderLocation")]
2434 pub default_leader_location: Option<bool>,
2435 /// The location of the serving resources, e.g., "us-central1".
2436 pub location: Option<String>,
2437 /// The type of replica.
2438 #[serde(rename = "type")]
2439 pub type_: Option<String>,
2440}
2441
2442impl common::Part for ReplicaInfo {}
2443
2444/// 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 will be used to process the request. * `type:READ_ONLY` --> The "READ_ONLY" type replica(s) in nearest available location will be used to process the request. * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s) in location "us-east1" will be used to process the request.
2445///
2446/// This type is not used in any activity, and only used as *part* of another schema.
2447///
2448#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2449#[serde_with::serde_as]
2450#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2451pub struct ReplicaSelection {
2452 /// The location or region of the serving requests, e.g. "us-east1".
2453 pub location: Option<String>,
2454 /// The type of replica.
2455 #[serde(rename = "type")]
2456 pub type_: Option<String>,
2457}
2458
2459impl common::Part for ReplicaSelection {}
2460
2461/// Common request options for various APIs.
2462///
2463/// This type is not used in any activity, and only used as *part* of another schema.
2464///
2465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2466#[serde_with::serde_as]
2467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2468pub struct RequestOptions {
2469 /// Priority for the request.
2470 pub priority: Option<String>,
2471 /// 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 (e.g. 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 will be removed from the string.
2472 #[serde(rename = "requestTag")]
2473 pub request_tag: Option<String>,
2474 /// 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 will be 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 will be removed from the string.
2475 #[serde(rename = "transactionTag")]
2476 pub transaction_tag: Option<String>,
2477}
2478
2479impl common::Part for RequestOptions {}
2480
2481/// Encryption configuration for the restored database.
2482///
2483/// This type is not used in any activity, and only used as *part* of another schema.
2484///
2485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2486#[serde_with::serde_as]
2487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2488pub struct RestoreDatabaseEncryptionConfig {
2489 /// Required. The encryption type of the restored database.
2490 #[serde(rename = "encryptionType")]
2491 pub encryption_type: Option<String>,
2492 /// Optional. The Cloud KMS key that will be used to encrypt/decrypt the restored database. This field should be set only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
2493 #[serde(rename = "kmsKeyName")]
2494 pub kms_key_name: Option<String>,
2495 /// Optional. Specifies the KMS configuration for the 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 instance configuration. Some examples: * For single region database instance configs, specify a single regional location KMS key. * For multi-regional database instance configs of type GOOGLE_MANAGED, either specify a multi-regional location KMS key or multiple regional location KMS keys that cover all regions in the instance config. * For a database instance config of type USER_MANAGED, please specify only regional location KMS keys to cover each region in the instance config. Multi-regional location KMS keys are not supported for USER_MANAGED instance configs.
2496 #[serde(rename = "kmsKeyNames")]
2497 pub kms_key_names: Option<Vec<String>>,
2498}
2499
2500impl common::Part for RestoreDatabaseEncryptionConfig {}
2501
2502/// The request for RestoreDatabase.
2503///
2504/// # Activities
2505///
2506/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2507/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2508///
2509/// * [instances databases restore projects](ProjectInstanceDatabaseRestoreCall) (request)
2510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2511#[serde_with::serde_as]
2512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2513pub struct RestoreDatabaseRequest {
2514 /// Name of the backup from which to restore. Values are of the form `projects//instances//backups/`.
2515 pub backup: Option<String>,
2516 /// 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/`.
2517 #[serde(rename = "databaseId")]
2518 pub database_id: Option<String>,
2519 /// 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`.
2520 #[serde(rename = "encryptionConfig")]
2521 pub encryption_config: Option<RestoreDatabaseEncryptionConfig>,
2522}
2523
2524impl common::RequestValue for RestoreDatabaseRequest {}
2525
2526/// Information about the database restore.
2527///
2528/// This type is not used in any activity, and only used as *part* of another schema.
2529///
2530#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2531#[serde_with::serde_as]
2532#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2533pub struct RestoreInfo {
2534 /// Information about the backup used to restore the database. The backup may no longer exist.
2535 #[serde(rename = "backupInfo")]
2536 pub backup_info: Option<BackupInfo>,
2537 /// The type of the restore source.
2538 #[serde(rename = "sourceType")]
2539 pub source_type: Option<String>,
2540}
2541
2542impl common::Part for RestoreInfo {}
2543
2544/// Results from Read or ExecuteSql.
2545///
2546/// # Activities
2547///
2548/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2549/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2550///
2551/// * [instances databases sessions execute sql projects](ProjectInstanceDatabaseSessionExecuteSqlCall) (response)
2552/// * [instances databases sessions read projects](ProjectInstanceDatabaseSessionReadCall) (response)
2553#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2554#[serde_with::serde_as]
2555#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2556pub struct ResultSet {
2557 /// Metadata about the result set, such as row type information.
2558 pub metadata: Option<ResultSetMetadata>,
2559 /// 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.
2560 pub rows: Option<Vec<Vec<serde_json::Value>>>,
2561 /// 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 may or may not be populated, based on the ExecuteSqlRequest.query_mode.
2562 pub stats: Option<ResultSetStats>,
2563}
2564
2565impl common::ResponseResult for ResultSet {}
2566
2567/// Metadata about a ResultSet or PartialResultSet.
2568///
2569/// This type is not used in any activity, and only used as *part* of another schema.
2570///
2571#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2572#[serde_with::serde_as]
2573#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2574pub struct ResultSetMetadata {
2575 /// 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" } }, ]
2576 #[serde(rename = "rowType")]
2577 pub row_type: Option<StructType>,
2578 /// If the read or SQL query began a transaction as a side-effect, the information about the new transaction is yielded here.
2579 pub transaction: Option<Transaction>,
2580 /// 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" } }, ]
2581 #[serde(rename = "undeclaredParameters")]
2582 pub undeclared_parameters: Option<StructType>,
2583}
2584
2585impl common::Part for ResultSetMetadata {}
2586
2587/// Additional statistics about a ResultSet or PartialResultSet.
2588///
2589/// This type is not used in any activity, and only used as *part* of another schema.
2590///
2591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2592#[serde_with::serde_as]
2593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2594pub struct ResultSetStats {
2595 /// QueryPlan for the query associated with this result.
2596 #[serde(rename = "queryPlan")]
2597 pub query_plan: Option<QueryPlan>,
2598 /// 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" }
2599 #[serde(rename = "queryStats")]
2600 pub query_stats: Option<HashMap<String, serde_json::Value>>,
2601 /// Standard DML returns an exact count of rows that were modified.
2602 #[serde(rename = "rowCountExact")]
2603 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2604 pub row_count_exact: Option<i64>,
2605 /// Partitioned DML does not offer exactly-once semantics, so it returns a lower bound of the rows modified.
2606 #[serde(rename = "rowCountLowerBound")]
2607 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2608 pub row_count_lower_bound: Option<i64>,
2609}
2610
2611impl common::Part for ResultSetStats {}
2612
2613/// The request for Rollback.
2614///
2615/// # Activities
2616///
2617/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2618/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2619///
2620/// * [instances databases sessions rollback projects](ProjectInstanceDatabaseSessionRollbackCall) (request)
2621#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2622#[serde_with::serde_as]
2623#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2624pub struct RollbackRequest {
2625 /// Required. The transaction to roll back.
2626 #[serde(rename = "transactionId")]
2627 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2628 pub transaction_id: Option<Vec<u8>>,
2629}
2630
2631impl common::RequestValue for RollbackRequest {}
2632
2633/// Scan is a structure which describes Cloud Key Visualizer scan information.
2634///
2635/// # Activities
2636///
2637/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2638/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2639///
2640/// * [instances databases get scans projects](ProjectInstanceDatabaseGetScanCall) (response)
2641/// * [list scans](ScanListCall) (none)
2642#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2643#[serde_with::serde_as]
2644#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2645pub struct Scan {
2646 /// Additional information provided by the implementer.
2647 pub details: Option<HashMap<String, serde_json::Value>>,
2648 /// The upper bound for when the scan is defined.
2649 #[serde(rename = "endTime")]
2650 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2651 /// The unique name of the scan, specific to the Database service implementing this interface.
2652 pub name: Option<String>,
2653 /// Output only. Cloud Key Visualizer scan data. Note, this field is not available to the ListScans method.
2654 #[serde(rename = "scanData")]
2655 pub scan_data: Option<ScanData>,
2656 /// A range of time (inclusive) for when the scan is defined. The lower bound for when the scan is defined.
2657 #[serde(rename = "startTime")]
2658 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2659}
2660
2661impl common::Resource for Scan {}
2662impl common::ResponseResult for Scan {}
2663
2664/// ScanData contains Cloud Key Visualizer scan data used by the caller to construct a visualization.
2665///
2666/// This type is not used in any activity, and only used as *part* of another schema.
2667///
2668#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2669#[serde_with::serde_as]
2670#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2671pub struct ScanData {
2672 /// 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.
2673 pub data: Option<VisualizationData>,
2674 /// The upper bound for when the contained data is defined.
2675 #[serde(rename = "endTime")]
2676 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2677 /// A range of time (inclusive) for when the contained data is defined. The lower bound for when the contained data is defined.
2678 #[serde(rename = "startTime")]
2679 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2680}
2681
2682impl common::Part for ScanData {}
2683
2684/// A session in the Cloud Spanner API.
2685///
2686/// # Activities
2687///
2688/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2689/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2690///
2691/// * [instances databases sessions create projects](ProjectInstanceDatabaseSessionCreateCall) (response)
2692/// * [instances databases sessions get projects](ProjectInstanceDatabaseSessionGetCall) (response)
2693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2694#[serde_with::serde_as]
2695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2696pub struct Session {
2697 /// Output only. The approximate timestamp when the session is last used. It is typically earlier than the actual last use time.
2698 #[serde(rename = "approximateLastUseTime")]
2699 pub approximate_last_use_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2700 /// Output only. The timestamp when the session is created.
2701 #[serde(rename = "createTime")]
2702 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2703 /// The database role which created this session.
2704 #[serde(rename = "creatorRole")]
2705 pub creator_role: Option<String>,
2706 /// 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.
2707 pub labels: Option<HashMap<String, String>>,
2708 /// Optional. If true, specifies a multiplexed session. Use a multiplexed session for multiple, concurrent read-only operations. Don't use them for read-write transactions, partitioned reads, or partitioned queries. Use CreateSession to create multiplexed sessions. Don't use BatchCreateSessions to create a multiplexed session. You can't delete or list multiplexed sessions.
2709 pub multiplexed: Option<bool>,
2710 /// Output only. The name of the session. This is always system-assigned.
2711 pub name: Option<String>,
2712}
2713
2714impl common::ResponseResult for Session {}
2715
2716/// Request message for `SetIamPolicy` method.
2717///
2718/// # Activities
2719///
2720/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2721/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2722///
2723/// * [instances backups set iam policy projects](ProjectInstanceBackupSetIamPolicyCall) (request)
2724/// * [instances databases set iam policy projects](ProjectInstanceDatabaseSetIamPolicyCall) (request)
2725/// * [instances set iam policy projects](ProjectInstanceSetIamPolicyCall) (request)
2726#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2727#[serde_with::serde_as]
2728#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2729pub struct SetIamPolicyRequest {
2730 /// 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.
2731 pub policy: Option<Policy>,
2732}
2733
2734impl common::RequestValue for SetIamPolicyRequest {}
2735
2736/// Condensed representation of a node and its subtree. Only present for `SCALAR` PlanNode(s).
2737///
2738/// This type is not used in any activity, and only used as *part* of another schema.
2739///
2740#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2741#[serde_with::serde_as]
2742#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2743pub struct ShortRepresentation {
2744 /// A string representation of the expression subtree rooted at this node.
2745 pub description: Option<String>,
2746 /// 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.
2747 pub subqueries: Option<HashMap<String, i32>>,
2748}
2749
2750impl common::Part for ShortRepresentation {}
2751
2752/// Message type for a single-region quorum.
2753///
2754/// This type is not used in any activity, and only used as *part* of another schema.
2755///
2756#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2757#[serde_with::serde_as]
2758#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2759pub struct SingleRegionQuorum {
2760 /// Required. The location of the serving region, e.g. "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 via [GetInstanceConfig[InstanceAdmin.GetInstanceConfig] API. This should only be used if you plan to change quorum in single-region quorum type.
2761 #[serde(rename = "servingLocation")]
2762 pub serving_location: Option<String>,
2763}
2764
2765impl common::Part for SingleRegionQuorum {}
2766
2767/// A single DML statement.
2768///
2769/// This type is not used in any activity, and only used as *part* of another schema.
2770///
2771#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2772#[serde_with::serde_as]
2773#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2774pub struct Statement {
2775 /// It is not 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.
2776 #[serde(rename = "paramTypes")]
2777 pub param_types: Option<HashMap<String, Type>>,
2778 /// 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 is an error to execute a SQL statement with unbound parameters.
2779 pub params: Option<HashMap<String, serde_json::Value>>,
2780 /// Required. The DML string.
2781 pub sql: Option<String>,
2782}
2783
2784impl common::Part for Statement {}
2785
2786/// 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).
2787///
2788/// This type is not used in any activity, and only used as *part* of another schema.
2789///
2790#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2791#[serde_with::serde_as]
2792#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2793pub struct Status {
2794 /// The status code, which should be an enum value of google.rpc.Code.
2795 pub code: Option<i32>,
2796 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2797 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2798 /// 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.
2799 pub message: Option<String>,
2800}
2801
2802impl common::Part for Status {}
2803
2804/// `StructType` defines the fields of a STRUCT type.
2805///
2806/// This type is not used in any activity, and only used as *part* of another schema.
2807///
2808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2809#[serde_with::serde_as]
2810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2811pub struct StructType {
2812 /// 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.
2813 pub fields: Option<Vec<Field>>,
2814}
2815
2816impl common::Part for StructType {}
2817
2818/// Request message for `TestIamPermissions` method.
2819///
2820/// # Activities
2821///
2822/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2823/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2824///
2825/// * [instances backups test iam permissions projects](ProjectInstanceBackupTestIamPermissionCall) (request)
2826/// * [instances databases database roles test iam permissions projects](ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall) (request)
2827/// * [instances databases test iam permissions projects](ProjectInstanceDatabaseTestIamPermissionCall) (request)
2828/// * [instances test iam permissions projects](ProjectInstanceTestIamPermissionCall) (request)
2829#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2830#[serde_with::serde_as]
2831#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2832pub struct TestIamPermissionsRequest {
2833 /// REQUIRED: The set of permissions to check for 'resource'. Permissions with wildcards (such as '*', 'spanner.*', 'spanner.instances.*') are not allowed.
2834 pub permissions: Option<Vec<String>>,
2835}
2836
2837impl common::RequestValue for TestIamPermissionsRequest {}
2838
2839/// Response message for `TestIamPermissions` method.
2840///
2841/// # Activities
2842///
2843/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2844/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2845///
2846/// * [instances backups test iam permissions projects](ProjectInstanceBackupTestIamPermissionCall) (response)
2847/// * [instances databases database roles test iam permissions projects](ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall) (response)
2848/// * [instances databases test iam permissions projects](ProjectInstanceDatabaseTestIamPermissionCall) (response)
2849/// * [instances test iam permissions projects](ProjectInstanceTestIamPermissionCall) (response)
2850#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2851#[serde_with::serde_as]
2852#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2853pub struct TestIamPermissionsResponse {
2854 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
2855 pub permissions: Option<Vec<String>>,
2856}
2857
2858impl common::ResponseResult for TestIamPermissionsResponse {}
2859
2860/// A transaction.
2861///
2862/// # Activities
2863///
2864/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2865/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2866///
2867/// * [instances databases sessions begin transaction projects](ProjectInstanceDatabaseSessionBeginTransactionCall) (response)
2868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2869#[serde_with::serde_as]
2870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2871pub struct Transaction {
2872 /// `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.
2873 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2874 pub id: Option<Vec<u8>>,
2875 /// 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"`.
2876 #[serde(rename = "readTimestamp")]
2877 pub read_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
2878}
2879
2880impl common::ResponseResult for Transaction {}
2881
2882/// Transactions: Each session can have at most one active transaction at a time (note that standalone reads and queries use a transaction internally and do count towards the one transaction limit). After the active transaction is completed, the session can immediately be re-used for the next transaction. It is not necessary to create a new session for each transaction. Transaction modes: Cloud Spanner supports three transaction modes: 1. Locking read-write. This type of transaction is the only way to write data into Cloud Spanner. These transactions rely on pessimistic locking and, if necessary, two-phase commit. Locking read-write transactions may abort, requiring the application to retry. 2. Snapshot read-only. Snapshot read-only transactions provide guaranteed consistency across several reads, but do not allow writes. Snapshot read-only transactions can be configured to read at timestamps in the past, or configured to perform a strong read (where Spanner will select a timestamp such that the read is guaranteed to see the effects of all transactions that have committed before the start of the read). Snapshot read-only transactions do not need to be committed. Queries on change streams must be performed with the snapshot read-only transaction mode, specifying a strong read. See TransactionOptions.ReadOnly.strong for more details. 3. Partitioned DML. This type of transaction is used to execute a single Partitioned DML statement. Partitioned DML partitions the key space and runs the DML statement over each partition in parallel using separate, internal transactions that commit independently. Partitioned DML transactions do not need to be committed. For transactions that only read, snapshot read-only transactions provide simpler semantics and are almost always faster. In particular, read-only transactions do not take locks, so they do not conflict with read-write transactions. As a consequence of not taking locks, they also do not abort, so retry loops are not needed. Transactions may only read-write data in a single database. They may, however, read-write data in different tables within that database. Locking read-write transactions: Locking transactions may be used to atomically read-modify-write data anywhere in a database. This type of transaction is externally consistent. Clients should attempt to minimize the amount of time a transaction is active. Faster transactions commit with higher probability and cause less contention. Cloud Spanner attempts to keep read locks active as long as the transaction continues to do reads, and the transaction has not been terminated by Commit or Rollback. Long periods of inactivity at the client may cause Cloud Spanner to release a transaction's locks and abort it. Conceptually, a read-write transaction consists of zero or more reads or SQL statements followed by Commit. At any time before Commit, the client can send a Rollback request to abort the transaction. Semantics: Cloud Spanner can commit the transaction if all read locks it acquired are still valid at commit time, and it is able to acquire write locks for all writes. Cloud Spanner can abort the transaction for any reason. If a commit attempt returns `ABORTED`, Cloud Spanner guarantees that the transaction has not modified any user data in Cloud Spanner. Unless the transaction commits, Cloud Spanner makes no guarantees about how long the transaction's locks were held for. It is an error to use Cloud Spanner locks for any sort of mutual exclusion other than between Cloud Spanner transactions themselves. Retrying aborted transactions: When a transaction aborts, the application can choose to retry the whole transaction again. To maximize the chances of successfully committing the retry, the client should execute the retry in the same session as the original attempt. The original session's lock priority increases with each consecutive abort, meaning that each attempt has a slightly better chance of success than the previous. Note that the lock priority is preserved per session (not per transaction). Lock priority is set by the first read or write in the first attempt of a read-write transaction. If the application starts a new session to retry the whole transaction, the transaction loses its original lock priority. Moreover, the lock priority is only preserved if the transaction fails with an `ABORTED` error. Under some circumstances (for example, many transactions attempting to modify the same row(s)), a transaction can abort many times in a short period before successfully committing. Thus, it is not a good idea to cap the number of retries a transaction can attempt; instead, it is better to limit the total amount of time spent retrying. Idle transactions: A transaction is considered idle if it has no outstanding reads or SQL queries and has not started a read or SQL query within the last 10 seconds. Idle transactions can be aborted by Cloud Spanner so that they don't hold on to locks indefinitely. If an idle transaction is aborted, the commit will fail with error `ABORTED`. If this behavior is undesirable, periodically executing a simple SQL query in the transaction (for example, `SELECT 1`) prevents the transaction from becoming idle. Snapshot read-only transactions: Snapshot read-only transactions provides a simpler method than locking read-write transactions for doing several consistent reads. However, this type of transaction does not support writes. Snapshot transactions do not take locks. Instead, they work by choosing a Cloud Spanner timestamp, then executing all reads at that timestamp. Since they do not acquire locks, they do not block concurrent read-write transactions. Unlike locking read-write transactions, snapshot read-only transactions never abort. They can fail if the chosen read timestamp is garbage collected; however, the default garbage collection policy is generous enough that most applications do not need to worry about this in practice. Snapshot read-only transactions do not need to call Commit or Rollback (and in fact are not permitted to do so). To execute a snapshot transaction, the client specifies a timestamp bound, which tells Cloud Spanner how to choose a read timestamp. The types of timestamp bound are: - Strong (the default). - Bounded staleness. - Exact staleness. If the Cloud Spanner database to be read is geographically distributed, stale read-only transactions can execute more quickly than strong or read-write transactions, because they are able to execute far from the leader replica. Each type of timestamp bound is discussed in detail below. Strong: Strong reads are guaranteed to see the effects of all transactions that have committed before the start of the read. Furthermore, all rows yielded by a single read are consistent with each other -- if any part of the read observes a transaction, all parts of the read see the transaction. Strong reads are not repeatable: two consecutive strong read-only transactions might return inconsistent results if there are concurrent writes. If consistency across reads is required, the reads should be executed within a transaction or at an exact read timestamp. Queries on change streams (see below for more details) must also specify the strong read timestamp bound. See TransactionOptions.ReadOnly.strong. Exact staleness: These timestamp bounds execute reads at a user-specified timestamp. Reads at a timestamp are guaranteed to see a consistent prefix of the global transaction history: they observe modifications done by all transactions with a commit timestamp less than or equal to the read timestamp, and observe none of the modifications done by transactions with a larger commit timestamp. They will block until all conflicting transactions that may be assigned commit timestamps <= the read timestamp have finished. The timestamp can either be expressed as an absolute Cloud Spanner commit timestamp or a staleness relative to the current time. These modes do not require a "negotiation phase" to pick a timestamp. As a result, they execute slightly faster than the equivalent boundedly stale concurrency modes. On the other hand, boundedly stale reads usually return fresher results. See TransactionOptions.ReadOnly.read_timestamp and TransactionOptions.ReadOnly.exact_staleness. Bounded staleness: Bounded staleness modes allow Cloud Spanner to pick the read timestamp, subject to a user-provided staleness bound. Cloud Spanner chooses the newest timestamp within the staleness bound that allows execution of the reads at the closest available replica without blocking. All rows yielded are consistent with each other -- if any part of the read observes a transaction, all parts of the read see the transaction. Boundedly stale reads are not repeatable: two stale reads, even if they use the same staleness bound, can execute at different timestamps and thus return inconsistent results. Boundedly stale reads execute in two phases: the first phase negotiates a timestamp among all replicas needed to serve the read. In the second phase, reads are executed at the negotiated timestamp. As a result of the two phase execution, bounded staleness reads are usually a little slower than comparable exact staleness reads. However, they are typically able to return fresher results, and are more likely to execute at the closest replica. Because the timestamp negotiation requires up-front knowledge of which rows will be read, it can only be used with single-use read-only transactions. See TransactionOptions.ReadOnly.max_staleness and TransactionOptions.ReadOnly.min_read_timestamp. Old read timestamps and garbage collection: Cloud Spanner continuously garbage collects deleted and overwritten data in the background to reclaim storage space. This process is known as "version GC". By default, version GC reclaims versions after they are one hour old. Because of this, Cloud Spanner cannot perform reads at read timestamps more than one hour in the past. This restriction also applies to in-progress reads and/or SQL queries whose timestamp become too old while executing. Reads and SQL queries with too-old read timestamps fail with the error `FAILED_PRECONDITION`. You can configure and extend the `VERSION_RETENTION_PERIOD` of a database up to a period as long as one week, which allows Cloud Spanner to perform reads up to one week in the past. Querying change Streams: A Change Stream is a schema object that can be configured to watch data changes on the entire database, a set of tables, or a set of columns in a database. When a change stream is created, Spanner automatically defines a corresponding SQL Table-Valued Function (TVF) that can be used to query the change records in the associated change stream using the ExecuteStreamingSql API. The name of the TVF for a change stream is generated from the name of the change stream: READ_. All queries on change stream TVFs must be executed using the ExecuteStreamingSql API with a single-use read-only transaction with a strong read-only timestamp_bound. The change stream TVF allows users to specify the start_timestamp and end_timestamp for the time range of interest. All change records within the retention period is accessible using the strong read-only timestamp_bound. All other TransactionOptions are invalid for change stream queries. In addition, if TransactionOptions.read_only.return_read_timestamp is set to true, a special value of 2^63 - 2 will be returned in the Transaction message that describes the transaction, instead of a valid read timestamp. This special value should be discarded and not used for any subsequent queries. Please see https://cloud.google.com/spanner/docs/change-streams for more details on how to query the change stream TVFs. Partitioned DML transactions: Partitioned DML transactions are used to execute DML statements with a different execution strategy that provides different, and often better, scalability properties for large, table-wide operations than DML in a ReadWrite transaction. Smaller scoped statements, such as an OLTP workload, should prefer using ReadWrite transactions. Partitioned DML partitions the keyspace and runs the DML statement on each partition in separate, internal transactions. These transactions commit automatically when complete, and run independently from one another. To reduce lock contention, this execution strategy only acquires read locks on rows that match the WHERE clause of the statement. Additionally, the smaller per-partition transactions hold locks for less time. That said, Partitioned DML is not a drop-in replacement for standard DML used in ReadWrite transactions. - The DML statement must be fully-partitionable. Specifically, the statement must be expressible as the union of many statements which each access only a single row of the table. - The statement is not applied atomically to all rows of the table. Rather, the statement is applied atomically to partitions of the table, in independent transactions. Secondary index rows are updated atomically with the base table rows. - Partitioned DML does not guarantee exactly-once execution semantics against a partition. The statement is applied at least once to each partition. It is strongly recommended that the DML statement should be idempotent to avoid unexpected results. For instance, it is potentially dangerous to run a statement such as `UPDATE table SET column = column + 1` as it could be run multiple times against some rows. - The partitions are committed automatically - there is no support for Commit or Rollback. If the call returns an error, or if the client issuing the ExecuteSql call dies, it is possible that some rows had the statement executed on them successfully. It is also possible that statement was never executed against other rows. - Partitioned DML transactions may only contain the execution of a single DML statement via ExecuteSql or ExecuteStreamingSql. - If any error is encountered during the execution of the partitioned DML operation (for instance, a UNIQUE INDEX violation, division by zero, or a value that cannot be stored due to schema constraints), then the operation is stopped at that point and an error is returned. It is possible that at this point, some partitions have been committed (or even committed multiple times), and other partitions have not been run at all. Given the above, Partitioned DML is good fit for large, database-wide, operations that are idempotent, such as deleting old rows from a very large table.
2883///
2884/// This type is not used in any activity, and only used as *part* of another schema.
2885///
2886#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2887#[serde_with::serde_as]
2888#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2889pub struct TransactionOptions {
2890 /// When `exclude_txn_from_change_streams` is set to `true`: * Modifications from this transaction will not be recorded in change streams with DDL option `allow_txn_exclusion=true` that are tracking columns modified by these transactions. * Modifications from this transaction will be recorded in change streams with DDL option `allow_txn_exclusion=false or not set` that are tracking columns modified by these transactions. When `exclude_txn_from_change_streams` is set to `false` or not set, Modifications from this transaction will be recorded in all change streams that are tracking columns modified by these transactions. `exclude_txn_from_change_streams` may only be specified for read-write or partitioned-dml transactions, otherwise the API will return an `INVALID_ARGUMENT` error.
2891 #[serde(rename = "excludeTxnFromChangeStreams")]
2892 pub exclude_txn_from_change_streams: Option<bool>,
2893 /// Partitioned DML transaction. Authorization to begin a Partitioned DML transaction requires `spanner.databases.beginPartitionedDmlTransaction` permission on the `session` resource.
2894 #[serde(rename = "partitionedDml")]
2895 pub partitioned_dml: Option<PartitionedDml>,
2896 /// Transaction will not write. Authorization to begin a read-only transaction requires `spanner.databases.beginReadOnlyTransaction` permission on the `session` resource.
2897 #[serde(rename = "readOnly")]
2898 pub read_only: Option<ReadOnly>,
2899 /// Transaction may write. Authorization to begin a read-write transaction requires `spanner.databases.beginOrRollbackReadWriteTransaction` permission on the `session` resource.
2900 #[serde(rename = "readWrite")]
2901 pub read_write: Option<ReadWrite>,
2902}
2903
2904impl common::Part for TransactionOptions {}
2905
2906/// This message is used to select the transaction in which a Read or ExecuteSql call runs. See TransactionOptions for more information about transactions.
2907///
2908/// This type is not used in any activity, and only used as *part* of another schema.
2909///
2910#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2911#[serde_with::serde_as]
2912#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2913pub struct TransactionSelector {
2914 /// 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.
2915 pub begin: Option<TransactionOptions>,
2916 /// Execute the read or SQL query in a previously-started transaction.
2917 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2918 pub id: Option<Vec<u8>>,
2919 /// 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.
2920 #[serde(rename = "singleUse")]
2921 pub single_use: Option<TransactionOptions>,
2922}
2923
2924impl common::Part for TransactionSelector {}
2925
2926/// `Type` indicates the type of a Cloud Spanner value, as might be stored in a table cell or returned from an SQL query.
2927///
2928/// This type is not used in any activity, and only used as *part* of another schema.
2929///
2930#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2931#[serde_with::serde_as]
2932#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2933pub struct Type {
2934 /// If code == ARRAY, then `array_element_type` is the type of the array elements.
2935 #[serde(rename = "arrayElementType")]
2936 pub array_element_type: Option<Option<Box<Type>>>,
2937 /// Required. The TypeCode for this type.
2938 pub code: Option<String>,
2939 /// If code == PROTO or code == ENUM, then `proto_type_fqn` is the fully qualified name of the proto type representing the proto/enum definition.
2940 #[serde(rename = "protoTypeFqn")]
2941 pub proto_type_fqn: Option<String>,
2942 /// If code == STRUCT, then `struct_type` provides type information for the struct's fields.
2943 #[serde(rename = "structType")]
2944 pub struct_type: Option<StructType>,
2945 /// 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.
2946 #[serde(rename = "typeAnnotation")]
2947 pub type_annotation: Option<String>,
2948}
2949
2950impl common::Part for Type {}
2951
2952/// 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 (e.g., 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.
2953///
2954/// # Activities
2955///
2956/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2957/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2958///
2959/// * [instances databases update ddl projects](ProjectInstanceDatabaseUpdateDdlCall) (request)
2960#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2961#[serde_with::serde_as]
2962#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2963pub struct UpdateDatabaseDdlRequest {
2964 /// 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`.
2965 #[serde(rename = "operationId")]
2966 pub operation_id: Option<String>,
2967 /// 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).
2968 #[serde(rename = "protoDescriptors")]
2969 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2970 pub proto_descriptors: Option<Vec<u8>>,
2971 /// Required. DDL statements to be applied to the database.
2972 pub statements: Option<Vec<String>>,
2973}
2974
2975impl common::RequestValue for UpdateDatabaseDdlRequest {}
2976
2977/// The request for UpdateInstanceConfigRequest.
2978///
2979/// # Activities
2980///
2981/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2982/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2983///
2984/// * [instance configs patch projects](ProjectInstanceConfigPatchCall) (request)
2985#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2986#[serde_with::serde_as]
2987#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2988pub struct UpdateInstanceConfigRequest {
2989 /// Required. The user instance config to update, which must always include the instance config name. Otherwise, only fields mentioned in update_mask need be included. To prevent conflicts of concurrent updates, etag can be used.
2990 #[serde(rename = "instanceConfig")]
2991 pub instance_config: Option<InstanceConfig>,
2992 /// 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.
2993 #[serde(rename = "updateMask")]
2994 pub update_mask: Option<common::FieldMask>,
2995 /// An option to validate, but not actually execute, a request, and provide the same response.
2996 #[serde(rename = "validateOnly")]
2997 pub validate_only: Option<bool>,
2998}
2999
3000impl common::RequestValue for UpdateInstanceConfigRequest {}
3001
3002/// The request for UpdateInstancePartition.
3003///
3004/// # Activities
3005///
3006/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3007/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3008///
3009/// * [instances instance partitions patch projects](ProjectInstanceInstancePartitionPatchCall) (request)
3010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3011#[serde_with::serde_as]
3012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3013pub struct UpdateInstancePartitionRequest {
3014 /// 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.
3015 #[serde(rename = "fieldMask")]
3016 pub field_mask: Option<common::FieldMask>,
3017 /// Required. The instance partition to update, which must always include the instance partition name. Otherwise, only fields mentioned in field_mask need be included.
3018 #[serde(rename = "instancePartition")]
3019 pub instance_partition: Option<InstancePartition>,
3020}
3021
3022impl common::RequestValue for UpdateInstancePartitionRequest {}
3023
3024/// The request for UpdateInstance.
3025///
3026/// # Activities
3027///
3028/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3029/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3030///
3031/// * [instances patch projects](ProjectInstancePatchCall) (request)
3032#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3033#[serde_with::serde_as]
3034#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3035pub struct UpdateInstanceRequest {
3036 /// 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.
3037 #[serde(rename = "fieldMask")]
3038 pub field_mask: Option<common::FieldMask>,
3039 /// Required. The instance to update, which must always include the instance name. Otherwise, only fields mentioned in field_mask need be included.
3040 pub instance: Option<Instance>,
3041}
3042
3043impl common::RequestValue for UpdateInstanceRequest {}
3044
3045/// There is no detailed description.
3046///
3047/// This type is not used in any activity, and only used as *part* of another schema.
3048///
3049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3050#[serde_with::serde_as]
3051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3052pub struct VisualizationData {
3053 /// The token signifying the end of a data_source.
3054 #[serde(rename = "dataSourceEndToken")]
3055 pub data_source_end_token: Option<String>,
3056 /// The token delimiting a datasource name from the rest of a key in a data_source.
3057 #[serde(rename = "dataSourceSeparatorToken")]
3058 pub data_source_separator_token: Option<String>,
3059 /// The list of messages (info, alerts, ...)
3060 #[serde(rename = "diagnosticMessages")]
3061 pub diagnostic_messages: Option<Vec<DiagnosticMessage>>,
3062 /// 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
3063 #[serde(rename = "endKeyStrings")]
3064 pub end_key_strings: Option<Vec<String>>,
3065 /// Whether this scan contains PII.
3066 #[serde(rename = "hasPii")]
3067 pub has_pii: Option<bool>,
3068 /// Keys of key ranges that contribute significantly to a given metric Can be thought of as heavy hitters.
3069 #[serde(rename = "indexedKeys")]
3070 pub indexed_keys: Option<Vec<String>>,
3071 /// The token delimiting the key prefixes.
3072 #[serde(rename = "keySeparator")]
3073 pub key_separator: Option<String>,
3074 /// The unit for the key: e.g. 'key' or 'chunk'.
3075 #[serde(rename = "keyUnit")]
3076 pub key_unit: Option<String>,
3077 /// The list of data objects for each metric.
3078 pub metrics: Option<Vec<Metric>>,
3079 /// The list of extracted key prefix nodes used in the key prefix hierarchy.
3080 #[serde(rename = "prefixNodes")]
3081 pub prefix_nodes: Option<Vec<PrefixNode>>,
3082}
3083
3084impl common::Part for VisualizationData {}
3085
3086/// Arguments to insert, update, insert_or_update, and replace operations.
3087///
3088/// This type is not used in any activity, and only used as *part* of another schema.
3089///
3090#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3091#[serde_with::serde_as]
3092#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3093pub struct Write {
3094 /// 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.
3095 pub columns: Option<Vec<String>>,
3096 /// Required. The table whose rows will be written.
3097 pub table: Option<String>,
3098 /// 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.
3099 pub values: Option<Vec<Vec<serde_json::Value>>>,
3100}
3101
3102impl common::Part for Write {}
3103
3104// ###################
3105// MethodBuilders ###
3106// #################
3107
3108/// A builder providing access to all methods supported on *project* resources.
3109/// It is not used directly, but through the [`Spanner`] hub.
3110///
3111/// # Example
3112///
3113/// Instantiate a resource builder
3114///
3115/// ```test_harness,no_run
3116/// extern crate hyper;
3117/// extern crate hyper_rustls;
3118/// extern crate google_spanner1 as spanner1;
3119///
3120/// # async fn dox() {
3121/// use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3122///
3123/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3124/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3125/// secret,
3126/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3127/// ).build().await.unwrap();
3128///
3129/// let client = hyper_util::client::legacy::Client::builder(
3130/// hyper_util::rt::TokioExecutor::new()
3131/// )
3132/// .build(
3133/// hyper_rustls::HttpsConnectorBuilder::new()
3134/// .with_native_roots()
3135/// .unwrap()
3136/// .https_or_http()
3137/// .enable_http1()
3138/// .build()
3139/// );
3140/// let mut hub = Spanner::new(client, auth);
3141/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3142/// // 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_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_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(...)`
3143/// // to build up your call.
3144/// let rb = hub.projects();
3145/// # }
3146/// ```
3147pub struct ProjectMethods<'a, C>
3148where
3149 C: 'a,
3150{
3151 hub: &'a Spanner<C>,
3152}
3153
3154impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3155
3156impl<'a, C> ProjectMethods<'a, C> {
3157 /// Create a builder to help you perform the following task:
3158 ///
3159 /// Lists the user-managed instance config long-running operations in the given project. An instance config 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.
3160 ///
3161 /// # Arguments
3162 ///
3163 /// * `parent` - Required. The project of the instance config operations. Values are of the form `projects/`.
3164 pub fn instance_config_operations_list(
3165 &self,
3166 parent: &str,
3167 ) -> ProjectInstanceConfigOperationListCall<'a, C> {
3168 ProjectInstanceConfigOperationListCall {
3169 hub: self.hub,
3170 _parent: parent.to_string(),
3171 _page_token: Default::default(),
3172 _page_size: Default::default(),
3173 _filter: Default::default(),
3174 _delegate: Default::default(),
3175 _additional_params: Default::default(),
3176 _scopes: Default::default(),
3177 }
3178 }
3179
3180 /// Create a builder to help you perform the following task:
3181 ///
3182 /// 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`.
3183 ///
3184 /// # Arguments
3185 ///
3186 /// * `name` - The name of the operation resource to be cancelled.
3187 pub fn instance_configs_operations_cancel(
3188 &self,
3189 name: &str,
3190 ) -> ProjectInstanceConfigOperationCancelCall<'a, C> {
3191 ProjectInstanceConfigOperationCancelCall {
3192 hub: self.hub,
3193 _name: name.to_string(),
3194 _delegate: Default::default(),
3195 _additional_params: Default::default(),
3196 _scopes: Default::default(),
3197 }
3198 }
3199
3200 /// Create a builder to help you perform the following task:
3201 ///
3202 /// 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`.
3203 ///
3204 /// # Arguments
3205 ///
3206 /// * `name` - The name of the operation resource to be deleted.
3207 pub fn instance_configs_operations_delete(
3208 &self,
3209 name: &str,
3210 ) -> ProjectInstanceConfigOperationDeleteCall<'a, C> {
3211 ProjectInstanceConfigOperationDeleteCall {
3212 hub: self.hub,
3213 _name: name.to_string(),
3214 _delegate: Default::default(),
3215 _additional_params: Default::default(),
3216 _scopes: Default::default(),
3217 }
3218 }
3219
3220 /// Create a builder to help you perform the following task:
3221 ///
3222 /// 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.
3223 ///
3224 /// # Arguments
3225 ///
3226 /// * `name` - The name of the operation resource.
3227 pub fn instance_configs_operations_get(
3228 &self,
3229 name: &str,
3230 ) -> ProjectInstanceConfigOperationGetCall<'a, C> {
3231 ProjectInstanceConfigOperationGetCall {
3232 hub: self.hub,
3233 _name: name.to_string(),
3234 _delegate: Default::default(),
3235 _additional_params: Default::default(),
3236 _scopes: Default::default(),
3237 }
3238 }
3239
3240 /// Create a builder to help you perform the following task:
3241 ///
3242 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3243 ///
3244 /// # Arguments
3245 ///
3246 /// * `name` - The name of the operation's parent resource.
3247 pub fn instance_configs_operations_list(
3248 &self,
3249 name: &str,
3250 ) -> ProjectInstanceConfigOperationListCall1<'a, C> {
3251 ProjectInstanceConfigOperationListCall1 {
3252 hub: self.hub,
3253 _name: name.to_string(),
3254 _page_token: Default::default(),
3255 _page_size: Default::default(),
3256 _filter: Default::default(),
3257 _delegate: Default::default(),
3258 _additional_params: Default::default(),
3259 _scopes: Default::default(),
3260 }
3261 }
3262
3263 /// Create a builder to help you perform the following task:
3264 ///
3265 /// 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`.
3266 ///
3267 /// # Arguments
3268 ///
3269 /// * `name` - The name of the operation resource to be cancelled.
3270 pub fn instance_configs_ssd_caches_operations_cancel(
3271 &self,
3272 name: &str,
3273 ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {
3274 ProjectInstanceConfigSsdCachOperationCancelCall {
3275 hub: self.hub,
3276 _name: name.to_string(),
3277 _delegate: Default::default(),
3278 _additional_params: Default::default(),
3279 _scopes: Default::default(),
3280 }
3281 }
3282
3283 /// Create a builder to help you perform the following task:
3284 ///
3285 /// 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`.
3286 ///
3287 /// # Arguments
3288 ///
3289 /// * `name` - The name of the operation resource to be deleted.
3290 pub fn instance_configs_ssd_caches_operations_delete(
3291 &self,
3292 name: &str,
3293 ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {
3294 ProjectInstanceConfigSsdCachOperationDeleteCall {
3295 hub: self.hub,
3296 _name: name.to_string(),
3297 _delegate: Default::default(),
3298 _additional_params: Default::default(),
3299 _scopes: Default::default(),
3300 }
3301 }
3302
3303 /// Create a builder to help you perform the following task:
3304 ///
3305 /// 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.
3306 ///
3307 /// # Arguments
3308 ///
3309 /// * `name` - The name of the operation resource.
3310 pub fn instance_configs_ssd_caches_operations_get(
3311 &self,
3312 name: &str,
3313 ) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {
3314 ProjectInstanceConfigSsdCachOperationGetCall {
3315 hub: self.hub,
3316 _name: name.to_string(),
3317 _delegate: Default::default(),
3318 _additional_params: Default::default(),
3319 _scopes: Default::default(),
3320 }
3321 }
3322
3323 /// Create a builder to help you perform the following task:
3324 ///
3325 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3326 ///
3327 /// # Arguments
3328 ///
3329 /// * `name` - The name of the operation's parent resource.
3330 pub fn instance_configs_ssd_caches_operations_list(
3331 &self,
3332 name: &str,
3333 ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
3334 ProjectInstanceConfigSsdCachOperationListCall {
3335 hub: self.hub,
3336 _name: name.to_string(),
3337 _page_token: Default::default(),
3338 _page_size: Default::default(),
3339 _filter: Default::default(),
3340 _delegate: Default::default(),
3341 _additional_params: Default::default(),
3342 _scopes: Default::default(),
3343 }
3344 }
3345
3346 /// Create a builder to help you perform the following task:
3347 ///
3348 /// Creates an instance config and begins preparing it to be used. The returned long-running operation can be used to track the progress of preparing the new instance config. The instance config name is assigned by the caller. If the named instance config already exists, `CreateInstanceConfig` returns `ALREADY_EXISTS`. Immediately after the request returns: * The instance config is readable via the API, with all requested attributes. The instance config's reconciling field is set to true. Its state is `CREATING`. While the operation is pending: * Cancelling the operation renders the instance config immediately unreadable via the API. * Except for deleting the creating resource, all other attempts to modify the instance config are rejected. Upon completion of the returned operation: * Instances can be created using the instance configuration. * The instance config'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 config. The metadata field type is CreateInstanceConfigMetadata. The response field type is InstanceConfig, if successful. Authorization requires `spanner.instanceConfigs.create` permission on the resource parent.
3349 ///
3350 /// # Arguments
3351 ///
3352 /// * `request` - No description provided.
3353 /// * `parent` - Required. The name of the project in which to create the instance config. Values are of the form `projects/`.
3354 pub fn instance_configs_create(
3355 &self,
3356 request: CreateInstanceConfigRequest,
3357 parent: &str,
3358 ) -> ProjectInstanceConfigCreateCall<'a, C> {
3359 ProjectInstanceConfigCreateCall {
3360 hub: self.hub,
3361 _request: request,
3362 _parent: parent.to_string(),
3363 _delegate: Default::default(),
3364 _additional_params: Default::default(),
3365 _scopes: Default::default(),
3366 }
3367 }
3368
3369 /// Create a builder to help you perform the following task:
3370 ///
3371 /// Deletes the instance config. Deletion is only allowed when no instances are using the configuration. If any instances are using the config, returns `FAILED_PRECONDITION`. Only user managed configurations can be deleted. Authorization requires `spanner.instanceConfigs.delete` permission on the resource name.
3372 ///
3373 /// # Arguments
3374 ///
3375 /// * `name` - Required. The name of the instance configuration to be deleted. Values are of the form `projects//instanceConfigs/`
3376 pub fn instance_configs_delete(&self, name: &str) -> ProjectInstanceConfigDeleteCall<'a, C> {
3377 ProjectInstanceConfigDeleteCall {
3378 hub: self.hub,
3379 _name: name.to_string(),
3380 _validate_only: Default::default(),
3381 _etag: Default::default(),
3382 _delegate: Default::default(),
3383 _additional_params: Default::default(),
3384 _scopes: Default::default(),
3385 }
3386 }
3387
3388 /// Create a builder to help you perform the following task:
3389 ///
3390 /// Gets information about a particular instance configuration.
3391 ///
3392 /// # Arguments
3393 ///
3394 /// * `name` - Required. The name of the requested instance configuration. Values are of the form `projects//instanceConfigs/`.
3395 pub fn instance_configs_get(&self, name: &str) -> ProjectInstanceConfigGetCall<'a, C> {
3396 ProjectInstanceConfigGetCall {
3397 hub: self.hub,
3398 _name: name.to_string(),
3399 _delegate: Default::default(),
3400 _additional_params: Default::default(),
3401 _scopes: Default::default(),
3402 }
3403 }
3404
3405 /// Create a builder to help you perform the following task:
3406 ///
3407 /// Lists the supported instance configurations for a given project. Returns both Google managed configs and user managed configs.
3408 ///
3409 /// # Arguments
3410 ///
3411 /// * `parent` - Required. The name of the project for which a list of supported instance configurations is requested. Values are of the form `projects/`.
3412 pub fn instance_configs_list(&self, parent: &str) -> ProjectInstanceConfigListCall<'a, C> {
3413 ProjectInstanceConfigListCall {
3414 hub: self.hub,
3415 _parent: parent.to_string(),
3416 _page_token: Default::default(),
3417 _page_size: Default::default(),
3418 _delegate: Default::default(),
3419 _additional_params: Default::default(),
3420 _scopes: Default::default(),
3421 }
3422 }
3423
3424 /// Create a builder to help you perform the following task:
3425 ///
3426 /// Updates an instance config. The returned long-running operation can be used to track the progress of updating the instance. If the named instance config does not exist, returns `NOT_FOUND`. Only user managed configurations can be updated. Immediately after the request returns: * The instance config'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 config are rejected. * Reading the instance config 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 instance config's new values are readable via the API. * The instance config'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 config 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.
3427 ///
3428 /// # Arguments
3429 ///
3430 /// * `request` - No description provided.
3431 /// * `name` - A unique identifier for the instance configuration. Values are of the form `projects//instanceConfigs/a-z*`. User instance config must start with `custom-`.
3432 pub fn instance_configs_patch(
3433 &self,
3434 request: UpdateInstanceConfigRequest,
3435 name: &str,
3436 ) -> ProjectInstanceConfigPatchCall<'a, C> {
3437 ProjectInstanceConfigPatchCall {
3438 hub: self.hub,
3439 _request: request,
3440 _name: name.to_string(),
3441 _delegate: Default::default(),
3442 _additional_params: Default::default(),
3443 _scopes: Default::default(),
3444 }
3445 }
3446
3447 /// Create a builder to help you perform the following task:
3448 ///
3449 /// 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.
3450 ///
3451 /// # Arguments
3452 ///
3453 /// * `parent` - Required. The instance of the backup operations. Values are of the form `projects//instances/`.
3454 pub fn instances_backup_operations_list(
3455 &self,
3456 parent: &str,
3457 ) -> ProjectInstanceBackupOperationListCall<'a, C> {
3458 ProjectInstanceBackupOperationListCall {
3459 hub: self.hub,
3460 _parent: parent.to_string(),
3461 _page_token: Default::default(),
3462 _page_size: Default::default(),
3463 _filter: Default::default(),
3464 _delegate: Default::default(),
3465 _additional_params: Default::default(),
3466 _scopes: Default::default(),
3467 }
3468 }
3469
3470 /// Create a builder to help you perform the following task:
3471 ///
3472 /// 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`.
3473 ///
3474 /// # Arguments
3475 ///
3476 /// * `name` - The name of the operation resource to be cancelled.
3477 pub fn instances_backups_operations_cancel(
3478 &self,
3479 name: &str,
3480 ) -> ProjectInstanceBackupOperationCancelCall<'a, C> {
3481 ProjectInstanceBackupOperationCancelCall {
3482 hub: self.hub,
3483 _name: name.to_string(),
3484 _delegate: Default::default(),
3485 _additional_params: Default::default(),
3486 _scopes: Default::default(),
3487 }
3488 }
3489
3490 /// Create a builder to help you perform the following task:
3491 ///
3492 /// 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`.
3493 ///
3494 /// # Arguments
3495 ///
3496 /// * `name` - The name of the operation resource to be deleted.
3497 pub fn instances_backups_operations_delete(
3498 &self,
3499 name: &str,
3500 ) -> ProjectInstanceBackupOperationDeleteCall<'a, C> {
3501 ProjectInstanceBackupOperationDeleteCall {
3502 hub: self.hub,
3503 _name: name.to_string(),
3504 _delegate: Default::default(),
3505 _additional_params: Default::default(),
3506 _scopes: Default::default(),
3507 }
3508 }
3509
3510 /// Create a builder to help you perform the following task:
3511 ///
3512 /// 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.
3513 ///
3514 /// # Arguments
3515 ///
3516 /// * `name` - The name of the operation resource.
3517 pub fn instances_backups_operations_get(
3518 &self,
3519 name: &str,
3520 ) -> ProjectInstanceBackupOperationGetCall<'a, C> {
3521 ProjectInstanceBackupOperationGetCall {
3522 hub: self.hub,
3523 _name: name.to_string(),
3524 _delegate: Default::default(),
3525 _additional_params: Default::default(),
3526 _scopes: Default::default(),
3527 }
3528 }
3529
3530 /// Create a builder to help you perform the following task:
3531 ///
3532 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3533 ///
3534 /// # Arguments
3535 ///
3536 /// * `name` - The name of the operation's parent resource.
3537 pub fn instances_backups_operations_list(
3538 &self,
3539 name: &str,
3540 ) -> ProjectInstanceBackupOperationListCall1<'a, C> {
3541 ProjectInstanceBackupOperationListCall1 {
3542 hub: self.hub,
3543 _name: name.to_string(),
3544 _page_token: Default::default(),
3545 _page_size: Default::default(),
3546 _filter: Default::default(),
3547 _delegate: Default::default(),
3548 _additional_params: Default::default(),
3549 _scopes: Default::default(),
3550 }
3551 }
3552
3553 /// Create a builder to help you perform the following task:
3554 ///
3555 /// 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.
3556 ///
3557 /// # Arguments
3558 ///
3559 /// * `request` - No description provided.
3560 /// * `parent` - Required. The name of the destination instance that will contain the backup copy. Values are of the form: `projects//instances/`.
3561 pub fn instances_backups_copy(
3562 &self,
3563 request: CopyBackupRequest,
3564 parent: &str,
3565 ) -> ProjectInstanceBackupCopyCall<'a, C> {
3566 ProjectInstanceBackupCopyCall {
3567 hub: self.hub,
3568 _request: request,
3569 _parent: parent.to_string(),
3570 _delegate: Default::default(),
3571 _additional_params: Default::default(),
3572 _scopes: Default::default(),
3573 }
3574 }
3575
3576 /// Create a builder to help you perform the following task:
3577 ///
3578 /// 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.
3579 ///
3580 /// # Arguments
3581 ///
3582 /// * `request` - No description provided.
3583 /// * `parent` - Required. The name of the instance in which the backup will be created. This must be the same instance that contains the database the backup will be created from. The backup will be stored in the location(s) specified in the instance configuration of this instance. Values are of the form `projects//instances/`.
3584 pub fn instances_backups_create(
3585 &self,
3586 request: Backup,
3587 parent: &str,
3588 ) -> ProjectInstanceBackupCreateCall<'a, C> {
3589 ProjectInstanceBackupCreateCall {
3590 hub: self.hub,
3591 _request: request,
3592 _parent: parent.to_string(),
3593 _encryption_config_kms_key_names: Default::default(),
3594 _encryption_config_kms_key_name: Default::default(),
3595 _encryption_config_encryption_type: Default::default(),
3596 _backup_id: Default::default(),
3597 _delegate: Default::default(),
3598 _additional_params: Default::default(),
3599 _scopes: Default::default(),
3600 }
3601 }
3602
3603 /// Create a builder to help you perform the following task:
3604 ///
3605 /// Deletes a pending or completed Backup.
3606 ///
3607 /// # Arguments
3608 ///
3609 /// * `name` - Required. Name of the backup to delete. Values are of the form `projects//instances//backups/`.
3610 pub fn instances_backups_delete(&self, name: &str) -> ProjectInstanceBackupDeleteCall<'a, C> {
3611 ProjectInstanceBackupDeleteCall {
3612 hub: self.hub,
3613 _name: name.to_string(),
3614 _delegate: Default::default(),
3615 _additional_params: Default::default(),
3616 _scopes: Default::default(),
3617 }
3618 }
3619
3620 /// Create a builder to help you perform the following task:
3621 ///
3622 /// Gets metadata on a pending or completed Backup.
3623 ///
3624 /// # Arguments
3625 ///
3626 /// * `name` - Required. Name of the backup. Values are of the form `projects//instances//backups/`.
3627 pub fn instances_backups_get(&self, name: &str) -> ProjectInstanceBackupGetCall<'a, C> {
3628 ProjectInstanceBackupGetCall {
3629 hub: self.hub,
3630 _name: name.to_string(),
3631 _delegate: Default::default(),
3632 _additional_params: Default::default(),
3633 _scopes: Default::default(),
3634 }
3635 }
3636
3637 /// Create a builder to help you perform the following task:
3638 ///
3639 /// 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.
3640 ///
3641 /// # Arguments
3642 ///
3643 /// * `request` - No description provided.
3644 /// * `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.
3645 pub fn instances_backups_get_iam_policy(
3646 &self,
3647 request: GetIamPolicyRequest,
3648 resource: &str,
3649 ) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
3650 ProjectInstanceBackupGetIamPolicyCall {
3651 hub: self.hub,
3652 _request: request,
3653 _resource: resource.to_string(),
3654 _delegate: Default::default(),
3655 _additional_params: Default::default(),
3656 _scopes: Default::default(),
3657 }
3658 }
3659
3660 /// Create a builder to help you perform the following task:
3661 ///
3662 /// Lists completed and pending backups. Backups returned are ordered by `create_time` in descending order, starting from the most recent `create_time`.
3663 ///
3664 /// # Arguments
3665 ///
3666 /// * `parent` - Required. The instance to list backups from. Values are of the form `projects//instances/`.
3667 pub fn instances_backups_list(&self, parent: &str) -> ProjectInstanceBackupListCall<'a, C> {
3668 ProjectInstanceBackupListCall {
3669 hub: self.hub,
3670 _parent: parent.to_string(),
3671 _page_token: Default::default(),
3672 _page_size: Default::default(),
3673 _filter: Default::default(),
3674 _delegate: Default::default(),
3675 _additional_params: Default::default(),
3676 _scopes: Default::default(),
3677 }
3678 }
3679
3680 /// Create a builder to help you perform the following task:
3681 ///
3682 /// Updates a pending or completed Backup.
3683 ///
3684 /// # Arguments
3685 ///
3686 /// * `request` - No description provided.
3687 /// * `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/`.
3688 pub fn instances_backups_patch(
3689 &self,
3690 request: Backup,
3691 name: &str,
3692 ) -> ProjectInstanceBackupPatchCall<'a, C> {
3693 ProjectInstanceBackupPatchCall {
3694 hub: self.hub,
3695 _request: request,
3696 _name: name.to_string(),
3697 _update_mask: Default::default(),
3698 _delegate: Default::default(),
3699 _additional_params: Default::default(),
3700 _scopes: Default::default(),
3701 }
3702 }
3703
3704 /// Create a builder to help you perform the following task:
3705 ///
3706 /// 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.
3707 ///
3708 /// # Arguments
3709 ///
3710 /// * `request` - No description provided.
3711 /// * `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.
3712 pub fn instances_backups_set_iam_policy(
3713 &self,
3714 request: SetIamPolicyRequest,
3715 resource: &str,
3716 ) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
3717 ProjectInstanceBackupSetIamPolicyCall {
3718 hub: self.hub,
3719 _request: request,
3720 _resource: resource.to_string(),
3721 _delegate: Default::default(),
3722 _additional_params: Default::default(),
3723 _scopes: Default::default(),
3724 }
3725 }
3726
3727 /// Create a builder to help you perform the following task:
3728 ///
3729 /// 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.
3730 ///
3731 /// # Arguments
3732 ///
3733 /// * `request` - No description provided.
3734 /// * `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.
3735 pub fn instances_backups_test_iam_permissions(
3736 &self,
3737 request: TestIamPermissionsRequest,
3738 resource: &str,
3739 ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
3740 ProjectInstanceBackupTestIamPermissionCall {
3741 hub: self.hub,
3742 _request: request,
3743 _resource: resource.to_string(),
3744 _delegate: Default::default(),
3745 _additional_params: Default::default(),
3746 _scopes: Default::default(),
3747 }
3748 }
3749
3750 /// Create a builder to help you perform the following task:
3751 ///
3752 /// 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.
3753 ///
3754 /// # Arguments
3755 ///
3756 /// * `parent` - Required. The instance of the database operations. Values are of the form `projects//instances/`.
3757 pub fn instances_database_operations_list(
3758 &self,
3759 parent: &str,
3760 ) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
3761 ProjectInstanceDatabaseOperationListCall {
3762 hub: self.hub,
3763 _parent: parent.to_string(),
3764 _page_token: Default::default(),
3765 _page_size: Default::default(),
3766 _filter: Default::default(),
3767 _delegate: Default::default(),
3768 _additional_params: Default::default(),
3769 _scopes: Default::default(),
3770 }
3771 }
3772
3773 /// Create a builder to help you perform the following task:
3774 ///
3775 /// Lists Cloud Spanner database roles.
3776 ///
3777 /// # Arguments
3778 ///
3779 /// * `parent` - Required. The database whose roles should be listed. Values are of the form `projects//instances//databases/`.
3780 pub fn instances_databases_database_roles_list(
3781 &self,
3782 parent: &str,
3783 ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
3784 ProjectInstanceDatabaseDatabaseRoleListCall {
3785 hub: self.hub,
3786 _parent: parent.to_string(),
3787 _page_token: Default::default(),
3788 _page_size: Default::default(),
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 /// 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.
3798 ///
3799 /// # Arguments
3800 ///
3801 /// * `request` - No description provided.
3802 /// * `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.
3803 pub fn instances_databases_database_roles_test_iam_permissions(
3804 &self,
3805 request: TestIamPermissionsRequest,
3806 resource: &str,
3807 ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
3808 ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall {
3809 hub: self.hub,
3810 _request: request,
3811 _resource: resource.to_string(),
3812 _delegate: Default::default(),
3813 _additional_params: Default::default(),
3814 _scopes: Default::default(),
3815 }
3816 }
3817
3818 /// Create a builder to help you perform the following task:
3819 ///
3820 /// 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`.
3821 ///
3822 /// # Arguments
3823 ///
3824 /// * `name` - The name of the operation resource to be cancelled.
3825 pub fn instances_databases_operations_cancel(
3826 &self,
3827 name: &str,
3828 ) -> ProjectInstanceDatabaseOperationCancelCall<'a, C> {
3829 ProjectInstanceDatabaseOperationCancelCall {
3830 hub: self.hub,
3831 _name: name.to_string(),
3832 _delegate: Default::default(),
3833 _additional_params: Default::default(),
3834 _scopes: Default::default(),
3835 }
3836 }
3837
3838 /// Create a builder to help you perform the following task:
3839 ///
3840 /// 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`.
3841 ///
3842 /// # Arguments
3843 ///
3844 /// * `name` - The name of the operation resource to be deleted.
3845 pub fn instances_databases_operations_delete(
3846 &self,
3847 name: &str,
3848 ) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C> {
3849 ProjectInstanceDatabaseOperationDeleteCall {
3850 hub: self.hub,
3851 _name: name.to_string(),
3852 _delegate: Default::default(),
3853 _additional_params: Default::default(),
3854 _scopes: Default::default(),
3855 }
3856 }
3857
3858 /// Create a builder to help you perform the following task:
3859 ///
3860 /// 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.
3861 ///
3862 /// # Arguments
3863 ///
3864 /// * `name` - The name of the operation resource.
3865 pub fn instances_databases_operations_get(
3866 &self,
3867 name: &str,
3868 ) -> ProjectInstanceDatabaseOperationGetCall<'a, C> {
3869 ProjectInstanceDatabaseOperationGetCall {
3870 hub: self.hub,
3871 _name: name.to_string(),
3872 _delegate: Default::default(),
3873 _additional_params: Default::default(),
3874 _scopes: Default::default(),
3875 }
3876 }
3877
3878 /// Create a builder to help you perform the following task:
3879 ///
3880 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3881 ///
3882 /// # Arguments
3883 ///
3884 /// * `name` - The name of the operation's parent resource.
3885 pub fn instances_databases_operations_list(
3886 &self,
3887 name: &str,
3888 ) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
3889 ProjectInstanceDatabaseOperationListCall1 {
3890 hub: self.hub,
3891 _name: name.to_string(),
3892 _page_token: Default::default(),
3893 _page_size: Default::default(),
3894 _filter: Default::default(),
3895 _delegate: Default::default(),
3896 _additional_params: Default::default(),
3897 _scopes: Default::default(),
3898 }
3899 }
3900
3901 /// Create a builder to help you perform the following task:
3902 ///
3903 /// 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.
3904 ///
3905 /// # Arguments
3906 ///
3907 /// * `request` - No description provided.
3908 /// * `database` - Required. The database in which the new sessions are created.
3909 pub fn instances_databases_sessions_batch_create(
3910 &self,
3911 request: BatchCreateSessionsRequest,
3912 database: &str,
3913 ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
3914 ProjectInstanceDatabaseSessionBatchCreateCall {
3915 hub: self.hub,
3916 _request: request,
3917 _database: database.to_string(),
3918 _delegate: Default::default(),
3919 _additional_params: Default::default(),
3920 _scopes: Default::default(),
3921 }
3922 }
3923
3924 /// Create a builder to help you perform the following task:
3925 ///
3926 /// 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, i.e., some groups may have been committed successfully, while some may 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 may be applied more than once. Replays of non-idempotent mutations may have undesirable effects. For example, replays of an insert mutation may produce an already exists error or if you use generated or commit timestamp-based keys, it may result in additional rows being added to the mutation's table. We recommend structuring your mutation groups to be idempotent to avoid this issue.
3927 ///
3928 /// # Arguments
3929 ///
3930 /// * `request` - No description provided.
3931 /// * `session` - Required. The session in which the batch request is to be run.
3932 pub fn instances_databases_sessions_batch_write(
3933 &self,
3934 request: BatchWriteRequest,
3935 session: &str,
3936 ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
3937 ProjectInstanceDatabaseSessionBatchWriteCall {
3938 hub: self.hub,
3939 _request: request,
3940 _session: session.to_string(),
3941 _delegate: Default::default(),
3942 _additional_params: Default::default(),
3943 _scopes: Default::default(),
3944 }
3945 }
3946
3947 /// Create a builder to help you perform the following task:
3948 ///
3949 /// Begins a new transaction. This step can often be skipped: Read, ExecuteSql and Commit can begin a new transaction as a side-effect.
3950 ///
3951 /// # Arguments
3952 ///
3953 /// * `request` - No description provided.
3954 /// * `session` - Required. The session in which the transaction runs.
3955 pub fn instances_databases_sessions_begin_transaction(
3956 &self,
3957 request: BeginTransactionRequest,
3958 session: &str,
3959 ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
3960 ProjectInstanceDatabaseSessionBeginTransactionCall {
3961 hub: self.hub,
3962 _request: request,
3963 _session: session.to_string(),
3964 _delegate: Default::default(),
3965 _additional_params: Default::default(),
3966 _scopes: Default::default(),
3967 }
3968 }
3969
3970 /// Create a builder to help you perform the following task:
3971 ///
3972 /// 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 re-attempt the transaction from the beginning, re-using 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.
3973 ///
3974 /// # Arguments
3975 ///
3976 /// * `request` - No description provided.
3977 /// * `session` - Required. The session in which the transaction to be committed is running.
3978 pub fn instances_databases_sessions_commit(
3979 &self,
3980 request: CommitRequest,
3981 session: &str,
3982 ) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
3983 ProjectInstanceDatabaseSessionCommitCall {
3984 hub: self.hub,
3985 _request: request,
3986 _session: session.to_string(),
3987 _delegate: Default::default(),
3988 _additional_params: Default::default(),
3989 _scopes: Default::default(),
3990 }
3991 }
3992
3993 /// Create a builder to help you perform the following task:
3994 ///
3995 /// 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 is a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner may delete sessions for which 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, e.g., `"SELECT 1"`.
3996 ///
3997 /// # Arguments
3998 ///
3999 /// * `request` - No description provided.
4000 /// * `database` - Required. The database in which the new session is created.
4001 pub fn instances_databases_sessions_create(
4002 &self,
4003 request: CreateSessionRequest,
4004 database: &str,
4005 ) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
4006 ProjectInstanceDatabaseSessionCreateCall {
4007 hub: self.hub,
4008 _request: request,
4009 _database: database.to_string(),
4010 _delegate: Default::default(),
4011 _additional_params: Default::default(),
4012 _scopes: Default::default(),
4013 }
4014 }
4015
4016 /// Create a builder to help you perform the following task:
4017 ///
4018 /// Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.
4019 ///
4020 /// # Arguments
4021 ///
4022 /// * `name` - Required. The name of the session to delete.
4023 pub fn instances_databases_sessions_delete(
4024 &self,
4025 name: &str,
4026 ) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C> {
4027 ProjectInstanceDatabaseSessionDeleteCall {
4028 hub: self.hub,
4029 _name: name.to_string(),
4030 _delegate: Default::default(),
4031 _additional_params: Default::default(),
4032 _scopes: Default::default(),
4033 }
4034 }
4035
4036 /// Create a builder to help you perform the following task:
4037 ///
4038 /// 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.
4039 ///
4040 /// # Arguments
4041 ///
4042 /// * `request` - No description provided.
4043 /// * `session` - Required. The session in which the DML statements should be performed.
4044 pub fn instances_databases_sessions_execute_batch_dml(
4045 &self,
4046 request: ExecuteBatchDmlRequest,
4047 session: &str,
4048 ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
4049 ProjectInstanceDatabaseSessionExecuteBatchDmlCall {
4050 hub: self.hub,
4051 _request: request,
4052 _session: session.to_string(),
4053 _delegate: Default::default(),
4054 _additional_params: Default::default(),
4055 _scopes: Default::default(),
4056 }
4057 }
4058
4059 /// Create a builder to help you perform the following task:
4060 ///
4061 /// Executes an SQL statement, returning all results in a single reply. This method cannot 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.
4062 ///
4063 /// # Arguments
4064 ///
4065 /// * `request` - No description provided.
4066 /// * `session` - Required. The session in which the SQL query should be performed.
4067 pub fn instances_databases_sessions_execute_sql(
4068 &self,
4069 request: ExecuteSqlRequest,
4070 session: &str,
4071 ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
4072 ProjectInstanceDatabaseSessionExecuteSqlCall {
4073 hub: self.hub,
4074 _request: request,
4075 _session: session.to_string(),
4076 _delegate: Default::default(),
4077 _additional_params: Default::default(),
4078 _scopes: Default::default(),
4079 }
4080 }
4081
4082 /// Create a builder to help you perform the following task:
4083 ///
4084 /// 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.
4085 ///
4086 /// # Arguments
4087 ///
4088 /// * `request` - No description provided.
4089 /// * `session` - Required. The session in which the SQL query should be performed.
4090 pub fn instances_databases_sessions_execute_streaming_sql(
4091 &self,
4092 request: ExecuteSqlRequest,
4093 session: &str,
4094 ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
4095 ProjectInstanceDatabaseSessionExecuteStreamingSqlCall {
4096 hub: self.hub,
4097 _request: request,
4098 _session: session.to_string(),
4099 _delegate: Default::default(),
4100 _additional_params: Default::default(),
4101 _scopes: Default::default(),
4102 }
4103 }
4104
4105 /// Create a builder to help you perform the following task:
4106 ///
4107 /// Gets a session. Returns `NOT_FOUND` if the session does not exist. This is mainly useful for determining whether a session is still alive.
4108 ///
4109 /// # Arguments
4110 ///
4111 /// * `name` - Required. The name of the session to retrieve.
4112 pub fn instances_databases_sessions_get(
4113 &self,
4114 name: &str,
4115 ) -> ProjectInstanceDatabaseSessionGetCall<'a, C> {
4116 ProjectInstanceDatabaseSessionGetCall {
4117 hub: self.hub,
4118 _name: name.to_string(),
4119 _delegate: Default::default(),
4120 _additional_params: Default::default(),
4121 _scopes: Default::default(),
4122 }
4123 }
4124
4125 /// Create a builder to help you perform the following task:
4126 ///
4127 /// Lists all sessions in a given database.
4128 ///
4129 /// # Arguments
4130 ///
4131 /// * `database` - Required. The database in which to list sessions.
4132 pub fn instances_databases_sessions_list(
4133 &self,
4134 database: &str,
4135 ) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
4136 ProjectInstanceDatabaseSessionListCall {
4137 hub: self.hub,
4138 _database: database.to_string(),
4139 _page_token: Default::default(),
4140 _page_size: Default::default(),
4141 _filter: Default::default(),
4142 _delegate: Default::default(),
4143 _additional_params: Default::default(),
4144 _scopes: Default::default(),
4145 }
4146 }
4147
4148 /// Create a builder to help you perform the following task:
4149 ///
4150 /// 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 is not possible to resume the query, and the whole operation must be restarted from the beginning.
4151 ///
4152 /// # Arguments
4153 ///
4154 /// * `request` - No description provided.
4155 /// * `session` - Required. The session used to create the partitions.
4156 pub fn instances_databases_sessions_partition_query(
4157 &self,
4158 request: PartitionQueryRequest,
4159 session: &str,
4160 ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
4161 ProjectInstanceDatabaseSessionPartitionQueryCall {
4162 hub: self.hub,
4163 _request: request,
4164 _session: session.to_string(),
4165 _delegate: Default::default(),
4166 _additional_params: Default::default(),
4167 _scopes: Default::default(),
4168 }
4169 }
4170
4171 /// Create a builder to help you perform the following task:
4172 ///
4173 /// 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 is not possible to resume the read, and the whole operation must be restarted from the beginning.
4174 ///
4175 /// # Arguments
4176 ///
4177 /// * `request` - No description provided.
4178 /// * `session` - Required. The session used to create the partitions.
4179 pub fn instances_databases_sessions_partition_read(
4180 &self,
4181 request: PartitionReadRequest,
4182 session: &str,
4183 ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
4184 ProjectInstanceDatabaseSessionPartitionReadCall {
4185 hub: self.hub,
4186 _request: request,
4187 _session: session.to_string(),
4188 _delegate: Default::default(),
4189 _additional_params: Default::default(),
4190 _scopes: Default::default(),
4191 }
4192 }
4193
4194 /// Create a builder to help you perform the following task:
4195 ///
4196 /// Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteSql. This method cannot 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.
4197 ///
4198 /// # Arguments
4199 ///
4200 /// * `request` - No description provided.
4201 /// * `session` - Required. The session in which the read should be performed.
4202 pub fn instances_databases_sessions_read(
4203 &self,
4204 request: ReadRequest,
4205 session: &str,
4206 ) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
4207 ProjectInstanceDatabaseSessionReadCall {
4208 hub: self.hub,
4209 _request: request,
4210 _session: session.to_string(),
4211 _delegate: Default::default(),
4212 _additional_params: Default::default(),
4213 _scopes: Default::default(),
4214 }
4215 }
4216
4217 /// Create a builder to help you perform the following task:
4218 ///
4219 /// Rolls back a transaction, releasing any locks it holds. It is 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 is not found. `Rollback` never returns `ABORTED`.
4220 ///
4221 /// # Arguments
4222 ///
4223 /// * `request` - No description provided.
4224 /// * `session` - Required. The session in which the transaction to roll back is running.
4225 pub fn instances_databases_sessions_rollback(
4226 &self,
4227 request: RollbackRequest,
4228 session: &str,
4229 ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
4230 ProjectInstanceDatabaseSessionRollbackCall {
4231 hub: self.hub,
4232 _request: request,
4233 _session: session.to_string(),
4234 _delegate: Default::default(),
4235 _additional_params: Default::default(),
4236 _scopes: Default::default(),
4237 }
4238 }
4239
4240 /// Create a builder to help you perform the following task:
4241 ///
4242 /// 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.
4243 ///
4244 /// # Arguments
4245 ///
4246 /// * `request` - No description provided.
4247 /// * `session` - Required. The session in which the read should be performed.
4248 pub fn instances_databases_sessions_streaming_read(
4249 &self,
4250 request: ReadRequest,
4251 session: &str,
4252 ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
4253 ProjectInstanceDatabaseSessionStreamingReadCall {
4254 hub: self.hub,
4255 _request: request,
4256 _session: session.to_string(),
4257 _delegate: Default::default(),
4258 _additional_params: Default::default(),
4259 _scopes: Default::default(),
4260 }
4261 }
4262
4263 /// Create a builder to help you perform the following task:
4264 ///
4265 /// ChangeQuorum is strictly restricted to databases that use dual region instance configurations. Initiates a background operation to change quorum a database from dual-region mode to single-region mode and vice versa. The returned long-running operation will have 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.
4266 ///
4267 /// # Arguments
4268 ///
4269 /// * `request` - No description provided.
4270 /// * `name` - Required. Name of the database in which to apply the ChangeQuorum. Values are of the form `projects//instances//databases/`.
4271 pub fn instances_databases_changequorum(
4272 &self,
4273 request: ChangeQuorumRequest,
4274 name: &str,
4275 ) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
4276 ProjectInstanceDatabaseChangequorumCall {
4277 hub: self.hub,
4278 _request: request,
4279 _name: name.to_string(),
4280 _delegate: Default::default(),
4281 _additional_params: Default::default(),
4282 _scopes: Default::default(),
4283 }
4284 }
4285
4286 /// Create a builder to help you perform the following task:
4287 ///
4288 /// Creates a new Cloud 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.
4289 ///
4290 /// # Arguments
4291 ///
4292 /// * `request` - No description provided.
4293 /// * `parent` - Required. The name of the instance that will serve the new database. Values are of the form `projects//instances/`.
4294 pub fn instances_databases_create(
4295 &self,
4296 request: CreateDatabaseRequest,
4297 parent: &str,
4298 ) -> ProjectInstanceDatabaseCreateCall<'a, C> {
4299 ProjectInstanceDatabaseCreateCall {
4300 hub: self.hub,
4301 _request: request,
4302 _parent: parent.to_string(),
4303 _delegate: Default::default(),
4304 _additional_params: Default::default(),
4305 _scopes: Default::default(),
4306 }
4307 }
4308
4309 /// Create a builder to help you perform the following task:
4310 ///
4311 /// 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.
4312 ///
4313 /// # Arguments
4314 ///
4315 /// * `database` - Required. The database to be dropped.
4316 pub fn instances_databases_drop_database(
4317 &self,
4318 database: &str,
4319 ) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C> {
4320 ProjectInstanceDatabaseDropDatabaseCall {
4321 hub: self.hub,
4322 _database: database.to_string(),
4323 _delegate: Default::default(),
4324 _additional_params: Default::default(),
4325 _scopes: Default::default(),
4326 }
4327 }
4328
4329 /// Create a builder to help you perform the following task:
4330 ///
4331 /// Gets the state of a Cloud Spanner database.
4332 ///
4333 /// # Arguments
4334 ///
4335 /// * `name` - Required. The name of the requested database. Values are of the form `projects//instances//databases/`.
4336 pub fn instances_databases_get(&self, name: &str) -> ProjectInstanceDatabaseGetCall<'a, C> {
4337 ProjectInstanceDatabaseGetCall {
4338 hub: self.hub,
4339 _name: name.to_string(),
4340 _delegate: Default::default(),
4341 _additional_params: Default::default(),
4342 _scopes: Default::default(),
4343 }
4344 }
4345
4346 /// Create a builder to help you perform the following task:
4347 ///
4348 /// 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.
4349 ///
4350 /// # Arguments
4351 ///
4352 /// * `database` - Required. The database whose schema we wish to get. Values are of the form `projects//instances//databases/`
4353 pub fn instances_databases_get_ddl(
4354 &self,
4355 database: &str,
4356 ) -> ProjectInstanceDatabaseGetDdlCall<'a, C> {
4357 ProjectInstanceDatabaseGetDdlCall {
4358 hub: self.hub,
4359 _database: database.to_string(),
4360 _delegate: Default::default(),
4361 _additional_params: Default::default(),
4362 _scopes: Default::default(),
4363 }
4364 }
4365
4366 /// Create a builder to help you perform the following task:
4367 ///
4368 /// 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.
4369 ///
4370 /// # Arguments
4371 ///
4372 /// * `request` - No description provided.
4373 /// * `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.
4374 pub fn instances_databases_get_iam_policy(
4375 &self,
4376 request: GetIamPolicyRequest,
4377 resource: &str,
4378 ) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
4379 ProjectInstanceDatabaseGetIamPolicyCall {
4380 hub: self.hub,
4381 _request: request,
4382 _resource: resource.to_string(),
4383 _delegate: Default::default(),
4384 _additional_params: Default::default(),
4385 _scopes: Default::default(),
4386 }
4387 }
4388
4389 /// Create a builder to help you perform the following task:
4390 ///
4391 /// Request a specific scan with Database-specific data for Cloud Key Visualizer.
4392 ///
4393 /// # Arguments
4394 ///
4395 /// * `name` - Required. The unique name of the scan containing the requested information, specific to the Database service implementing this interface.
4396 pub fn instances_databases_get_scans(
4397 &self,
4398 name: &str,
4399 ) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
4400 ProjectInstanceDatabaseGetScanCall {
4401 hub: self.hub,
4402 _name: name.to_string(),
4403 _view: Default::default(),
4404 _start_time: Default::default(),
4405 _end_time: Default::default(),
4406 _delegate: Default::default(),
4407 _additional_params: Default::default(),
4408 _scopes: Default::default(),
4409 }
4410 }
4411
4412 /// Create a builder to help you perform the following task:
4413 ///
4414 /// Lists Cloud Spanner databases.
4415 ///
4416 /// # Arguments
4417 ///
4418 /// * `parent` - Required. The instance whose databases should be listed. Values are of the form `projects//instances/`.
4419 pub fn instances_databases_list(&self, parent: &str) -> ProjectInstanceDatabaseListCall<'a, C> {
4420 ProjectInstanceDatabaseListCall {
4421 hub: self.hub,
4422 _parent: parent.to_string(),
4423 _page_token: Default::default(),
4424 _page_size: Default::default(),
4425 _delegate: Default::default(),
4426 _additional_params: Default::default(),
4427 _scopes: Default::default(),
4428 }
4429 }
4430
4431 /// Create a builder to help you perform the following task:
4432 ///
4433 /// 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.
4434 ///
4435 /// # Arguments
4436 ///
4437 /// * `request` - No description provided.
4438 /// * `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.
4439 pub fn instances_databases_patch(
4440 &self,
4441 request: Database,
4442 name: &str,
4443 ) -> ProjectInstanceDatabasePatchCall<'a, C> {
4444 ProjectInstanceDatabasePatchCall {
4445 hub: self.hub,
4446 _request: request,
4447 _name: name.to_string(),
4448 _update_mask: Default::default(),
4449 _delegate: Default::default(),
4450 _additional_params: Default::default(),
4451 _scopes: Default::default(),
4452 }
4453 }
4454
4455 /// Create a builder to help you perform the following task:
4456 ///
4457 /// 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.
4458 ///
4459 /// # Arguments
4460 ///
4461 /// * `request` - No description provided.
4462 /// * `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/`.
4463 pub fn instances_databases_restore(
4464 &self,
4465 request: RestoreDatabaseRequest,
4466 parent: &str,
4467 ) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
4468 ProjectInstanceDatabaseRestoreCall {
4469 hub: self.hub,
4470 _request: request,
4471 _parent: parent.to_string(),
4472 _delegate: Default::default(),
4473 _additional_params: Default::default(),
4474 _scopes: Default::default(),
4475 }
4476 }
4477
4478 /// Create a builder to help you perform the following task:
4479 ///
4480 /// 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.
4481 ///
4482 /// # Arguments
4483 ///
4484 /// * `request` - No description provided.
4485 /// * `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.
4486 pub fn instances_databases_set_iam_policy(
4487 &self,
4488 request: SetIamPolicyRequest,
4489 resource: &str,
4490 ) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
4491 ProjectInstanceDatabaseSetIamPolicyCall {
4492 hub: self.hub,
4493 _request: request,
4494 _resource: resource.to_string(),
4495 _delegate: Default::default(),
4496 _additional_params: Default::default(),
4497 _scopes: Default::default(),
4498 }
4499 }
4500
4501 /// Create a builder to help you perform the following task:
4502 ///
4503 /// 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.
4504 ///
4505 /// # Arguments
4506 ///
4507 /// * `request` - No description provided.
4508 /// * `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.
4509 pub fn instances_databases_test_iam_permissions(
4510 &self,
4511 request: TestIamPermissionsRequest,
4512 resource: &str,
4513 ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
4514 ProjectInstanceDatabaseTestIamPermissionCall {
4515 hub: self.hub,
4516 _request: request,
4517 _resource: resource.to_string(),
4518 _delegate: Default::default(),
4519 _additional_params: Default::default(),
4520 _scopes: Default::default(),
4521 }
4522 }
4523
4524 /// Create a builder to help you perform the following task:
4525 ///
4526 /// 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 change(s). The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response.
4527 ///
4528 /// # Arguments
4529 ///
4530 /// * `request` - No description provided.
4531 /// * `database` - Required. The database to update.
4532 pub fn instances_databases_update_ddl(
4533 &self,
4534 request: UpdateDatabaseDdlRequest,
4535 database: &str,
4536 ) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
4537 ProjectInstanceDatabaseUpdateDdlCall {
4538 hub: self.hub,
4539 _request: request,
4540 _database: database.to_string(),
4541 _delegate: Default::default(),
4542 _additional_params: Default::default(),
4543 _scopes: Default::default(),
4544 }
4545 }
4546
4547 /// Create a builder to help you perform the following task:
4548 ///
4549 /// 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.
4550 ///
4551 /// # Arguments
4552 ///
4553 /// * `parent` - Required. The parent instance of the instance partition operations. Values are of the form `projects//instances/`.
4554 pub fn instances_instance_partition_operations_list(
4555 &self,
4556 parent: &str,
4557 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
4558 ProjectInstanceInstancePartitionOperationListCall {
4559 hub: self.hub,
4560 _parent: parent.to_string(),
4561 _page_token: Default::default(),
4562 _page_size: Default::default(),
4563 _instance_partition_deadline: Default::default(),
4564 _filter: Default::default(),
4565 _delegate: Default::default(),
4566 _additional_params: Default::default(),
4567 _scopes: Default::default(),
4568 }
4569 }
4570
4571 /// Create a builder to help you perform the following task:
4572 ///
4573 /// 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`.
4574 ///
4575 /// # Arguments
4576 ///
4577 /// * `name` - The name of the operation resource to be cancelled.
4578 pub fn instances_instance_partitions_operations_cancel(
4579 &self,
4580 name: &str,
4581 ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {
4582 ProjectInstanceInstancePartitionOperationCancelCall {
4583 hub: self.hub,
4584 _name: name.to_string(),
4585 _delegate: Default::default(),
4586 _additional_params: Default::default(),
4587 _scopes: Default::default(),
4588 }
4589 }
4590
4591 /// Create a builder to help you perform the following task:
4592 ///
4593 /// 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`.
4594 ///
4595 /// # Arguments
4596 ///
4597 /// * `name` - The name of the operation resource to be deleted.
4598 pub fn instances_instance_partitions_operations_delete(
4599 &self,
4600 name: &str,
4601 ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {
4602 ProjectInstanceInstancePartitionOperationDeleteCall {
4603 hub: self.hub,
4604 _name: name.to_string(),
4605 _delegate: Default::default(),
4606 _additional_params: Default::default(),
4607 _scopes: Default::default(),
4608 }
4609 }
4610
4611 /// Create a builder to help you perform the following task:
4612 ///
4613 /// 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.
4614 ///
4615 /// # Arguments
4616 ///
4617 /// * `name` - The name of the operation resource.
4618 pub fn instances_instance_partitions_operations_get(
4619 &self,
4620 name: &str,
4621 ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C> {
4622 ProjectInstanceInstancePartitionOperationGetCall {
4623 hub: self.hub,
4624 _name: name.to_string(),
4625 _delegate: Default::default(),
4626 _additional_params: Default::default(),
4627 _scopes: Default::default(),
4628 }
4629 }
4630
4631 /// Create a builder to help you perform the following task:
4632 ///
4633 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4634 ///
4635 /// # Arguments
4636 ///
4637 /// * `name` - The name of the operation's parent resource.
4638 pub fn instances_instance_partitions_operations_list(
4639 &self,
4640 name: &str,
4641 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
4642 ProjectInstanceInstancePartitionOperationListCall1 {
4643 hub: self.hub,
4644 _name: name.to_string(),
4645 _page_token: Default::default(),
4646 _page_size: Default::default(),
4647 _filter: Default::default(),
4648 _delegate: Default::default(),
4649 _additional_params: Default::default(),
4650 _scopes: Default::default(),
4651 }
4652 }
4653
4654 /// Create a builder to help you perform the following task:
4655 ///
4656 /// 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.
4657 ///
4658 /// # Arguments
4659 ///
4660 /// * `request` - No description provided.
4661 /// * `parent` - Required. The name of the instance in which to create the instance partition. Values are of the form `projects//instances/`.
4662 pub fn instances_instance_partitions_create(
4663 &self,
4664 request: CreateInstancePartitionRequest,
4665 parent: &str,
4666 ) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
4667 ProjectInstanceInstancePartitionCreateCall {
4668 hub: self.hub,
4669 _request: request,
4670 _parent: parent.to_string(),
4671 _delegate: Default::default(),
4672 _additional_params: Default::default(),
4673 _scopes: Default::default(),
4674 }
4675 }
4676
4677 /// Create a builder to help you perform the following task:
4678 ///
4679 /// 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.
4680 ///
4681 /// # Arguments
4682 ///
4683 /// * `name` - Required. The name of the instance partition to be deleted. Values are of the form `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`
4684 pub fn instances_instance_partitions_delete(
4685 &self,
4686 name: &str,
4687 ) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
4688 ProjectInstanceInstancePartitionDeleteCall {
4689 hub: self.hub,
4690 _name: name.to_string(),
4691 _etag: Default::default(),
4692 _delegate: Default::default(),
4693 _additional_params: Default::default(),
4694 _scopes: Default::default(),
4695 }
4696 }
4697
4698 /// Create a builder to help you perform the following task:
4699 ///
4700 /// Gets information about a particular instance partition.
4701 ///
4702 /// # Arguments
4703 ///
4704 /// * `name` - Required. The name of the requested instance partition. Values are of the form `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`.
4705 pub fn instances_instance_partitions_get(
4706 &self,
4707 name: &str,
4708 ) -> ProjectInstanceInstancePartitionGetCall<'a, C> {
4709 ProjectInstanceInstancePartitionGetCall {
4710 hub: self.hub,
4711 _name: name.to_string(),
4712 _delegate: Default::default(),
4713 _additional_params: Default::default(),
4714 _scopes: Default::default(),
4715 }
4716 }
4717
4718 /// Create a builder to help you perform the following task:
4719 ///
4720 /// Lists all instance partitions for the given instance.
4721 ///
4722 /// # Arguments
4723 ///
4724 /// * `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/-`.
4725 pub fn instances_instance_partitions_list(
4726 &self,
4727 parent: &str,
4728 ) -> ProjectInstanceInstancePartitionListCall<'a, C> {
4729 ProjectInstanceInstancePartitionListCall {
4730 hub: self.hub,
4731 _parent: parent.to_string(),
4732 _page_token: Default::default(),
4733 _page_size: Default::default(),
4734 _instance_partition_deadline: Default::default(),
4735 _delegate: Default::default(),
4736 _additional_params: Default::default(),
4737 _scopes: Default::default(),
4738 }
4739 }
4740
4741 /// Create a builder to help you perform the following task:
4742 ///
4743 /// 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.
4744 ///
4745 /// # Arguments
4746 ///
4747 /// * `request` - No description provided.
4748 /// * `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.
4749 pub fn instances_instance_partitions_patch(
4750 &self,
4751 request: UpdateInstancePartitionRequest,
4752 name: &str,
4753 ) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
4754 ProjectInstanceInstancePartitionPatchCall {
4755 hub: self.hub,
4756 _request: request,
4757 _name: name.to_string(),
4758 _delegate: Default::default(),
4759 _additional_params: Default::default(),
4760 _scopes: Default::default(),
4761 }
4762 }
4763
4764 /// Create a builder to help you perform the following task:
4765 ///
4766 /// 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`.
4767 ///
4768 /// # Arguments
4769 ///
4770 /// * `name` - The name of the operation resource to be cancelled.
4771 pub fn instances_operations_cancel(
4772 &self,
4773 name: &str,
4774 ) -> ProjectInstanceOperationCancelCall<'a, C> {
4775 ProjectInstanceOperationCancelCall {
4776 hub: self.hub,
4777 _name: name.to_string(),
4778 _delegate: Default::default(),
4779 _additional_params: Default::default(),
4780 _scopes: Default::default(),
4781 }
4782 }
4783
4784 /// Create a builder to help you perform the following task:
4785 ///
4786 /// 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`.
4787 ///
4788 /// # Arguments
4789 ///
4790 /// * `name` - The name of the operation resource to be deleted.
4791 pub fn instances_operations_delete(
4792 &self,
4793 name: &str,
4794 ) -> ProjectInstanceOperationDeleteCall<'a, C> {
4795 ProjectInstanceOperationDeleteCall {
4796 hub: self.hub,
4797 _name: name.to_string(),
4798 _delegate: Default::default(),
4799 _additional_params: Default::default(),
4800 _scopes: Default::default(),
4801 }
4802 }
4803
4804 /// Create a builder to help you perform the following task:
4805 ///
4806 /// 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.
4807 ///
4808 /// # Arguments
4809 ///
4810 /// * `name` - The name of the operation resource.
4811 pub fn instances_operations_get(&self, name: &str) -> ProjectInstanceOperationGetCall<'a, C> {
4812 ProjectInstanceOperationGetCall {
4813 hub: self.hub,
4814 _name: name.to_string(),
4815 _delegate: Default::default(),
4816 _additional_params: Default::default(),
4817 _scopes: Default::default(),
4818 }
4819 }
4820
4821 /// Create a builder to help you perform the following task:
4822 ///
4823 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4824 ///
4825 /// # Arguments
4826 ///
4827 /// * `name` - The name of the operation's parent resource.
4828 pub fn instances_operations_list(&self, name: &str) -> ProjectInstanceOperationListCall<'a, C> {
4829 ProjectInstanceOperationListCall {
4830 hub: self.hub,
4831 _name: name.to_string(),
4832 _page_token: Default::default(),
4833 _page_size: Default::default(),
4834 _filter: Default::default(),
4835 _delegate: Default::default(),
4836 _additional_params: Default::default(),
4837 _scopes: Default::default(),
4838 }
4839 }
4840
4841 /// Create a builder to help you perform the following task:
4842 ///
4843 /// 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.
4844 ///
4845 /// # Arguments
4846 ///
4847 /// * `request` - No description provided.
4848 /// * `parent` - Required. The name of the project in which to create the instance. Values are of the form `projects/`.
4849 pub fn instances_create(
4850 &self,
4851 request: CreateInstanceRequest,
4852 parent: &str,
4853 ) -> ProjectInstanceCreateCall<'a, C> {
4854 ProjectInstanceCreateCall {
4855 hub: self.hub,
4856 _request: request,
4857 _parent: parent.to_string(),
4858 _delegate: Default::default(),
4859 _additional_params: Default::default(),
4860 _scopes: Default::default(),
4861 }
4862 }
4863
4864 /// Create a builder to help you perform the following task:
4865 ///
4866 /// 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.
4867 ///
4868 /// # Arguments
4869 ///
4870 /// * `name` - Required. The name of the instance to be deleted. Values are of the form `projects//instances/`
4871 pub fn instances_delete(&self, name: &str) -> ProjectInstanceDeleteCall<'a, C> {
4872 ProjectInstanceDeleteCall {
4873 hub: self.hub,
4874 _name: name.to_string(),
4875 _delegate: Default::default(),
4876 _additional_params: Default::default(),
4877 _scopes: Default::default(),
4878 }
4879 }
4880
4881 /// Create a builder to help you perform the following task:
4882 ///
4883 /// Gets information about a particular instance.
4884 ///
4885 /// # Arguments
4886 ///
4887 /// * `name` - Required. The name of the requested instance. Values are of the form `projects//instances/`.
4888 pub fn instances_get(&self, name: &str) -> ProjectInstanceGetCall<'a, C> {
4889 ProjectInstanceGetCall {
4890 hub: self.hub,
4891 _name: name.to_string(),
4892 _field_mask: Default::default(),
4893 _delegate: Default::default(),
4894 _additional_params: Default::default(),
4895 _scopes: Default::default(),
4896 }
4897 }
4898
4899 /// Create a builder to help you perform the following task:
4900 ///
4901 /// 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.
4902 ///
4903 /// # Arguments
4904 ///
4905 /// * `request` - No description provided.
4906 /// * `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.
4907 pub fn instances_get_iam_policy(
4908 &self,
4909 request: GetIamPolicyRequest,
4910 resource: &str,
4911 ) -> ProjectInstanceGetIamPolicyCall<'a, C> {
4912 ProjectInstanceGetIamPolicyCall {
4913 hub: self.hub,
4914 _request: request,
4915 _resource: resource.to_string(),
4916 _delegate: Default::default(),
4917 _additional_params: Default::default(),
4918 _scopes: Default::default(),
4919 }
4920 }
4921
4922 /// Create a builder to help you perform the following task:
4923 ///
4924 /// Lists all instances in the given project.
4925 ///
4926 /// # Arguments
4927 ///
4928 /// * `parent` - Required. The name of the project for which a list of instances is requested. Values are of the form `projects/`.
4929 pub fn instances_list(&self, parent: &str) -> ProjectInstanceListCall<'a, C> {
4930 ProjectInstanceListCall {
4931 hub: self.hub,
4932 _parent: parent.to_string(),
4933 _page_token: Default::default(),
4934 _page_size: Default::default(),
4935 _instance_deadline: Default::default(),
4936 _filter: Default::default(),
4937 _delegate: Default::default(),
4938 _additional_params: Default::default(),
4939 _scopes: Default::default(),
4940 }
4941 }
4942
4943 /// Create a builder to help you perform the following task:
4944 ///
4945 /// Moves the instance to the target instance config. The returned long-running operation can be used to track the progress of moving the instance. `MoveInstance` returns `FAILED_PRECONDITION` if the instance meets any of the following criteria: * Has an ongoing move to a different instance config * Has backups * Has an ongoing update * Is under free trial * Contains any CMEK-enabled databases 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 configs are subject to hourly compute and storage charges. * The instance may experience higher read-write latencies and a higher transaction abort rate. However, moving an instance does not cause any downtime. The returned long-running operation will have 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 since it involves moving any data previously moved to target instance config back to the original instance config. The same operation can be used to track the progress of the cancellation. Upon successful completion of the cancellation, the operation terminates with CANCELLED status. Upon completion(if not cancelled) of the returned operation: * Instance would be successfully moved to the target instance config. * You are billed for compute and storage in target instance config. Authorization requires `spanner.instances.update` permission on the resource instance. For more details, please see [documentation](https://cloud.google.com/spanner/docs/move-instance).
4946 ///
4947 /// # Arguments
4948 ///
4949 /// * `request` - No description provided.
4950 /// * `name` - Required. The instance to move. Values are of the form `projects//instances/`.
4951 pub fn instances_move(
4952 &self,
4953 request: MoveInstanceRequest,
4954 name: &str,
4955 ) -> ProjectInstanceMoveCall<'a, C> {
4956 ProjectInstanceMoveCall {
4957 hub: self.hub,
4958 _request: request,
4959 _name: name.to_string(),
4960 _delegate: Default::default(),
4961 _additional_params: Default::default(),
4962 _scopes: Default::default(),
4963 }
4964 }
4965
4966 /// Create a builder to help you perform the following task:
4967 ///
4968 /// 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.
4969 ///
4970 /// # Arguments
4971 ///
4972 /// * `request` - No description provided.
4973 /// * `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.
4974 pub fn instances_patch(
4975 &self,
4976 request: UpdateInstanceRequest,
4977 name: &str,
4978 ) -> ProjectInstancePatchCall<'a, C> {
4979 ProjectInstancePatchCall {
4980 hub: self.hub,
4981 _request: request,
4982 _name: name.to_string(),
4983 _delegate: Default::default(),
4984 _additional_params: Default::default(),
4985 _scopes: Default::default(),
4986 }
4987 }
4988
4989 /// Create a builder to help you perform the following task:
4990 ///
4991 /// Sets the access control policy on an instance resource. Replaces any existing policy. Authorization requires `spanner.instances.setIamPolicy` on resource.
4992 ///
4993 /// # Arguments
4994 ///
4995 /// * `request` - No description provided.
4996 /// * `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.
4997 pub fn instances_set_iam_policy(
4998 &self,
4999 request: SetIamPolicyRequest,
5000 resource: &str,
5001 ) -> ProjectInstanceSetIamPolicyCall<'a, C> {
5002 ProjectInstanceSetIamPolicyCall {
5003 hub: self.hub,
5004 _request: request,
5005 _resource: resource.to_string(),
5006 _delegate: Default::default(),
5007 _additional_params: Default::default(),
5008 _scopes: Default::default(),
5009 }
5010 }
5011
5012 /// Create a builder to help you perform the following task:
5013 ///
5014 /// 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.
5015 ///
5016 /// # Arguments
5017 ///
5018 /// * `request` - No description provided.
5019 /// * `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.
5020 pub fn instances_test_iam_permissions(
5021 &self,
5022 request: TestIamPermissionsRequest,
5023 resource: &str,
5024 ) -> ProjectInstanceTestIamPermissionCall<'a, C> {
5025 ProjectInstanceTestIamPermissionCall {
5026 hub: self.hub,
5027 _request: request,
5028 _resource: resource.to_string(),
5029 _delegate: Default::default(),
5030 _additional_params: Default::default(),
5031 _scopes: Default::default(),
5032 }
5033 }
5034}
5035
5036/// A builder providing access to all methods supported on *scan* resources.
5037/// It is not used directly, but through the [`Spanner`] hub.
5038///
5039/// # Example
5040///
5041/// Instantiate a resource builder
5042///
5043/// ```test_harness,no_run
5044/// extern crate hyper;
5045/// extern crate hyper_rustls;
5046/// extern crate google_spanner1 as spanner1;
5047///
5048/// # async fn dox() {
5049/// use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5050///
5051/// let secret: yup_oauth2::ApplicationSecret = Default::default();
5052/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5053/// secret,
5054/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5055/// ).build().await.unwrap();
5056///
5057/// let client = hyper_util::client::legacy::Client::builder(
5058/// hyper_util::rt::TokioExecutor::new()
5059/// )
5060/// .build(
5061/// hyper_rustls::HttpsConnectorBuilder::new()
5062/// .with_native_roots()
5063/// .unwrap()
5064/// .https_or_http()
5065/// .enable_http1()
5066/// .build()
5067/// );
5068/// let mut hub = Spanner::new(client, auth);
5069/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
5070/// // like `list(...)`
5071/// // to build up your call.
5072/// let rb = hub.scans();
5073/// # }
5074/// ```
5075pub struct ScanMethods<'a, C>
5076where
5077 C: 'a,
5078{
5079 hub: &'a Spanner<C>,
5080}
5081
5082impl<'a, C> common::MethodsBuilder for ScanMethods<'a, C> {}
5083
5084impl<'a, C> ScanMethods<'a, C> {
5085 /// Create a builder to help you perform the following task:
5086 ///
5087 /// Return available scans given a Database-specific resource name.
5088 ///
5089 /// # Arguments
5090 ///
5091 /// * `parent` - Required. The unique name of the parent resource, specific to the Database service implementing this interface.
5092 pub fn list(&self, parent: &str) -> ScanListCall<'a, C> {
5093 ScanListCall {
5094 hub: self.hub,
5095 _parent: parent.to_string(),
5096 _view: Default::default(),
5097 _page_token: Default::default(),
5098 _page_size: Default::default(),
5099 _filter: Default::default(),
5100 _delegate: Default::default(),
5101 _additional_params: Default::default(),
5102 _scopes: Default::default(),
5103 }
5104 }
5105}
5106
5107// ###################
5108// CallBuilders ###
5109// #################
5110
5111/// Lists the user-managed instance config long-running operations in the given project. An instance config 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.
5112///
5113/// A builder for the *instanceConfigOperations.list* method supported by a *project* resource.
5114/// It is not used directly, but through a [`ProjectMethods`] instance.
5115///
5116/// # Example
5117///
5118/// Instantiate a resource method builder
5119///
5120/// ```test_harness,no_run
5121/// # extern crate hyper;
5122/// # extern crate hyper_rustls;
5123/// # extern crate google_spanner1 as spanner1;
5124/// # async fn dox() {
5125/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5126///
5127/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5129/// # secret,
5130/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5131/// # ).build().await.unwrap();
5132///
5133/// # let client = hyper_util::client::legacy::Client::builder(
5134/// # hyper_util::rt::TokioExecutor::new()
5135/// # )
5136/// # .build(
5137/// # hyper_rustls::HttpsConnectorBuilder::new()
5138/// # .with_native_roots()
5139/// # .unwrap()
5140/// # .https_or_http()
5141/// # .enable_http1()
5142/// # .build()
5143/// # );
5144/// # let mut hub = Spanner::new(client, auth);
5145/// // You can configure optional parameters by calling the respective setters at will, and
5146/// // execute the final call using `doit()`.
5147/// // Values shown here are possibly random and not representative !
5148/// let result = hub.projects().instance_config_operations_list("parent")
5149/// .page_token("eos")
5150/// .page_size(-4)
5151/// .filter("ea")
5152/// .doit().await;
5153/// # }
5154/// ```
5155pub struct ProjectInstanceConfigOperationListCall<'a, C>
5156where
5157 C: 'a,
5158{
5159 hub: &'a Spanner<C>,
5160 _parent: String,
5161 _page_token: Option<String>,
5162 _page_size: Option<i32>,
5163 _filter: Option<String>,
5164 _delegate: Option<&'a mut dyn common::Delegate>,
5165 _additional_params: HashMap<String, String>,
5166 _scopes: BTreeSet<String>,
5167}
5168
5169impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationListCall<'a, C> {}
5170
5171impl<'a, C> ProjectInstanceConfigOperationListCall<'a, C>
5172where
5173 C: common::Connector,
5174{
5175 /// Perform the operation you have build so far.
5176 pub async fn doit(
5177 mut self,
5178 ) -> common::Result<(common::Response, ListInstanceConfigOperationsResponse)> {
5179 use std::borrow::Cow;
5180 use std::io::{Read, Seek};
5181
5182 use common::{url::Params, ToParts};
5183 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5184
5185 let mut dd = common::DefaultDelegate;
5186 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5187 dlg.begin(common::MethodInfo {
5188 id: "spanner.projects.instanceConfigOperations.list",
5189 http_method: hyper::Method::GET,
5190 });
5191
5192 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
5193 if self._additional_params.contains_key(field) {
5194 dlg.finished(false);
5195 return Err(common::Error::FieldClash(field));
5196 }
5197 }
5198
5199 let mut params = Params::with_capacity(6 + self._additional_params.len());
5200 params.push("parent", self._parent);
5201 if let Some(value) = self._page_token.as_ref() {
5202 params.push("pageToken", value);
5203 }
5204 if let Some(value) = self._page_size.as_ref() {
5205 params.push("pageSize", value.to_string());
5206 }
5207 if let Some(value) = self._filter.as_ref() {
5208 params.push("filter", value);
5209 }
5210
5211 params.extend(self._additional_params.iter());
5212
5213 params.push("alt", "json");
5214 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instanceConfigOperations";
5215 if self._scopes.is_empty() {
5216 self._scopes
5217 .insert(Scope::CloudPlatform.as_ref().to_string());
5218 }
5219
5220 #[allow(clippy::single_element_loop)]
5221 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5222 url = params.uri_replacement(url, param_name, find_this, true);
5223 }
5224 {
5225 let to_remove = ["parent"];
5226 params.remove_params(&to_remove);
5227 }
5228
5229 let url = params.parse_with_url(&url);
5230
5231 loop {
5232 let token = match self
5233 .hub
5234 .auth
5235 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5236 .await
5237 {
5238 Ok(token) => token,
5239 Err(e) => match dlg.token(e) {
5240 Ok(token) => token,
5241 Err(e) => {
5242 dlg.finished(false);
5243 return Err(common::Error::MissingToken(e));
5244 }
5245 },
5246 };
5247 let mut req_result = {
5248 let client = &self.hub.client;
5249 dlg.pre_request();
5250 let mut req_builder = hyper::Request::builder()
5251 .method(hyper::Method::GET)
5252 .uri(url.as_str())
5253 .header(USER_AGENT, self.hub._user_agent.clone());
5254
5255 if let Some(token) = token.as_ref() {
5256 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5257 }
5258
5259 let request = req_builder
5260 .header(CONTENT_LENGTH, 0_u64)
5261 .body(common::to_body::<String>(None));
5262
5263 client.request(request.unwrap()).await
5264 };
5265
5266 match req_result {
5267 Err(err) => {
5268 if let common::Retry::After(d) = dlg.http_error(&err) {
5269 sleep(d).await;
5270 continue;
5271 }
5272 dlg.finished(false);
5273 return Err(common::Error::HttpError(err));
5274 }
5275 Ok(res) => {
5276 let (mut parts, body) = res.into_parts();
5277 let mut body = common::Body::new(body);
5278 if !parts.status.is_success() {
5279 let bytes = common::to_bytes(body).await.unwrap_or_default();
5280 let error = serde_json::from_str(&common::to_string(&bytes));
5281 let response = common::to_response(parts, bytes.into());
5282
5283 if let common::Retry::After(d) =
5284 dlg.http_failure(&response, error.as_ref().ok())
5285 {
5286 sleep(d).await;
5287 continue;
5288 }
5289
5290 dlg.finished(false);
5291
5292 return Err(match error {
5293 Ok(value) => common::Error::BadRequest(value),
5294 _ => common::Error::Failure(response),
5295 });
5296 }
5297 let response = {
5298 let bytes = common::to_bytes(body).await.unwrap_or_default();
5299 let encoded = common::to_string(&bytes);
5300 match serde_json::from_str(&encoded) {
5301 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5302 Err(error) => {
5303 dlg.response_json_decode_error(&encoded, &error);
5304 return Err(common::Error::JsonDecodeError(
5305 encoded.to_string(),
5306 error,
5307 ));
5308 }
5309 }
5310 };
5311
5312 dlg.finished(true);
5313 return Ok(response);
5314 }
5315 }
5316 }
5317 }
5318
5319 /// Required. The project of the instance config operations. Values are of the form `projects/`.
5320 ///
5321 /// Sets the *parent* path property to the given value.
5322 ///
5323 /// Even though the property as already been set when instantiating this call,
5324 /// we provide this method for API completeness.
5325 pub fn parent(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall<'a, C> {
5326 self._parent = new_value.to_string();
5327 self
5328 }
5329 /// If non-empty, `page_token` should contain a next_page_token from a previous ListInstanceConfigOperationsResponse to the same `parent` and with the same `filter`.
5330 ///
5331 /// Sets the *page token* query property to the given value.
5332 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall<'a, C> {
5333 self._page_token = Some(new_value.to_string());
5334 self
5335 }
5336 /// Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
5337 ///
5338 /// Sets the *page size* query property to the given value.
5339 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceConfigOperationListCall<'a, C> {
5340 self._page_size = Some(new_value);
5341 self
5342 }
5343 /// 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 config name contains "custom-config". * The operation started before 2021-03-28T14:50:00Z. * The operation resulted in an error.
5344 ///
5345 /// Sets the *filter* query property to the given value.
5346 pub fn filter(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall<'a, C> {
5347 self._filter = Some(new_value.to_string());
5348 self
5349 }
5350 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5351 /// while executing the actual API request.
5352 ///
5353 /// ````text
5354 /// It should be used to handle progress information, and to implement a certain level of resilience.
5355 /// ````
5356 ///
5357 /// Sets the *delegate* property to the given value.
5358 pub fn delegate(
5359 mut self,
5360 new_value: &'a mut dyn common::Delegate,
5361 ) -> ProjectInstanceConfigOperationListCall<'a, C> {
5362 self._delegate = Some(new_value);
5363 self
5364 }
5365
5366 /// Set any additional parameter of the query string used in the request.
5367 /// It should be used to set parameters which are not yet available through their own
5368 /// setters.
5369 ///
5370 /// Please note that this method must not be used to set any of the known parameters
5371 /// which have their own setter method. If done anyway, the request will fail.
5372 ///
5373 /// # Additional Parameters
5374 ///
5375 /// * *$.xgafv* (query-string) - V1 error format.
5376 /// * *access_token* (query-string) - OAuth access token.
5377 /// * *alt* (query-string) - Data format for response.
5378 /// * *callback* (query-string) - JSONP
5379 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5380 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5381 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5382 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5383 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5384 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5385 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5386 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationListCall<'a, C>
5387 where
5388 T: AsRef<str>,
5389 {
5390 self._additional_params
5391 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5392 self
5393 }
5394
5395 /// Identifies the authorization scope for the method you are building.
5396 ///
5397 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5398 /// [`Scope::CloudPlatform`].
5399 ///
5400 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5401 /// tokens for more than one scope.
5402 ///
5403 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5404 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5405 /// sufficient, a read-write scope will do as well.
5406 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationListCall<'a, C>
5407 where
5408 St: AsRef<str>,
5409 {
5410 self._scopes.insert(String::from(scope.as_ref()));
5411 self
5412 }
5413 /// Identifies the authorization scope(s) for the method you are building.
5414 ///
5415 /// See [`Self::add_scope()`] for details.
5416 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationListCall<'a, C>
5417 where
5418 I: IntoIterator<Item = St>,
5419 St: AsRef<str>,
5420 {
5421 self._scopes
5422 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5423 self
5424 }
5425
5426 /// Removes all scopes, and no default scope will be used either.
5427 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5428 /// for details).
5429 pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationListCall<'a, C> {
5430 self._scopes.clear();
5431 self
5432 }
5433}
5434
5435/// 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`.
5436///
5437/// A builder for the *instanceConfigs.operations.cancel* method supported by a *project* resource.
5438/// It is not used directly, but through a [`ProjectMethods`] instance.
5439///
5440/// # Example
5441///
5442/// Instantiate a resource method builder
5443///
5444/// ```test_harness,no_run
5445/// # extern crate hyper;
5446/// # extern crate hyper_rustls;
5447/// # extern crate google_spanner1 as spanner1;
5448/// # async fn dox() {
5449/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5450///
5451/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5452/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5453/// # secret,
5454/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5455/// # ).build().await.unwrap();
5456///
5457/// # let client = hyper_util::client::legacy::Client::builder(
5458/// # hyper_util::rt::TokioExecutor::new()
5459/// # )
5460/// # .build(
5461/// # hyper_rustls::HttpsConnectorBuilder::new()
5462/// # .with_native_roots()
5463/// # .unwrap()
5464/// # .https_or_http()
5465/// # .enable_http1()
5466/// # .build()
5467/// # );
5468/// # let mut hub = Spanner::new(client, auth);
5469/// // You can configure optional parameters by calling the respective setters at will, and
5470/// // execute the final call using `doit()`.
5471/// // Values shown here are possibly random and not representative !
5472/// let result = hub.projects().instance_configs_operations_cancel("name")
5473/// .doit().await;
5474/// # }
5475/// ```
5476pub struct ProjectInstanceConfigOperationCancelCall<'a, C>
5477where
5478 C: 'a,
5479{
5480 hub: &'a Spanner<C>,
5481 _name: String,
5482 _delegate: Option<&'a mut dyn common::Delegate>,
5483 _additional_params: HashMap<String, String>,
5484 _scopes: BTreeSet<String>,
5485}
5486
5487impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationCancelCall<'a, C> {}
5488
5489impl<'a, C> ProjectInstanceConfigOperationCancelCall<'a, C>
5490where
5491 C: common::Connector,
5492{
5493 /// Perform the operation you have build so far.
5494 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5495 use std::borrow::Cow;
5496 use std::io::{Read, Seek};
5497
5498 use common::{url::Params, ToParts};
5499 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5500
5501 let mut dd = common::DefaultDelegate;
5502 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5503 dlg.begin(common::MethodInfo {
5504 id: "spanner.projects.instanceConfigs.operations.cancel",
5505 http_method: hyper::Method::POST,
5506 });
5507
5508 for &field in ["alt", "name"].iter() {
5509 if self._additional_params.contains_key(field) {
5510 dlg.finished(false);
5511 return Err(common::Error::FieldClash(field));
5512 }
5513 }
5514
5515 let mut params = Params::with_capacity(3 + self._additional_params.len());
5516 params.push("name", self._name);
5517
5518 params.extend(self._additional_params.iter());
5519
5520 params.push("alt", "json");
5521 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
5522 if self._scopes.is_empty() {
5523 self._scopes
5524 .insert(Scope::CloudPlatform.as_ref().to_string());
5525 }
5526
5527 #[allow(clippy::single_element_loop)]
5528 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5529 url = params.uri_replacement(url, param_name, find_this, true);
5530 }
5531 {
5532 let to_remove = ["name"];
5533 params.remove_params(&to_remove);
5534 }
5535
5536 let url = params.parse_with_url(&url);
5537
5538 loop {
5539 let token = match self
5540 .hub
5541 .auth
5542 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5543 .await
5544 {
5545 Ok(token) => token,
5546 Err(e) => match dlg.token(e) {
5547 Ok(token) => token,
5548 Err(e) => {
5549 dlg.finished(false);
5550 return Err(common::Error::MissingToken(e));
5551 }
5552 },
5553 };
5554 let mut req_result = {
5555 let client = &self.hub.client;
5556 dlg.pre_request();
5557 let mut req_builder = hyper::Request::builder()
5558 .method(hyper::Method::POST)
5559 .uri(url.as_str())
5560 .header(USER_AGENT, self.hub._user_agent.clone());
5561
5562 if let Some(token) = token.as_ref() {
5563 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5564 }
5565
5566 let request = req_builder
5567 .header(CONTENT_LENGTH, 0_u64)
5568 .body(common::to_body::<String>(None));
5569
5570 client.request(request.unwrap()).await
5571 };
5572
5573 match req_result {
5574 Err(err) => {
5575 if let common::Retry::After(d) = dlg.http_error(&err) {
5576 sleep(d).await;
5577 continue;
5578 }
5579 dlg.finished(false);
5580 return Err(common::Error::HttpError(err));
5581 }
5582 Ok(res) => {
5583 let (mut parts, body) = res.into_parts();
5584 let mut body = common::Body::new(body);
5585 if !parts.status.is_success() {
5586 let bytes = common::to_bytes(body).await.unwrap_or_default();
5587 let error = serde_json::from_str(&common::to_string(&bytes));
5588 let response = common::to_response(parts, bytes.into());
5589
5590 if let common::Retry::After(d) =
5591 dlg.http_failure(&response, error.as_ref().ok())
5592 {
5593 sleep(d).await;
5594 continue;
5595 }
5596
5597 dlg.finished(false);
5598
5599 return Err(match error {
5600 Ok(value) => common::Error::BadRequest(value),
5601 _ => common::Error::Failure(response),
5602 });
5603 }
5604 let response = {
5605 let bytes = common::to_bytes(body).await.unwrap_or_default();
5606 let encoded = common::to_string(&bytes);
5607 match serde_json::from_str(&encoded) {
5608 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5609 Err(error) => {
5610 dlg.response_json_decode_error(&encoded, &error);
5611 return Err(common::Error::JsonDecodeError(
5612 encoded.to_string(),
5613 error,
5614 ));
5615 }
5616 }
5617 };
5618
5619 dlg.finished(true);
5620 return Ok(response);
5621 }
5622 }
5623 }
5624 }
5625
5626 /// The name of the operation resource to be cancelled.
5627 ///
5628 /// Sets the *name* path property to the given value.
5629 ///
5630 /// Even though the property as already been set when instantiating this call,
5631 /// we provide this method for API completeness.
5632 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigOperationCancelCall<'a, C> {
5633 self._name = new_value.to_string();
5634 self
5635 }
5636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5637 /// while executing the actual API request.
5638 ///
5639 /// ````text
5640 /// It should be used to handle progress information, and to implement a certain level of resilience.
5641 /// ````
5642 ///
5643 /// Sets the *delegate* property to the given value.
5644 pub fn delegate(
5645 mut self,
5646 new_value: &'a mut dyn common::Delegate,
5647 ) -> ProjectInstanceConfigOperationCancelCall<'a, C> {
5648 self._delegate = Some(new_value);
5649 self
5650 }
5651
5652 /// Set any additional parameter of the query string used in the request.
5653 /// It should be used to set parameters which are not yet available through their own
5654 /// setters.
5655 ///
5656 /// Please note that this method must not be used to set any of the known parameters
5657 /// which have their own setter method. If done anyway, the request will fail.
5658 ///
5659 /// # Additional Parameters
5660 ///
5661 /// * *$.xgafv* (query-string) - V1 error format.
5662 /// * *access_token* (query-string) - OAuth access token.
5663 /// * *alt* (query-string) - Data format for response.
5664 /// * *callback* (query-string) - JSONP
5665 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5666 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5667 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5668 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5669 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5670 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5671 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5672 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationCancelCall<'a, C>
5673 where
5674 T: AsRef<str>,
5675 {
5676 self._additional_params
5677 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5678 self
5679 }
5680
5681 /// Identifies the authorization scope for the method you are building.
5682 ///
5683 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5684 /// [`Scope::CloudPlatform`].
5685 ///
5686 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5687 /// tokens for more than one scope.
5688 ///
5689 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5690 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5691 /// sufficient, a read-write scope will do as well.
5692 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationCancelCall<'a, C>
5693 where
5694 St: AsRef<str>,
5695 {
5696 self._scopes.insert(String::from(scope.as_ref()));
5697 self
5698 }
5699 /// Identifies the authorization scope(s) for the method you are building.
5700 ///
5701 /// See [`Self::add_scope()`] for details.
5702 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationCancelCall<'a, C>
5703 where
5704 I: IntoIterator<Item = St>,
5705 St: AsRef<str>,
5706 {
5707 self._scopes
5708 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5709 self
5710 }
5711
5712 /// Removes all scopes, and no default scope will be used either.
5713 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5714 /// for details).
5715 pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationCancelCall<'a, C> {
5716 self._scopes.clear();
5717 self
5718 }
5719}
5720
5721/// 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`.
5722///
5723/// A builder for the *instanceConfigs.operations.delete* method supported by a *project* resource.
5724/// It is not used directly, but through a [`ProjectMethods`] instance.
5725///
5726/// # Example
5727///
5728/// Instantiate a resource method builder
5729///
5730/// ```test_harness,no_run
5731/// # extern crate hyper;
5732/// # extern crate hyper_rustls;
5733/// # extern crate google_spanner1 as spanner1;
5734/// # async fn dox() {
5735/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5736///
5737/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5738/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5739/// # secret,
5740/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5741/// # ).build().await.unwrap();
5742///
5743/// # let client = hyper_util::client::legacy::Client::builder(
5744/// # hyper_util::rt::TokioExecutor::new()
5745/// # )
5746/// # .build(
5747/// # hyper_rustls::HttpsConnectorBuilder::new()
5748/// # .with_native_roots()
5749/// # .unwrap()
5750/// # .https_or_http()
5751/// # .enable_http1()
5752/// # .build()
5753/// # );
5754/// # let mut hub = Spanner::new(client, auth);
5755/// // You can configure optional parameters by calling the respective setters at will, and
5756/// // execute the final call using `doit()`.
5757/// // Values shown here are possibly random and not representative !
5758/// let result = hub.projects().instance_configs_operations_delete("name")
5759/// .doit().await;
5760/// # }
5761/// ```
5762pub struct ProjectInstanceConfigOperationDeleteCall<'a, C>
5763where
5764 C: 'a,
5765{
5766 hub: &'a Spanner<C>,
5767 _name: String,
5768 _delegate: Option<&'a mut dyn common::Delegate>,
5769 _additional_params: HashMap<String, String>,
5770 _scopes: BTreeSet<String>,
5771}
5772
5773impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationDeleteCall<'a, C> {}
5774
5775impl<'a, C> ProjectInstanceConfigOperationDeleteCall<'a, C>
5776where
5777 C: common::Connector,
5778{
5779 /// Perform the operation you have build so far.
5780 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5781 use std::borrow::Cow;
5782 use std::io::{Read, Seek};
5783
5784 use common::{url::Params, ToParts};
5785 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5786
5787 let mut dd = common::DefaultDelegate;
5788 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5789 dlg.begin(common::MethodInfo {
5790 id: "spanner.projects.instanceConfigs.operations.delete",
5791 http_method: hyper::Method::DELETE,
5792 });
5793
5794 for &field in ["alt", "name"].iter() {
5795 if self._additional_params.contains_key(field) {
5796 dlg.finished(false);
5797 return Err(common::Error::FieldClash(field));
5798 }
5799 }
5800
5801 let mut params = Params::with_capacity(3 + self._additional_params.len());
5802 params.push("name", self._name);
5803
5804 params.extend(self._additional_params.iter());
5805
5806 params.push("alt", "json");
5807 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5808 if self._scopes.is_empty() {
5809 self._scopes
5810 .insert(Scope::CloudPlatform.as_ref().to_string());
5811 }
5812
5813 #[allow(clippy::single_element_loop)]
5814 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5815 url = params.uri_replacement(url, param_name, find_this, true);
5816 }
5817 {
5818 let to_remove = ["name"];
5819 params.remove_params(&to_remove);
5820 }
5821
5822 let url = params.parse_with_url(&url);
5823
5824 loop {
5825 let token = match self
5826 .hub
5827 .auth
5828 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5829 .await
5830 {
5831 Ok(token) => token,
5832 Err(e) => match dlg.token(e) {
5833 Ok(token) => token,
5834 Err(e) => {
5835 dlg.finished(false);
5836 return Err(common::Error::MissingToken(e));
5837 }
5838 },
5839 };
5840 let mut req_result = {
5841 let client = &self.hub.client;
5842 dlg.pre_request();
5843 let mut req_builder = hyper::Request::builder()
5844 .method(hyper::Method::DELETE)
5845 .uri(url.as_str())
5846 .header(USER_AGENT, self.hub._user_agent.clone());
5847
5848 if let Some(token) = token.as_ref() {
5849 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5850 }
5851
5852 let request = req_builder
5853 .header(CONTENT_LENGTH, 0_u64)
5854 .body(common::to_body::<String>(None));
5855
5856 client.request(request.unwrap()).await
5857 };
5858
5859 match req_result {
5860 Err(err) => {
5861 if let common::Retry::After(d) = dlg.http_error(&err) {
5862 sleep(d).await;
5863 continue;
5864 }
5865 dlg.finished(false);
5866 return Err(common::Error::HttpError(err));
5867 }
5868 Ok(res) => {
5869 let (mut parts, body) = res.into_parts();
5870 let mut body = common::Body::new(body);
5871 if !parts.status.is_success() {
5872 let bytes = common::to_bytes(body).await.unwrap_or_default();
5873 let error = serde_json::from_str(&common::to_string(&bytes));
5874 let response = common::to_response(parts, bytes.into());
5875
5876 if let common::Retry::After(d) =
5877 dlg.http_failure(&response, error.as_ref().ok())
5878 {
5879 sleep(d).await;
5880 continue;
5881 }
5882
5883 dlg.finished(false);
5884
5885 return Err(match error {
5886 Ok(value) => common::Error::BadRequest(value),
5887 _ => common::Error::Failure(response),
5888 });
5889 }
5890 let response = {
5891 let bytes = common::to_bytes(body).await.unwrap_or_default();
5892 let encoded = common::to_string(&bytes);
5893 match serde_json::from_str(&encoded) {
5894 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5895 Err(error) => {
5896 dlg.response_json_decode_error(&encoded, &error);
5897 return Err(common::Error::JsonDecodeError(
5898 encoded.to_string(),
5899 error,
5900 ));
5901 }
5902 }
5903 };
5904
5905 dlg.finished(true);
5906 return Ok(response);
5907 }
5908 }
5909 }
5910 }
5911
5912 /// The name of the operation resource to be deleted.
5913 ///
5914 /// Sets the *name* path property to the given value.
5915 ///
5916 /// Even though the property as already been set when instantiating this call,
5917 /// we provide this method for API completeness.
5918 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigOperationDeleteCall<'a, C> {
5919 self._name = new_value.to_string();
5920 self
5921 }
5922 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5923 /// while executing the actual API request.
5924 ///
5925 /// ````text
5926 /// It should be used to handle progress information, and to implement a certain level of resilience.
5927 /// ````
5928 ///
5929 /// Sets the *delegate* property to the given value.
5930 pub fn delegate(
5931 mut self,
5932 new_value: &'a mut dyn common::Delegate,
5933 ) -> ProjectInstanceConfigOperationDeleteCall<'a, C> {
5934 self._delegate = Some(new_value);
5935 self
5936 }
5937
5938 /// Set any additional parameter of the query string used in the request.
5939 /// It should be used to set parameters which are not yet available through their own
5940 /// setters.
5941 ///
5942 /// Please note that this method must not be used to set any of the known parameters
5943 /// which have their own setter method. If done anyway, the request will fail.
5944 ///
5945 /// # Additional Parameters
5946 ///
5947 /// * *$.xgafv* (query-string) - V1 error format.
5948 /// * *access_token* (query-string) - OAuth access token.
5949 /// * *alt* (query-string) - Data format for response.
5950 /// * *callback* (query-string) - JSONP
5951 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5952 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5953 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5954 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5955 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5956 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5957 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5958 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationDeleteCall<'a, C>
5959 where
5960 T: AsRef<str>,
5961 {
5962 self._additional_params
5963 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5964 self
5965 }
5966
5967 /// Identifies the authorization scope for the method you are building.
5968 ///
5969 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5970 /// [`Scope::CloudPlatform`].
5971 ///
5972 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5973 /// tokens for more than one scope.
5974 ///
5975 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5976 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5977 /// sufficient, a read-write scope will do as well.
5978 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationDeleteCall<'a, C>
5979 where
5980 St: AsRef<str>,
5981 {
5982 self._scopes.insert(String::from(scope.as_ref()));
5983 self
5984 }
5985 /// Identifies the authorization scope(s) for the method you are building.
5986 ///
5987 /// See [`Self::add_scope()`] for details.
5988 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationDeleteCall<'a, C>
5989 where
5990 I: IntoIterator<Item = St>,
5991 St: AsRef<str>,
5992 {
5993 self._scopes
5994 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5995 self
5996 }
5997
5998 /// Removes all scopes, and no default scope will be used either.
5999 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6000 /// for details).
6001 pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationDeleteCall<'a, C> {
6002 self._scopes.clear();
6003 self
6004 }
6005}
6006
6007/// 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.
6008///
6009/// A builder for the *instanceConfigs.operations.get* method supported by a *project* resource.
6010/// It is not used directly, but through a [`ProjectMethods`] instance.
6011///
6012/// # Example
6013///
6014/// Instantiate a resource method builder
6015///
6016/// ```test_harness,no_run
6017/// # extern crate hyper;
6018/// # extern crate hyper_rustls;
6019/// # extern crate google_spanner1 as spanner1;
6020/// # async fn dox() {
6021/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6022///
6023/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6024/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6025/// # secret,
6026/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6027/// # ).build().await.unwrap();
6028///
6029/// # let client = hyper_util::client::legacy::Client::builder(
6030/// # hyper_util::rt::TokioExecutor::new()
6031/// # )
6032/// # .build(
6033/// # hyper_rustls::HttpsConnectorBuilder::new()
6034/// # .with_native_roots()
6035/// # .unwrap()
6036/// # .https_or_http()
6037/// # .enable_http1()
6038/// # .build()
6039/// # );
6040/// # let mut hub = Spanner::new(client, auth);
6041/// // You can configure optional parameters by calling the respective setters at will, and
6042/// // execute the final call using `doit()`.
6043/// // Values shown here are possibly random and not representative !
6044/// let result = hub.projects().instance_configs_operations_get("name")
6045/// .doit().await;
6046/// # }
6047/// ```
6048pub struct ProjectInstanceConfigOperationGetCall<'a, C>
6049where
6050 C: 'a,
6051{
6052 hub: &'a Spanner<C>,
6053 _name: String,
6054 _delegate: Option<&'a mut dyn common::Delegate>,
6055 _additional_params: HashMap<String, String>,
6056 _scopes: BTreeSet<String>,
6057}
6058
6059impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationGetCall<'a, C> {}
6060
6061impl<'a, C> ProjectInstanceConfigOperationGetCall<'a, C>
6062where
6063 C: common::Connector,
6064{
6065 /// Perform the operation you have build so far.
6066 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6067 use std::borrow::Cow;
6068 use std::io::{Read, Seek};
6069
6070 use common::{url::Params, ToParts};
6071 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6072
6073 let mut dd = common::DefaultDelegate;
6074 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6075 dlg.begin(common::MethodInfo {
6076 id: "spanner.projects.instanceConfigs.operations.get",
6077 http_method: hyper::Method::GET,
6078 });
6079
6080 for &field in ["alt", "name"].iter() {
6081 if self._additional_params.contains_key(field) {
6082 dlg.finished(false);
6083 return Err(common::Error::FieldClash(field));
6084 }
6085 }
6086
6087 let mut params = Params::with_capacity(3 + self._additional_params.len());
6088 params.push("name", self._name);
6089
6090 params.extend(self._additional_params.iter());
6091
6092 params.push("alt", "json");
6093 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6094 if self._scopes.is_empty() {
6095 self._scopes
6096 .insert(Scope::CloudPlatform.as_ref().to_string());
6097 }
6098
6099 #[allow(clippy::single_element_loop)]
6100 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6101 url = params.uri_replacement(url, param_name, find_this, true);
6102 }
6103 {
6104 let to_remove = ["name"];
6105 params.remove_params(&to_remove);
6106 }
6107
6108 let url = params.parse_with_url(&url);
6109
6110 loop {
6111 let token = match self
6112 .hub
6113 .auth
6114 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6115 .await
6116 {
6117 Ok(token) => token,
6118 Err(e) => match dlg.token(e) {
6119 Ok(token) => token,
6120 Err(e) => {
6121 dlg.finished(false);
6122 return Err(common::Error::MissingToken(e));
6123 }
6124 },
6125 };
6126 let mut req_result = {
6127 let client = &self.hub.client;
6128 dlg.pre_request();
6129 let mut req_builder = hyper::Request::builder()
6130 .method(hyper::Method::GET)
6131 .uri(url.as_str())
6132 .header(USER_AGENT, self.hub._user_agent.clone());
6133
6134 if let Some(token) = token.as_ref() {
6135 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6136 }
6137
6138 let request = req_builder
6139 .header(CONTENT_LENGTH, 0_u64)
6140 .body(common::to_body::<String>(None));
6141
6142 client.request(request.unwrap()).await
6143 };
6144
6145 match req_result {
6146 Err(err) => {
6147 if let common::Retry::After(d) = dlg.http_error(&err) {
6148 sleep(d).await;
6149 continue;
6150 }
6151 dlg.finished(false);
6152 return Err(common::Error::HttpError(err));
6153 }
6154 Ok(res) => {
6155 let (mut parts, body) = res.into_parts();
6156 let mut body = common::Body::new(body);
6157 if !parts.status.is_success() {
6158 let bytes = common::to_bytes(body).await.unwrap_or_default();
6159 let error = serde_json::from_str(&common::to_string(&bytes));
6160 let response = common::to_response(parts, bytes.into());
6161
6162 if let common::Retry::After(d) =
6163 dlg.http_failure(&response, error.as_ref().ok())
6164 {
6165 sleep(d).await;
6166 continue;
6167 }
6168
6169 dlg.finished(false);
6170
6171 return Err(match error {
6172 Ok(value) => common::Error::BadRequest(value),
6173 _ => common::Error::Failure(response),
6174 });
6175 }
6176 let response = {
6177 let bytes = common::to_bytes(body).await.unwrap_or_default();
6178 let encoded = common::to_string(&bytes);
6179 match serde_json::from_str(&encoded) {
6180 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6181 Err(error) => {
6182 dlg.response_json_decode_error(&encoded, &error);
6183 return Err(common::Error::JsonDecodeError(
6184 encoded.to_string(),
6185 error,
6186 ));
6187 }
6188 }
6189 };
6190
6191 dlg.finished(true);
6192 return Ok(response);
6193 }
6194 }
6195 }
6196 }
6197
6198 /// The name of the operation resource.
6199 ///
6200 /// Sets the *name* path property to the given value.
6201 ///
6202 /// Even though the property as already been set when instantiating this call,
6203 /// we provide this method for API completeness.
6204 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigOperationGetCall<'a, C> {
6205 self._name = new_value.to_string();
6206 self
6207 }
6208 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6209 /// while executing the actual API request.
6210 ///
6211 /// ````text
6212 /// It should be used to handle progress information, and to implement a certain level of resilience.
6213 /// ````
6214 ///
6215 /// Sets the *delegate* property to the given value.
6216 pub fn delegate(
6217 mut self,
6218 new_value: &'a mut dyn common::Delegate,
6219 ) -> ProjectInstanceConfigOperationGetCall<'a, C> {
6220 self._delegate = Some(new_value);
6221 self
6222 }
6223
6224 /// Set any additional parameter of the query string used in the request.
6225 /// It should be used to set parameters which are not yet available through their own
6226 /// setters.
6227 ///
6228 /// Please note that this method must not be used to set any of the known parameters
6229 /// which have their own setter method. If done anyway, the request will fail.
6230 ///
6231 /// # Additional Parameters
6232 ///
6233 /// * *$.xgafv* (query-string) - V1 error format.
6234 /// * *access_token* (query-string) - OAuth access token.
6235 /// * *alt* (query-string) - Data format for response.
6236 /// * *callback* (query-string) - JSONP
6237 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6238 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6239 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6240 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6241 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6242 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6243 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6244 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationGetCall<'a, C>
6245 where
6246 T: AsRef<str>,
6247 {
6248 self._additional_params
6249 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6250 self
6251 }
6252
6253 /// Identifies the authorization scope for the method you are building.
6254 ///
6255 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6256 /// [`Scope::CloudPlatform`].
6257 ///
6258 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6259 /// tokens for more than one scope.
6260 ///
6261 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6262 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6263 /// sufficient, a read-write scope will do as well.
6264 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationGetCall<'a, C>
6265 where
6266 St: AsRef<str>,
6267 {
6268 self._scopes.insert(String::from(scope.as_ref()));
6269 self
6270 }
6271 /// Identifies the authorization scope(s) for the method you are building.
6272 ///
6273 /// See [`Self::add_scope()`] for details.
6274 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationGetCall<'a, C>
6275 where
6276 I: IntoIterator<Item = St>,
6277 St: AsRef<str>,
6278 {
6279 self._scopes
6280 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6281 self
6282 }
6283
6284 /// Removes all scopes, and no default scope will be used either.
6285 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6286 /// for details).
6287 pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationGetCall<'a, C> {
6288 self._scopes.clear();
6289 self
6290 }
6291}
6292
6293/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
6294///
6295/// A builder for the *instanceConfigs.operations.list* method supported by a *project* resource.
6296/// It is not used directly, but through a [`ProjectMethods`] instance.
6297///
6298/// # Example
6299///
6300/// Instantiate a resource method builder
6301///
6302/// ```test_harness,no_run
6303/// # extern crate hyper;
6304/// # extern crate hyper_rustls;
6305/// # extern crate google_spanner1 as spanner1;
6306/// # async fn dox() {
6307/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6308///
6309/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6310/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6311/// # secret,
6312/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6313/// # ).build().await.unwrap();
6314///
6315/// # let client = hyper_util::client::legacy::Client::builder(
6316/// # hyper_util::rt::TokioExecutor::new()
6317/// # )
6318/// # .build(
6319/// # hyper_rustls::HttpsConnectorBuilder::new()
6320/// # .with_native_roots()
6321/// # .unwrap()
6322/// # .https_or_http()
6323/// # .enable_http1()
6324/// # .build()
6325/// # );
6326/// # let mut hub = Spanner::new(client, auth);
6327/// // You can configure optional parameters by calling the respective setters at will, and
6328/// // execute the final call using `doit()`.
6329/// // Values shown here are possibly random and not representative !
6330/// let result = hub.projects().instance_configs_operations_list("name")
6331/// .page_token("ipsum")
6332/// .page_size(-93)
6333/// .filter("ut")
6334/// .doit().await;
6335/// # }
6336/// ```
6337pub struct ProjectInstanceConfigOperationListCall1<'a, C>
6338where
6339 C: 'a,
6340{
6341 hub: &'a Spanner<C>,
6342 _name: String,
6343 _page_token: Option<String>,
6344 _page_size: Option<i32>,
6345 _filter: Option<String>,
6346 _delegate: Option<&'a mut dyn common::Delegate>,
6347 _additional_params: HashMap<String, String>,
6348 _scopes: BTreeSet<String>,
6349}
6350
6351impl<'a, C> common::CallBuilder for ProjectInstanceConfigOperationListCall1<'a, C> {}
6352
6353impl<'a, C> ProjectInstanceConfigOperationListCall1<'a, C>
6354where
6355 C: common::Connector,
6356{
6357 /// Perform the operation you have build so far.
6358 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
6359 use std::borrow::Cow;
6360 use std::io::{Read, Seek};
6361
6362 use common::{url::Params, ToParts};
6363 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6364
6365 let mut dd = common::DefaultDelegate;
6366 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6367 dlg.begin(common::MethodInfo {
6368 id: "spanner.projects.instanceConfigs.operations.list",
6369 http_method: hyper::Method::GET,
6370 });
6371
6372 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
6373 if self._additional_params.contains_key(field) {
6374 dlg.finished(false);
6375 return Err(common::Error::FieldClash(field));
6376 }
6377 }
6378
6379 let mut params = Params::with_capacity(6 + self._additional_params.len());
6380 params.push("name", self._name);
6381 if let Some(value) = self._page_token.as_ref() {
6382 params.push("pageToken", value);
6383 }
6384 if let Some(value) = self._page_size.as_ref() {
6385 params.push("pageSize", value.to_string());
6386 }
6387 if let Some(value) = self._filter.as_ref() {
6388 params.push("filter", value);
6389 }
6390
6391 params.extend(self._additional_params.iter());
6392
6393 params.push("alt", "json");
6394 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6395 if self._scopes.is_empty() {
6396 self._scopes
6397 .insert(Scope::CloudPlatform.as_ref().to_string());
6398 }
6399
6400 #[allow(clippy::single_element_loop)]
6401 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6402 url = params.uri_replacement(url, param_name, find_this, true);
6403 }
6404 {
6405 let to_remove = ["name"];
6406 params.remove_params(&to_remove);
6407 }
6408
6409 let url = params.parse_with_url(&url);
6410
6411 loop {
6412 let token = match self
6413 .hub
6414 .auth
6415 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6416 .await
6417 {
6418 Ok(token) => token,
6419 Err(e) => match dlg.token(e) {
6420 Ok(token) => token,
6421 Err(e) => {
6422 dlg.finished(false);
6423 return Err(common::Error::MissingToken(e));
6424 }
6425 },
6426 };
6427 let mut req_result = {
6428 let client = &self.hub.client;
6429 dlg.pre_request();
6430 let mut req_builder = hyper::Request::builder()
6431 .method(hyper::Method::GET)
6432 .uri(url.as_str())
6433 .header(USER_AGENT, self.hub._user_agent.clone());
6434
6435 if let Some(token) = token.as_ref() {
6436 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6437 }
6438
6439 let request = req_builder
6440 .header(CONTENT_LENGTH, 0_u64)
6441 .body(common::to_body::<String>(None));
6442
6443 client.request(request.unwrap()).await
6444 };
6445
6446 match req_result {
6447 Err(err) => {
6448 if let common::Retry::After(d) = dlg.http_error(&err) {
6449 sleep(d).await;
6450 continue;
6451 }
6452 dlg.finished(false);
6453 return Err(common::Error::HttpError(err));
6454 }
6455 Ok(res) => {
6456 let (mut parts, body) = res.into_parts();
6457 let mut body = common::Body::new(body);
6458 if !parts.status.is_success() {
6459 let bytes = common::to_bytes(body).await.unwrap_or_default();
6460 let error = serde_json::from_str(&common::to_string(&bytes));
6461 let response = common::to_response(parts, bytes.into());
6462
6463 if let common::Retry::After(d) =
6464 dlg.http_failure(&response, error.as_ref().ok())
6465 {
6466 sleep(d).await;
6467 continue;
6468 }
6469
6470 dlg.finished(false);
6471
6472 return Err(match error {
6473 Ok(value) => common::Error::BadRequest(value),
6474 _ => common::Error::Failure(response),
6475 });
6476 }
6477 let response = {
6478 let bytes = common::to_bytes(body).await.unwrap_or_default();
6479 let encoded = common::to_string(&bytes);
6480 match serde_json::from_str(&encoded) {
6481 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6482 Err(error) => {
6483 dlg.response_json_decode_error(&encoded, &error);
6484 return Err(common::Error::JsonDecodeError(
6485 encoded.to_string(),
6486 error,
6487 ));
6488 }
6489 }
6490 };
6491
6492 dlg.finished(true);
6493 return Ok(response);
6494 }
6495 }
6496 }
6497 }
6498
6499 /// The name of the operation's parent resource.
6500 ///
6501 /// Sets the *name* path property to the given value.
6502 ///
6503 /// Even though the property as already been set when instantiating this call,
6504 /// we provide this method for API completeness.
6505 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall1<'a, C> {
6506 self._name = new_value.to_string();
6507 self
6508 }
6509 /// The standard list page token.
6510 ///
6511 /// Sets the *page token* query property to the given value.
6512 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall1<'a, C> {
6513 self._page_token = Some(new_value.to_string());
6514 self
6515 }
6516 /// The standard list page size.
6517 ///
6518 /// Sets the *page size* query property to the given value.
6519 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceConfigOperationListCall1<'a, C> {
6520 self._page_size = Some(new_value);
6521 self
6522 }
6523 /// The standard list filter.
6524 ///
6525 /// Sets the *filter* query property to the given value.
6526 pub fn filter(mut self, new_value: &str) -> ProjectInstanceConfigOperationListCall1<'a, C> {
6527 self._filter = Some(new_value.to_string());
6528 self
6529 }
6530 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6531 /// while executing the actual API request.
6532 ///
6533 /// ````text
6534 /// It should be used to handle progress information, and to implement a certain level of resilience.
6535 /// ````
6536 ///
6537 /// Sets the *delegate* property to the given value.
6538 pub fn delegate(
6539 mut self,
6540 new_value: &'a mut dyn common::Delegate,
6541 ) -> ProjectInstanceConfigOperationListCall1<'a, C> {
6542 self._delegate = Some(new_value);
6543 self
6544 }
6545
6546 /// Set any additional parameter of the query string used in the request.
6547 /// It should be used to set parameters which are not yet available through their own
6548 /// setters.
6549 ///
6550 /// Please note that this method must not be used to set any of the known parameters
6551 /// which have their own setter method. If done anyway, the request will fail.
6552 ///
6553 /// # Additional Parameters
6554 ///
6555 /// * *$.xgafv* (query-string) - V1 error format.
6556 /// * *access_token* (query-string) - OAuth access token.
6557 /// * *alt* (query-string) - Data format for response.
6558 /// * *callback* (query-string) - JSONP
6559 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6560 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6561 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6562 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6563 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6564 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6565 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6566 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigOperationListCall1<'a, C>
6567 where
6568 T: AsRef<str>,
6569 {
6570 self._additional_params
6571 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6572 self
6573 }
6574
6575 /// Identifies the authorization scope for the method you are building.
6576 ///
6577 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6578 /// [`Scope::CloudPlatform`].
6579 ///
6580 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6581 /// tokens for more than one scope.
6582 ///
6583 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6584 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6585 /// sufficient, a read-write scope will do as well.
6586 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigOperationListCall1<'a, C>
6587 where
6588 St: AsRef<str>,
6589 {
6590 self._scopes.insert(String::from(scope.as_ref()));
6591 self
6592 }
6593 /// Identifies the authorization scope(s) for the method you are building.
6594 ///
6595 /// See [`Self::add_scope()`] for details.
6596 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigOperationListCall1<'a, C>
6597 where
6598 I: IntoIterator<Item = St>,
6599 St: AsRef<str>,
6600 {
6601 self._scopes
6602 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6603 self
6604 }
6605
6606 /// Removes all scopes, and no default scope will be used either.
6607 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6608 /// for details).
6609 pub fn clear_scopes(mut self) -> ProjectInstanceConfigOperationListCall1<'a, C> {
6610 self._scopes.clear();
6611 self
6612 }
6613}
6614
6615/// 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`.
6616///
6617/// A builder for the *instanceConfigs.ssdCaches.operations.cancel* method supported by a *project* resource.
6618/// It is not used directly, but through a [`ProjectMethods`] instance.
6619///
6620/// # Example
6621///
6622/// Instantiate a resource method builder
6623///
6624/// ```test_harness,no_run
6625/// # extern crate hyper;
6626/// # extern crate hyper_rustls;
6627/// # extern crate google_spanner1 as spanner1;
6628/// # async fn dox() {
6629/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6630///
6631/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6632/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6633/// # secret,
6634/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6635/// # ).build().await.unwrap();
6636///
6637/// # let client = hyper_util::client::legacy::Client::builder(
6638/// # hyper_util::rt::TokioExecutor::new()
6639/// # )
6640/// # .build(
6641/// # hyper_rustls::HttpsConnectorBuilder::new()
6642/// # .with_native_roots()
6643/// # .unwrap()
6644/// # .https_or_http()
6645/// # .enable_http1()
6646/// # .build()
6647/// # );
6648/// # let mut hub = Spanner::new(client, auth);
6649/// // You can configure optional parameters by calling the respective setters at will, and
6650/// // execute the final call using `doit()`.
6651/// // Values shown here are possibly random and not representative !
6652/// let result = hub.projects().instance_configs_ssd_caches_operations_cancel("name")
6653/// .doit().await;
6654/// # }
6655/// ```
6656pub struct ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
6657where
6658 C: 'a,
6659{
6660 hub: &'a Spanner<C>,
6661 _name: String,
6662 _delegate: Option<&'a mut dyn common::Delegate>,
6663 _additional_params: HashMap<String, String>,
6664 _scopes: BTreeSet<String>,
6665}
6666
6667impl<'a, C> common::CallBuilder for ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {}
6668
6669impl<'a, C> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
6670where
6671 C: common::Connector,
6672{
6673 /// Perform the operation you have build so far.
6674 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6675 use std::borrow::Cow;
6676 use std::io::{Read, Seek};
6677
6678 use common::{url::Params, ToParts};
6679 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6680
6681 let mut dd = common::DefaultDelegate;
6682 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6683 dlg.begin(common::MethodInfo {
6684 id: "spanner.projects.instanceConfigs.ssdCaches.operations.cancel",
6685 http_method: hyper::Method::POST,
6686 });
6687
6688 for &field in ["alt", "name"].iter() {
6689 if self._additional_params.contains_key(field) {
6690 dlg.finished(false);
6691 return Err(common::Error::FieldClash(field));
6692 }
6693 }
6694
6695 let mut params = Params::with_capacity(3 + self._additional_params.len());
6696 params.push("name", self._name);
6697
6698 params.extend(self._additional_params.iter());
6699
6700 params.push("alt", "json");
6701 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
6702 if self._scopes.is_empty() {
6703 self._scopes
6704 .insert(Scope::CloudPlatform.as_ref().to_string());
6705 }
6706
6707 #[allow(clippy::single_element_loop)]
6708 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6709 url = params.uri_replacement(url, param_name, find_this, true);
6710 }
6711 {
6712 let to_remove = ["name"];
6713 params.remove_params(&to_remove);
6714 }
6715
6716 let url = params.parse_with_url(&url);
6717
6718 loop {
6719 let token = match self
6720 .hub
6721 .auth
6722 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6723 .await
6724 {
6725 Ok(token) => token,
6726 Err(e) => match dlg.token(e) {
6727 Ok(token) => token,
6728 Err(e) => {
6729 dlg.finished(false);
6730 return Err(common::Error::MissingToken(e));
6731 }
6732 },
6733 };
6734 let mut req_result = {
6735 let client = &self.hub.client;
6736 dlg.pre_request();
6737 let mut req_builder = hyper::Request::builder()
6738 .method(hyper::Method::POST)
6739 .uri(url.as_str())
6740 .header(USER_AGENT, self.hub._user_agent.clone());
6741
6742 if let Some(token) = token.as_ref() {
6743 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6744 }
6745
6746 let request = req_builder
6747 .header(CONTENT_LENGTH, 0_u64)
6748 .body(common::to_body::<String>(None));
6749
6750 client.request(request.unwrap()).await
6751 };
6752
6753 match req_result {
6754 Err(err) => {
6755 if let common::Retry::After(d) = dlg.http_error(&err) {
6756 sleep(d).await;
6757 continue;
6758 }
6759 dlg.finished(false);
6760 return Err(common::Error::HttpError(err));
6761 }
6762 Ok(res) => {
6763 let (mut parts, body) = res.into_parts();
6764 let mut body = common::Body::new(body);
6765 if !parts.status.is_success() {
6766 let bytes = common::to_bytes(body).await.unwrap_or_default();
6767 let error = serde_json::from_str(&common::to_string(&bytes));
6768 let response = common::to_response(parts, bytes.into());
6769
6770 if let common::Retry::After(d) =
6771 dlg.http_failure(&response, error.as_ref().ok())
6772 {
6773 sleep(d).await;
6774 continue;
6775 }
6776
6777 dlg.finished(false);
6778
6779 return Err(match error {
6780 Ok(value) => common::Error::BadRequest(value),
6781 _ => common::Error::Failure(response),
6782 });
6783 }
6784 let response = {
6785 let bytes = common::to_bytes(body).await.unwrap_or_default();
6786 let encoded = common::to_string(&bytes);
6787 match serde_json::from_str(&encoded) {
6788 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6789 Err(error) => {
6790 dlg.response_json_decode_error(&encoded, &error);
6791 return Err(common::Error::JsonDecodeError(
6792 encoded.to_string(),
6793 error,
6794 ));
6795 }
6796 }
6797 };
6798
6799 dlg.finished(true);
6800 return Ok(response);
6801 }
6802 }
6803 }
6804 }
6805
6806 /// The name of the operation resource to be cancelled.
6807 ///
6808 /// Sets the *name* path property to the given value.
6809 ///
6810 /// Even though the property as already been set when instantiating this call,
6811 /// we provide this method for API completeness.
6812 pub fn name(
6813 mut self,
6814 new_value: &str,
6815 ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {
6816 self._name = new_value.to_string();
6817 self
6818 }
6819 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6820 /// while executing the actual API request.
6821 ///
6822 /// ````text
6823 /// It should be used to handle progress information, and to implement a certain level of resilience.
6824 /// ````
6825 ///
6826 /// Sets the *delegate* property to the given value.
6827 pub fn delegate(
6828 mut self,
6829 new_value: &'a mut dyn common::Delegate,
6830 ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {
6831 self._delegate = Some(new_value);
6832 self
6833 }
6834
6835 /// Set any additional parameter of the query string used in the request.
6836 /// It should be used to set parameters which are not yet available through their own
6837 /// setters.
6838 ///
6839 /// Please note that this method must not be used to set any of the known parameters
6840 /// which have their own setter method. If done anyway, the request will fail.
6841 ///
6842 /// # Additional Parameters
6843 ///
6844 /// * *$.xgafv* (query-string) - V1 error format.
6845 /// * *access_token* (query-string) - OAuth access token.
6846 /// * *alt* (query-string) - Data format for response.
6847 /// * *callback* (query-string) - JSONP
6848 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6849 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6850 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6851 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6852 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6853 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6854 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6855 pub fn param<T>(
6856 mut self,
6857 name: T,
6858 value: T,
6859 ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
6860 where
6861 T: AsRef<str>,
6862 {
6863 self._additional_params
6864 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6865 self
6866 }
6867
6868 /// Identifies the authorization scope for the method you are building.
6869 ///
6870 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6871 /// [`Scope::CloudPlatform`].
6872 ///
6873 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6874 /// tokens for more than one scope.
6875 ///
6876 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6877 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6878 /// sufficient, a read-write scope will do as well.
6879 pub fn add_scope<St>(
6880 mut self,
6881 scope: St,
6882 ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
6883 where
6884 St: AsRef<str>,
6885 {
6886 self._scopes.insert(String::from(scope.as_ref()));
6887 self
6888 }
6889 /// Identifies the authorization scope(s) for the method you are building.
6890 ///
6891 /// See [`Self::add_scope()`] for details.
6892 pub fn add_scopes<I, St>(
6893 mut self,
6894 scopes: I,
6895 ) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C>
6896 where
6897 I: IntoIterator<Item = St>,
6898 St: AsRef<str>,
6899 {
6900 self._scopes
6901 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6902 self
6903 }
6904
6905 /// Removes all scopes, and no default scope will be used either.
6906 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6907 /// for details).
6908 pub fn clear_scopes(mut self) -> ProjectInstanceConfigSsdCachOperationCancelCall<'a, C> {
6909 self._scopes.clear();
6910 self
6911 }
6912}
6913
6914/// 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`.
6915///
6916/// A builder for the *instanceConfigs.ssdCaches.operations.delete* method supported by a *project* resource.
6917/// It is not used directly, but through a [`ProjectMethods`] instance.
6918///
6919/// # Example
6920///
6921/// Instantiate a resource method builder
6922///
6923/// ```test_harness,no_run
6924/// # extern crate hyper;
6925/// # extern crate hyper_rustls;
6926/// # extern crate google_spanner1 as spanner1;
6927/// # async fn dox() {
6928/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6929///
6930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6931/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6932/// # secret,
6933/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6934/// # ).build().await.unwrap();
6935///
6936/// # let client = hyper_util::client::legacy::Client::builder(
6937/// # hyper_util::rt::TokioExecutor::new()
6938/// # )
6939/// # .build(
6940/// # hyper_rustls::HttpsConnectorBuilder::new()
6941/// # .with_native_roots()
6942/// # .unwrap()
6943/// # .https_or_http()
6944/// # .enable_http1()
6945/// # .build()
6946/// # );
6947/// # let mut hub = Spanner::new(client, auth);
6948/// // You can configure optional parameters by calling the respective setters at will, and
6949/// // execute the final call using `doit()`.
6950/// // Values shown here are possibly random and not representative !
6951/// let result = hub.projects().instance_configs_ssd_caches_operations_delete("name")
6952/// .doit().await;
6953/// # }
6954/// ```
6955pub struct ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
6956where
6957 C: 'a,
6958{
6959 hub: &'a Spanner<C>,
6960 _name: String,
6961 _delegate: Option<&'a mut dyn common::Delegate>,
6962 _additional_params: HashMap<String, String>,
6963 _scopes: BTreeSet<String>,
6964}
6965
6966impl<'a, C> common::CallBuilder for ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {}
6967
6968impl<'a, C> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
6969where
6970 C: common::Connector,
6971{
6972 /// Perform the operation you have build so far.
6973 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6974 use std::borrow::Cow;
6975 use std::io::{Read, Seek};
6976
6977 use common::{url::Params, ToParts};
6978 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6979
6980 let mut dd = common::DefaultDelegate;
6981 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6982 dlg.begin(common::MethodInfo {
6983 id: "spanner.projects.instanceConfigs.ssdCaches.operations.delete",
6984 http_method: hyper::Method::DELETE,
6985 });
6986
6987 for &field in ["alt", "name"].iter() {
6988 if self._additional_params.contains_key(field) {
6989 dlg.finished(false);
6990 return Err(common::Error::FieldClash(field));
6991 }
6992 }
6993
6994 let mut params = Params::with_capacity(3 + self._additional_params.len());
6995 params.push("name", self._name);
6996
6997 params.extend(self._additional_params.iter());
6998
6999 params.push("alt", "json");
7000 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7001 if self._scopes.is_empty() {
7002 self._scopes
7003 .insert(Scope::CloudPlatform.as_ref().to_string());
7004 }
7005
7006 #[allow(clippy::single_element_loop)]
7007 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7008 url = params.uri_replacement(url, param_name, find_this, true);
7009 }
7010 {
7011 let to_remove = ["name"];
7012 params.remove_params(&to_remove);
7013 }
7014
7015 let url = params.parse_with_url(&url);
7016
7017 loop {
7018 let token = match self
7019 .hub
7020 .auth
7021 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7022 .await
7023 {
7024 Ok(token) => token,
7025 Err(e) => match dlg.token(e) {
7026 Ok(token) => token,
7027 Err(e) => {
7028 dlg.finished(false);
7029 return Err(common::Error::MissingToken(e));
7030 }
7031 },
7032 };
7033 let mut req_result = {
7034 let client = &self.hub.client;
7035 dlg.pre_request();
7036 let mut req_builder = hyper::Request::builder()
7037 .method(hyper::Method::DELETE)
7038 .uri(url.as_str())
7039 .header(USER_AGENT, self.hub._user_agent.clone());
7040
7041 if let Some(token) = token.as_ref() {
7042 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7043 }
7044
7045 let request = req_builder
7046 .header(CONTENT_LENGTH, 0_u64)
7047 .body(common::to_body::<String>(None));
7048
7049 client.request(request.unwrap()).await
7050 };
7051
7052 match req_result {
7053 Err(err) => {
7054 if let common::Retry::After(d) = dlg.http_error(&err) {
7055 sleep(d).await;
7056 continue;
7057 }
7058 dlg.finished(false);
7059 return Err(common::Error::HttpError(err));
7060 }
7061 Ok(res) => {
7062 let (mut parts, body) = res.into_parts();
7063 let mut body = common::Body::new(body);
7064 if !parts.status.is_success() {
7065 let bytes = common::to_bytes(body).await.unwrap_or_default();
7066 let error = serde_json::from_str(&common::to_string(&bytes));
7067 let response = common::to_response(parts, bytes.into());
7068
7069 if let common::Retry::After(d) =
7070 dlg.http_failure(&response, error.as_ref().ok())
7071 {
7072 sleep(d).await;
7073 continue;
7074 }
7075
7076 dlg.finished(false);
7077
7078 return Err(match error {
7079 Ok(value) => common::Error::BadRequest(value),
7080 _ => common::Error::Failure(response),
7081 });
7082 }
7083 let response = {
7084 let bytes = common::to_bytes(body).await.unwrap_or_default();
7085 let encoded = common::to_string(&bytes);
7086 match serde_json::from_str(&encoded) {
7087 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7088 Err(error) => {
7089 dlg.response_json_decode_error(&encoded, &error);
7090 return Err(common::Error::JsonDecodeError(
7091 encoded.to_string(),
7092 error,
7093 ));
7094 }
7095 }
7096 };
7097
7098 dlg.finished(true);
7099 return Ok(response);
7100 }
7101 }
7102 }
7103 }
7104
7105 /// The name of the operation resource to be deleted.
7106 ///
7107 /// Sets the *name* path property to the given value.
7108 ///
7109 /// Even though the property as already been set when instantiating this call,
7110 /// we provide this method for API completeness.
7111 pub fn name(
7112 mut self,
7113 new_value: &str,
7114 ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {
7115 self._name = new_value.to_string();
7116 self
7117 }
7118 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7119 /// while executing the actual API request.
7120 ///
7121 /// ````text
7122 /// It should be used to handle progress information, and to implement a certain level of resilience.
7123 /// ````
7124 ///
7125 /// Sets the *delegate* property to the given value.
7126 pub fn delegate(
7127 mut self,
7128 new_value: &'a mut dyn common::Delegate,
7129 ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {
7130 self._delegate = Some(new_value);
7131 self
7132 }
7133
7134 /// Set any additional parameter of the query string used in the request.
7135 /// It should be used to set parameters which are not yet available through their own
7136 /// setters.
7137 ///
7138 /// Please note that this method must not be used to set any of the known parameters
7139 /// which have their own setter method. If done anyway, the request will fail.
7140 ///
7141 /// # Additional Parameters
7142 ///
7143 /// * *$.xgafv* (query-string) - V1 error format.
7144 /// * *access_token* (query-string) - OAuth access token.
7145 /// * *alt* (query-string) - Data format for response.
7146 /// * *callback* (query-string) - JSONP
7147 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7148 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7149 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7150 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7151 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7152 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7153 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7154 pub fn param<T>(
7155 mut self,
7156 name: T,
7157 value: T,
7158 ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
7159 where
7160 T: AsRef<str>,
7161 {
7162 self._additional_params
7163 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7164 self
7165 }
7166
7167 /// Identifies the authorization scope for the method you are building.
7168 ///
7169 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7170 /// [`Scope::CloudPlatform`].
7171 ///
7172 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7173 /// tokens for more than one scope.
7174 ///
7175 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7176 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7177 /// sufficient, a read-write scope will do as well.
7178 pub fn add_scope<St>(
7179 mut self,
7180 scope: St,
7181 ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
7182 where
7183 St: AsRef<str>,
7184 {
7185 self._scopes.insert(String::from(scope.as_ref()));
7186 self
7187 }
7188 /// Identifies the authorization scope(s) for the method you are building.
7189 ///
7190 /// See [`Self::add_scope()`] for details.
7191 pub fn add_scopes<I, St>(
7192 mut self,
7193 scopes: I,
7194 ) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C>
7195 where
7196 I: IntoIterator<Item = St>,
7197 St: AsRef<str>,
7198 {
7199 self._scopes
7200 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7201 self
7202 }
7203
7204 /// Removes all scopes, and no default scope will be used either.
7205 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7206 /// for details).
7207 pub fn clear_scopes(mut self) -> ProjectInstanceConfigSsdCachOperationDeleteCall<'a, C> {
7208 self._scopes.clear();
7209 self
7210 }
7211}
7212
7213/// 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.
7214///
7215/// A builder for the *instanceConfigs.ssdCaches.operations.get* method supported by a *project* resource.
7216/// It is not used directly, but through a [`ProjectMethods`] instance.
7217///
7218/// # Example
7219///
7220/// Instantiate a resource method builder
7221///
7222/// ```test_harness,no_run
7223/// # extern crate hyper;
7224/// # extern crate hyper_rustls;
7225/// # extern crate google_spanner1 as spanner1;
7226/// # async fn dox() {
7227/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7228///
7229/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7230/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7231/// # secret,
7232/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7233/// # ).build().await.unwrap();
7234///
7235/// # let client = hyper_util::client::legacy::Client::builder(
7236/// # hyper_util::rt::TokioExecutor::new()
7237/// # )
7238/// # .build(
7239/// # hyper_rustls::HttpsConnectorBuilder::new()
7240/// # .with_native_roots()
7241/// # .unwrap()
7242/// # .https_or_http()
7243/// # .enable_http1()
7244/// # .build()
7245/// # );
7246/// # let mut hub = Spanner::new(client, auth);
7247/// // You can configure optional parameters by calling the respective setters at will, and
7248/// // execute the final call using `doit()`.
7249/// // Values shown here are possibly random and not representative !
7250/// let result = hub.projects().instance_configs_ssd_caches_operations_get("name")
7251/// .doit().await;
7252/// # }
7253/// ```
7254pub struct ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
7255where
7256 C: 'a,
7257{
7258 hub: &'a Spanner<C>,
7259 _name: String,
7260 _delegate: Option<&'a mut dyn common::Delegate>,
7261 _additional_params: HashMap<String, String>,
7262 _scopes: BTreeSet<String>,
7263}
7264
7265impl<'a, C> common::CallBuilder for ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {}
7266
7267impl<'a, C> ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
7268where
7269 C: common::Connector,
7270{
7271 /// Perform the operation you have build so far.
7272 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7273 use std::borrow::Cow;
7274 use std::io::{Read, Seek};
7275
7276 use common::{url::Params, ToParts};
7277 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7278
7279 let mut dd = common::DefaultDelegate;
7280 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7281 dlg.begin(common::MethodInfo {
7282 id: "spanner.projects.instanceConfigs.ssdCaches.operations.get",
7283 http_method: hyper::Method::GET,
7284 });
7285
7286 for &field in ["alt", "name"].iter() {
7287 if self._additional_params.contains_key(field) {
7288 dlg.finished(false);
7289 return Err(common::Error::FieldClash(field));
7290 }
7291 }
7292
7293 let mut params = Params::with_capacity(3 + self._additional_params.len());
7294 params.push("name", self._name);
7295
7296 params.extend(self._additional_params.iter());
7297
7298 params.push("alt", "json");
7299 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7300 if self._scopes.is_empty() {
7301 self._scopes
7302 .insert(Scope::CloudPlatform.as_ref().to_string());
7303 }
7304
7305 #[allow(clippy::single_element_loop)]
7306 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7307 url = params.uri_replacement(url, param_name, find_this, true);
7308 }
7309 {
7310 let to_remove = ["name"];
7311 params.remove_params(&to_remove);
7312 }
7313
7314 let url = params.parse_with_url(&url);
7315
7316 loop {
7317 let token = match self
7318 .hub
7319 .auth
7320 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7321 .await
7322 {
7323 Ok(token) => token,
7324 Err(e) => match dlg.token(e) {
7325 Ok(token) => token,
7326 Err(e) => {
7327 dlg.finished(false);
7328 return Err(common::Error::MissingToken(e));
7329 }
7330 },
7331 };
7332 let mut req_result = {
7333 let client = &self.hub.client;
7334 dlg.pre_request();
7335 let mut req_builder = hyper::Request::builder()
7336 .method(hyper::Method::GET)
7337 .uri(url.as_str())
7338 .header(USER_AGENT, self.hub._user_agent.clone());
7339
7340 if let Some(token) = token.as_ref() {
7341 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7342 }
7343
7344 let request = req_builder
7345 .header(CONTENT_LENGTH, 0_u64)
7346 .body(common::to_body::<String>(None));
7347
7348 client.request(request.unwrap()).await
7349 };
7350
7351 match req_result {
7352 Err(err) => {
7353 if let common::Retry::After(d) = dlg.http_error(&err) {
7354 sleep(d).await;
7355 continue;
7356 }
7357 dlg.finished(false);
7358 return Err(common::Error::HttpError(err));
7359 }
7360 Ok(res) => {
7361 let (mut parts, body) = res.into_parts();
7362 let mut body = common::Body::new(body);
7363 if !parts.status.is_success() {
7364 let bytes = common::to_bytes(body).await.unwrap_or_default();
7365 let error = serde_json::from_str(&common::to_string(&bytes));
7366 let response = common::to_response(parts, bytes.into());
7367
7368 if let common::Retry::After(d) =
7369 dlg.http_failure(&response, error.as_ref().ok())
7370 {
7371 sleep(d).await;
7372 continue;
7373 }
7374
7375 dlg.finished(false);
7376
7377 return Err(match error {
7378 Ok(value) => common::Error::BadRequest(value),
7379 _ => common::Error::Failure(response),
7380 });
7381 }
7382 let response = {
7383 let bytes = common::to_bytes(body).await.unwrap_or_default();
7384 let encoded = common::to_string(&bytes);
7385 match serde_json::from_str(&encoded) {
7386 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7387 Err(error) => {
7388 dlg.response_json_decode_error(&encoded, &error);
7389 return Err(common::Error::JsonDecodeError(
7390 encoded.to_string(),
7391 error,
7392 ));
7393 }
7394 }
7395 };
7396
7397 dlg.finished(true);
7398 return Ok(response);
7399 }
7400 }
7401 }
7402 }
7403
7404 /// The name of the operation resource.
7405 ///
7406 /// Sets the *name* path property to the given value.
7407 ///
7408 /// Even though the property as already been set when instantiating this call,
7409 /// we provide this method for API completeness.
7410 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {
7411 self._name = new_value.to_string();
7412 self
7413 }
7414 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7415 /// while executing the actual API request.
7416 ///
7417 /// ````text
7418 /// It should be used to handle progress information, and to implement a certain level of resilience.
7419 /// ````
7420 ///
7421 /// Sets the *delegate* property to the given value.
7422 pub fn delegate(
7423 mut self,
7424 new_value: &'a mut dyn common::Delegate,
7425 ) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {
7426 self._delegate = Some(new_value);
7427 self
7428 }
7429
7430 /// Set any additional parameter of the query string used in the request.
7431 /// It should be used to set parameters which are not yet available through their own
7432 /// setters.
7433 ///
7434 /// Please note that this method must not be used to set any of the known parameters
7435 /// which have their own setter method. If done anyway, the request will fail.
7436 ///
7437 /// # Additional Parameters
7438 ///
7439 /// * *$.xgafv* (query-string) - V1 error format.
7440 /// * *access_token* (query-string) - OAuth access token.
7441 /// * *alt* (query-string) - Data format for response.
7442 /// * *callback* (query-string) - JSONP
7443 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7444 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7445 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7446 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7447 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7448 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7449 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7450 pub fn param<T>(
7451 mut self,
7452 name: T,
7453 value: T,
7454 ) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
7455 where
7456 T: AsRef<str>,
7457 {
7458 self._additional_params
7459 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7460 self
7461 }
7462
7463 /// Identifies the authorization scope for the method you are building.
7464 ///
7465 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7466 /// [`Scope::CloudPlatform`].
7467 ///
7468 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7469 /// tokens for more than one scope.
7470 ///
7471 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7472 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7473 /// sufficient, a read-write scope will do as well.
7474 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
7475 where
7476 St: AsRef<str>,
7477 {
7478 self._scopes.insert(String::from(scope.as_ref()));
7479 self
7480 }
7481 /// Identifies the authorization scope(s) for the method you are building.
7482 ///
7483 /// See [`Self::add_scope()`] for details.
7484 pub fn add_scopes<I, St>(
7485 mut self,
7486 scopes: I,
7487 ) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C>
7488 where
7489 I: IntoIterator<Item = St>,
7490 St: AsRef<str>,
7491 {
7492 self._scopes
7493 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7494 self
7495 }
7496
7497 /// Removes all scopes, and no default scope will be used either.
7498 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7499 /// for details).
7500 pub fn clear_scopes(mut self) -> ProjectInstanceConfigSsdCachOperationGetCall<'a, C> {
7501 self._scopes.clear();
7502 self
7503 }
7504}
7505
7506/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
7507///
7508/// A builder for the *instanceConfigs.ssdCaches.operations.list* method supported by a *project* resource.
7509/// It is not used directly, but through a [`ProjectMethods`] instance.
7510///
7511/// # Example
7512///
7513/// Instantiate a resource method builder
7514///
7515/// ```test_harness,no_run
7516/// # extern crate hyper;
7517/// # extern crate hyper_rustls;
7518/// # extern crate google_spanner1 as spanner1;
7519/// # async fn dox() {
7520/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7521///
7522/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7523/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7524/// # secret,
7525/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7526/// # ).build().await.unwrap();
7527///
7528/// # let client = hyper_util::client::legacy::Client::builder(
7529/// # hyper_util::rt::TokioExecutor::new()
7530/// # )
7531/// # .build(
7532/// # hyper_rustls::HttpsConnectorBuilder::new()
7533/// # .with_native_roots()
7534/// # .unwrap()
7535/// # .https_or_http()
7536/// # .enable_http1()
7537/// # .build()
7538/// # );
7539/// # let mut hub = Spanner::new(client, auth);
7540/// // You can configure optional parameters by calling the respective setters at will, and
7541/// // execute the final call using `doit()`.
7542/// // Values shown here are possibly random and not representative !
7543/// let result = hub.projects().instance_configs_ssd_caches_operations_list("name")
7544/// .page_token("ipsum")
7545/// .page_size(-7)
7546/// .filter("gubergren")
7547/// .doit().await;
7548/// # }
7549/// ```
7550pub struct ProjectInstanceConfigSsdCachOperationListCall<'a, C>
7551where
7552 C: 'a,
7553{
7554 hub: &'a Spanner<C>,
7555 _name: String,
7556 _page_token: Option<String>,
7557 _page_size: Option<i32>,
7558 _filter: Option<String>,
7559 _delegate: Option<&'a mut dyn common::Delegate>,
7560 _additional_params: HashMap<String, String>,
7561 _scopes: BTreeSet<String>,
7562}
7563
7564impl<'a, C> common::CallBuilder for ProjectInstanceConfigSsdCachOperationListCall<'a, C> {}
7565
7566impl<'a, C> ProjectInstanceConfigSsdCachOperationListCall<'a, C>
7567where
7568 C: common::Connector,
7569{
7570 /// Perform the operation you have build so far.
7571 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
7572 use std::borrow::Cow;
7573 use std::io::{Read, Seek};
7574
7575 use common::{url::Params, ToParts};
7576 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7577
7578 let mut dd = common::DefaultDelegate;
7579 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7580 dlg.begin(common::MethodInfo {
7581 id: "spanner.projects.instanceConfigs.ssdCaches.operations.list",
7582 http_method: hyper::Method::GET,
7583 });
7584
7585 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
7586 if self._additional_params.contains_key(field) {
7587 dlg.finished(false);
7588 return Err(common::Error::FieldClash(field));
7589 }
7590 }
7591
7592 let mut params = Params::with_capacity(6 + self._additional_params.len());
7593 params.push("name", self._name);
7594 if let Some(value) = self._page_token.as_ref() {
7595 params.push("pageToken", value);
7596 }
7597 if let Some(value) = self._page_size.as_ref() {
7598 params.push("pageSize", value.to_string());
7599 }
7600 if let Some(value) = self._filter.as_ref() {
7601 params.push("filter", value);
7602 }
7603
7604 params.extend(self._additional_params.iter());
7605
7606 params.push("alt", "json");
7607 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7608 if self._scopes.is_empty() {
7609 self._scopes
7610 .insert(Scope::CloudPlatform.as_ref().to_string());
7611 }
7612
7613 #[allow(clippy::single_element_loop)]
7614 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7615 url = params.uri_replacement(url, param_name, find_this, true);
7616 }
7617 {
7618 let to_remove = ["name"];
7619 params.remove_params(&to_remove);
7620 }
7621
7622 let url = params.parse_with_url(&url);
7623
7624 loop {
7625 let token = match self
7626 .hub
7627 .auth
7628 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7629 .await
7630 {
7631 Ok(token) => token,
7632 Err(e) => match dlg.token(e) {
7633 Ok(token) => token,
7634 Err(e) => {
7635 dlg.finished(false);
7636 return Err(common::Error::MissingToken(e));
7637 }
7638 },
7639 };
7640 let mut req_result = {
7641 let client = &self.hub.client;
7642 dlg.pre_request();
7643 let mut req_builder = hyper::Request::builder()
7644 .method(hyper::Method::GET)
7645 .uri(url.as_str())
7646 .header(USER_AGENT, self.hub._user_agent.clone());
7647
7648 if let Some(token) = token.as_ref() {
7649 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7650 }
7651
7652 let request = req_builder
7653 .header(CONTENT_LENGTH, 0_u64)
7654 .body(common::to_body::<String>(None));
7655
7656 client.request(request.unwrap()).await
7657 };
7658
7659 match req_result {
7660 Err(err) => {
7661 if let common::Retry::After(d) = dlg.http_error(&err) {
7662 sleep(d).await;
7663 continue;
7664 }
7665 dlg.finished(false);
7666 return Err(common::Error::HttpError(err));
7667 }
7668 Ok(res) => {
7669 let (mut parts, body) = res.into_parts();
7670 let mut body = common::Body::new(body);
7671 if !parts.status.is_success() {
7672 let bytes = common::to_bytes(body).await.unwrap_or_default();
7673 let error = serde_json::from_str(&common::to_string(&bytes));
7674 let response = common::to_response(parts, bytes.into());
7675
7676 if let common::Retry::After(d) =
7677 dlg.http_failure(&response, error.as_ref().ok())
7678 {
7679 sleep(d).await;
7680 continue;
7681 }
7682
7683 dlg.finished(false);
7684
7685 return Err(match error {
7686 Ok(value) => common::Error::BadRequest(value),
7687 _ => common::Error::Failure(response),
7688 });
7689 }
7690 let response = {
7691 let bytes = common::to_bytes(body).await.unwrap_or_default();
7692 let encoded = common::to_string(&bytes);
7693 match serde_json::from_str(&encoded) {
7694 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7695 Err(error) => {
7696 dlg.response_json_decode_error(&encoded, &error);
7697 return Err(common::Error::JsonDecodeError(
7698 encoded.to_string(),
7699 error,
7700 ));
7701 }
7702 }
7703 };
7704
7705 dlg.finished(true);
7706 return Ok(response);
7707 }
7708 }
7709 }
7710 }
7711
7712 /// The name of the operation's parent resource.
7713 ///
7714 /// Sets the *name* path property to the given value.
7715 ///
7716 /// Even though the property as already been set when instantiating this call,
7717 /// we provide this method for API completeness.
7718 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
7719 self._name = new_value.to_string();
7720 self
7721 }
7722 /// The standard list page token.
7723 ///
7724 /// Sets the *page token* query property to the given value.
7725 pub fn page_token(
7726 mut self,
7727 new_value: &str,
7728 ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
7729 self._page_token = Some(new_value.to_string());
7730 self
7731 }
7732 /// The standard list page size.
7733 ///
7734 /// Sets the *page size* query property to the given value.
7735 pub fn page_size(
7736 mut self,
7737 new_value: i32,
7738 ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
7739 self._page_size = Some(new_value);
7740 self
7741 }
7742 /// The standard list filter.
7743 ///
7744 /// Sets the *filter* query property to the given value.
7745 pub fn filter(
7746 mut self,
7747 new_value: &str,
7748 ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
7749 self._filter = Some(new_value.to_string());
7750 self
7751 }
7752 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7753 /// while executing the actual API request.
7754 ///
7755 /// ````text
7756 /// It should be used to handle progress information, and to implement a certain level of resilience.
7757 /// ````
7758 ///
7759 /// Sets the *delegate* property to the given value.
7760 pub fn delegate(
7761 mut self,
7762 new_value: &'a mut dyn common::Delegate,
7763 ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
7764 self._delegate = Some(new_value);
7765 self
7766 }
7767
7768 /// Set any additional parameter of the query string used in the request.
7769 /// It should be used to set parameters which are not yet available through their own
7770 /// setters.
7771 ///
7772 /// Please note that this method must not be used to set any of the known parameters
7773 /// which have their own setter method. If done anyway, the request will fail.
7774 ///
7775 /// # Additional Parameters
7776 ///
7777 /// * *$.xgafv* (query-string) - V1 error format.
7778 /// * *access_token* (query-string) - OAuth access token.
7779 /// * *alt* (query-string) - Data format for response.
7780 /// * *callback* (query-string) - JSONP
7781 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7782 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7783 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7784 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7785 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7786 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7787 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7788 pub fn param<T>(
7789 mut self,
7790 name: T,
7791 value: T,
7792 ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C>
7793 where
7794 T: AsRef<str>,
7795 {
7796 self._additional_params
7797 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7798 self
7799 }
7800
7801 /// Identifies the authorization scope for the method you are building.
7802 ///
7803 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7804 /// [`Scope::CloudPlatform`].
7805 ///
7806 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7807 /// tokens for more than one scope.
7808 ///
7809 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7810 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7811 /// sufficient, a read-write scope will do as well.
7812 pub fn add_scope<St>(
7813 mut self,
7814 scope: St,
7815 ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C>
7816 where
7817 St: AsRef<str>,
7818 {
7819 self._scopes.insert(String::from(scope.as_ref()));
7820 self
7821 }
7822 /// Identifies the authorization scope(s) for the method you are building.
7823 ///
7824 /// See [`Self::add_scope()`] for details.
7825 pub fn add_scopes<I, St>(
7826 mut self,
7827 scopes: I,
7828 ) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C>
7829 where
7830 I: IntoIterator<Item = St>,
7831 St: AsRef<str>,
7832 {
7833 self._scopes
7834 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7835 self
7836 }
7837
7838 /// Removes all scopes, and no default scope will be used either.
7839 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7840 /// for details).
7841 pub fn clear_scopes(mut self) -> ProjectInstanceConfigSsdCachOperationListCall<'a, C> {
7842 self._scopes.clear();
7843 self
7844 }
7845}
7846
7847/// Creates an instance config and begins preparing it to be used. The returned long-running operation can be used to track the progress of preparing the new instance config. The instance config name is assigned by the caller. If the named instance config already exists, `CreateInstanceConfig` returns `ALREADY_EXISTS`. Immediately after the request returns: * The instance config is readable via the API, with all requested attributes. The instance config's reconciling field is set to true. Its state is `CREATING`. While the operation is pending: * Cancelling the operation renders the instance config immediately unreadable via the API. * Except for deleting the creating resource, all other attempts to modify the instance config are rejected. Upon completion of the returned operation: * Instances can be created using the instance configuration. * The instance config'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 config. The metadata field type is CreateInstanceConfigMetadata. The response field type is InstanceConfig, if successful. Authorization requires `spanner.instanceConfigs.create` permission on the resource parent.
7848///
7849/// A builder for the *instanceConfigs.create* method supported by a *project* resource.
7850/// It is not used directly, but through a [`ProjectMethods`] instance.
7851///
7852/// # Example
7853///
7854/// Instantiate a resource method builder
7855///
7856/// ```test_harness,no_run
7857/// # extern crate hyper;
7858/// # extern crate hyper_rustls;
7859/// # extern crate google_spanner1 as spanner1;
7860/// use spanner1::api::CreateInstanceConfigRequest;
7861/// # async fn dox() {
7862/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7863///
7864/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7865/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7866/// # secret,
7867/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7868/// # ).build().await.unwrap();
7869///
7870/// # let client = hyper_util::client::legacy::Client::builder(
7871/// # hyper_util::rt::TokioExecutor::new()
7872/// # )
7873/// # .build(
7874/// # hyper_rustls::HttpsConnectorBuilder::new()
7875/// # .with_native_roots()
7876/// # .unwrap()
7877/// # .https_or_http()
7878/// # .enable_http1()
7879/// # .build()
7880/// # );
7881/// # let mut hub = Spanner::new(client, auth);
7882/// // As the method needs a request, you would usually fill it with the desired information
7883/// // into the respective structure. Some of the parts shown here might not be applicable !
7884/// // Values shown here are possibly random and not representative !
7885/// let mut req = CreateInstanceConfigRequest::default();
7886///
7887/// // You can configure optional parameters by calling the respective setters at will, and
7888/// // execute the final call using `doit()`.
7889/// // Values shown here are possibly random and not representative !
7890/// let result = hub.projects().instance_configs_create(req, "parent")
7891/// .doit().await;
7892/// # }
7893/// ```
7894pub struct ProjectInstanceConfigCreateCall<'a, C>
7895where
7896 C: 'a,
7897{
7898 hub: &'a Spanner<C>,
7899 _request: CreateInstanceConfigRequest,
7900 _parent: String,
7901 _delegate: Option<&'a mut dyn common::Delegate>,
7902 _additional_params: HashMap<String, String>,
7903 _scopes: BTreeSet<String>,
7904}
7905
7906impl<'a, C> common::CallBuilder for ProjectInstanceConfigCreateCall<'a, C> {}
7907
7908impl<'a, C> ProjectInstanceConfigCreateCall<'a, C>
7909where
7910 C: common::Connector,
7911{
7912 /// Perform the operation you have build so far.
7913 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7914 use std::borrow::Cow;
7915 use std::io::{Read, Seek};
7916
7917 use common::{url::Params, ToParts};
7918 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7919
7920 let mut dd = common::DefaultDelegate;
7921 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7922 dlg.begin(common::MethodInfo {
7923 id: "spanner.projects.instanceConfigs.create",
7924 http_method: hyper::Method::POST,
7925 });
7926
7927 for &field in ["alt", "parent"].iter() {
7928 if self._additional_params.contains_key(field) {
7929 dlg.finished(false);
7930 return Err(common::Error::FieldClash(field));
7931 }
7932 }
7933
7934 let mut params = Params::with_capacity(4 + self._additional_params.len());
7935 params.push("parent", self._parent);
7936
7937 params.extend(self._additional_params.iter());
7938
7939 params.push("alt", "json");
7940 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instanceConfigs";
7941 if self._scopes.is_empty() {
7942 self._scopes
7943 .insert(Scope::CloudPlatform.as_ref().to_string());
7944 }
7945
7946 #[allow(clippy::single_element_loop)]
7947 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7948 url = params.uri_replacement(url, param_name, find_this, true);
7949 }
7950 {
7951 let to_remove = ["parent"];
7952 params.remove_params(&to_remove);
7953 }
7954
7955 let url = params.parse_with_url(&url);
7956
7957 let mut json_mime_type = mime::APPLICATION_JSON;
7958 let mut request_value_reader = {
7959 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7960 common::remove_json_null_values(&mut value);
7961 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7962 serde_json::to_writer(&mut dst, &value).unwrap();
7963 dst
7964 };
7965 let request_size = request_value_reader
7966 .seek(std::io::SeekFrom::End(0))
7967 .unwrap();
7968 request_value_reader
7969 .seek(std::io::SeekFrom::Start(0))
7970 .unwrap();
7971
7972 loop {
7973 let token = match self
7974 .hub
7975 .auth
7976 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7977 .await
7978 {
7979 Ok(token) => token,
7980 Err(e) => match dlg.token(e) {
7981 Ok(token) => token,
7982 Err(e) => {
7983 dlg.finished(false);
7984 return Err(common::Error::MissingToken(e));
7985 }
7986 },
7987 };
7988 request_value_reader
7989 .seek(std::io::SeekFrom::Start(0))
7990 .unwrap();
7991 let mut req_result = {
7992 let client = &self.hub.client;
7993 dlg.pre_request();
7994 let mut req_builder = hyper::Request::builder()
7995 .method(hyper::Method::POST)
7996 .uri(url.as_str())
7997 .header(USER_AGENT, self.hub._user_agent.clone());
7998
7999 if let Some(token) = token.as_ref() {
8000 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8001 }
8002
8003 let request = req_builder
8004 .header(CONTENT_TYPE, json_mime_type.to_string())
8005 .header(CONTENT_LENGTH, request_size as u64)
8006 .body(common::to_body(
8007 request_value_reader.get_ref().clone().into(),
8008 ));
8009
8010 client.request(request.unwrap()).await
8011 };
8012
8013 match req_result {
8014 Err(err) => {
8015 if let common::Retry::After(d) = dlg.http_error(&err) {
8016 sleep(d).await;
8017 continue;
8018 }
8019 dlg.finished(false);
8020 return Err(common::Error::HttpError(err));
8021 }
8022 Ok(res) => {
8023 let (mut parts, body) = res.into_parts();
8024 let mut body = common::Body::new(body);
8025 if !parts.status.is_success() {
8026 let bytes = common::to_bytes(body).await.unwrap_or_default();
8027 let error = serde_json::from_str(&common::to_string(&bytes));
8028 let response = common::to_response(parts, bytes.into());
8029
8030 if let common::Retry::After(d) =
8031 dlg.http_failure(&response, error.as_ref().ok())
8032 {
8033 sleep(d).await;
8034 continue;
8035 }
8036
8037 dlg.finished(false);
8038
8039 return Err(match error {
8040 Ok(value) => common::Error::BadRequest(value),
8041 _ => common::Error::Failure(response),
8042 });
8043 }
8044 let response = {
8045 let bytes = common::to_bytes(body).await.unwrap_or_default();
8046 let encoded = common::to_string(&bytes);
8047 match serde_json::from_str(&encoded) {
8048 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8049 Err(error) => {
8050 dlg.response_json_decode_error(&encoded, &error);
8051 return Err(common::Error::JsonDecodeError(
8052 encoded.to_string(),
8053 error,
8054 ));
8055 }
8056 }
8057 };
8058
8059 dlg.finished(true);
8060 return Ok(response);
8061 }
8062 }
8063 }
8064 }
8065
8066 ///
8067 /// Sets the *request* property to the given value.
8068 ///
8069 /// Even though the property as already been set when instantiating this call,
8070 /// we provide this method for API completeness.
8071 pub fn request(
8072 mut self,
8073 new_value: CreateInstanceConfigRequest,
8074 ) -> ProjectInstanceConfigCreateCall<'a, C> {
8075 self._request = new_value;
8076 self
8077 }
8078 /// Required. The name of the project in which to create the instance config. Values are of the form `projects/`.
8079 ///
8080 /// Sets the *parent* path property to the given value.
8081 ///
8082 /// Even though the property as already been set when instantiating this call,
8083 /// we provide this method for API completeness.
8084 pub fn parent(mut self, new_value: &str) -> ProjectInstanceConfigCreateCall<'a, C> {
8085 self._parent = new_value.to_string();
8086 self
8087 }
8088 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8089 /// while executing the actual API request.
8090 ///
8091 /// ````text
8092 /// It should be used to handle progress information, and to implement a certain level of resilience.
8093 /// ````
8094 ///
8095 /// Sets the *delegate* property to the given value.
8096 pub fn delegate(
8097 mut self,
8098 new_value: &'a mut dyn common::Delegate,
8099 ) -> ProjectInstanceConfigCreateCall<'a, C> {
8100 self._delegate = Some(new_value);
8101 self
8102 }
8103
8104 /// Set any additional parameter of the query string used in the request.
8105 /// It should be used to set parameters which are not yet available through their own
8106 /// setters.
8107 ///
8108 /// Please note that this method must not be used to set any of the known parameters
8109 /// which have their own setter method. If done anyway, the request will fail.
8110 ///
8111 /// # Additional Parameters
8112 ///
8113 /// * *$.xgafv* (query-string) - V1 error format.
8114 /// * *access_token* (query-string) - OAuth access token.
8115 /// * *alt* (query-string) - Data format for response.
8116 /// * *callback* (query-string) - JSONP
8117 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8118 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8119 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8120 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8121 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8122 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8123 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8124 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigCreateCall<'a, C>
8125 where
8126 T: AsRef<str>,
8127 {
8128 self._additional_params
8129 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8130 self
8131 }
8132
8133 /// Identifies the authorization scope for the method you are building.
8134 ///
8135 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8136 /// [`Scope::CloudPlatform`].
8137 ///
8138 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8139 /// tokens for more than one scope.
8140 ///
8141 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8142 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8143 /// sufficient, a read-write scope will do as well.
8144 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigCreateCall<'a, C>
8145 where
8146 St: AsRef<str>,
8147 {
8148 self._scopes.insert(String::from(scope.as_ref()));
8149 self
8150 }
8151 /// Identifies the authorization scope(s) for the method you are building.
8152 ///
8153 /// See [`Self::add_scope()`] for details.
8154 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigCreateCall<'a, C>
8155 where
8156 I: IntoIterator<Item = St>,
8157 St: AsRef<str>,
8158 {
8159 self._scopes
8160 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8161 self
8162 }
8163
8164 /// Removes all scopes, and no default scope will be used either.
8165 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8166 /// for details).
8167 pub fn clear_scopes(mut self) -> ProjectInstanceConfigCreateCall<'a, C> {
8168 self._scopes.clear();
8169 self
8170 }
8171}
8172
8173/// Deletes the instance config. Deletion is only allowed when no instances are using the configuration. If any instances are using the config, returns `FAILED_PRECONDITION`. Only user managed configurations can be deleted. Authorization requires `spanner.instanceConfigs.delete` permission on the resource name.
8174///
8175/// A builder for the *instanceConfigs.delete* method supported by a *project* resource.
8176/// It is not used directly, but through a [`ProjectMethods`] instance.
8177///
8178/// # Example
8179///
8180/// Instantiate a resource method builder
8181///
8182/// ```test_harness,no_run
8183/// # extern crate hyper;
8184/// # extern crate hyper_rustls;
8185/// # extern crate google_spanner1 as spanner1;
8186/// # async fn dox() {
8187/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8188///
8189/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8190/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8191/// # secret,
8192/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8193/// # ).build().await.unwrap();
8194///
8195/// # let client = hyper_util::client::legacy::Client::builder(
8196/// # hyper_util::rt::TokioExecutor::new()
8197/// # )
8198/// # .build(
8199/// # hyper_rustls::HttpsConnectorBuilder::new()
8200/// # .with_native_roots()
8201/// # .unwrap()
8202/// # .https_or_http()
8203/// # .enable_http1()
8204/// # .build()
8205/// # );
8206/// # let mut hub = Spanner::new(client, auth);
8207/// // You can configure optional parameters by calling the respective setters at will, and
8208/// // execute the final call using `doit()`.
8209/// // Values shown here are possibly random and not representative !
8210/// let result = hub.projects().instance_configs_delete("name")
8211/// .validate_only(true)
8212/// .etag("eos")
8213/// .doit().await;
8214/// # }
8215/// ```
8216pub struct ProjectInstanceConfigDeleteCall<'a, C>
8217where
8218 C: 'a,
8219{
8220 hub: &'a Spanner<C>,
8221 _name: String,
8222 _validate_only: Option<bool>,
8223 _etag: Option<String>,
8224 _delegate: Option<&'a mut dyn common::Delegate>,
8225 _additional_params: HashMap<String, String>,
8226 _scopes: BTreeSet<String>,
8227}
8228
8229impl<'a, C> common::CallBuilder for ProjectInstanceConfigDeleteCall<'a, C> {}
8230
8231impl<'a, C> ProjectInstanceConfigDeleteCall<'a, C>
8232where
8233 C: common::Connector,
8234{
8235 /// Perform the operation you have build so far.
8236 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8237 use std::borrow::Cow;
8238 use std::io::{Read, Seek};
8239
8240 use common::{url::Params, ToParts};
8241 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8242
8243 let mut dd = common::DefaultDelegate;
8244 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8245 dlg.begin(common::MethodInfo {
8246 id: "spanner.projects.instanceConfigs.delete",
8247 http_method: hyper::Method::DELETE,
8248 });
8249
8250 for &field in ["alt", "name", "validateOnly", "etag"].iter() {
8251 if self._additional_params.contains_key(field) {
8252 dlg.finished(false);
8253 return Err(common::Error::FieldClash(field));
8254 }
8255 }
8256
8257 let mut params = Params::with_capacity(5 + self._additional_params.len());
8258 params.push("name", self._name);
8259 if let Some(value) = self._validate_only.as_ref() {
8260 params.push("validateOnly", value.to_string());
8261 }
8262 if let Some(value) = self._etag.as_ref() {
8263 params.push("etag", value);
8264 }
8265
8266 params.extend(self._additional_params.iter());
8267
8268 params.push("alt", "json");
8269 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8270 if self._scopes.is_empty() {
8271 self._scopes
8272 .insert(Scope::CloudPlatform.as_ref().to_string());
8273 }
8274
8275 #[allow(clippy::single_element_loop)]
8276 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8277 url = params.uri_replacement(url, param_name, find_this, true);
8278 }
8279 {
8280 let to_remove = ["name"];
8281 params.remove_params(&to_remove);
8282 }
8283
8284 let url = params.parse_with_url(&url);
8285
8286 loop {
8287 let token = match self
8288 .hub
8289 .auth
8290 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8291 .await
8292 {
8293 Ok(token) => token,
8294 Err(e) => match dlg.token(e) {
8295 Ok(token) => token,
8296 Err(e) => {
8297 dlg.finished(false);
8298 return Err(common::Error::MissingToken(e));
8299 }
8300 },
8301 };
8302 let mut req_result = {
8303 let client = &self.hub.client;
8304 dlg.pre_request();
8305 let mut req_builder = hyper::Request::builder()
8306 .method(hyper::Method::DELETE)
8307 .uri(url.as_str())
8308 .header(USER_AGENT, self.hub._user_agent.clone());
8309
8310 if let Some(token) = token.as_ref() {
8311 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8312 }
8313
8314 let request = req_builder
8315 .header(CONTENT_LENGTH, 0_u64)
8316 .body(common::to_body::<String>(None));
8317
8318 client.request(request.unwrap()).await
8319 };
8320
8321 match req_result {
8322 Err(err) => {
8323 if let common::Retry::After(d) = dlg.http_error(&err) {
8324 sleep(d).await;
8325 continue;
8326 }
8327 dlg.finished(false);
8328 return Err(common::Error::HttpError(err));
8329 }
8330 Ok(res) => {
8331 let (mut parts, body) = res.into_parts();
8332 let mut body = common::Body::new(body);
8333 if !parts.status.is_success() {
8334 let bytes = common::to_bytes(body).await.unwrap_or_default();
8335 let error = serde_json::from_str(&common::to_string(&bytes));
8336 let response = common::to_response(parts, bytes.into());
8337
8338 if let common::Retry::After(d) =
8339 dlg.http_failure(&response, error.as_ref().ok())
8340 {
8341 sleep(d).await;
8342 continue;
8343 }
8344
8345 dlg.finished(false);
8346
8347 return Err(match error {
8348 Ok(value) => common::Error::BadRequest(value),
8349 _ => common::Error::Failure(response),
8350 });
8351 }
8352 let response = {
8353 let bytes = common::to_bytes(body).await.unwrap_or_default();
8354 let encoded = common::to_string(&bytes);
8355 match serde_json::from_str(&encoded) {
8356 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8357 Err(error) => {
8358 dlg.response_json_decode_error(&encoded, &error);
8359 return Err(common::Error::JsonDecodeError(
8360 encoded.to_string(),
8361 error,
8362 ));
8363 }
8364 }
8365 };
8366
8367 dlg.finished(true);
8368 return Ok(response);
8369 }
8370 }
8371 }
8372 }
8373
8374 /// Required. The name of the instance configuration to be deleted. Values are of the form `projects//instanceConfigs/`
8375 ///
8376 /// Sets the *name* path property to the given value.
8377 ///
8378 /// Even though the property as already been set when instantiating this call,
8379 /// we provide this method for API completeness.
8380 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigDeleteCall<'a, C> {
8381 self._name = new_value.to_string();
8382 self
8383 }
8384 /// An option to validate, but not actually execute, a request, and provide the same response.
8385 ///
8386 /// Sets the *validate only* query property to the given value.
8387 pub fn validate_only(mut self, new_value: bool) -> ProjectInstanceConfigDeleteCall<'a, C> {
8388 self._validate_only = Some(new_value);
8389 self
8390 }
8391 /// Used for optimistic concurrency control as a way to help prevent simultaneous deletes of an instance config from overwriting each other. If not empty, the API only deletes the instance config when the etag provided matches the current status of the requested instance config. Otherwise, deletes the instance config without checking the current status of the requested instance config.
8392 ///
8393 /// Sets the *etag* query property to the given value.
8394 pub fn etag(mut self, new_value: &str) -> ProjectInstanceConfigDeleteCall<'a, C> {
8395 self._etag = Some(new_value.to_string());
8396 self
8397 }
8398 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8399 /// while executing the actual API request.
8400 ///
8401 /// ````text
8402 /// It should be used to handle progress information, and to implement a certain level of resilience.
8403 /// ````
8404 ///
8405 /// Sets the *delegate* property to the given value.
8406 pub fn delegate(
8407 mut self,
8408 new_value: &'a mut dyn common::Delegate,
8409 ) -> ProjectInstanceConfigDeleteCall<'a, C> {
8410 self._delegate = Some(new_value);
8411 self
8412 }
8413
8414 /// Set any additional parameter of the query string used in the request.
8415 /// It should be used to set parameters which are not yet available through their own
8416 /// setters.
8417 ///
8418 /// Please note that this method must not be used to set any of the known parameters
8419 /// which have their own setter method. If done anyway, the request will fail.
8420 ///
8421 /// # Additional Parameters
8422 ///
8423 /// * *$.xgafv* (query-string) - V1 error format.
8424 /// * *access_token* (query-string) - OAuth access token.
8425 /// * *alt* (query-string) - Data format for response.
8426 /// * *callback* (query-string) - JSONP
8427 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8428 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8429 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8430 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8431 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8432 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8433 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8434 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigDeleteCall<'a, C>
8435 where
8436 T: AsRef<str>,
8437 {
8438 self._additional_params
8439 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8440 self
8441 }
8442
8443 /// Identifies the authorization scope for the method you are building.
8444 ///
8445 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8446 /// [`Scope::CloudPlatform`].
8447 ///
8448 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8449 /// tokens for more than one scope.
8450 ///
8451 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8452 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8453 /// sufficient, a read-write scope will do as well.
8454 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigDeleteCall<'a, C>
8455 where
8456 St: AsRef<str>,
8457 {
8458 self._scopes.insert(String::from(scope.as_ref()));
8459 self
8460 }
8461 /// Identifies the authorization scope(s) for the method you are building.
8462 ///
8463 /// See [`Self::add_scope()`] for details.
8464 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigDeleteCall<'a, C>
8465 where
8466 I: IntoIterator<Item = St>,
8467 St: AsRef<str>,
8468 {
8469 self._scopes
8470 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8471 self
8472 }
8473
8474 /// Removes all scopes, and no default scope will be used either.
8475 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8476 /// for details).
8477 pub fn clear_scopes(mut self) -> ProjectInstanceConfigDeleteCall<'a, C> {
8478 self._scopes.clear();
8479 self
8480 }
8481}
8482
8483/// Gets information about a particular instance configuration.
8484///
8485/// A builder for the *instanceConfigs.get* method supported by a *project* resource.
8486/// It is not used directly, but through a [`ProjectMethods`] instance.
8487///
8488/// # Example
8489///
8490/// Instantiate a resource method builder
8491///
8492/// ```test_harness,no_run
8493/// # extern crate hyper;
8494/// # extern crate hyper_rustls;
8495/// # extern crate google_spanner1 as spanner1;
8496/// # async fn dox() {
8497/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8498///
8499/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8500/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8501/// # secret,
8502/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8503/// # ).build().await.unwrap();
8504///
8505/// # let client = hyper_util::client::legacy::Client::builder(
8506/// # hyper_util::rt::TokioExecutor::new()
8507/// # )
8508/// # .build(
8509/// # hyper_rustls::HttpsConnectorBuilder::new()
8510/// # .with_native_roots()
8511/// # .unwrap()
8512/// # .https_or_http()
8513/// # .enable_http1()
8514/// # .build()
8515/// # );
8516/// # let mut hub = Spanner::new(client, auth);
8517/// // You can configure optional parameters by calling the respective setters at will, and
8518/// // execute the final call using `doit()`.
8519/// // Values shown here are possibly random and not representative !
8520/// let result = hub.projects().instance_configs_get("name")
8521/// .doit().await;
8522/// # }
8523/// ```
8524pub struct ProjectInstanceConfigGetCall<'a, C>
8525where
8526 C: 'a,
8527{
8528 hub: &'a Spanner<C>,
8529 _name: String,
8530 _delegate: Option<&'a mut dyn common::Delegate>,
8531 _additional_params: HashMap<String, String>,
8532 _scopes: BTreeSet<String>,
8533}
8534
8535impl<'a, C> common::CallBuilder for ProjectInstanceConfigGetCall<'a, C> {}
8536
8537impl<'a, C> ProjectInstanceConfigGetCall<'a, C>
8538where
8539 C: common::Connector,
8540{
8541 /// Perform the operation you have build so far.
8542 pub async fn doit(mut self) -> common::Result<(common::Response, InstanceConfig)> {
8543 use std::borrow::Cow;
8544 use std::io::{Read, Seek};
8545
8546 use common::{url::Params, ToParts};
8547 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8548
8549 let mut dd = common::DefaultDelegate;
8550 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8551 dlg.begin(common::MethodInfo {
8552 id: "spanner.projects.instanceConfigs.get",
8553 http_method: hyper::Method::GET,
8554 });
8555
8556 for &field in ["alt", "name"].iter() {
8557 if self._additional_params.contains_key(field) {
8558 dlg.finished(false);
8559 return Err(common::Error::FieldClash(field));
8560 }
8561 }
8562
8563 let mut params = Params::with_capacity(3 + self._additional_params.len());
8564 params.push("name", self._name);
8565
8566 params.extend(self._additional_params.iter());
8567
8568 params.push("alt", "json");
8569 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8570 if self._scopes.is_empty() {
8571 self._scopes
8572 .insert(Scope::CloudPlatform.as_ref().to_string());
8573 }
8574
8575 #[allow(clippy::single_element_loop)]
8576 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8577 url = params.uri_replacement(url, param_name, find_this, true);
8578 }
8579 {
8580 let to_remove = ["name"];
8581 params.remove_params(&to_remove);
8582 }
8583
8584 let url = params.parse_with_url(&url);
8585
8586 loop {
8587 let token = match self
8588 .hub
8589 .auth
8590 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8591 .await
8592 {
8593 Ok(token) => token,
8594 Err(e) => match dlg.token(e) {
8595 Ok(token) => token,
8596 Err(e) => {
8597 dlg.finished(false);
8598 return Err(common::Error::MissingToken(e));
8599 }
8600 },
8601 };
8602 let mut req_result = {
8603 let client = &self.hub.client;
8604 dlg.pre_request();
8605 let mut req_builder = hyper::Request::builder()
8606 .method(hyper::Method::GET)
8607 .uri(url.as_str())
8608 .header(USER_AGENT, self.hub._user_agent.clone());
8609
8610 if let Some(token) = token.as_ref() {
8611 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8612 }
8613
8614 let request = req_builder
8615 .header(CONTENT_LENGTH, 0_u64)
8616 .body(common::to_body::<String>(None));
8617
8618 client.request(request.unwrap()).await
8619 };
8620
8621 match req_result {
8622 Err(err) => {
8623 if let common::Retry::After(d) = dlg.http_error(&err) {
8624 sleep(d).await;
8625 continue;
8626 }
8627 dlg.finished(false);
8628 return Err(common::Error::HttpError(err));
8629 }
8630 Ok(res) => {
8631 let (mut parts, body) = res.into_parts();
8632 let mut body = common::Body::new(body);
8633 if !parts.status.is_success() {
8634 let bytes = common::to_bytes(body).await.unwrap_or_default();
8635 let error = serde_json::from_str(&common::to_string(&bytes));
8636 let response = common::to_response(parts, bytes.into());
8637
8638 if let common::Retry::After(d) =
8639 dlg.http_failure(&response, error.as_ref().ok())
8640 {
8641 sleep(d).await;
8642 continue;
8643 }
8644
8645 dlg.finished(false);
8646
8647 return Err(match error {
8648 Ok(value) => common::Error::BadRequest(value),
8649 _ => common::Error::Failure(response),
8650 });
8651 }
8652 let response = {
8653 let bytes = common::to_bytes(body).await.unwrap_or_default();
8654 let encoded = common::to_string(&bytes);
8655 match serde_json::from_str(&encoded) {
8656 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8657 Err(error) => {
8658 dlg.response_json_decode_error(&encoded, &error);
8659 return Err(common::Error::JsonDecodeError(
8660 encoded.to_string(),
8661 error,
8662 ));
8663 }
8664 }
8665 };
8666
8667 dlg.finished(true);
8668 return Ok(response);
8669 }
8670 }
8671 }
8672 }
8673
8674 /// Required. The name of the requested instance configuration. Values are of the form `projects//instanceConfigs/`.
8675 ///
8676 /// Sets the *name* path property to the given value.
8677 ///
8678 /// Even though the property as already been set when instantiating this call,
8679 /// we provide this method for API completeness.
8680 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigGetCall<'a, C> {
8681 self._name = new_value.to_string();
8682 self
8683 }
8684 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8685 /// while executing the actual API request.
8686 ///
8687 /// ````text
8688 /// It should be used to handle progress information, and to implement a certain level of resilience.
8689 /// ````
8690 ///
8691 /// Sets the *delegate* property to the given value.
8692 pub fn delegate(
8693 mut self,
8694 new_value: &'a mut dyn common::Delegate,
8695 ) -> ProjectInstanceConfigGetCall<'a, C> {
8696 self._delegate = Some(new_value);
8697 self
8698 }
8699
8700 /// Set any additional parameter of the query string used in the request.
8701 /// It should be used to set parameters which are not yet available through their own
8702 /// setters.
8703 ///
8704 /// Please note that this method must not be used to set any of the known parameters
8705 /// which have their own setter method. If done anyway, the request will fail.
8706 ///
8707 /// # Additional Parameters
8708 ///
8709 /// * *$.xgafv* (query-string) - V1 error format.
8710 /// * *access_token* (query-string) - OAuth access token.
8711 /// * *alt* (query-string) - Data format for response.
8712 /// * *callback* (query-string) - JSONP
8713 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8714 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8715 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8716 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8717 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8718 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8719 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8720 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigGetCall<'a, C>
8721 where
8722 T: AsRef<str>,
8723 {
8724 self._additional_params
8725 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8726 self
8727 }
8728
8729 /// Identifies the authorization scope for the method you are building.
8730 ///
8731 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8732 /// [`Scope::CloudPlatform`].
8733 ///
8734 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8735 /// tokens for more than one scope.
8736 ///
8737 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8738 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8739 /// sufficient, a read-write scope will do as well.
8740 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigGetCall<'a, C>
8741 where
8742 St: AsRef<str>,
8743 {
8744 self._scopes.insert(String::from(scope.as_ref()));
8745 self
8746 }
8747 /// Identifies the authorization scope(s) for the method you are building.
8748 ///
8749 /// See [`Self::add_scope()`] for details.
8750 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigGetCall<'a, C>
8751 where
8752 I: IntoIterator<Item = St>,
8753 St: AsRef<str>,
8754 {
8755 self._scopes
8756 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8757 self
8758 }
8759
8760 /// Removes all scopes, and no default scope will be used either.
8761 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8762 /// for details).
8763 pub fn clear_scopes(mut self) -> ProjectInstanceConfigGetCall<'a, C> {
8764 self._scopes.clear();
8765 self
8766 }
8767}
8768
8769/// Lists the supported instance configurations for a given project. Returns both Google managed configs and user managed configs.
8770///
8771/// A builder for the *instanceConfigs.list* method supported by a *project* resource.
8772/// It is not used directly, but through a [`ProjectMethods`] instance.
8773///
8774/// # Example
8775///
8776/// Instantiate a resource method builder
8777///
8778/// ```test_harness,no_run
8779/// # extern crate hyper;
8780/// # extern crate hyper_rustls;
8781/// # extern crate google_spanner1 as spanner1;
8782/// # async fn dox() {
8783/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8784///
8785/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8786/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8787/// # secret,
8788/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8789/// # ).build().await.unwrap();
8790///
8791/// # let client = hyper_util::client::legacy::Client::builder(
8792/// # hyper_util::rt::TokioExecutor::new()
8793/// # )
8794/// # .build(
8795/// # hyper_rustls::HttpsConnectorBuilder::new()
8796/// # .with_native_roots()
8797/// # .unwrap()
8798/// # .https_or_http()
8799/// # .enable_http1()
8800/// # .build()
8801/// # );
8802/// # let mut hub = Spanner::new(client, auth);
8803/// // You can configure optional parameters by calling the respective setters at will, and
8804/// // execute the final call using `doit()`.
8805/// // Values shown here are possibly random and not representative !
8806/// let result = hub.projects().instance_configs_list("parent")
8807/// .page_token("duo")
8808/// .page_size(-80)
8809/// .doit().await;
8810/// # }
8811/// ```
8812pub struct ProjectInstanceConfigListCall<'a, C>
8813where
8814 C: 'a,
8815{
8816 hub: &'a Spanner<C>,
8817 _parent: String,
8818 _page_token: Option<String>,
8819 _page_size: Option<i32>,
8820 _delegate: Option<&'a mut dyn common::Delegate>,
8821 _additional_params: HashMap<String, String>,
8822 _scopes: BTreeSet<String>,
8823}
8824
8825impl<'a, C> common::CallBuilder for ProjectInstanceConfigListCall<'a, C> {}
8826
8827impl<'a, C> ProjectInstanceConfigListCall<'a, C>
8828where
8829 C: common::Connector,
8830{
8831 /// Perform the operation you have build so far.
8832 pub async fn doit(mut self) -> common::Result<(common::Response, ListInstanceConfigsResponse)> {
8833 use std::borrow::Cow;
8834 use std::io::{Read, Seek};
8835
8836 use common::{url::Params, ToParts};
8837 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8838
8839 let mut dd = common::DefaultDelegate;
8840 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8841 dlg.begin(common::MethodInfo {
8842 id: "spanner.projects.instanceConfigs.list",
8843 http_method: hyper::Method::GET,
8844 });
8845
8846 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8847 if self._additional_params.contains_key(field) {
8848 dlg.finished(false);
8849 return Err(common::Error::FieldClash(field));
8850 }
8851 }
8852
8853 let mut params = Params::with_capacity(5 + self._additional_params.len());
8854 params.push("parent", self._parent);
8855 if let Some(value) = self._page_token.as_ref() {
8856 params.push("pageToken", value);
8857 }
8858 if let Some(value) = self._page_size.as_ref() {
8859 params.push("pageSize", value.to_string());
8860 }
8861
8862 params.extend(self._additional_params.iter());
8863
8864 params.push("alt", "json");
8865 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instanceConfigs";
8866 if self._scopes.is_empty() {
8867 self._scopes
8868 .insert(Scope::CloudPlatform.as_ref().to_string());
8869 }
8870
8871 #[allow(clippy::single_element_loop)]
8872 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8873 url = params.uri_replacement(url, param_name, find_this, true);
8874 }
8875 {
8876 let to_remove = ["parent"];
8877 params.remove_params(&to_remove);
8878 }
8879
8880 let url = params.parse_with_url(&url);
8881
8882 loop {
8883 let token = match self
8884 .hub
8885 .auth
8886 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8887 .await
8888 {
8889 Ok(token) => token,
8890 Err(e) => match dlg.token(e) {
8891 Ok(token) => token,
8892 Err(e) => {
8893 dlg.finished(false);
8894 return Err(common::Error::MissingToken(e));
8895 }
8896 },
8897 };
8898 let mut req_result = {
8899 let client = &self.hub.client;
8900 dlg.pre_request();
8901 let mut req_builder = hyper::Request::builder()
8902 .method(hyper::Method::GET)
8903 .uri(url.as_str())
8904 .header(USER_AGENT, self.hub._user_agent.clone());
8905
8906 if let Some(token) = token.as_ref() {
8907 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8908 }
8909
8910 let request = req_builder
8911 .header(CONTENT_LENGTH, 0_u64)
8912 .body(common::to_body::<String>(None));
8913
8914 client.request(request.unwrap()).await
8915 };
8916
8917 match req_result {
8918 Err(err) => {
8919 if let common::Retry::After(d) = dlg.http_error(&err) {
8920 sleep(d).await;
8921 continue;
8922 }
8923 dlg.finished(false);
8924 return Err(common::Error::HttpError(err));
8925 }
8926 Ok(res) => {
8927 let (mut parts, body) = res.into_parts();
8928 let mut body = common::Body::new(body);
8929 if !parts.status.is_success() {
8930 let bytes = common::to_bytes(body).await.unwrap_or_default();
8931 let error = serde_json::from_str(&common::to_string(&bytes));
8932 let response = common::to_response(parts, bytes.into());
8933
8934 if let common::Retry::After(d) =
8935 dlg.http_failure(&response, error.as_ref().ok())
8936 {
8937 sleep(d).await;
8938 continue;
8939 }
8940
8941 dlg.finished(false);
8942
8943 return Err(match error {
8944 Ok(value) => common::Error::BadRequest(value),
8945 _ => common::Error::Failure(response),
8946 });
8947 }
8948 let response = {
8949 let bytes = common::to_bytes(body).await.unwrap_or_default();
8950 let encoded = common::to_string(&bytes);
8951 match serde_json::from_str(&encoded) {
8952 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8953 Err(error) => {
8954 dlg.response_json_decode_error(&encoded, &error);
8955 return Err(common::Error::JsonDecodeError(
8956 encoded.to_string(),
8957 error,
8958 ));
8959 }
8960 }
8961 };
8962
8963 dlg.finished(true);
8964 return Ok(response);
8965 }
8966 }
8967 }
8968 }
8969
8970 /// Required. The name of the project for which a list of supported instance configurations is requested. Values are of the form `projects/`.
8971 ///
8972 /// Sets the *parent* path property to the given value.
8973 ///
8974 /// Even though the property as already been set when instantiating this call,
8975 /// we provide this method for API completeness.
8976 pub fn parent(mut self, new_value: &str) -> ProjectInstanceConfigListCall<'a, C> {
8977 self._parent = new_value.to_string();
8978 self
8979 }
8980 /// If non-empty, `page_token` should contain a next_page_token from a previous ListInstanceConfigsResponse.
8981 ///
8982 /// Sets the *page token* query property to the given value.
8983 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceConfigListCall<'a, C> {
8984 self._page_token = Some(new_value.to_string());
8985 self
8986 }
8987 /// Number of instance configurations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
8988 ///
8989 /// Sets the *page size* query property to the given value.
8990 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceConfigListCall<'a, C> {
8991 self._page_size = Some(new_value);
8992 self
8993 }
8994 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8995 /// while executing the actual API request.
8996 ///
8997 /// ````text
8998 /// It should be used to handle progress information, and to implement a certain level of resilience.
8999 /// ````
9000 ///
9001 /// Sets the *delegate* property to the given value.
9002 pub fn delegate(
9003 mut self,
9004 new_value: &'a mut dyn common::Delegate,
9005 ) -> ProjectInstanceConfigListCall<'a, C> {
9006 self._delegate = Some(new_value);
9007 self
9008 }
9009
9010 /// Set any additional parameter of the query string used in the request.
9011 /// It should be used to set parameters which are not yet available through their own
9012 /// setters.
9013 ///
9014 /// Please note that this method must not be used to set any of the known parameters
9015 /// which have their own setter method. If done anyway, the request will fail.
9016 ///
9017 /// # Additional Parameters
9018 ///
9019 /// * *$.xgafv* (query-string) - V1 error format.
9020 /// * *access_token* (query-string) - OAuth access token.
9021 /// * *alt* (query-string) - Data format for response.
9022 /// * *callback* (query-string) - JSONP
9023 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9024 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9025 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9026 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9027 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9028 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9029 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9030 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigListCall<'a, C>
9031 where
9032 T: AsRef<str>,
9033 {
9034 self._additional_params
9035 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9036 self
9037 }
9038
9039 /// Identifies the authorization scope for the method you are building.
9040 ///
9041 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9042 /// [`Scope::CloudPlatform`].
9043 ///
9044 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9045 /// tokens for more than one scope.
9046 ///
9047 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9048 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9049 /// sufficient, a read-write scope will do as well.
9050 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigListCall<'a, C>
9051 where
9052 St: AsRef<str>,
9053 {
9054 self._scopes.insert(String::from(scope.as_ref()));
9055 self
9056 }
9057 /// Identifies the authorization scope(s) for the method you are building.
9058 ///
9059 /// See [`Self::add_scope()`] for details.
9060 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigListCall<'a, C>
9061 where
9062 I: IntoIterator<Item = St>,
9063 St: AsRef<str>,
9064 {
9065 self._scopes
9066 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9067 self
9068 }
9069
9070 /// Removes all scopes, and no default scope will be used either.
9071 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9072 /// for details).
9073 pub fn clear_scopes(mut self) -> ProjectInstanceConfigListCall<'a, C> {
9074 self._scopes.clear();
9075 self
9076 }
9077}
9078
9079/// Updates an instance config. The returned long-running operation can be used to track the progress of updating the instance. If the named instance config does not exist, returns `NOT_FOUND`. Only user managed configurations can be updated. Immediately after the request returns: * The instance config'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 config are rejected. * Reading the instance config 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 instance config's new values are readable via the API. * The instance config'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 config 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.
9080///
9081/// A builder for the *instanceConfigs.patch* method supported by a *project* resource.
9082/// It is not used directly, but through a [`ProjectMethods`] instance.
9083///
9084/// # Example
9085///
9086/// Instantiate a resource method builder
9087///
9088/// ```test_harness,no_run
9089/// # extern crate hyper;
9090/// # extern crate hyper_rustls;
9091/// # extern crate google_spanner1 as spanner1;
9092/// use spanner1::api::UpdateInstanceConfigRequest;
9093/// # async fn dox() {
9094/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9095///
9096/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9097/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9098/// # secret,
9099/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9100/// # ).build().await.unwrap();
9101///
9102/// # let client = hyper_util::client::legacy::Client::builder(
9103/// # hyper_util::rt::TokioExecutor::new()
9104/// # )
9105/// # .build(
9106/// # hyper_rustls::HttpsConnectorBuilder::new()
9107/// # .with_native_roots()
9108/// # .unwrap()
9109/// # .https_or_http()
9110/// # .enable_http1()
9111/// # .build()
9112/// # );
9113/// # let mut hub = Spanner::new(client, auth);
9114/// // As the method needs a request, you would usually fill it with the desired information
9115/// // into the respective structure. Some of the parts shown here might not be applicable !
9116/// // Values shown here are possibly random and not representative !
9117/// let mut req = UpdateInstanceConfigRequest::default();
9118///
9119/// // You can configure optional parameters by calling the respective setters at will, and
9120/// // execute the final call using `doit()`.
9121/// // Values shown here are possibly random and not representative !
9122/// let result = hub.projects().instance_configs_patch(req, "name")
9123/// .doit().await;
9124/// # }
9125/// ```
9126pub struct ProjectInstanceConfigPatchCall<'a, C>
9127where
9128 C: 'a,
9129{
9130 hub: &'a Spanner<C>,
9131 _request: UpdateInstanceConfigRequest,
9132 _name: String,
9133 _delegate: Option<&'a mut dyn common::Delegate>,
9134 _additional_params: HashMap<String, String>,
9135 _scopes: BTreeSet<String>,
9136}
9137
9138impl<'a, C> common::CallBuilder for ProjectInstanceConfigPatchCall<'a, C> {}
9139
9140impl<'a, C> ProjectInstanceConfigPatchCall<'a, C>
9141where
9142 C: common::Connector,
9143{
9144 /// Perform the operation you have build so far.
9145 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9146 use std::borrow::Cow;
9147 use std::io::{Read, Seek};
9148
9149 use common::{url::Params, ToParts};
9150 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9151
9152 let mut dd = common::DefaultDelegate;
9153 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9154 dlg.begin(common::MethodInfo {
9155 id: "spanner.projects.instanceConfigs.patch",
9156 http_method: hyper::Method::PATCH,
9157 });
9158
9159 for &field in ["alt", "name"].iter() {
9160 if self._additional_params.contains_key(field) {
9161 dlg.finished(false);
9162 return Err(common::Error::FieldClash(field));
9163 }
9164 }
9165
9166 let mut params = Params::with_capacity(4 + self._additional_params.len());
9167 params.push("name", self._name);
9168
9169 params.extend(self._additional_params.iter());
9170
9171 params.push("alt", "json");
9172 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9173 if self._scopes.is_empty() {
9174 self._scopes
9175 .insert(Scope::CloudPlatform.as_ref().to_string());
9176 }
9177
9178 #[allow(clippy::single_element_loop)]
9179 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9180 url = params.uri_replacement(url, param_name, find_this, true);
9181 }
9182 {
9183 let to_remove = ["name"];
9184 params.remove_params(&to_remove);
9185 }
9186
9187 let url = params.parse_with_url(&url);
9188
9189 let mut json_mime_type = mime::APPLICATION_JSON;
9190 let mut request_value_reader = {
9191 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9192 common::remove_json_null_values(&mut value);
9193 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9194 serde_json::to_writer(&mut dst, &value).unwrap();
9195 dst
9196 };
9197 let request_size = request_value_reader
9198 .seek(std::io::SeekFrom::End(0))
9199 .unwrap();
9200 request_value_reader
9201 .seek(std::io::SeekFrom::Start(0))
9202 .unwrap();
9203
9204 loop {
9205 let token = match self
9206 .hub
9207 .auth
9208 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9209 .await
9210 {
9211 Ok(token) => token,
9212 Err(e) => match dlg.token(e) {
9213 Ok(token) => token,
9214 Err(e) => {
9215 dlg.finished(false);
9216 return Err(common::Error::MissingToken(e));
9217 }
9218 },
9219 };
9220 request_value_reader
9221 .seek(std::io::SeekFrom::Start(0))
9222 .unwrap();
9223 let mut req_result = {
9224 let client = &self.hub.client;
9225 dlg.pre_request();
9226 let mut req_builder = hyper::Request::builder()
9227 .method(hyper::Method::PATCH)
9228 .uri(url.as_str())
9229 .header(USER_AGENT, self.hub._user_agent.clone());
9230
9231 if let Some(token) = token.as_ref() {
9232 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9233 }
9234
9235 let request = req_builder
9236 .header(CONTENT_TYPE, json_mime_type.to_string())
9237 .header(CONTENT_LENGTH, request_size as u64)
9238 .body(common::to_body(
9239 request_value_reader.get_ref().clone().into(),
9240 ));
9241
9242 client.request(request.unwrap()).await
9243 };
9244
9245 match req_result {
9246 Err(err) => {
9247 if let common::Retry::After(d) = dlg.http_error(&err) {
9248 sleep(d).await;
9249 continue;
9250 }
9251 dlg.finished(false);
9252 return Err(common::Error::HttpError(err));
9253 }
9254 Ok(res) => {
9255 let (mut parts, body) = res.into_parts();
9256 let mut body = common::Body::new(body);
9257 if !parts.status.is_success() {
9258 let bytes = common::to_bytes(body).await.unwrap_or_default();
9259 let error = serde_json::from_str(&common::to_string(&bytes));
9260 let response = common::to_response(parts, bytes.into());
9261
9262 if let common::Retry::After(d) =
9263 dlg.http_failure(&response, error.as_ref().ok())
9264 {
9265 sleep(d).await;
9266 continue;
9267 }
9268
9269 dlg.finished(false);
9270
9271 return Err(match error {
9272 Ok(value) => common::Error::BadRequest(value),
9273 _ => common::Error::Failure(response),
9274 });
9275 }
9276 let response = {
9277 let bytes = common::to_bytes(body).await.unwrap_or_default();
9278 let encoded = common::to_string(&bytes);
9279 match serde_json::from_str(&encoded) {
9280 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9281 Err(error) => {
9282 dlg.response_json_decode_error(&encoded, &error);
9283 return Err(common::Error::JsonDecodeError(
9284 encoded.to_string(),
9285 error,
9286 ));
9287 }
9288 }
9289 };
9290
9291 dlg.finished(true);
9292 return Ok(response);
9293 }
9294 }
9295 }
9296 }
9297
9298 ///
9299 /// Sets the *request* property to the given value.
9300 ///
9301 /// Even though the property as already been set when instantiating this call,
9302 /// we provide this method for API completeness.
9303 pub fn request(
9304 mut self,
9305 new_value: UpdateInstanceConfigRequest,
9306 ) -> ProjectInstanceConfigPatchCall<'a, C> {
9307 self._request = new_value;
9308 self
9309 }
9310 /// A unique identifier for the instance configuration. Values are of the form `projects//instanceConfigs/a-z*`. User instance config must start with `custom-`.
9311 ///
9312 /// Sets the *name* path property to the given value.
9313 ///
9314 /// Even though the property as already been set when instantiating this call,
9315 /// we provide this method for API completeness.
9316 pub fn name(mut self, new_value: &str) -> ProjectInstanceConfigPatchCall<'a, C> {
9317 self._name = new_value.to_string();
9318 self
9319 }
9320 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9321 /// while executing the actual API request.
9322 ///
9323 /// ````text
9324 /// It should be used to handle progress information, and to implement a certain level of resilience.
9325 /// ````
9326 ///
9327 /// Sets the *delegate* property to the given value.
9328 pub fn delegate(
9329 mut self,
9330 new_value: &'a mut dyn common::Delegate,
9331 ) -> ProjectInstanceConfigPatchCall<'a, C> {
9332 self._delegate = Some(new_value);
9333 self
9334 }
9335
9336 /// Set any additional parameter of the query string used in the request.
9337 /// It should be used to set parameters which are not yet available through their own
9338 /// setters.
9339 ///
9340 /// Please note that this method must not be used to set any of the known parameters
9341 /// which have their own setter method. If done anyway, the request will fail.
9342 ///
9343 /// # Additional Parameters
9344 ///
9345 /// * *$.xgafv* (query-string) - V1 error format.
9346 /// * *access_token* (query-string) - OAuth access token.
9347 /// * *alt* (query-string) - Data format for response.
9348 /// * *callback* (query-string) - JSONP
9349 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9350 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9351 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9352 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9353 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9354 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9355 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9356 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceConfigPatchCall<'a, C>
9357 where
9358 T: AsRef<str>,
9359 {
9360 self._additional_params
9361 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9362 self
9363 }
9364
9365 /// Identifies the authorization scope for the method you are building.
9366 ///
9367 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9368 /// [`Scope::CloudPlatform`].
9369 ///
9370 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9371 /// tokens for more than one scope.
9372 ///
9373 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9374 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9375 /// sufficient, a read-write scope will do as well.
9376 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceConfigPatchCall<'a, C>
9377 where
9378 St: AsRef<str>,
9379 {
9380 self._scopes.insert(String::from(scope.as_ref()));
9381 self
9382 }
9383 /// Identifies the authorization scope(s) for the method you are building.
9384 ///
9385 /// See [`Self::add_scope()`] for details.
9386 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceConfigPatchCall<'a, C>
9387 where
9388 I: IntoIterator<Item = St>,
9389 St: AsRef<str>,
9390 {
9391 self._scopes
9392 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9393 self
9394 }
9395
9396 /// Removes all scopes, and no default scope will be used either.
9397 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9398 /// for details).
9399 pub fn clear_scopes(mut self) -> ProjectInstanceConfigPatchCall<'a, C> {
9400 self._scopes.clear();
9401 self
9402 }
9403}
9404
9405/// 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.
9406///
9407/// A builder for the *instances.backupOperations.list* method supported by a *project* resource.
9408/// It is not used directly, but through a [`ProjectMethods`] instance.
9409///
9410/// # Example
9411///
9412/// Instantiate a resource method builder
9413///
9414/// ```test_harness,no_run
9415/// # extern crate hyper;
9416/// # extern crate hyper_rustls;
9417/// # extern crate google_spanner1 as spanner1;
9418/// # async fn dox() {
9419/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9420///
9421/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9422/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9423/// # secret,
9424/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9425/// # ).build().await.unwrap();
9426///
9427/// # let client = hyper_util::client::legacy::Client::builder(
9428/// # hyper_util::rt::TokioExecutor::new()
9429/// # )
9430/// # .build(
9431/// # hyper_rustls::HttpsConnectorBuilder::new()
9432/// # .with_native_roots()
9433/// # .unwrap()
9434/// # .https_or_http()
9435/// # .enable_http1()
9436/// # .build()
9437/// # );
9438/// # let mut hub = Spanner::new(client, auth);
9439/// // You can configure optional parameters by calling the respective setters at will, and
9440/// // execute the final call using `doit()`.
9441/// // Values shown here are possibly random and not representative !
9442/// let result = hub.projects().instances_backup_operations_list("parent")
9443/// .page_token("kasd")
9444/// .page_size(-24)
9445/// .filter("sed")
9446/// .doit().await;
9447/// # }
9448/// ```
9449pub struct ProjectInstanceBackupOperationListCall<'a, C>
9450where
9451 C: 'a,
9452{
9453 hub: &'a Spanner<C>,
9454 _parent: String,
9455 _page_token: Option<String>,
9456 _page_size: Option<i32>,
9457 _filter: Option<String>,
9458 _delegate: Option<&'a mut dyn common::Delegate>,
9459 _additional_params: HashMap<String, String>,
9460 _scopes: BTreeSet<String>,
9461}
9462
9463impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationListCall<'a, C> {}
9464
9465impl<'a, C> ProjectInstanceBackupOperationListCall<'a, C>
9466where
9467 C: common::Connector,
9468{
9469 /// Perform the operation you have build so far.
9470 pub async fn doit(
9471 mut self,
9472 ) -> common::Result<(common::Response, ListBackupOperationsResponse)> {
9473 use std::borrow::Cow;
9474 use std::io::{Read, Seek};
9475
9476 use common::{url::Params, ToParts};
9477 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9478
9479 let mut dd = common::DefaultDelegate;
9480 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9481 dlg.begin(common::MethodInfo {
9482 id: "spanner.projects.instances.backupOperations.list",
9483 http_method: hyper::Method::GET,
9484 });
9485
9486 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
9487 if self._additional_params.contains_key(field) {
9488 dlg.finished(false);
9489 return Err(common::Error::FieldClash(field));
9490 }
9491 }
9492
9493 let mut params = Params::with_capacity(6 + self._additional_params.len());
9494 params.push("parent", self._parent);
9495 if let Some(value) = self._page_token.as_ref() {
9496 params.push("pageToken", value);
9497 }
9498 if let Some(value) = self._page_size.as_ref() {
9499 params.push("pageSize", value.to_string());
9500 }
9501 if let Some(value) = self._filter.as_ref() {
9502 params.push("filter", value);
9503 }
9504
9505 params.extend(self._additional_params.iter());
9506
9507 params.push("alt", "json");
9508 let mut url = self.hub._base_url.clone() + "v1/{+parent}/backupOperations";
9509 if self._scopes.is_empty() {
9510 self._scopes
9511 .insert(Scope::CloudPlatform.as_ref().to_string());
9512 }
9513
9514 #[allow(clippy::single_element_loop)]
9515 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9516 url = params.uri_replacement(url, param_name, find_this, true);
9517 }
9518 {
9519 let to_remove = ["parent"];
9520 params.remove_params(&to_remove);
9521 }
9522
9523 let url = params.parse_with_url(&url);
9524
9525 loop {
9526 let token = match self
9527 .hub
9528 .auth
9529 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9530 .await
9531 {
9532 Ok(token) => token,
9533 Err(e) => match dlg.token(e) {
9534 Ok(token) => token,
9535 Err(e) => {
9536 dlg.finished(false);
9537 return Err(common::Error::MissingToken(e));
9538 }
9539 },
9540 };
9541 let mut req_result = {
9542 let client = &self.hub.client;
9543 dlg.pre_request();
9544 let mut req_builder = hyper::Request::builder()
9545 .method(hyper::Method::GET)
9546 .uri(url.as_str())
9547 .header(USER_AGENT, self.hub._user_agent.clone());
9548
9549 if let Some(token) = token.as_ref() {
9550 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9551 }
9552
9553 let request = req_builder
9554 .header(CONTENT_LENGTH, 0_u64)
9555 .body(common::to_body::<String>(None));
9556
9557 client.request(request.unwrap()).await
9558 };
9559
9560 match req_result {
9561 Err(err) => {
9562 if let common::Retry::After(d) = dlg.http_error(&err) {
9563 sleep(d).await;
9564 continue;
9565 }
9566 dlg.finished(false);
9567 return Err(common::Error::HttpError(err));
9568 }
9569 Ok(res) => {
9570 let (mut parts, body) = res.into_parts();
9571 let mut body = common::Body::new(body);
9572 if !parts.status.is_success() {
9573 let bytes = common::to_bytes(body).await.unwrap_or_default();
9574 let error = serde_json::from_str(&common::to_string(&bytes));
9575 let response = common::to_response(parts, bytes.into());
9576
9577 if let common::Retry::After(d) =
9578 dlg.http_failure(&response, error.as_ref().ok())
9579 {
9580 sleep(d).await;
9581 continue;
9582 }
9583
9584 dlg.finished(false);
9585
9586 return Err(match error {
9587 Ok(value) => common::Error::BadRequest(value),
9588 _ => common::Error::Failure(response),
9589 });
9590 }
9591 let response = {
9592 let bytes = common::to_bytes(body).await.unwrap_or_default();
9593 let encoded = common::to_string(&bytes);
9594 match serde_json::from_str(&encoded) {
9595 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9596 Err(error) => {
9597 dlg.response_json_decode_error(&encoded, &error);
9598 return Err(common::Error::JsonDecodeError(
9599 encoded.to_string(),
9600 error,
9601 ));
9602 }
9603 }
9604 };
9605
9606 dlg.finished(true);
9607 return Ok(response);
9608 }
9609 }
9610 }
9611 }
9612
9613 /// Required. The instance of the backup operations. Values are of the form `projects//instances/`.
9614 ///
9615 /// Sets the *parent* path property to the given value.
9616 ///
9617 /// Even though the property as already been set when instantiating this call,
9618 /// we provide this method for API completeness.
9619 pub fn parent(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall<'a, C> {
9620 self._parent = new_value.to_string();
9621 self
9622 }
9623 /// If non-empty, `page_token` should contain a next_page_token from a previous ListBackupOperationsResponse to the same `parent` and with the same `filter`.
9624 ///
9625 /// Sets the *page token* query property to the given value.
9626 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall<'a, C> {
9627 self._page_token = Some(new_value.to_string());
9628 self
9629 }
9630 /// Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
9631 ///
9632 /// Sets the *page size* query property to the given value.
9633 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceBackupOperationListCall<'a, C> {
9634 self._page_size = Some(new_value);
9635 self
9636 }
9637 /// 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.
9638 ///
9639 /// Sets the *filter* query property to the given value.
9640 pub fn filter(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall<'a, C> {
9641 self._filter = Some(new_value.to_string());
9642 self
9643 }
9644 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9645 /// while executing the actual API request.
9646 ///
9647 /// ````text
9648 /// It should be used to handle progress information, and to implement a certain level of resilience.
9649 /// ````
9650 ///
9651 /// Sets the *delegate* property to the given value.
9652 pub fn delegate(
9653 mut self,
9654 new_value: &'a mut dyn common::Delegate,
9655 ) -> ProjectInstanceBackupOperationListCall<'a, C> {
9656 self._delegate = Some(new_value);
9657 self
9658 }
9659
9660 /// Set any additional parameter of the query string used in the request.
9661 /// It should be used to set parameters which are not yet available through their own
9662 /// setters.
9663 ///
9664 /// Please note that this method must not be used to set any of the known parameters
9665 /// which have their own setter method. If done anyway, the request will fail.
9666 ///
9667 /// # Additional Parameters
9668 ///
9669 /// * *$.xgafv* (query-string) - V1 error format.
9670 /// * *access_token* (query-string) - OAuth access token.
9671 /// * *alt* (query-string) - Data format for response.
9672 /// * *callback* (query-string) - JSONP
9673 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9674 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9675 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9676 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9677 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9678 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9679 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9680 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationListCall<'a, C>
9681 where
9682 T: AsRef<str>,
9683 {
9684 self._additional_params
9685 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9686 self
9687 }
9688
9689 /// Identifies the authorization scope for the method you are building.
9690 ///
9691 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9692 /// [`Scope::CloudPlatform`].
9693 ///
9694 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9695 /// tokens for more than one scope.
9696 ///
9697 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9698 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9699 /// sufficient, a read-write scope will do as well.
9700 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationListCall<'a, C>
9701 where
9702 St: AsRef<str>,
9703 {
9704 self._scopes.insert(String::from(scope.as_ref()));
9705 self
9706 }
9707 /// Identifies the authorization scope(s) for the method you are building.
9708 ///
9709 /// See [`Self::add_scope()`] for details.
9710 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationListCall<'a, C>
9711 where
9712 I: IntoIterator<Item = St>,
9713 St: AsRef<str>,
9714 {
9715 self._scopes
9716 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9717 self
9718 }
9719
9720 /// Removes all scopes, and no default scope will be used either.
9721 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9722 /// for details).
9723 pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationListCall<'a, C> {
9724 self._scopes.clear();
9725 self
9726 }
9727}
9728
9729/// 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`.
9730///
9731/// A builder for the *instances.backups.operations.cancel* method supported by a *project* resource.
9732/// It is not used directly, but through a [`ProjectMethods`] instance.
9733///
9734/// # Example
9735///
9736/// Instantiate a resource method builder
9737///
9738/// ```test_harness,no_run
9739/// # extern crate hyper;
9740/// # extern crate hyper_rustls;
9741/// # extern crate google_spanner1 as spanner1;
9742/// # async fn dox() {
9743/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9744///
9745/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9746/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9747/// # secret,
9748/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9749/// # ).build().await.unwrap();
9750///
9751/// # let client = hyper_util::client::legacy::Client::builder(
9752/// # hyper_util::rt::TokioExecutor::new()
9753/// # )
9754/// # .build(
9755/// # hyper_rustls::HttpsConnectorBuilder::new()
9756/// # .with_native_roots()
9757/// # .unwrap()
9758/// # .https_or_http()
9759/// # .enable_http1()
9760/// # .build()
9761/// # );
9762/// # let mut hub = Spanner::new(client, auth);
9763/// // You can configure optional parameters by calling the respective setters at will, and
9764/// // execute the final call using `doit()`.
9765/// // Values shown here are possibly random and not representative !
9766/// let result = hub.projects().instances_backups_operations_cancel("name")
9767/// .doit().await;
9768/// # }
9769/// ```
9770pub struct ProjectInstanceBackupOperationCancelCall<'a, C>
9771where
9772 C: 'a,
9773{
9774 hub: &'a Spanner<C>,
9775 _name: String,
9776 _delegate: Option<&'a mut dyn common::Delegate>,
9777 _additional_params: HashMap<String, String>,
9778 _scopes: BTreeSet<String>,
9779}
9780
9781impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationCancelCall<'a, C> {}
9782
9783impl<'a, C> ProjectInstanceBackupOperationCancelCall<'a, C>
9784where
9785 C: common::Connector,
9786{
9787 /// Perform the operation you have build so far.
9788 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9789 use std::borrow::Cow;
9790 use std::io::{Read, Seek};
9791
9792 use common::{url::Params, ToParts};
9793 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9794
9795 let mut dd = common::DefaultDelegate;
9796 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9797 dlg.begin(common::MethodInfo {
9798 id: "spanner.projects.instances.backups.operations.cancel",
9799 http_method: hyper::Method::POST,
9800 });
9801
9802 for &field in ["alt", "name"].iter() {
9803 if self._additional_params.contains_key(field) {
9804 dlg.finished(false);
9805 return Err(common::Error::FieldClash(field));
9806 }
9807 }
9808
9809 let mut params = Params::with_capacity(3 + self._additional_params.len());
9810 params.push("name", self._name);
9811
9812 params.extend(self._additional_params.iter());
9813
9814 params.push("alt", "json");
9815 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
9816 if self._scopes.is_empty() {
9817 self._scopes
9818 .insert(Scope::CloudPlatform.as_ref().to_string());
9819 }
9820
9821 #[allow(clippy::single_element_loop)]
9822 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9823 url = params.uri_replacement(url, param_name, find_this, true);
9824 }
9825 {
9826 let to_remove = ["name"];
9827 params.remove_params(&to_remove);
9828 }
9829
9830 let url = params.parse_with_url(&url);
9831
9832 loop {
9833 let token = match self
9834 .hub
9835 .auth
9836 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9837 .await
9838 {
9839 Ok(token) => token,
9840 Err(e) => match dlg.token(e) {
9841 Ok(token) => token,
9842 Err(e) => {
9843 dlg.finished(false);
9844 return Err(common::Error::MissingToken(e));
9845 }
9846 },
9847 };
9848 let mut req_result = {
9849 let client = &self.hub.client;
9850 dlg.pre_request();
9851 let mut req_builder = hyper::Request::builder()
9852 .method(hyper::Method::POST)
9853 .uri(url.as_str())
9854 .header(USER_AGENT, self.hub._user_agent.clone());
9855
9856 if let Some(token) = token.as_ref() {
9857 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9858 }
9859
9860 let request = req_builder
9861 .header(CONTENT_LENGTH, 0_u64)
9862 .body(common::to_body::<String>(None));
9863
9864 client.request(request.unwrap()).await
9865 };
9866
9867 match req_result {
9868 Err(err) => {
9869 if let common::Retry::After(d) = dlg.http_error(&err) {
9870 sleep(d).await;
9871 continue;
9872 }
9873 dlg.finished(false);
9874 return Err(common::Error::HttpError(err));
9875 }
9876 Ok(res) => {
9877 let (mut parts, body) = res.into_parts();
9878 let mut body = common::Body::new(body);
9879 if !parts.status.is_success() {
9880 let bytes = common::to_bytes(body).await.unwrap_or_default();
9881 let error = serde_json::from_str(&common::to_string(&bytes));
9882 let response = common::to_response(parts, bytes.into());
9883
9884 if let common::Retry::After(d) =
9885 dlg.http_failure(&response, error.as_ref().ok())
9886 {
9887 sleep(d).await;
9888 continue;
9889 }
9890
9891 dlg.finished(false);
9892
9893 return Err(match error {
9894 Ok(value) => common::Error::BadRequest(value),
9895 _ => common::Error::Failure(response),
9896 });
9897 }
9898 let response = {
9899 let bytes = common::to_bytes(body).await.unwrap_or_default();
9900 let encoded = common::to_string(&bytes);
9901 match serde_json::from_str(&encoded) {
9902 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9903 Err(error) => {
9904 dlg.response_json_decode_error(&encoded, &error);
9905 return Err(common::Error::JsonDecodeError(
9906 encoded.to_string(),
9907 error,
9908 ));
9909 }
9910 }
9911 };
9912
9913 dlg.finished(true);
9914 return Ok(response);
9915 }
9916 }
9917 }
9918 }
9919
9920 /// The name of the operation resource to be cancelled.
9921 ///
9922 /// Sets the *name* path property to the given value.
9923 ///
9924 /// Even though the property as already been set when instantiating this call,
9925 /// we provide this method for API completeness.
9926 pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupOperationCancelCall<'a, C> {
9927 self._name = new_value.to_string();
9928 self
9929 }
9930 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9931 /// while executing the actual API request.
9932 ///
9933 /// ````text
9934 /// It should be used to handle progress information, and to implement a certain level of resilience.
9935 /// ````
9936 ///
9937 /// Sets the *delegate* property to the given value.
9938 pub fn delegate(
9939 mut self,
9940 new_value: &'a mut dyn common::Delegate,
9941 ) -> ProjectInstanceBackupOperationCancelCall<'a, C> {
9942 self._delegate = Some(new_value);
9943 self
9944 }
9945
9946 /// Set any additional parameter of the query string used in the request.
9947 /// It should be used to set parameters which are not yet available through their own
9948 /// setters.
9949 ///
9950 /// Please note that this method must not be used to set any of the known parameters
9951 /// which have their own setter method. If done anyway, the request will fail.
9952 ///
9953 /// # Additional Parameters
9954 ///
9955 /// * *$.xgafv* (query-string) - V1 error format.
9956 /// * *access_token* (query-string) - OAuth access token.
9957 /// * *alt* (query-string) - Data format for response.
9958 /// * *callback* (query-string) - JSONP
9959 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9960 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9961 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9962 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9963 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9964 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9965 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9966 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationCancelCall<'a, C>
9967 where
9968 T: AsRef<str>,
9969 {
9970 self._additional_params
9971 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9972 self
9973 }
9974
9975 /// Identifies the authorization scope for the method you are building.
9976 ///
9977 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9978 /// [`Scope::CloudPlatform`].
9979 ///
9980 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9981 /// tokens for more than one scope.
9982 ///
9983 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9984 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9985 /// sufficient, a read-write scope will do as well.
9986 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationCancelCall<'a, C>
9987 where
9988 St: AsRef<str>,
9989 {
9990 self._scopes.insert(String::from(scope.as_ref()));
9991 self
9992 }
9993 /// Identifies the authorization scope(s) for the method you are building.
9994 ///
9995 /// See [`Self::add_scope()`] for details.
9996 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationCancelCall<'a, C>
9997 where
9998 I: IntoIterator<Item = St>,
9999 St: AsRef<str>,
10000 {
10001 self._scopes
10002 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10003 self
10004 }
10005
10006 /// Removes all scopes, and no default scope will be used either.
10007 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10008 /// for details).
10009 pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationCancelCall<'a, C> {
10010 self._scopes.clear();
10011 self
10012 }
10013}
10014
10015/// 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`.
10016///
10017/// A builder for the *instances.backups.operations.delete* method supported by a *project* resource.
10018/// It is not used directly, but through a [`ProjectMethods`] instance.
10019///
10020/// # Example
10021///
10022/// Instantiate a resource method builder
10023///
10024/// ```test_harness,no_run
10025/// # extern crate hyper;
10026/// # extern crate hyper_rustls;
10027/// # extern crate google_spanner1 as spanner1;
10028/// # async fn dox() {
10029/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10030///
10031/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10032/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10033/// # secret,
10034/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10035/// # ).build().await.unwrap();
10036///
10037/// # let client = hyper_util::client::legacy::Client::builder(
10038/// # hyper_util::rt::TokioExecutor::new()
10039/// # )
10040/// # .build(
10041/// # hyper_rustls::HttpsConnectorBuilder::new()
10042/// # .with_native_roots()
10043/// # .unwrap()
10044/// # .https_or_http()
10045/// # .enable_http1()
10046/// # .build()
10047/// # );
10048/// # let mut hub = Spanner::new(client, auth);
10049/// // You can configure optional parameters by calling the respective setters at will, and
10050/// // execute the final call using `doit()`.
10051/// // Values shown here are possibly random and not representative !
10052/// let result = hub.projects().instances_backups_operations_delete("name")
10053/// .doit().await;
10054/// # }
10055/// ```
10056pub struct ProjectInstanceBackupOperationDeleteCall<'a, C>
10057where
10058 C: 'a,
10059{
10060 hub: &'a Spanner<C>,
10061 _name: String,
10062 _delegate: Option<&'a mut dyn common::Delegate>,
10063 _additional_params: HashMap<String, String>,
10064 _scopes: BTreeSet<String>,
10065}
10066
10067impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationDeleteCall<'a, C> {}
10068
10069impl<'a, C> ProjectInstanceBackupOperationDeleteCall<'a, C>
10070where
10071 C: common::Connector,
10072{
10073 /// Perform the operation you have build so far.
10074 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
10075 use std::borrow::Cow;
10076 use std::io::{Read, Seek};
10077
10078 use common::{url::Params, ToParts};
10079 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10080
10081 let mut dd = common::DefaultDelegate;
10082 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10083 dlg.begin(common::MethodInfo {
10084 id: "spanner.projects.instances.backups.operations.delete",
10085 http_method: hyper::Method::DELETE,
10086 });
10087
10088 for &field in ["alt", "name"].iter() {
10089 if self._additional_params.contains_key(field) {
10090 dlg.finished(false);
10091 return Err(common::Error::FieldClash(field));
10092 }
10093 }
10094
10095 let mut params = Params::with_capacity(3 + self._additional_params.len());
10096 params.push("name", self._name);
10097
10098 params.extend(self._additional_params.iter());
10099
10100 params.push("alt", "json");
10101 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10102 if self._scopes.is_empty() {
10103 self._scopes
10104 .insert(Scope::CloudPlatform.as_ref().to_string());
10105 }
10106
10107 #[allow(clippy::single_element_loop)]
10108 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10109 url = params.uri_replacement(url, param_name, find_this, true);
10110 }
10111 {
10112 let to_remove = ["name"];
10113 params.remove_params(&to_remove);
10114 }
10115
10116 let url = params.parse_with_url(&url);
10117
10118 loop {
10119 let token = match self
10120 .hub
10121 .auth
10122 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10123 .await
10124 {
10125 Ok(token) => token,
10126 Err(e) => match dlg.token(e) {
10127 Ok(token) => token,
10128 Err(e) => {
10129 dlg.finished(false);
10130 return Err(common::Error::MissingToken(e));
10131 }
10132 },
10133 };
10134 let mut req_result = {
10135 let client = &self.hub.client;
10136 dlg.pre_request();
10137 let mut req_builder = hyper::Request::builder()
10138 .method(hyper::Method::DELETE)
10139 .uri(url.as_str())
10140 .header(USER_AGENT, self.hub._user_agent.clone());
10141
10142 if let Some(token) = token.as_ref() {
10143 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10144 }
10145
10146 let request = req_builder
10147 .header(CONTENT_LENGTH, 0_u64)
10148 .body(common::to_body::<String>(None));
10149
10150 client.request(request.unwrap()).await
10151 };
10152
10153 match req_result {
10154 Err(err) => {
10155 if let common::Retry::After(d) = dlg.http_error(&err) {
10156 sleep(d).await;
10157 continue;
10158 }
10159 dlg.finished(false);
10160 return Err(common::Error::HttpError(err));
10161 }
10162 Ok(res) => {
10163 let (mut parts, body) = res.into_parts();
10164 let mut body = common::Body::new(body);
10165 if !parts.status.is_success() {
10166 let bytes = common::to_bytes(body).await.unwrap_or_default();
10167 let error = serde_json::from_str(&common::to_string(&bytes));
10168 let response = common::to_response(parts, bytes.into());
10169
10170 if let common::Retry::After(d) =
10171 dlg.http_failure(&response, error.as_ref().ok())
10172 {
10173 sleep(d).await;
10174 continue;
10175 }
10176
10177 dlg.finished(false);
10178
10179 return Err(match error {
10180 Ok(value) => common::Error::BadRequest(value),
10181 _ => common::Error::Failure(response),
10182 });
10183 }
10184 let response = {
10185 let bytes = common::to_bytes(body).await.unwrap_or_default();
10186 let encoded = common::to_string(&bytes);
10187 match serde_json::from_str(&encoded) {
10188 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10189 Err(error) => {
10190 dlg.response_json_decode_error(&encoded, &error);
10191 return Err(common::Error::JsonDecodeError(
10192 encoded.to_string(),
10193 error,
10194 ));
10195 }
10196 }
10197 };
10198
10199 dlg.finished(true);
10200 return Ok(response);
10201 }
10202 }
10203 }
10204 }
10205
10206 /// The name of the operation resource to be deleted.
10207 ///
10208 /// Sets the *name* path property to the given value.
10209 ///
10210 /// Even though the property as already been set when instantiating this call,
10211 /// we provide this method for API completeness.
10212 pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupOperationDeleteCall<'a, C> {
10213 self._name = new_value.to_string();
10214 self
10215 }
10216 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10217 /// while executing the actual API request.
10218 ///
10219 /// ````text
10220 /// It should be used to handle progress information, and to implement a certain level of resilience.
10221 /// ````
10222 ///
10223 /// Sets the *delegate* property to the given value.
10224 pub fn delegate(
10225 mut self,
10226 new_value: &'a mut dyn common::Delegate,
10227 ) -> ProjectInstanceBackupOperationDeleteCall<'a, C> {
10228 self._delegate = Some(new_value);
10229 self
10230 }
10231
10232 /// Set any additional parameter of the query string used in the request.
10233 /// It should be used to set parameters which are not yet available through their own
10234 /// setters.
10235 ///
10236 /// Please note that this method must not be used to set any of the known parameters
10237 /// which have their own setter method. If done anyway, the request will fail.
10238 ///
10239 /// # Additional Parameters
10240 ///
10241 /// * *$.xgafv* (query-string) - V1 error format.
10242 /// * *access_token* (query-string) - OAuth access token.
10243 /// * *alt* (query-string) - Data format for response.
10244 /// * *callback* (query-string) - JSONP
10245 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10246 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10247 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10248 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10249 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10250 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10251 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10252 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationDeleteCall<'a, C>
10253 where
10254 T: AsRef<str>,
10255 {
10256 self._additional_params
10257 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10258 self
10259 }
10260
10261 /// Identifies the authorization scope for the method you are building.
10262 ///
10263 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10264 /// [`Scope::CloudPlatform`].
10265 ///
10266 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10267 /// tokens for more than one scope.
10268 ///
10269 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10270 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10271 /// sufficient, a read-write scope will do as well.
10272 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationDeleteCall<'a, C>
10273 where
10274 St: AsRef<str>,
10275 {
10276 self._scopes.insert(String::from(scope.as_ref()));
10277 self
10278 }
10279 /// Identifies the authorization scope(s) for the method you are building.
10280 ///
10281 /// See [`Self::add_scope()`] for details.
10282 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationDeleteCall<'a, C>
10283 where
10284 I: IntoIterator<Item = St>,
10285 St: AsRef<str>,
10286 {
10287 self._scopes
10288 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10289 self
10290 }
10291
10292 /// Removes all scopes, and no default scope will be used either.
10293 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10294 /// for details).
10295 pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationDeleteCall<'a, C> {
10296 self._scopes.clear();
10297 self
10298 }
10299}
10300
10301/// 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.
10302///
10303/// A builder for the *instances.backups.operations.get* method supported by a *project* resource.
10304/// It is not used directly, but through a [`ProjectMethods`] instance.
10305///
10306/// # Example
10307///
10308/// Instantiate a resource method builder
10309///
10310/// ```test_harness,no_run
10311/// # extern crate hyper;
10312/// # extern crate hyper_rustls;
10313/// # extern crate google_spanner1 as spanner1;
10314/// # async fn dox() {
10315/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10316///
10317/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10318/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10319/// # secret,
10320/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10321/// # ).build().await.unwrap();
10322///
10323/// # let client = hyper_util::client::legacy::Client::builder(
10324/// # hyper_util::rt::TokioExecutor::new()
10325/// # )
10326/// # .build(
10327/// # hyper_rustls::HttpsConnectorBuilder::new()
10328/// # .with_native_roots()
10329/// # .unwrap()
10330/// # .https_or_http()
10331/// # .enable_http1()
10332/// # .build()
10333/// # );
10334/// # let mut hub = Spanner::new(client, auth);
10335/// // You can configure optional parameters by calling the respective setters at will, and
10336/// // execute the final call using `doit()`.
10337/// // Values shown here are possibly random and not representative !
10338/// let result = hub.projects().instances_backups_operations_get("name")
10339/// .doit().await;
10340/// # }
10341/// ```
10342pub struct ProjectInstanceBackupOperationGetCall<'a, C>
10343where
10344 C: 'a,
10345{
10346 hub: &'a Spanner<C>,
10347 _name: String,
10348 _delegate: Option<&'a mut dyn common::Delegate>,
10349 _additional_params: HashMap<String, String>,
10350 _scopes: BTreeSet<String>,
10351}
10352
10353impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationGetCall<'a, C> {}
10354
10355impl<'a, C> ProjectInstanceBackupOperationGetCall<'a, C>
10356where
10357 C: common::Connector,
10358{
10359 /// Perform the operation you have build so far.
10360 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10361 use std::borrow::Cow;
10362 use std::io::{Read, Seek};
10363
10364 use common::{url::Params, ToParts};
10365 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10366
10367 let mut dd = common::DefaultDelegate;
10368 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10369 dlg.begin(common::MethodInfo {
10370 id: "spanner.projects.instances.backups.operations.get",
10371 http_method: hyper::Method::GET,
10372 });
10373
10374 for &field in ["alt", "name"].iter() {
10375 if self._additional_params.contains_key(field) {
10376 dlg.finished(false);
10377 return Err(common::Error::FieldClash(field));
10378 }
10379 }
10380
10381 let mut params = Params::with_capacity(3 + self._additional_params.len());
10382 params.push("name", self._name);
10383
10384 params.extend(self._additional_params.iter());
10385
10386 params.push("alt", "json");
10387 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10388 if self._scopes.is_empty() {
10389 self._scopes
10390 .insert(Scope::CloudPlatform.as_ref().to_string());
10391 }
10392
10393 #[allow(clippy::single_element_loop)]
10394 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10395 url = params.uri_replacement(url, param_name, find_this, true);
10396 }
10397 {
10398 let to_remove = ["name"];
10399 params.remove_params(&to_remove);
10400 }
10401
10402 let url = params.parse_with_url(&url);
10403
10404 loop {
10405 let token = match self
10406 .hub
10407 .auth
10408 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10409 .await
10410 {
10411 Ok(token) => token,
10412 Err(e) => match dlg.token(e) {
10413 Ok(token) => token,
10414 Err(e) => {
10415 dlg.finished(false);
10416 return Err(common::Error::MissingToken(e));
10417 }
10418 },
10419 };
10420 let mut req_result = {
10421 let client = &self.hub.client;
10422 dlg.pre_request();
10423 let mut req_builder = hyper::Request::builder()
10424 .method(hyper::Method::GET)
10425 .uri(url.as_str())
10426 .header(USER_AGENT, self.hub._user_agent.clone());
10427
10428 if let Some(token) = token.as_ref() {
10429 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10430 }
10431
10432 let request = req_builder
10433 .header(CONTENT_LENGTH, 0_u64)
10434 .body(common::to_body::<String>(None));
10435
10436 client.request(request.unwrap()).await
10437 };
10438
10439 match req_result {
10440 Err(err) => {
10441 if let common::Retry::After(d) = dlg.http_error(&err) {
10442 sleep(d).await;
10443 continue;
10444 }
10445 dlg.finished(false);
10446 return Err(common::Error::HttpError(err));
10447 }
10448 Ok(res) => {
10449 let (mut parts, body) = res.into_parts();
10450 let mut body = common::Body::new(body);
10451 if !parts.status.is_success() {
10452 let bytes = common::to_bytes(body).await.unwrap_or_default();
10453 let error = serde_json::from_str(&common::to_string(&bytes));
10454 let response = common::to_response(parts, bytes.into());
10455
10456 if let common::Retry::After(d) =
10457 dlg.http_failure(&response, error.as_ref().ok())
10458 {
10459 sleep(d).await;
10460 continue;
10461 }
10462
10463 dlg.finished(false);
10464
10465 return Err(match error {
10466 Ok(value) => common::Error::BadRequest(value),
10467 _ => common::Error::Failure(response),
10468 });
10469 }
10470 let response = {
10471 let bytes = common::to_bytes(body).await.unwrap_or_default();
10472 let encoded = common::to_string(&bytes);
10473 match serde_json::from_str(&encoded) {
10474 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10475 Err(error) => {
10476 dlg.response_json_decode_error(&encoded, &error);
10477 return Err(common::Error::JsonDecodeError(
10478 encoded.to_string(),
10479 error,
10480 ));
10481 }
10482 }
10483 };
10484
10485 dlg.finished(true);
10486 return Ok(response);
10487 }
10488 }
10489 }
10490 }
10491
10492 /// The name of the operation resource.
10493 ///
10494 /// Sets the *name* path property to the given value.
10495 ///
10496 /// Even though the property as already been set when instantiating this call,
10497 /// we provide this method for API completeness.
10498 pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupOperationGetCall<'a, C> {
10499 self._name = new_value.to_string();
10500 self
10501 }
10502 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10503 /// while executing the actual API request.
10504 ///
10505 /// ````text
10506 /// It should be used to handle progress information, and to implement a certain level of resilience.
10507 /// ````
10508 ///
10509 /// Sets the *delegate* property to the given value.
10510 pub fn delegate(
10511 mut self,
10512 new_value: &'a mut dyn common::Delegate,
10513 ) -> ProjectInstanceBackupOperationGetCall<'a, C> {
10514 self._delegate = Some(new_value);
10515 self
10516 }
10517
10518 /// Set any additional parameter of the query string used in the request.
10519 /// It should be used to set parameters which are not yet available through their own
10520 /// setters.
10521 ///
10522 /// Please note that this method must not be used to set any of the known parameters
10523 /// which have their own setter method. If done anyway, the request will fail.
10524 ///
10525 /// # Additional Parameters
10526 ///
10527 /// * *$.xgafv* (query-string) - V1 error format.
10528 /// * *access_token* (query-string) - OAuth access token.
10529 /// * *alt* (query-string) - Data format for response.
10530 /// * *callback* (query-string) - JSONP
10531 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10532 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10533 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10534 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10535 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10536 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10537 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10538 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationGetCall<'a, C>
10539 where
10540 T: AsRef<str>,
10541 {
10542 self._additional_params
10543 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10544 self
10545 }
10546
10547 /// Identifies the authorization scope for the method you are building.
10548 ///
10549 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10550 /// [`Scope::CloudPlatform`].
10551 ///
10552 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10553 /// tokens for more than one scope.
10554 ///
10555 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10556 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10557 /// sufficient, a read-write scope will do as well.
10558 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationGetCall<'a, C>
10559 where
10560 St: AsRef<str>,
10561 {
10562 self._scopes.insert(String::from(scope.as_ref()));
10563 self
10564 }
10565 /// Identifies the authorization scope(s) for the method you are building.
10566 ///
10567 /// See [`Self::add_scope()`] for details.
10568 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationGetCall<'a, C>
10569 where
10570 I: IntoIterator<Item = St>,
10571 St: AsRef<str>,
10572 {
10573 self._scopes
10574 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10575 self
10576 }
10577
10578 /// Removes all scopes, and no default scope will be used either.
10579 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10580 /// for details).
10581 pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationGetCall<'a, C> {
10582 self._scopes.clear();
10583 self
10584 }
10585}
10586
10587/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
10588///
10589/// A builder for the *instances.backups.operations.list* method supported by a *project* resource.
10590/// It is not used directly, but through a [`ProjectMethods`] instance.
10591///
10592/// # Example
10593///
10594/// Instantiate a resource method builder
10595///
10596/// ```test_harness,no_run
10597/// # extern crate hyper;
10598/// # extern crate hyper_rustls;
10599/// # extern crate google_spanner1 as spanner1;
10600/// # async fn dox() {
10601/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10602///
10603/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10604/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10605/// # secret,
10606/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10607/// # ).build().await.unwrap();
10608///
10609/// # let client = hyper_util::client::legacy::Client::builder(
10610/// # hyper_util::rt::TokioExecutor::new()
10611/// # )
10612/// # .build(
10613/// # hyper_rustls::HttpsConnectorBuilder::new()
10614/// # .with_native_roots()
10615/// # .unwrap()
10616/// # .https_or_http()
10617/// # .enable_http1()
10618/// # .build()
10619/// # );
10620/// # let mut hub = Spanner::new(client, auth);
10621/// // You can configure optional parameters by calling the respective setters at will, and
10622/// // execute the final call using `doit()`.
10623/// // Values shown here are possibly random and not representative !
10624/// let result = hub.projects().instances_backups_operations_list("name")
10625/// .page_token("sed")
10626/// .page_size(-20)
10627/// .filter("dolore")
10628/// .doit().await;
10629/// # }
10630/// ```
10631pub struct ProjectInstanceBackupOperationListCall1<'a, C>
10632where
10633 C: 'a,
10634{
10635 hub: &'a Spanner<C>,
10636 _name: String,
10637 _page_token: Option<String>,
10638 _page_size: Option<i32>,
10639 _filter: Option<String>,
10640 _delegate: Option<&'a mut dyn common::Delegate>,
10641 _additional_params: HashMap<String, String>,
10642 _scopes: BTreeSet<String>,
10643}
10644
10645impl<'a, C> common::CallBuilder for ProjectInstanceBackupOperationListCall1<'a, C> {}
10646
10647impl<'a, C> ProjectInstanceBackupOperationListCall1<'a, C>
10648where
10649 C: common::Connector,
10650{
10651 /// Perform the operation you have build so far.
10652 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
10653 use std::borrow::Cow;
10654 use std::io::{Read, Seek};
10655
10656 use common::{url::Params, ToParts};
10657 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10658
10659 let mut dd = common::DefaultDelegate;
10660 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10661 dlg.begin(common::MethodInfo {
10662 id: "spanner.projects.instances.backups.operations.list",
10663 http_method: hyper::Method::GET,
10664 });
10665
10666 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
10667 if self._additional_params.contains_key(field) {
10668 dlg.finished(false);
10669 return Err(common::Error::FieldClash(field));
10670 }
10671 }
10672
10673 let mut params = Params::with_capacity(6 + self._additional_params.len());
10674 params.push("name", self._name);
10675 if let Some(value) = self._page_token.as_ref() {
10676 params.push("pageToken", value);
10677 }
10678 if let Some(value) = self._page_size.as_ref() {
10679 params.push("pageSize", value.to_string());
10680 }
10681 if let Some(value) = self._filter.as_ref() {
10682 params.push("filter", value);
10683 }
10684
10685 params.extend(self._additional_params.iter());
10686
10687 params.push("alt", "json");
10688 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10689 if self._scopes.is_empty() {
10690 self._scopes
10691 .insert(Scope::CloudPlatform.as_ref().to_string());
10692 }
10693
10694 #[allow(clippy::single_element_loop)]
10695 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10696 url = params.uri_replacement(url, param_name, find_this, true);
10697 }
10698 {
10699 let to_remove = ["name"];
10700 params.remove_params(&to_remove);
10701 }
10702
10703 let url = params.parse_with_url(&url);
10704
10705 loop {
10706 let token = match self
10707 .hub
10708 .auth
10709 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10710 .await
10711 {
10712 Ok(token) => token,
10713 Err(e) => match dlg.token(e) {
10714 Ok(token) => token,
10715 Err(e) => {
10716 dlg.finished(false);
10717 return Err(common::Error::MissingToken(e));
10718 }
10719 },
10720 };
10721 let mut req_result = {
10722 let client = &self.hub.client;
10723 dlg.pre_request();
10724 let mut req_builder = hyper::Request::builder()
10725 .method(hyper::Method::GET)
10726 .uri(url.as_str())
10727 .header(USER_AGENT, self.hub._user_agent.clone());
10728
10729 if let Some(token) = token.as_ref() {
10730 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10731 }
10732
10733 let request = req_builder
10734 .header(CONTENT_LENGTH, 0_u64)
10735 .body(common::to_body::<String>(None));
10736
10737 client.request(request.unwrap()).await
10738 };
10739
10740 match req_result {
10741 Err(err) => {
10742 if let common::Retry::After(d) = dlg.http_error(&err) {
10743 sleep(d).await;
10744 continue;
10745 }
10746 dlg.finished(false);
10747 return Err(common::Error::HttpError(err));
10748 }
10749 Ok(res) => {
10750 let (mut parts, body) = res.into_parts();
10751 let mut body = common::Body::new(body);
10752 if !parts.status.is_success() {
10753 let bytes = common::to_bytes(body).await.unwrap_or_default();
10754 let error = serde_json::from_str(&common::to_string(&bytes));
10755 let response = common::to_response(parts, bytes.into());
10756
10757 if let common::Retry::After(d) =
10758 dlg.http_failure(&response, error.as_ref().ok())
10759 {
10760 sleep(d).await;
10761 continue;
10762 }
10763
10764 dlg.finished(false);
10765
10766 return Err(match error {
10767 Ok(value) => common::Error::BadRequest(value),
10768 _ => common::Error::Failure(response),
10769 });
10770 }
10771 let response = {
10772 let bytes = common::to_bytes(body).await.unwrap_or_default();
10773 let encoded = common::to_string(&bytes);
10774 match serde_json::from_str(&encoded) {
10775 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10776 Err(error) => {
10777 dlg.response_json_decode_error(&encoded, &error);
10778 return Err(common::Error::JsonDecodeError(
10779 encoded.to_string(),
10780 error,
10781 ));
10782 }
10783 }
10784 };
10785
10786 dlg.finished(true);
10787 return Ok(response);
10788 }
10789 }
10790 }
10791 }
10792
10793 /// The name of the operation's parent resource.
10794 ///
10795 /// Sets the *name* path property to the given value.
10796 ///
10797 /// Even though the property as already been set when instantiating this call,
10798 /// we provide this method for API completeness.
10799 pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall1<'a, C> {
10800 self._name = new_value.to_string();
10801 self
10802 }
10803 /// The standard list page token.
10804 ///
10805 /// Sets the *page token* query property to the given value.
10806 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall1<'a, C> {
10807 self._page_token = Some(new_value.to_string());
10808 self
10809 }
10810 /// The standard list page size.
10811 ///
10812 /// Sets the *page size* query property to the given value.
10813 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceBackupOperationListCall1<'a, C> {
10814 self._page_size = Some(new_value);
10815 self
10816 }
10817 /// The standard list filter.
10818 ///
10819 /// Sets the *filter* query property to the given value.
10820 pub fn filter(mut self, new_value: &str) -> ProjectInstanceBackupOperationListCall1<'a, C> {
10821 self._filter = Some(new_value.to_string());
10822 self
10823 }
10824 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10825 /// while executing the actual API request.
10826 ///
10827 /// ````text
10828 /// It should be used to handle progress information, and to implement a certain level of resilience.
10829 /// ````
10830 ///
10831 /// Sets the *delegate* property to the given value.
10832 pub fn delegate(
10833 mut self,
10834 new_value: &'a mut dyn common::Delegate,
10835 ) -> ProjectInstanceBackupOperationListCall1<'a, C> {
10836 self._delegate = Some(new_value);
10837 self
10838 }
10839
10840 /// Set any additional parameter of the query string used in the request.
10841 /// It should be used to set parameters which are not yet available through their own
10842 /// setters.
10843 ///
10844 /// Please note that this method must not be used to set any of the known parameters
10845 /// which have their own setter method. If done anyway, the request will fail.
10846 ///
10847 /// # Additional Parameters
10848 ///
10849 /// * *$.xgafv* (query-string) - V1 error format.
10850 /// * *access_token* (query-string) - OAuth access token.
10851 /// * *alt* (query-string) - Data format for response.
10852 /// * *callback* (query-string) - JSONP
10853 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10854 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10855 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10856 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10857 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10858 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10859 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10860 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupOperationListCall1<'a, C>
10861 where
10862 T: AsRef<str>,
10863 {
10864 self._additional_params
10865 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10866 self
10867 }
10868
10869 /// Identifies the authorization scope for the method you are building.
10870 ///
10871 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10872 /// [`Scope::CloudPlatform`].
10873 ///
10874 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10875 /// tokens for more than one scope.
10876 ///
10877 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10878 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10879 /// sufficient, a read-write scope will do as well.
10880 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupOperationListCall1<'a, C>
10881 where
10882 St: AsRef<str>,
10883 {
10884 self._scopes.insert(String::from(scope.as_ref()));
10885 self
10886 }
10887 /// Identifies the authorization scope(s) for the method you are building.
10888 ///
10889 /// See [`Self::add_scope()`] for details.
10890 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupOperationListCall1<'a, C>
10891 where
10892 I: IntoIterator<Item = St>,
10893 St: AsRef<str>,
10894 {
10895 self._scopes
10896 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10897 self
10898 }
10899
10900 /// Removes all scopes, and no default scope will be used either.
10901 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10902 /// for details).
10903 pub fn clear_scopes(mut self) -> ProjectInstanceBackupOperationListCall1<'a, C> {
10904 self._scopes.clear();
10905 self
10906 }
10907}
10908
10909/// 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.
10910///
10911/// A builder for the *instances.backups.copy* method supported by a *project* resource.
10912/// It is not used directly, but through a [`ProjectMethods`] instance.
10913///
10914/// # Example
10915///
10916/// Instantiate a resource method builder
10917///
10918/// ```test_harness,no_run
10919/// # extern crate hyper;
10920/// # extern crate hyper_rustls;
10921/// # extern crate google_spanner1 as spanner1;
10922/// use spanner1::api::CopyBackupRequest;
10923/// # async fn dox() {
10924/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10925///
10926/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10927/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10928/// # secret,
10929/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10930/// # ).build().await.unwrap();
10931///
10932/// # let client = hyper_util::client::legacy::Client::builder(
10933/// # hyper_util::rt::TokioExecutor::new()
10934/// # )
10935/// # .build(
10936/// # hyper_rustls::HttpsConnectorBuilder::new()
10937/// # .with_native_roots()
10938/// # .unwrap()
10939/// # .https_or_http()
10940/// # .enable_http1()
10941/// # .build()
10942/// # );
10943/// # let mut hub = Spanner::new(client, auth);
10944/// // As the method needs a request, you would usually fill it with the desired information
10945/// // into the respective structure. Some of the parts shown here might not be applicable !
10946/// // Values shown here are possibly random and not representative !
10947/// let mut req = CopyBackupRequest::default();
10948///
10949/// // You can configure optional parameters by calling the respective setters at will, and
10950/// // execute the final call using `doit()`.
10951/// // Values shown here are possibly random and not representative !
10952/// let result = hub.projects().instances_backups_copy(req, "parent")
10953/// .doit().await;
10954/// # }
10955/// ```
10956pub struct ProjectInstanceBackupCopyCall<'a, C>
10957where
10958 C: 'a,
10959{
10960 hub: &'a Spanner<C>,
10961 _request: CopyBackupRequest,
10962 _parent: String,
10963 _delegate: Option<&'a mut dyn common::Delegate>,
10964 _additional_params: HashMap<String, String>,
10965 _scopes: BTreeSet<String>,
10966}
10967
10968impl<'a, C> common::CallBuilder for ProjectInstanceBackupCopyCall<'a, C> {}
10969
10970impl<'a, C> ProjectInstanceBackupCopyCall<'a, C>
10971where
10972 C: common::Connector,
10973{
10974 /// Perform the operation you have build so far.
10975 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10976 use std::borrow::Cow;
10977 use std::io::{Read, Seek};
10978
10979 use common::{url::Params, ToParts};
10980 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10981
10982 let mut dd = common::DefaultDelegate;
10983 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10984 dlg.begin(common::MethodInfo {
10985 id: "spanner.projects.instances.backups.copy",
10986 http_method: hyper::Method::POST,
10987 });
10988
10989 for &field in ["alt", "parent"].iter() {
10990 if self._additional_params.contains_key(field) {
10991 dlg.finished(false);
10992 return Err(common::Error::FieldClash(field));
10993 }
10994 }
10995
10996 let mut params = Params::with_capacity(4 + self._additional_params.len());
10997 params.push("parent", self._parent);
10998
10999 params.extend(self._additional_params.iter());
11000
11001 params.push("alt", "json");
11002 let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups:copy";
11003 if self._scopes.is_empty() {
11004 self._scopes
11005 .insert(Scope::CloudPlatform.as_ref().to_string());
11006 }
11007
11008 #[allow(clippy::single_element_loop)]
11009 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11010 url = params.uri_replacement(url, param_name, find_this, true);
11011 }
11012 {
11013 let to_remove = ["parent"];
11014 params.remove_params(&to_remove);
11015 }
11016
11017 let url = params.parse_with_url(&url);
11018
11019 let mut json_mime_type = mime::APPLICATION_JSON;
11020 let mut request_value_reader = {
11021 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11022 common::remove_json_null_values(&mut value);
11023 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11024 serde_json::to_writer(&mut dst, &value).unwrap();
11025 dst
11026 };
11027 let request_size = request_value_reader
11028 .seek(std::io::SeekFrom::End(0))
11029 .unwrap();
11030 request_value_reader
11031 .seek(std::io::SeekFrom::Start(0))
11032 .unwrap();
11033
11034 loop {
11035 let token = match self
11036 .hub
11037 .auth
11038 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11039 .await
11040 {
11041 Ok(token) => token,
11042 Err(e) => match dlg.token(e) {
11043 Ok(token) => token,
11044 Err(e) => {
11045 dlg.finished(false);
11046 return Err(common::Error::MissingToken(e));
11047 }
11048 },
11049 };
11050 request_value_reader
11051 .seek(std::io::SeekFrom::Start(0))
11052 .unwrap();
11053 let mut req_result = {
11054 let client = &self.hub.client;
11055 dlg.pre_request();
11056 let mut req_builder = hyper::Request::builder()
11057 .method(hyper::Method::POST)
11058 .uri(url.as_str())
11059 .header(USER_AGENT, self.hub._user_agent.clone());
11060
11061 if let Some(token) = token.as_ref() {
11062 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11063 }
11064
11065 let request = req_builder
11066 .header(CONTENT_TYPE, json_mime_type.to_string())
11067 .header(CONTENT_LENGTH, request_size as u64)
11068 .body(common::to_body(
11069 request_value_reader.get_ref().clone().into(),
11070 ));
11071
11072 client.request(request.unwrap()).await
11073 };
11074
11075 match req_result {
11076 Err(err) => {
11077 if let common::Retry::After(d) = dlg.http_error(&err) {
11078 sleep(d).await;
11079 continue;
11080 }
11081 dlg.finished(false);
11082 return Err(common::Error::HttpError(err));
11083 }
11084 Ok(res) => {
11085 let (mut parts, body) = res.into_parts();
11086 let mut body = common::Body::new(body);
11087 if !parts.status.is_success() {
11088 let bytes = common::to_bytes(body).await.unwrap_or_default();
11089 let error = serde_json::from_str(&common::to_string(&bytes));
11090 let response = common::to_response(parts, bytes.into());
11091
11092 if let common::Retry::After(d) =
11093 dlg.http_failure(&response, error.as_ref().ok())
11094 {
11095 sleep(d).await;
11096 continue;
11097 }
11098
11099 dlg.finished(false);
11100
11101 return Err(match error {
11102 Ok(value) => common::Error::BadRequest(value),
11103 _ => common::Error::Failure(response),
11104 });
11105 }
11106 let response = {
11107 let bytes = common::to_bytes(body).await.unwrap_or_default();
11108 let encoded = common::to_string(&bytes);
11109 match serde_json::from_str(&encoded) {
11110 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11111 Err(error) => {
11112 dlg.response_json_decode_error(&encoded, &error);
11113 return Err(common::Error::JsonDecodeError(
11114 encoded.to_string(),
11115 error,
11116 ));
11117 }
11118 }
11119 };
11120
11121 dlg.finished(true);
11122 return Ok(response);
11123 }
11124 }
11125 }
11126 }
11127
11128 ///
11129 /// Sets the *request* property to the given value.
11130 ///
11131 /// Even though the property as already been set when instantiating this call,
11132 /// we provide this method for API completeness.
11133 pub fn request(mut self, new_value: CopyBackupRequest) -> ProjectInstanceBackupCopyCall<'a, C> {
11134 self._request = new_value;
11135 self
11136 }
11137 /// Required. The name of the destination instance that will contain the backup copy. Values are of the form: `projects//instances/`.
11138 ///
11139 /// Sets the *parent* path property to the given value.
11140 ///
11141 /// Even though the property as already been set when instantiating this call,
11142 /// we provide this method for API completeness.
11143 pub fn parent(mut self, new_value: &str) -> ProjectInstanceBackupCopyCall<'a, C> {
11144 self._parent = new_value.to_string();
11145 self
11146 }
11147 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11148 /// while executing the actual API request.
11149 ///
11150 /// ````text
11151 /// It should be used to handle progress information, and to implement a certain level of resilience.
11152 /// ````
11153 ///
11154 /// Sets the *delegate* property to the given value.
11155 pub fn delegate(
11156 mut self,
11157 new_value: &'a mut dyn common::Delegate,
11158 ) -> ProjectInstanceBackupCopyCall<'a, C> {
11159 self._delegate = Some(new_value);
11160 self
11161 }
11162
11163 /// Set any additional parameter of the query string used in the request.
11164 /// It should be used to set parameters which are not yet available through their own
11165 /// setters.
11166 ///
11167 /// Please note that this method must not be used to set any of the known parameters
11168 /// which have their own setter method. If done anyway, the request will fail.
11169 ///
11170 /// # Additional Parameters
11171 ///
11172 /// * *$.xgafv* (query-string) - V1 error format.
11173 /// * *access_token* (query-string) - OAuth access token.
11174 /// * *alt* (query-string) - Data format for response.
11175 /// * *callback* (query-string) - JSONP
11176 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11177 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11178 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11179 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11180 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11181 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11182 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11183 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupCopyCall<'a, C>
11184 where
11185 T: AsRef<str>,
11186 {
11187 self._additional_params
11188 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11189 self
11190 }
11191
11192 /// Identifies the authorization scope for the method you are building.
11193 ///
11194 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11195 /// [`Scope::CloudPlatform`].
11196 ///
11197 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11198 /// tokens for more than one scope.
11199 ///
11200 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11201 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11202 /// sufficient, a read-write scope will do as well.
11203 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupCopyCall<'a, C>
11204 where
11205 St: AsRef<str>,
11206 {
11207 self._scopes.insert(String::from(scope.as_ref()));
11208 self
11209 }
11210 /// Identifies the authorization scope(s) for the method you are building.
11211 ///
11212 /// See [`Self::add_scope()`] for details.
11213 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupCopyCall<'a, C>
11214 where
11215 I: IntoIterator<Item = St>,
11216 St: AsRef<str>,
11217 {
11218 self._scopes
11219 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11220 self
11221 }
11222
11223 /// Removes all scopes, and no default scope will be used either.
11224 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11225 /// for details).
11226 pub fn clear_scopes(mut self) -> ProjectInstanceBackupCopyCall<'a, C> {
11227 self._scopes.clear();
11228 self
11229 }
11230}
11231
11232/// 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.
11233///
11234/// A builder for the *instances.backups.create* method supported by a *project* resource.
11235/// It is not used directly, but through a [`ProjectMethods`] instance.
11236///
11237/// # Example
11238///
11239/// Instantiate a resource method builder
11240///
11241/// ```test_harness,no_run
11242/// # extern crate hyper;
11243/// # extern crate hyper_rustls;
11244/// # extern crate google_spanner1 as spanner1;
11245/// use spanner1::api::Backup;
11246/// # async fn dox() {
11247/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11248///
11249/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11250/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11251/// # secret,
11252/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11253/// # ).build().await.unwrap();
11254///
11255/// # let client = hyper_util::client::legacy::Client::builder(
11256/// # hyper_util::rt::TokioExecutor::new()
11257/// # )
11258/// # .build(
11259/// # hyper_rustls::HttpsConnectorBuilder::new()
11260/// # .with_native_roots()
11261/// # .unwrap()
11262/// # .https_or_http()
11263/// # .enable_http1()
11264/// # .build()
11265/// # );
11266/// # let mut hub = Spanner::new(client, auth);
11267/// // As the method needs a request, you would usually fill it with the desired information
11268/// // into the respective structure. Some of the parts shown here might not be applicable !
11269/// // Values shown here are possibly random and not representative !
11270/// let mut req = Backup::default();
11271///
11272/// // You can configure optional parameters by calling the respective setters at will, and
11273/// // execute the final call using `doit()`.
11274/// // Values shown here are possibly random and not representative !
11275/// let result = hub.projects().instances_backups_create(req, "parent")
11276/// .add_encryption_config_kms_key_names("amet.")
11277/// .encryption_config_kms_key_name("consetetur")
11278/// .encryption_config_encryption_type("diam")
11279/// .backup_id("dolor")
11280/// .doit().await;
11281/// # }
11282/// ```
11283pub struct ProjectInstanceBackupCreateCall<'a, C>
11284where
11285 C: 'a,
11286{
11287 hub: &'a Spanner<C>,
11288 _request: Backup,
11289 _parent: String,
11290 _encryption_config_kms_key_names: Vec<String>,
11291 _encryption_config_kms_key_name: Option<String>,
11292 _encryption_config_encryption_type: Option<String>,
11293 _backup_id: Option<String>,
11294 _delegate: Option<&'a mut dyn common::Delegate>,
11295 _additional_params: HashMap<String, String>,
11296 _scopes: BTreeSet<String>,
11297}
11298
11299impl<'a, C> common::CallBuilder for ProjectInstanceBackupCreateCall<'a, C> {}
11300
11301impl<'a, C> ProjectInstanceBackupCreateCall<'a, C>
11302where
11303 C: common::Connector,
11304{
11305 /// Perform the operation you have build so far.
11306 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11307 use std::borrow::Cow;
11308 use std::io::{Read, Seek};
11309
11310 use common::{url::Params, ToParts};
11311 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11312
11313 let mut dd = common::DefaultDelegate;
11314 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11315 dlg.begin(common::MethodInfo {
11316 id: "spanner.projects.instances.backups.create",
11317 http_method: hyper::Method::POST,
11318 });
11319
11320 for &field in [
11321 "alt",
11322 "parent",
11323 "encryptionConfig.kmsKeyNames",
11324 "encryptionConfig.kmsKeyName",
11325 "encryptionConfig.encryptionType",
11326 "backupId",
11327 ]
11328 .iter()
11329 {
11330 if self._additional_params.contains_key(field) {
11331 dlg.finished(false);
11332 return Err(common::Error::FieldClash(field));
11333 }
11334 }
11335
11336 let mut params = Params::with_capacity(8 + self._additional_params.len());
11337 params.push("parent", self._parent);
11338 if !self._encryption_config_kms_key_names.is_empty() {
11339 for f in self._encryption_config_kms_key_names.iter() {
11340 params.push("encryptionConfig.kmsKeyNames", f);
11341 }
11342 }
11343 if let Some(value) = self._encryption_config_kms_key_name.as_ref() {
11344 params.push("encryptionConfig.kmsKeyName", value);
11345 }
11346 if let Some(value) = self._encryption_config_encryption_type.as_ref() {
11347 params.push("encryptionConfig.encryptionType", value);
11348 }
11349 if let Some(value) = self._backup_id.as_ref() {
11350 params.push("backupId", value);
11351 }
11352
11353 params.extend(self._additional_params.iter());
11354
11355 params.push("alt", "json");
11356 let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
11357 if self._scopes.is_empty() {
11358 self._scopes
11359 .insert(Scope::CloudPlatform.as_ref().to_string());
11360 }
11361
11362 #[allow(clippy::single_element_loop)]
11363 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11364 url = params.uri_replacement(url, param_name, find_this, true);
11365 }
11366 {
11367 let to_remove = ["parent"];
11368 params.remove_params(&to_remove);
11369 }
11370
11371 let url = params.parse_with_url(&url);
11372
11373 let mut json_mime_type = mime::APPLICATION_JSON;
11374 let mut request_value_reader = {
11375 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11376 common::remove_json_null_values(&mut value);
11377 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11378 serde_json::to_writer(&mut dst, &value).unwrap();
11379 dst
11380 };
11381 let request_size = request_value_reader
11382 .seek(std::io::SeekFrom::End(0))
11383 .unwrap();
11384 request_value_reader
11385 .seek(std::io::SeekFrom::Start(0))
11386 .unwrap();
11387
11388 loop {
11389 let token = match self
11390 .hub
11391 .auth
11392 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11393 .await
11394 {
11395 Ok(token) => token,
11396 Err(e) => match dlg.token(e) {
11397 Ok(token) => token,
11398 Err(e) => {
11399 dlg.finished(false);
11400 return Err(common::Error::MissingToken(e));
11401 }
11402 },
11403 };
11404 request_value_reader
11405 .seek(std::io::SeekFrom::Start(0))
11406 .unwrap();
11407 let mut req_result = {
11408 let client = &self.hub.client;
11409 dlg.pre_request();
11410 let mut req_builder = hyper::Request::builder()
11411 .method(hyper::Method::POST)
11412 .uri(url.as_str())
11413 .header(USER_AGENT, self.hub._user_agent.clone());
11414
11415 if let Some(token) = token.as_ref() {
11416 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11417 }
11418
11419 let request = req_builder
11420 .header(CONTENT_TYPE, json_mime_type.to_string())
11421 .header(CONTENT_LENGTH, request_size as u64)
11422 .body(common::to_body(
11423 request_value_reader.get_ref().clone().into(),
11424 ));
11425
11426 client.request(request.unwrap()).await
11427 };
11428
11429 match req_result {
11430 Err(err) => {
11431 if let common::Retry::After(d) = dlg.http_error(&err) {
11432 sleep(d).await;
11433 continue;
11434 }
11435 dlg.finished(false);
11436 return Err(common::Error::HttpError(err));
11437 }
11438 Ok(res) => {
11439 let (mut parts, body) = res.into_parts();
11440 let mut body = common::Body::new(body);
11441 if !parts.status.is_success() {
11442 let bytes = common::to_bytes(body).await.unwrap_or_default();
11443 let error = serde_json::from_str(&common::to_string(&bytes));
11444 let response = common::to_response(parts, bytes.into());
11445
11446 if let common::Retry::After(d) =
11447 dlg.http_failure(&response, error.as_ref().ok())
11448 {
11449 sleep(d).await;
11450 continue;
11451 }
11452
11453 dlg.finished(false);
11454
11455 return Err(match error {
11456 Ok(value) => common::Error::BadRequest(value),
11457 _ => common::Error::Failure(response),
11458 });
11459 }
11460 let response = {
11461 let bytes = common::to_bytes(body).await.unwrap_or_default();
11462 let encoded = common::to_string(&bytes);
11463 match serde_json::from_str(&encoded) {
11464 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11465 Err(error) => {
11466 dlg.response_json_decode_error(&encoded, &error);
11467 return Err(common::Error::JsonDecodeError(
11468 encoded.to_string(),
11469 error,
11470 ));
11471 }
11472 }
11473 };
11474
11475 dlg.finished(true);
11476 return Ok(response);
11477 }
11478 }
11479 }
11480 }
11481
11482 ///
11483 /// Sets the *request* property to the given value.
11484 ///
11485 /// Even though the property as already been set when instantiating this call,
11486 /// we provide this method for API completeness.
11487 pub fn request(mut self, new_value: Backup) -> ProjectInstanceBackupCreateCall<'a, C> {
11488 self._request = new_value;
11489 self
11490 }
11491 /// Required. The name of the instance in which the backup will be created. This must be the same instance that contains the database the backup will be created from. The backup will be stored in the location(s) specified in the instance configuration of this instance. Values are of the form `projects//instances/`.
11492 ///
11493 /// Sets the *parent* path property to the given value.
11494 ///
11495 /// Even though the property as already been set when instantiating this call,
11496 /// we provide this method for API completeness.
11497 pub fn parent(mut self, new_value: &str) -> ProjectInstanceBackupCreateCall<'a, C> {
11498 self._parent = new_value.to_string();
11499 self
11500 }
11501 /// 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 single region instance configs, specify a single regional location KMS key. * For multi-regional instance configs of type GOOGLE_MANAGED, either specify a multi-regional location KMS key or multiple regional location KMS keys that cover all regions in the instance config. * For an instance config of type USER_MANAGED, please specify only regional location KMS keys to cover each region in the instance config. Multi-regional location KMS keys are not supported for USER_MANAGED instance configs.
11502 ///
11503 /// Append the given value to the *encryption config.kms key names* query property.
11504 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11505 pub fn add_encryption_config_kms_key_names(
11506 mut self,
11507 new_value: &str,
11508 ) -> ProjectInstanceBackupCreateCall<'a, C> {
11509 self._encryption_config_kms_key_names
11510 .push(new_value.to_string());
11511 self
11512 }
11513 /// Optional. The Cloud KMS key that will be used to protect the backup. This field should be set only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
11514 ///
11515 /// Sets the *encryption config.kms key name* query property to the given value.
11516 pub fn encryption_config_kms_key_name(
11517 mut self,
11518 new_value: &str,
11519 ) -> ProjectInstanceBackupCreateCall<'a, C> {
11520 self._encryption_config_kms_key_name = Some(new_value.to_string());
11521 self
11522 }
11523 /// Required. The encryption type of the backup.
11524 ///
11525 /// Sets the *encryption config.encryption type* query property to the given value.
11526 pub fn encryption_config_encryption_type(
11527 mut self,
11528 new_value: &str,
11529 ) -> ProjectInstanceBackupCreateCall<'a, C> {
11530 self._encryption_config_encryption_type = Some(new_value.to_string());
11531 self
11532 }
11533 /// 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/`.
11534 ///
11535 /// Sets the *backup id* query property to the given value.
11536 pub fn backup_id(mut self, new_value: &str) -> ProjectInstanceBackupCreateCall<'a, C> {
11537 self._backup_id = Some(new_value.to_string());
11538 self
11539 }
11540 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11541 /// while executing the actual API request.
11542 ///
11543 /// ````text
11544 /// It should be used to handle progress information, and to implement a certain level of resilience.
11545 /// ````
11546 ///
11547 /// Sets the *delegate* property to the given value.
11548 pub fn delegate(
11549 mut self,
11550 new_value: &'a mut dyn common::Delegate,
11551 ) -> ProjectInstanceBackupCreateCall<'a, C> {
11552 self._delegate = Some(new_value);
11553 self
11554 }
11555
11556 /// Set any additional parameter of the query string used in the request.
11557 /// It should be used to set parameters which are not yet available through their own
11558 /// setters.
11559 ///
11560 /// Please note that this method must not be used to set any of the known parameters
11561 /// which have their own setter method. If done anyway, the request will fail.
11562 ///
11563 /// # Additional Parameters
11564 ///
11565 /// * *$.xgafv* (query-string) - V1 error format.
11566 /// * *access_token* (query-string) - OAuth access token.
11567 /// * *alt* (query-string) - Data format for response.
11568 /// * *callback* (query-string) - JSONP
11569 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11570 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11571 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11572 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11573 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11574 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11575 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11576 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupCreateCall<'a, C>
11577 where
11578 T: AsRef<str>,
11579 {
11580 self._additional_params
11581 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11582 self
11583 }
11584
11585 /// Identifies the authorization scope for the method you are building.
11586 ///
11587 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11588 /// [`Scope::CloudPlatform`].
11589 ///
11590 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11591 /// tokens for more than one scope.
11592 ///
11593 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11594 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11595 /// sufficient, a read-write scope will do as well.
11596 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupCreateCall<'a, C>
11597 where
11598 St: AsRef<str>,
11599 {
11600 self._scopes.insert(String::from(scope.as_ref()));
11601 self
11602 }
11603 /// Identifies the authorization scope(s) for the method you are building.
11604 ///
11605 /// See [`Self::add_scope()`] for details.
11606 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupCreateCall<'a, C>
11607 where
11608 I: IntoIterator<Item = St>,
11609 St: AsRef<str>,
11610 {
11611 self._scopes
11612 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11613 self
11614 }
11615
11616 /// Removes all scopes, and no default scope will be used either.
11617 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11618 /// for details).
11619 pub fn clear_scopes(mut self) -> ProjectInstanceBackupCreateCall<'a, C> {
11620 self._scopes.clear();
11621 self
11622 }
11623}
11624
11625/// Deletes a pending or completed Backup.
11626///
11627/// A builder for the *instances.backups.delete* method supported by a *project* resource.
11628/// It is not used directly, but through a [`ProjectMethods`] instance.
11629///
11630/// # Example
11631///
11632/// Instantiate a resource method builder
11633///
11634/// ```test_harness,no_run
11635/// # extern crate hyper;
11636/// # extern crate hyper_rustls;
11637/// # extern crate google_spanner1 as spanner1;
11638/// # async fn dox() {
11639/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11640///
11641/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11642/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11643/// # secret,
11644/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11645/// # ).build().await.unwrap();
11646///
11647/// # let client = hyper_util::client::legacy::Client::builder(
11648/// # hyper_util::rt::TokioExecutor::new()
11649/// # )
11650/// # .build(
11651/// # hyper_rustls::HttpsConnectorBuilder::new()
11652/// # .with_native_roots()
11653/// # .unwrap()
11654/// # .https_or_http()
11655/// # .enable_http1()
11656/// # .build()
11657/// # );
11658/// # let mut hub = Spanner::new(client, auth);
11659/// // You can configure optional parameters by calling the respective setters at will, and
11660/// // execute the final call using `doit()`.
11661/// // Values shown here are possibly random and not representative !
11662/// let result = hub.projects().instances_backups_delete("name")
11663/// .doit().await;
11664/// # }
11665/// ```
11666pub struct ProjectInstanceBackupDeleteCall<'a, C>
11667where
11668 C: 'a,
11669{
11670 hub: &'a Spanner<C>,
11671 _name: String,
11672 _delegate: Option<&'a mut dyn common::Delegate>,
11673 _additional_params: HashMap<String, String>,
11674 _scopes: BTreeSet<String>,
11675}
11676
11677impl<'a, C> common::CallBuilder for ProjectInstanceBackupDeleteCall<'a, C> {}
11678
11679impl<'a, C> ProjectInstanceBackupDeleteCall<'a, C>
11680where
11681 C: common::Connector,
11682{
11683 /// Perform the operation you have build so far.
11684 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11685 use std::borrow::Cow;
11686 use std::io::{Read, Seek};
11687
11688 use common::{url::Params, ToParts};
11689 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11690
11691 let mut dd = common::DefaultDelegate;
11692 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11693 dlg.begin(common::MethodInfo {
11694 id: "spanner.projects.instances.backups.delete",
11695 http_method: hyper::Method::DELETE,
11696 });
11697
11698 for &field in ["alt", "name"].iter() {
11699 if self._additional_params.contains_key(field) {
11700 dlg.finished(false);
11701 return Err(common::Error::FieldClash(field));
11702 }
11703 }
11704
11705 let mut params = Params::with_capacity(3 + self._additional_params.len());
11706 params.push("name", self._name);
11707
11708 params.extend(self._additional_params.iter());
11709
11710 params.push("alt", "json");
11711 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11712 if self._scopes.is_empty() {
11713 self._scopes
11714 .insert(Scope::CloudPlatform.as_ref().to_string());
11715 }
11716
11717 #[allow(clippy::single_element_loop)]
11718 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11719 url = params.uri_replacement(url, param_name, find_this, true);
11720 }
11721 {
11722 let to_remove = ["name"];
11723 params.remove_params(&to_remove);
11724 }
11725
11726 let url = params.parse_with_url(&url);
11727
11728 loop {
11729 let token = match self
11730 .hub
11731 .auth
11732 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11733 .await
11734 {
11735 Ok(token) => token,
11736 Err(e) => match dlg.token(e) {
11737 Ok(token) => token,
11738 Err(e) => {
11739 dlg.finished(false);
11740 return Err(common::Error::MissingToken(e));
11741 }
11742 },
11743 };
11744 let mut req_result = {
11745 let client = &self.hub.client;
11746 dlg.pre_request();
11747 let mut req_builder = hyper::Request::builder()
11748 .method(hyper::Method::DELETE)
11749 .uri(url.as_str())
11750 .header(USER_AGENT, self.hub._user_agent.clone());
11751
11752 if let Some(token) = token.as_ref() {
11753 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11754 }
11755
11756 let request = req_builder
11757 .header(CONTENT_LENGTH, 0_u64)
11758 .body(common::to_body::<String>(None));
11759
11760 client.request(request.unwrap()).await
11761 };
11762
11763 match req_result {
11764 Err(err) => {
11765 if let common::Retry::After(d) = dlg.http_error(&err) {
11766 sleep(d).await;
11767 continue;
11768 }
11769 dlg.finished(false);
11770 return Err(common::Error::HttpError(err));
11771 }
11772 Ok(res) => {
11773 let (mut parts, body) = res.into_parts();
11774 let mut body = common::Body::new(body);
11775 if !parts.status.is_success() {
11776 let bytes = common::to_bytes(body).await.unwrap_or_default();
11777 let error = serde_json::from_str(&common::to_string(&bytes));
11778 let response = common::to_response(parts, bytes.into());
11779
11780 if let common::Retry::After(d) =
11781 dlg.http_failure(&response, error.as_ref().ok())
11782 {
11783 sleep(d).await;
11784 continue;
11785 }
11786
11787 dlg.finished(false);
11788
11789 return Err(match error {
11790 Ok(value) => common::Error::BadRequest(value),
11791 _ => common::Error::Failure(response),
11792 });
11793 }
11794 let response = {
11795 let bytes = common::to_bytes(body).await.unwrap_or_default();
11796 let encoded = common::to_string(&bytes);
11797 match serde_json::from_str(&encoded) {
11798 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11799 Err(error) => {
11800 dlg.response_json_decode_error(&encoded, &error);
11801 return Err(common::Error::JsonDecodeError(
11802 encoded.to_string(),
11803 error,
11804 ));
11805 }
11806 }
11807 };
11808
11809 dlg.finished(true);
11810 return Ok(response);
11811 }
11812 }
11813 }
11814 }
11815
11816 /// Required. Name of the backup to delete. Values are of the form `projects//instances//backups/`.
11817 ///
11818 /// Sets the *name* path property to the given value.
11819 ///
11820 /// Even though the property as already been set when instantiating this call,
11821 /// we provide this method for API completeness.
11822 pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupDeleteCall<'a, C> {
11823 self._name = new_value.to_string();
11824 self
11825 }
11826 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11827 /// while executing the actual API request.
11828 ///
11829 /// ````text
11830 /// It should be used to handle progress information, and to implement a certain level of resilience.
11831 /// ````
11832 ///
11833 /// Sets the *delegate* property to the given value.
11834 pub fn delegate(
11835 mut self,
11836 new_value: &'a mut dyn common::Delegate,
11837 ) -> ProjectInstanceBackupDeleteCall<'a, C> {
11838 self._delegate = Some(new_value);
11839 self
11840 }
11841
11842 /// Set any additional parameter of the query string used in the request.
11843 /// It should be used to set parameters which are not yet available through their own
11844 /// setters.
11845 ///
11846 /// Please note that this method must not be used to set any of the known parameters
11847 /// which have their own setter method. If done anyway, the request will fail.
11848 ///
11849 /// # Additional Parameters
11850 ///
11851 /// * *$.xgafv* (query-string) - V1 error format.
11852 /// * *access_token* (query-string) - OAuth access token.
11853 /// * *alt* (query-string) - Data format for response.
11854 /// * *callback* (query-string) - JSONP
11855 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11856 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11857 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11858 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11859 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11860 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11861 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11862 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupDeleteCall<'a, C>
11863 where
11864 T: AsRef<str>,
11865 {
11866 self._additional_params
11867 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11868 self
11869 }
11870
11871 /// Identifies the authorization scope for the method you are building.
11872 ///
11873 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11874 /// [`Scope::CloudPlatform`].
11875 ///
11876 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11877 /// tokens for more than one scope.
11878 ///
11879 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11880 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11881 /// sufficient, a read-write scope will do as well.
11882 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupDeleteCall<'a, C>
11883 where
11884 St: AsRef<str>,
11885 {
11886 self._scopes.insert(String::from(scope.as_ref()));
11887 self
11888 }
11889 /// Identifies the authorization scope(s) for the method you are building.
11890 ///
11891 /// See [`Self::add_scope()`] for details.
11892 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupDeleteCall<'a, C>
11893 where
11894 I: IntoIterator<Item = St>,
11895 St: AsRef<str>,
11896 {
11897 self._scopes
11898 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11899 self
11900 }
11901
11902 /// Removes all scopes, and no default scope will be used either.
11903 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11904 /// for details).
11905 pub fn clear_scopes(mut self) -> ProjectInstanceBackupDeleteCall<'a, C> {
11906 self._scopes.clear();
11907 self
11908 }
11909}
11910
11911/// Gets metadata on a pending or completed Backup.
11912///
11913/// A builder for the *instances.backups.get* method supported by a *project* resource.
11914/// It is not used directly, but through a [`ProjectMethods`] instance.
11915///
11916/// # Example
11917///
11918/// Instantiate a resource method builder
11919///
11920/// ```test_harness,no_run
11921/// # extern crate hyper;
11922/// # extern crate hyper_rustls;
11923/// # extern crate google_spanner1 as spanner1;
11924/// # async fn dox() {
11925/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11926///
11927/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11928/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11929/// # secret,
11930/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11931/// # ).build().await.unwrap();
11932///
11933/// # let client = hyper_util::client::legacy::Client::builder(
11934/// # hyper_util::rt::TokioExecutor::new()
11935/// # )
11936/// # .build(
11937/// # hyper_rustls::HttpsConnectorBuilder::new()
11938/// # .with_native_roots()
11939/// # .unwrap()
11940/// # .https_or_http()
11941/// # .enable_http1()
11942/// # .build()
11943/// # );
11944/// # let mut hub = Spanner::new(client, auth);
11945/// // You can configure optional parameters by calling the respective setters at will, and
11946/// // execute the final call using `doit()`.
11947/// // Values shown here are possibly random and not representative !
11948/// let result = hub.projects().instances_backups_get("name")
11949/// .doit().await;
11950/// # }
11951/// ```
11952pub struct ProjectInstanceBackupGetCall<'a, C>
11953where
11954 C: 'a,
11955{
11956 hub: &'a Spanner<C>,
11957 _name: String,
11958 _delegate: Option<&'a mut dyn common::Delegate>,
11959 _additional_params: HashMap<String, String>,
11960 _scopes: BTreeSet<String>,
11961}
11962
11963impl<'a, C> common::CallBuilder for ProjectInstanceBackupGetCall<'a, C> {}
11964
11965impl<'a, C> ProjectInstanceBackupGetCall<'a, C>
11966where
11967 C: common::Connector,
11968{
11969 /// Perform the operation you have build so far.
11970 pub async fn doit(mut self) -> common::Result<(common::Response, Backup)> {
11971 use std::borrow::Cow;
11972 use std::io::{Read, Seek};
11973
11974 use common::{url::Params, ToParts};
11975 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11976
11977 let mut dd = common::DefaultDelegate;
11978 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11979 dlg.begin(common::MethodInfo {
11980 id: "spanner.projects.instances.backups.get",
11981 http_method: hyper::Method::GET,
11982 });
11983
11984 for &field in ["alt", "name"].iter() {
11985 if self._additional_params.contains_key(field) {
11986 dlg.finished(false);
11987 return Err(common::Error::FieldClash(field));
11988 }
11989 }
11990
11991 let mut params = Params::with_capacity(3 + self._additional_params.len());
11992 params.push("name", self._name);
11993
11994 params.extend(self._additional_params.iter());
11995
11996 params.push("alt", "json");
11997 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11998 if self._scopes.is_empty() {
11999 self._scopes
12000 .insert(Scope::CloudPlatform.as_ref().to_string());
12001 }
12002
12003 #[allow(clippy::single_element_loop)]
12004 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12005 url = params.uri_replacement(url, param_name, find_this, true);
12006 }
12007 {
12008 let to_remove = ["name"];
12009 params.remove_params(&to_remove);
12010 }
12011
12012 let url = params.parse_with_url(&url);
12013
12014 loop {
12015 let token = match self
12016 .hub
12017 .auth
12018 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12019 .await
12020 {
12021 Ok(token) => token,
12022 Err(e) => match dlg.token(e) {
12023 Ok(token) => token,
12024 Err(e) => {
12025 dlg.finished(false);
12026 return Err(common::Error::MissingToken(e));
12027 }
12028 },
12029 };
12030 let mut req_result = {
12031 let client = &self.hub.client;
12032 dlg.pre_request();
12033 let mut req_builder = hyper::Request::builder()
12034 .method(hyper::Method::GET)
12035 .uri(url.as_str())
12036 .header(USER_AGENT, self.hub._user_agent.clone());
12037
12038 if let Some(token) = token.as_ref() {
12039 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12040 }
12041
12042 let request = req_builder
12043 .header(CONTENT_LENGTH, 0_u64)
12044 .body(common::to_body::<String>(None));
12045
12046 client.request(request.unwrap()).await
12047 };
12048
12049 match req_result {
12050 Err(err) => {
12051 if let common::Retry::After(d) = dlg.http_error(&err) {
12052 sleep(d).await;
12053 continue;
12054 }
12055 dlg.finished(false);
12056 return Err(common::Error::HttpError(err));
12057 }
12058 Ok(res) => {
12059 let (mut parts, body) = res.into_parts();
12060 let mut body = common::Body::new(body);
12061 if !parts.status.is_success() {
12062 let bytes = common::to_bytes(body).await.unwrap_or_default();
12063 let error = serde_json::from_str(&common::to_string(&bytes));
12064 let response = common::to_response(parts, bytes.into());
12065
12066 if let common::Retry::After(d) =
12067 dlg.http_failure(&response, error.as_ref().ok())
12068 {
12069 sleep(d).await;
12070 continue;
12071 }
12072
12073 dlg.finished(false);
12074
12075 return Err(match error {
12076 Ok(value) => common::Error::BadRequest(value),
12077 _ => common::Error::Failure(response),
12078 });
12079 }
12080 let response = {
12081 let bytes = common::to_bytes(body).await.unwrap_or_default();
12082 let encoded = common::to_string(&bytes);
12083 match serde_json::from_str(&encoded) {
12084 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12085 Err(error) => {
12086 dlg.response_json_decode_error(&encoded, &error);
12087 return Err(common::Error::JsonDecodeError(
12088 encoded.to_string(),
12089 error,
12090 ));
12091 }
12092 }
12093 };
12094
12095 dlg.finished(true);
12096 return Ok(response);
12097 }
12098 }
12099 }
12100 }
12101
12102 /// Required. Name of the backup. Values are of the form `projects//instances//backups/`.
12103 ///
12104 /// Sets the *name* path property to the given value.
12105 ///
12106 /// Even though the property as already been set when instantiating this call,
12107 /// we provide this method for API completeness.
12108 pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupGetCall<'a, C> {
12109 self._name = new_value.to_string();
12110 self
12111 }
12112 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12113 /// while executing the actual API request.
12114 ///
12115 /// ````text
12116 /// It should be used to handle progress information, and to implement a certain level of resilience.
12117 /// ````
12118 ///
12119 /// Sets the *delegate* property to the given value.
12120 pub fn delegate(
12121 mut self,
12122 new_value: &'a mut dyn common::Delegate,
12123 ) -> ProjectInstanceBackupGetCall<'a, C> {
12124 self._delegate = Some(new_value);
12125 self
12126 }
12127
12128 /// Set any additional parameter of the query string used in the request.
12129 /// It should be used to set parameters which are not yet available through their own
12130 /// setters.
12131 ///
12132 /// Please note that this method must not be used to set any of the known parameters
12133 /// which have their own setter method. If done anyway, the request will fail.
12134 ///
12135 /// # Additional Parameters
12136 ///
12137 /// * *$.xgafv* (query-string) - V1 error format.
12138 /// * *access_token* (query-string) - OAuth access token.
12139 /// * *alt* (query-string) - Data format for response.
12140 /// * *callback* (query-string) - JSONP
12141 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12142 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12143 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12144 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12145 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12146 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12147 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12148 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupGetCall<'a, C>
12149 where
12150 T: AsRef<str>,
12151 {
12152 self._additional_params
12153 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12154 self
12155 }
12156
12157 /// Identifies the authorization scope for the method you are building.
12158 ///
12159 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12160 /// [`Scope::CloudPlatform`].
12161 ///
12162 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12163 /// tokens for more than one scope.
12164 ///
12165 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12166 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12167 /// sufficient, a read-write scope will do as well.
12168 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupGetCall<'a, C>
12169 where
12170 St: AsRef<str>,
12171 {
12172 self._scopes.insert(String::from(scope.as_ref()));
12173 self
12174 }
12175 /// Identifies the authorization scope(s) for the method you are building.
12176 ///
12177 /// See [`Self::add_scope()`] for details.
12178 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupGetCall<'a, C>
12179 where
12180 I: IntoIterator<Item = St>,
12181 St: AsRef<str>,
12182 {
12183 self._scopes
12184 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12185 self
12186 }
12187
12188 /// Removes all scopes, and no default scope will be used either.
12189 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12190 /// for details).
12191 pub fn clear_scopes(mut self) -> ProjectInstanceBackupGetCall<'a, C> {
12192 self._scopes.clear();
12193 self
12194 }
12195}
12196
12197/// 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.
12198///
12199/// A builder for the *instances.backups.getIamPolicy* method supported by a *project* resource.
12200/// It is not used directly, but through a [`ProjectMethods`] instance.
12201///
12202/// # Example
12203///
12204/// Instantiate a resource method builder
12205///
12206/// ```test_harness,no_run
12207/// # extern crate hyper;
12208/// # extern crate hyper_rustls;
12209/// # extern crate google_spanner1 as spanner1;
12210/// use spanner1::api::GetIamPolicyRequest;
12211/// # async fn dox() {
12212/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12213///
12214/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12215/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12216/// # secret,
12217/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12218/// # ).build().await.unwrap();
12219///
12220/// # let client = hyper_util::client::legacy::Client::builder(
12221/// # hyper_util::rt::TokioExecutor::new()
12222/// # )
12223/// # .build(
12224/// # hyper_rustls::HttpsConnectorBuilder::new()
12225/// # .with_native_roots()
12226/// # .unwrap()
12227/// # .https_or_http()
12228/// # .enable_http1()
12229/// # .build()
12230/// # );
12231/// # let mut hub = Spanner::new(client, auth);
12232/// // As the method needs a request, you would usually fill it with the desired information
12233/// // into the respective structure. Some of the parts shown here might not be applicable !
12234/// // Values shown here are possibly random and not representative !
12235/// let mut req = GetIamPolicyRequest::default();
12236///
12237/// // You can configure optional parameters by calling the respective setters at will, and
12238/// // execute the final call using `doit()`.
12239/// // Values shown here are possibly random and not representative !
12240/// let result = hub.projects().instances_backups_get_iam_policy(req, "resource")
12241/// .doit().await;
12242/// # }
12243/// ```
12244pub struct ProjectInstanceBackupGetIamPolicyCall<'a, C>
12245where
12246 C: 'a,
12247{
12248 hub: &'a Spanner<C>,
12249 _request: GetIamPolicyRequest,
12250 _resource: String,
12251 _delegate: Option<&'a mut dyn common::Delegate>,
12252 _additional_params: HashMap<String, String>,
12253 _scopes: BTreeSet<String>,
12254}
12255
12256impl<'a, C> common::CallBuilder for ProjectInstanceBackupGetIamPolicyCall<'a, C> {}
12257
12258impl<'a, C> ProjectInstanceBackupGetIamPolicyCall<'a, C>
12259where
12260 C: common::Connector,
12261{
12262 /// Perform the operation you have build so far.
12263 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
12264 use std::borrow::Cow;
12265 use std::io::{Read, Seek};
12266
12267 use common::{url::Params, ToParts};
12268 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12269
12270 let mut dd = common::DefaultDelegate;
12271 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12272 dlg.begin(common::MethodInfo {
12273 id: "spanner.projects.instances.backups.getIamPolicy",
12274 http_method: hyper::Method::POST,
12275 });
12276
12277 for &field in ["alt", "resource"].iter() {
12278 if self._additional_params.contains_key(field) {
12279 dlg.finished(false);
12280 return Err(common::Error::FieldClash(field));
12281 }
12282 }
12283
12284 let mut params = Params::with_capacity(4 + self._additional_params.len());
12285 params.push("resource", self._resource);
12286
12287 params.extend(self._additional_params.iter());
12288
12289 params.push("alt", "json");
12290 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
12291 if self._scopes.is_empty() {
12292 self._scopes
12293 .insert(Scope::CloudPlatform.as_ref().to_string());
12294 }
12295
12296 #[allow(clippy::single_element_loop)]
12297 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12298 url = params.uri_replacement(url, param_name, find_this, true);
12299 }
12300 {
12301 let to_remove = ["resource"];
12302 params.remove_params(&to_remove);
12303 }
12304
12305 let url = params.parse_with_url(&url);
12306
12307 let mut json_mime_type = mime::APPLICATION_JSON;
12308 let mut request_value_reader = {
12309 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12310 common::remove_json_null_values(&mut value);
12311 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12312 serde_json::to_writer(&mut dst, &value).unwrap();
12313 dst
12314 };
12315 let request_size = request_value_reader
12316 .seek(std::io::SeekFrom::End(0))
12317 .unwrap();
12318 request_value_reader
12319 .seek(std::io::SeekFrom::Start(0))
12320 .unwrap();
12321
12322 loop {
12323 let token = match self
12324 .hub
12325 .auth
12326 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12327 .await
12328 {
12329 Ok(token) => token,
12330 Err(e) => match dlg.token(e) {
12331 Ok(token) => token,
12332 Err(e) => {
12333 dlg.finished(false);
12334 return Err(common::Error::MissingToken(e));
12335 }
12336 },
12337 };
12338 request_value_reader
12339 .seek(std::io::SeekFrom::Start(0))
12340 .unwrap();
12341 let mut req_result = {
12342 let client = &self.hub.client;
12343 dlg.pre_request();
12344 let mut req_builder = hyper::Request::builder()
12345 .method(hyper::Method::POST)
12346 .uri(url.as_str())
12347 .header(USER_AGENT, self.hub._user_agent.clone());
12348
12349 if let Some(token) = token.as_ref() {
12350 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12351 }
12352
12353 let request = req_builder
12354 .header(CONTENT_TYPE, json_mime_type.to_string())
12355 .header(CONTENT_LENGTH, request_size as u64)
12356 .body(common::to_body(
12357 request_value_reader.get_ref().clone().into(),
12358 ));
12359
12360 client.request(request.unwrap()).await
12361 };
12362
12363 match req_result {
12364 Err(err) => {
12365 if let common::Retry::After(d) = dlg.http_error(&err) {
12366 sleep(d).await;
12367 continue;
12368 }
12369 dlg.finished(false);
12370 return Err(common::Error::HttpError(err));
12371 }
12372 Ok(res) => {
12373 let (mut parts, body) = res.into_parts();
12374 let mut body = common::Body::new(body);
12375 if !parts.status.is_success() {
12376 let bytes = common::to_bytes(body).await.unwrap_or_default();
12377 let error = serde_json::from_str(&common::to_string(&bytes));
12378 let response = common::to_response(parts, bytes.into());
12379
12380 if let common::Retry::After(d) =
12381 dlg.http_failure(&response, error.as_ref().ok())
12382 {
12383 sleep(d).await;
12384 continue;
12385 }
12386
12387 dlg.finished(false);
12388
12389 return Err(match error {
12390 Ok(value) => common::Error::BadRequest(value),
12391 _ => common::Error::Failure(response),
12392 });
12393 }
12394 let response = {
12395 let bytes = common::to_bytes(body).await.unwrap_or_default();
12396 let encoded = common::to_string(&bytes);
12397 match serde_json::from_str(&encoded) {
12398 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12399 Err(error) => {
12400 dlg.response_json_decode_error(&encoded, &error);
12401 return Err(common::Error::JsonDecodeError(
12402 encoded.to_string(),
12403 error,
12404 ));
12405 }
12406 }
12407 };
12408
12409 dlg.finished(true);
12410 return Ok(response);
12411 }
12412 }
12413 }
12414 }
12415
12416 ///
12417 /// Sets the *request* property to the given value.
12418 ///
12419 /// Even though the property as already been set when instantiating this call,
12420 /// we provide this method for API completeness.
12421 pub fn request(
12422 mut self,
12423 new_value: GetIamPolicyRequest,
12424 ) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
12425 self._request = new_value;
12426 self
12427 }
12428 /// 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.
12429 ///
12430 /// Sets the *resource* path property to the given value.
12431 ///
12432 /// Even though the property as already been set when instantiating this call,
12433 /// we provide this method for API completeness.
12434 pub fn resource(mut self, new_value: &str) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
12435 self._resource = new_value.to_string();
12436 self
12437 }
12438 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12439 /// while executing the actual API request.
12440 ///
12441 /// ````text
12442 /// It should be used to handle progress information, and to implement a certain level of resilience.
12443 /// ````
12444 ///
12445 /// Sets the *delegate* property to the given value.
12446 pub fn delegate(
12447 mut self,
12448 new_value: &'a mut dyn common::Delegate,
12449 ) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
12450 self._delegate = Some(new_value);
12451 self
12452 }
12453
12454 /// Set any additional parameter of the query string used in the request.
12455 /// It should be used to set parameters which are not yet available through their own
12456 /// setters.
12457 ///
12458 /// Please note that this method must not be used to set any of the known parameters
12459 /// which have their own setter method. If done anyway, the request will fail.
12460 ///
12461 /// # Additional Parameters
12462 ///
12463 /// * *$.xgafv* (query-string) - V1 error format.
12464 /// * *access_token* (query-string) - OAuth access token.
12465 /// * *alt* (query-string) - Data format for response.
12466 /// * *callback* (query-string) - JSONP
12467 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12468 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12469 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12470 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12471 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12472 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12473 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12474 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupGetIamPolicyCall<'a, C>
12475 where
12476 T: AsRef<str>,
12477 {
12478 self._additional_params
12479 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12480 self
12481 }
12482
12483 /// Identifies the authorization scope for the method you are building.
12484 ///
12485 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12486 /// [`Scope::CloudPlatform`].
12487 ///
12488 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12489 /// tokens for more than one scope.
12490 ///
12491 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12492 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12493 /// sufficient, a read-write scope will do as well.
12494 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupGetIamPolicyCall<'a, C>
12495 where
12496 St: AsRef<str>,
12497 {
12498 self._scopes.insert(String::from(scope.as_ref()));
12499 self
12500 }
12501 /// Identifies the authorization scope(s) for the method you are building.
12502 ///
12503 /// See [`Self::add_scope()`] for details.
12504 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupGetIamPolicyCall<'a, C>
12505 where
12506 I: IntoIterator<Item = St>,
12507 St: AsRef<str>,
12508 {
12509 self._scopes
12510 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12511 self
12512 }
12513
12514 /// Removes all scopes, and no default scope will be used either.
12515 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12516 /// for details).
12517 pub fn clear_scopes(mut self) -> ProjectInstanceBackupGetIamPolicyCall<'a, C> {
12518 self._scopes.clear();
12519 self
12520 }
12521}
12522
12523/// Lists completed and pending backups. Backups returned are ordered by `create_time` in descending order, starting from the most recent `create_time`.
12524///
12525/// A builder for the *instances.backups.list* method supported by a *project* resource.
12526/// It is not used directly, but through a [`ProjectMethods`] instance.
12527///
12528/// # Example
12529///
12530/// Instantiate a resource method builder
12531///
12532/// ```test_harness,no_run
12533/// # extern crate hyper;
12534/// # extern crate hyper_rustls;
12535/// # extern crate google_spanner1 as spanner1;
12536/// # async fn dox() {
12537/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12538///
12539/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12540/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12541/// # secret,
12542/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12543/// # ).build().await.unwrap();
12544///
12545/// # let client = hyper_util::client::legacy::Client::builder(
12546/// # hyper_util::rt::TokioExecutor::new()
12547/// # )
12548/// # .build(
12549/// # hyper_rustls::HttpsConnectorBuilder::new()
12550/// # .with_native_roots()
12551/// # .unwrap()
12552/// # .https_or_http()
12553/// # .enable_http1()
12554/// # .build()
12555/// # );
12556/// # let mut hub = Spanner::new(client, auth);
12557/// // You can configure optional parameters by calling the respective setters at will, and
12558/// // execute the final call using `doit()`.
12559/// // Values shown here are possibly random and not representative !
12560/// let result = hub.projects().instances_backups_list("parent")
12561/// .page_token("dolor")
12562/// .page_size(-20)
12563/// .filter("vero")
12564/// .doit().await;
12565/// # }
12566/// ```
12567pub struct ProjectInstanceBackupListCall<'a, C>
12568where
12569 C: 'a,
12570{
12571 hub: &'a Spanner<C>,
12572 _parent: String,
12573 _page_token: Option<String>,
12574 _page_size: Option<i32>,
12575 _filter: Option<String>,
12576 _delegate: Option<&'a mut dyn common::Delegate>,
12577 _additional_params: HashMap<String, String>,
12578 _scopes: BTreeSet<String>,
12579}
12580
12581impl<'a, C> common::CallBuilder for ProjectInstanceBackupListCall<'a, C> {}
12582
12583impl<'a, C> ProjectInstanceBackupListCall<'a, C>
12584where
12585 C: common::Connector,
12586{
12587 /// Perform the operation you have build so far.
12588 pub async fn doit(mut self) -> common::Result<(common::Response, ListBackupsResponse)> {
12589 use std::borrow::Cow;
12590 use std::io::{Read, Seek};
12591
12592 use common::{url::Params, ToParts};
12593 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12594
12595 let mut dd = common::DefaultDelegate;
12596 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12597 dlg.begin(common::MethodInfo {
12598 id: "spanner.projects.instances.backups.list",
12599 http_method: hyper::Method::GET,
12600 });
12601
12602 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
12603 if self._additional_params.contains_key(field) {
12604 dlg.finished(false);
12605 return Err(common::Error::FieldClash(field));
12606 }
12607 }
12608
12609 let mut params = Params::with_capacity(6 + self._additional_params.len());
12610 params.push("parent", self._parent);
12611 if let Some(value) = self._page_token.as_ref() {
12612 params.push("pageToken", value);
12613 }
12614 if let Some(value) = self._page_size.as_ref() {
12615 params.push("pageSize", value.to_string());
12616 }
12617 if let Some(value) = self._filter.as_ref() {
12618 params.push("filter", value);
12619 }
12620
12621 params.extend(self._additional_params.iter());
12622
12623 params.push("alt", "json");
12624 let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
12625 if self._scopes.is_empty() {
12626 self._scopes
12627 .insert(Scope::CloudPlatform.as_ref().to_string());
12628 }
12629
12630 #[allow(clippy::single_element_loop)]
12631 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12632 url = params.uri_replacement(url, param_name, find_this, true);
12633 }
12634 {
12635 let to_remove = ["parent"];
12636 params.remove_params(&to_remove);
12637 }
12638
12639 let url = params.parse_with_url(&url);
12640
12641 loop {
12642 let token = match self
12643 .hub
12644 .auth
12645 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12646 .await
12647 {
12648 Ok(token) => token,
12649 Err(e) => match dlg.token(e) {
12650 Ok(token) => token,
12651 Err(e) => {
12652 dlg.finished(false);
12653 return Err(common::Error::MissingToken(e));
12654 }
12655 },
12656 };
12657 let mut req_result = {
12658 let client = &self.hub.client;
12659 dlg.pre_request();
12660 let mut req_builder = hyper::Request::builder()
12661 .method(hyper::Method::GET)
12662 .uri(url.as_str())
12663 .header(USER_AGENT, self.hub._user_agent.clone());
12664
12665 if let Some(token) = token.as_ref() {
12666 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12667 }
12668
12669 let request = req_builder
12670 .header(CONTENT_LENGTH, 0_u64)
12671 .body(common::to_body::<String>(None));
12672
12673 client.request(request.unwrap()).await
12674 };
12675
12676 match req_result {
12677 Err(err) => {
12678 if let common::Retry::After(d) = dlg.http_error(&err) {
12679 sleep(d).await;
12680 continue;
12681 }
12682 dlg.finished(false);
12683 return Err(common::Error::HttpError(err));
12684 }
12685 Ok(res) => {
12686 let (mut parts, body) = res.into_parts();
12687 let mut body = common::Body::new(body);
12688 if !parts.status.is_success() {
12689 let bytes = common::to_bytes(body).await.unwrap_or_default();
12690 let error = serde_json::from_str(&common::to_string(&bytes));
12691 let response = common::to_response(parts, bytes.into());
12692
12693 if let common::Retry::After(d) =
12694 dlg.http_failure(&response, error.as_ref().ok())
12695 {
12696 sleep(d).await;
12697 continue;
12698 }
12699
12700 dlg.finished(false);
12701
12702 return Err(match error {
12703 Ok(value) => common::Error::BadRequest(value),
12704 _ => common::Error::Failure(response),
12705 });
12706 }
12707 let response = {
12708 let bytes = common::to_bytes(body).await.unwrap_or_default();
12709 let encoded = common::to_string(&bytes);
12710 match serde_json::from_str(&encoded) {
12711 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12712 Err(error) => {
12713 dlg.response_json_decode_error(&encoded, &error);
12714 return Err(common::Error::JsonDecodeError(
12715 encoded.to_string(),
12716 error,
12717 ));
12718 }
12719 }
12720 };
12721
12722 dlg.finished(true);
12723 return Ok(response);
12724 }
12725 }
12726 }
12727 }
12728
12729 /// Required. The instance to list backups from. Values are of the form `projects//instances/`.
12730 ///
12731 /// Sets the *parent* path property to the given value.
12732 ///
12733 /// Even though the property as already been set when instantiating this call,
12734 /// we provide this method for API completeness.
12735 pub fn parent(mut self, new_value: &str) -> ProjectInstanceBackupListCall<'a, C> {
12736 self._parent = new_value.to_string();
12737 self
12738 }
12739 /// If non-empty, `page_token` should contain a next_page_token from a previous ListBackupsResponse to the same `parent` and with the same `filter`.
12740 ///
12741 /// Sets the *page token* query property to the given value.
12742 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceBackupListCall<'a, C> {
12743 self._page_token = Some(new_value.to_string());
12744 self
12745 }
12746 /// Number of backups to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
12747 ///
12748 /// Sets the *page size* query property to the given value.
12749 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceBackupListCall<'a, C> {
12750 self._page_size = Some(new_value);
12751 self
12752 }
12753 /// 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` 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
12754 ///
12755 /// Sets the *filter* query property to the given value.
12756 pub fn filter(mut self, new_value: &str) -> ProjectInstanceBackupListCall<'a, C> {
12757 self._filter = Some(new_value.to_string());
12758 self
12759 }
12760 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12761 /// while executing the actual API request.
12762 ///
12763 /// ````text
12764 /// It should be used to handle progress information, and to implement a certain level of resilience.
12765 /// ````
12766 ///
12767 /// Sets the *delegate* property to the given value.
12768 pub fn delegate(
12769 mut self,
12770 new_value: &'a mut dyn common::Delegate,
12771 ) -> ProjectInstanceBackupListCall<'a, C> {
12772 self._delegate = Some(new_value);
12773 self
12774 }
12775
12776 /// Set any additional parameter of the query string used in the request.
12777 /// It should be used to set parameters which are not yet available through their own
12778 /// setters.
12779 ///
12780 /// Please note that this method must not be used to set any of the known parameters
12781 /// which have their own setter method. If done anyway, the request will fail.
12782 ///
12783 /// # Additional Parameters
12784 ///
12785 /// * *$.xgafv* (query-string) - V1 error format.
12786 /// * *access_token* (query-string) - OAuth access token.
12787 /// * *alt* (query-string) - Data format for response.
12788 /// * *callback* (query-string) - JSONP
12789 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12790 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12791 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12792 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12793 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12794 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12795 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12796 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupListCall<'a, C>
12797 where
12798 T: AsRef<str>,
12799 {
12800 self._additional_params
12801 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12802 self
12803 }
12804
12805 /// Identifies the authorization scope for the method you are building.
12806 ///
12807 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12808 /// [`Scope::CloudPlatform`].
12809 ///
12810 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12811 /// tokens for more than one scope.
12812 ///
12813 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12814 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12815 /// sufficient, a read-write scope will do as well.
12816 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupListCall<'a, C>
12817 where
12818 St: AsRef<str>,
12819 {
12820 self._scopes.insert(String::from(scope.as_ref()));
12821 self
12822 }
12823 /// Identifies the authorization scope(s) for the method you are building.
12824 ///
12825 /// See [`Self::add_scope()`] for details.
12826 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupListCall<'a, C>
12827 where
12828 I: IntoIterator<Item = St>,
12829 St: AsRef<str>,
12830 {
12831 self._scopes
12832 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12833 self
12834 }
12835
12836 /// Removes all scopes, and no default scope will be used either.
12837 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12838 /// for details).
12839 pub fn clear_scopes(mut self) -> ProjectInstanceBackupListCall<'a, C> {
12840 self._scopes.clear();
12841 self
12842 }
12843}
12844
12845/// Updates a pending or completed Backup.
12846///
12847/// A builder for the *instances.backups.patch* method supported by a *project* resource.
12848/// It is not used directly, but through a [`ProjectMethods`] instance.
12849///
12850/// # Example
12851///
12852/// Instantiate a resource method builder
12853///
12854/// ```test_harness,no_run
12855/// # extern crate hyper;
12856/// # extern crate hyper_rustls;
12857/// # extern crate google_spanner1 as spanner1;
12858/// use spanner1::api::Backup;
12859/// # async fn dox() {
12860/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12861///
12862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12863/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12864/// # secret,
12865/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12866/// # ).build().await.unwrap();
12867///
12868/// # let client = hyper_util::client::legacy::Client::builder(
12869/// # hyper_util::rt::TokioExecutor::new()
12870/// # )
12871/// # .build(
12872/// # hyper_rustls::HttpsConnectorBuilder::new()
12873/// # .with_native_roots()
12874/// # .unwrap()
12875/// # .https_or_http()
12876/// # .enable_http1()
12877/// # .build()
12878/// # );
12879/// # let mut hub = Spanner::new(client, auth);
12880/// // As the method needs a request, you would usually fill it with the desired information
12881/// // into the respective structure. Some of the parts shown here might not be applicable !
12882/// // Values shown here are possibly random and not representative !
12883/// let mut req = Backup::default();
12884///
12885/// // You can configure optional parameters by calling the respective setters at will, and
12886/// // execute the final call using `doit()`.
12887/// // Values shown here are possibly random and not representative !
12888/// let result = hub.projects().instances_backups_patch(req, "name")
12889/// .update_mask(FieldMask::new::<&str>(&[]))
12890/// .doit().await;
12891/// # }
12892/// ```
12893pub struct ProjectInstanceBackupPatchCall<'a, C>
12894where
12895 C: 'a,
12896{
12897 hub: &'a Spanner<C>,
12898 _request: Backup,
12899 _name: String,
12900 _update_mask: Option<common::FieldMask>,
12901 _delegate: Option<&'a mut dyn common::Delegate>,
12902 _additional_params: HashMap<String, String>,
12903 _scopes: BTreeSet<String>,
12904}
12905
12906impl<'a, C> common::CallBuilder for ProjectInstanceBackupPatchCall<'a, C> {}
12907
12908impl<'a, C> ProjectInstanceBackupPatchCall<'a, C>
12909where
12910 C: common::Connector,
12911{
12912 /// Perform the operation you have build so far.
12913 pub async fn doit(mut self) -> common::Result<(common::Response, Backup)> {
12914 use std::borrow::Cow;
12915 use std::io::{Read, Seek};
12916
12917 use common::{url::Params, ToParts};
12918 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12919
12920 let mut dd = common::DefaultDelegate;
12921 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12922 dlg.begin(common::MethodInfo {
12923 id: "spanner.projects.instances.backups.patch",
12924 http_method: hyper::Method::PATCH,
12925 });
12926
12927 for &field in ["alt", "name", "updateMask"].iter() {
12928 if self._additional_params.contains_key(field) {
12929 dlg.finished(false);
12930 return Err(common::Error::FieldClash(field));
12931 }
12932 }
12933
12934 let mut params = Params::with_capacity(5 + self._additional_params.len());
12935 params.push("name", self._name);
12936 if let Some(value) = self._update_mask.as_ref() {
12937 params.push("updateMask", value.to_string());
12938 }
12939
12940 params.extend(self._additional_params.iter());
12941
12942 params.push("alt", "json");
12943 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12944 if self._scopes.is_empty() {
12945 self._scopes
12946 .insert(Scope::CloudPlatform.as_ref().to_string());
12947 }
12948
12949 #[allow(clippy::single_element_loop)]
12950 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12951 url = params.uri_replacement(url, param_name, find_this, true);
12952 }
12953 {
12954 let to_remove = ["name"];
12955 params.remove_params(&to_remove);
12956 }
12957
12958 let url = params.parse_with_url(&url);
12959
12960 let mut json_mime_type = mime::APPLICATION_JSON;
12961 let mut request_value_reader = {
12962 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12963 common::remove_json_null_values(&mut value);
12964 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12965 serde_json::to_writer(&mut dst, &value).unwrap();
12966 dst
12967 };
12968 let request_size = request_value_reader
12969 .seek(std::io::SeekFrom::End(0))
12970 .unwrap();
12971 request_value_reader
12972 .seek(std::io::SeekFrom::Start(0))
12973 .unwrap();
12974
12975 loop {
12976 let token = match self
12977 .hub
12978 .auth
12979 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12980 .await
12981 {
12982 Ok(token) => token,
12983 Err(e) => match dlg.token(e) {
12984 Ok(token) => token,
12985 Err(e) => {
12986 dlg.finished(false);
12987 return Err(common::Error::MissingToken(e));
12988 }
12989 },
12990 };
12991 request_value_reader
12992 .seek(std::io::SeekFrom::Start(0))
12993 .unwrap();
12994 let mut req_result = {
12995 let client = &self.hub.client;
12996 dlg.pre_request();
12997 let mut req_builder = hyper::Request::builder()
12998 .method(hyper::Method::PATCH)
12999 .uri(url.as_str())
13000 .header(USER_AGENT, self.hub._user_agent.clone());
13001
13002 if let Some(token) = token.as_ref() {
13003 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13004 }
13005
13006 let request = req_builder
13007 .header(CONTENT_TYPE, json_mime_type.to_string())
13008 .header(CONTENT_LENGTH, request_size as u64)
13009 .body(common::to_body(
13010 request_value_reader.get_ref().clone().into(),
13011 ));
13012
13013 client.request(request.unwrap()).await
13014 };
13015
13016 match req_result {
13017 Err(err) => {
13018 if let common::Retry::After(d) = dlg.http_error(&err) {
13019 sleep(d).await;
13020 continue;
13021 }
13022 dlg.finished(false);
13023 return Err(common::Error::HttpError(err));
13024 }
13025 Ok(res) => {
13026 let (mut parts, body) = res.into_parts();
13027 let mut body = common::Body::new(body);
13028 if !parts.status.is_success() {
13029 let bytes = common::to_bytes(body).await.unwrap_or_default();
13030 let error = serde_json::from_str(&common::to_string(&bytes));
13031 let response = common::to_response(parts, bytes.into());
13032
13033 if let common::Retry::After(d) =
13034 dlg.http_failure(&response, error.as_ref().ok())
13035 {
13036 sleep(d).await;
13037 continue;
13038 }
13039
13040 dlg.finished(false);
13041
13042 return Err(match error {
13043 Ok(value) => common::Error::BadRequest(value),
13044 _ => common::Error::Failure(response),
13045 });
13046 }
13047 let response = {
13048 let bytes = common::to_bytes(body).await.unwrap_or_default();
13049 let encoded = common::to_string(&bytes);
13050 match serde_json::from_str(&encoded) {
13051 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13052 Err(error) => {
13053 dlg.response_json_decode_error(&encoded, &error);
13054 return Err(common::Error::JsonDecodeError(
13055 encoded.to_string(),
13056 error,
13057 ));
13058 }
13059 }
13060 };
13061
13062 dlg.finished(true);
13063 return Ok(response);
13064 }
13065 }
13066 }
13067 }
13068
13069 ///
13070 /// Sets the *request* property to the given value.
13071 ///
13072 /// Even though the property as already been set when instantiating this call,
13073 /// we provide this method for API completeness.
13074 pub fn request(mut self, new_value: Backup) -> ProjectInstanceBackupPatchCall<'a, C> {
13075 self._request = new_value;
13076 self
13077 }
13078 /// 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/`.
13079 ///
13080 /// Sets the *name* path property to the given value.
13081 ///
13082 /// Even though the property as already been set when instantiating this call,
13083 /// we provide this method for API completeness.
13084 pub fn name(mut self, new_value: &str) -> ProjectInstanceBackupPatchCall<'a, C> {
13085 self._name = new_value.to_string();
13086 self
13087 }
13088 /// Required. A mask specifying which fields (e.g. `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.
13089 ///
13090 /// Sets the *update mask* query property to the given value.
13091 pub fn update_mask(
13092 mut self,
13093 new_value: common::FieldMask,
13094 ) -> ProjectInstanceBackupPatchCall<'a, C> {
13095 self._update_mask = Some(new_value);
13096 self
13097 }
13098 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13099 /// while executing the actual API request.
13100 ///
13101 /// ````text
13102 /// It should be used to handle progress information, and to implement a certain level of resilience.
13103 /// ````
13104 ///
13105 /// Sets the *delegate* property to the given value.
13106 pub fn delegate(
13107 mut self,
13108 new_value: &'a mut dyn common::Delegate,
13109 ) -> ProjectInstanceBackupPatchCall<'a, C> {
13110 self._delegate = Some(new_value);
13111 self
13112 }
13113
13114 /// Set any additional parameter of the query string used in the request.
13115 /// It should be used to set parameters which are not yet available through their own
13116 /// setters.
13117 ///
13118 /// Please note that this method must not be used to set any of the known parameters
13119 /// which have their own setter method. If done anyway, the request will fail.
13120 ///
13121 /// # Additional Parameters
13122 ///
13123 /// * *$.xgafv* (query-string) - V1 error format.
13124 /// * *access_token* (query-string) - OAuth access token.
13125 /// * *alt* (query-string) - Data format for response.
13126 /// * *callback* (query-string) - JSONP
13127 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13128 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13129 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13130 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13131 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13132 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13133 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13134 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupPatchCall<'a, C>
13135 where
13136 T: AsRef<str>,
13137 {
13138 self._additional_params
13139 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13140 self
13141 }
13142
13143 /// Identifies the authorization scope for the method you are building.
13144 ///
13145 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13146 /// [`Scope::CloudPlatform`].
13147 ///
13148 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13149 /// tokens for more than one scope.
13150 ///
13151 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13152 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13153 /// sufficient, a read-write scope will do as well.
13154 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupPatchCall<'a, C>
13155 where
13156 St: AsRef<str>,
13157 {
13158 self._scopes.insert(String::from(scope.as_ref()));
13159 self
13160 }
13161 /// Identifies the authorization scope(s) for the method you are building.
13162 ///
13163 /// See [`Self::add_scope()`] for details.
13164 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupPatchCall<'a, C>
13165 where
13166 I: IntoIterator<Item = St>,
13167 St: AsRef<str>,
13168 {
13169 self._scopes
13170 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13171 self
13172 }
13173
13174 /// Removes all scopes, and no default scope will be used either.
13175 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13176 /// for details).
13177 pub fn clear_scopes(mut self) -> ProjectInstanceBackupPatchCall<'a, C> {
13178 self._scopes.clear();
13179 self
13180 }
13181}
13182
13183/// 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.
13184///
13185/// A builder for the *instances.backups.setIamPolicy* method supported by a *project* resource.
13186/// It is not used directly, but through a [`ProjectMethods`] instance.
13187///
13188/// # Example
13189///
13190/// Instantiate a resource method builder
13191///
13192/// ```test_harness,no_run
13193/// # extern crate hyper;
13194/// # extern crate hyper_rustls;
13195/// # extern crate google_spanner1 as spanner1;
13196/// use spanner1::api::SetIamPolicyRequest;
13197/// # async fn dox() {
13198/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13199///
13200/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13201/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13202/// # secret,
13203/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13204/// # ).build().await.unwrap();
13205///
13206/// # let client = hyper_util::client::legacy::Client::builder(
13207/// # hyper_util::rt::TokioExecutor::new()
13208/// # )
13209/// # .build(
13210/// # hyper_rustls::HttpsConnectorBuilder::new()
13211/// # .with_native_roots()
13212/// # .unwrap()
13213/// # .https_or_http()
13214/// # .enable_http1()
13215/// # .build()
13216/// # );
13217/// # let mut hub = Spanner::new(client, auth);
13218/// // As the method needs a request, you would usually fill it with the desired information
13219/// // into the respective structure. Some of the parts shown here might not be applicable !
13220/// // Values shown here are possibly random and not representative !
13221/// let mut req = SetIamPolicyRequest::default();
13222///
13223/// // You can configure optional parameters by calling the respective setters at will, and
13224/// // execute the final call using `doit()`.
13225/// // Values shown here are possibly random and not representative !
13226/// let result = hub.projects().instances_backups_set_iam_policy(req, "resource")
13227/// .doit().await;
13228/// # }
13229/// ```
13230pub struct ProjectInstanceBackupSetIamPolicyCall<'a, C>
13231where
13232 C: 'a,
13233{
13234 hub: &'a Spanner<C>,
13235 _request: SetIamPolicyRequest,
13236 _resource: String,
13237 _delegate: Option<&'a mut dyn common::Delegate>,
13238 _additional_params: HashMap<String, String>,
13239 _scopes: BTreeSet<String>,
13240}
13241
13242impl<'a, C> common::CallBuilder for ProjectInstanceBackupSetIamPolicyCall<'a, C> {}
13243
13244impl<'a, C> ProjectInstanceBackupSetIamPolicyCall<'a, C>
13245where
13246 C: common::Connector,
13247{
13248 /// Perform the operation you have build so far.
13249 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
13250 use std::borrow::Cow;
13251 use std::io::{Read, Seek};
13252
13253 use common::{url::Params, ToParts};
13254 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13255
13256 let mut dd = common::DefaultDelegate;
13257 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13258 dlg.begin(common::MethodInfo {
13259 id: "spanner.projects.instances.backups.setIamPolicy",
13260 http_method: hyper::Method::POST,
13261 });
13262
13263 for &field in ["alt", "resource"].iter() {
13264 if self._additional_params.contains_key(field) {
13265 dlg.finished(false);
13266 return Err(common::Error::FieldClash(field));
13267 }
13268 }
13269
13270 let mut params = Params::with_capacity(4 + self._additional_params.len());
13271 params.push("resource", self._resource);
13272
13273 params.extend(self._additional_params.iter());
13274
13275 params.push("alt", "json");
13276 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
13277 if self._scopes.is_empty() {
13278 self._scopes
13279 .insert(Scope::CloudPlatform.as_ref().to_string());
13280 }
13281
13282 #[allow(clippy::single_element_loop)]
13283 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
13284 url = params.uri_replacement(url, param_name, find_this, true);
13285 }
13286 {
13287 let to_remove = ["resource"];
13288 params.remove_params(&to_remove);
13289 }
13290
13291 let url = params.parse_with_url(&url);
13292
13293 let mut json_mime_type = mime::APPLICATION_JSON;
13294 let mut request_value_reader = {
13295 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13296 common::remove_json_null_values(&mut value);
13297 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13298 serde_json::to_writer(&mut dst, &value).unwrap();
13299 dst
13300 };
13301 let request_size = request_value_reader
13302 .seek(std::io::SeekFrom::End(0))
13303 .unwrap();
13304 request_value_reader
13305 .seek(std::io::SeekFrom::Start(0))
13306 .unwrap();
13307
13308 loop {
13309 let token = match self
13310 .hub
13311 .auth
13312 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13313 .await
13314 {
13315 Ok(token) => token,
13316 Err(e) => match dlg.token(e) {
13317 Ok(token) => token,
13318 Err(e) => {
13319 dlg.finished(false);
13320 return Err(common::Error::MissingToken(e));
13321 }
13322 },
13323 };
13324 request_value_reader
13325 .seek(std::io::SeekFrom::Start(0))
13326 .unwrap();
13327 let mut req_result = {
13328 let client = &self.hub.client;
13329 dlg.pre_request();
13330 let mut req_builder = hyper::Request::builder()
13331 .method(hyper::Method::POST)
13332 .uri(url.as_str())
13333 .header(USER_AGENT, self.hub._user_agent.clone());
13334
13335 if let Some(token) = token.as_ref() {
13336 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13337 }
13338
13339 let request = req_builder
13340 .header(CONTENT_TYPE, json_mime_type.to_string())
13341 .header(CONTENT_LENGTH, request_size as u64)
13342 .body(common::to_body(
13343 request_value_reader.get_ref().clone().into(),
13344 ));
13345
13346 client.request(request.unwrap()).await
13347 };
13348
13349 match req_result {
13350 Err(err) => {
13351 if let common::Retry::After(d) = dlg.http_error(&err) {
13352 sleep(d).await;
13353 continue;
13354 }
13355 dlg.finished(false);
13356 return Err(common::Error::HttpError(err));
13357 }
13358 Ok(res) => {
13359 let (mut parts, body) = res.into_parts();
13360 let mut body = common::Body::new(body);
13361 if !parts.status.is_success() {
13362 let bytes = common::to_bytes(body).await.unwrap_or_default();
13363 let error = serde_json::from_str(&common::to_string(&bytes));
13364 let response = common::to_response(parts, bytes.into());
13365
13366 if let common::Retry::After(d) =
13367 dlg.http_failure(&response, error.as_ref().ok())
13368 {
13369 sleep(d).await;
13370 continue;
13371 }
13372
13373 dlg.finished(false);
13374
13375 return Err(match error {
13376 Ok(value) => common::Error::BadRequest(value),
13377 _ => common::Error::Failure(response),
13378 });
13379 }
13380 let response = {
13381 let bytes = common::to_bytes(body).await.unwrap_or_default();
13382 let encoded = common::to_string(&bytes);
13383 match serde_json::from_str(&encoded) {
13384 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13385 Err(error) => {
13386 dlg.response_json_decode_error(&encoded, &error);
13387 return Err(common::Error::JsonDecodeError(
13388 encoded.to_string(),
13389 error,
13390 ));
13391 }
13392 }
13393 };
13394
13395 dlg.finished(true);
13396 return Ok(response);
13397 }
13398 }
13399 }
13400 }
13401
13402 ///
13403 /// Sets the *request* property to the given value.
13404 ///
13405 /// Even though the property as already been set when instantiating this call,
13406 /// we provide this method for API completeness.
13407 pub fn request(
13408 mut self,
13409 new_value: SetIamPolicyRequest,
13410 ) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
13411 self._request = new_value;
13412 self
13413 }
13414 /// 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.
13415 ///
13416 /// Sets the *resource* path property to the given value.
13417 ///
13418 /// Even though the property as already been set when instantiating this call,
13419 /// we provide this method for API completeness.
13420 pub fn resource(mut self, new_value: &str) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
13421 self._resource = new_value.to_string();
13422 self
13423 }
13424 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13425 /// while executing the actual API request.
13426 ///
13427 /// ````text
13428 /// It should be used to handle progress information, and to implement a certain level of resilience.
13429 /// ````
13430 ///
13431 /// Sets the *delegate* property to the given value.
13432 pub fn delegate(
13433 mut self,
13434 new_value: &'a mut dyn common::Delegate,
13435 ) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
13436 self._delegate = Some(new_value);
13437 self
13438 }
13439
13440 /// Set any additional parameter of the query string used in the request.
13441 /// It should be used to set parameters which are not yet available through their own
13442 /// setters.
13443 ///
13444 /// Please note that this method must not be used to set any of the known parameters
13445 /// which have their own setter method. If done anyway, the request will fail.
13446 ///
13447 /// # Additional Parameters
13448 ///
13449 /// * *$.xgafv* (query-string) - V1 error format.
13450 /// * *access_token* (query-string) - OAuth access token.
13451 /// * *alt* (query-string) - Data format for response.
13452 /// * *callback* (query-string) - JSONP
13453 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13454 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13455 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13456 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13457 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13458 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13459 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13460 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceBackupSetIamPolicyCall<'a, C>
13461 where
13462 T: AsRef<str>,
13463 {
13464 self._additional_params
13465 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13466 self
13467 }
13468
13469 /// Identifies the authorization scope for the method you are building.
13470 ///
13471 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13472 /// [`Scope::CloudPlatform`].
13473 ///
13474 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13475 /// tokens for more than one scope.
13476 ///
13477 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13478 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13479 /// sufficient, a read-write scope will do as well.
13480 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupSetIamPolicyCall<'a, C>
13481 where
13482 St: AsRef<str>,
13483 {
13484 self._scopes.insert(String::from(scope.as_ref()));
13485 self
13486 }
13487 /// Identifies the authorization scope(s) for the method you are building.
13488 ///
13489 /// See [`Self::add_scope()`] for details.
13490 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceBackupSetIamPolicyCall<'a, C>
13491 where
13492 I: IntoIterator<Item = St>,
13493 St: AsRef<str>,
13494 {
13495 self._scopes
13496 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13497 self
13498 }
13499
13500 /// Removes all scopes, and no default scope will be used either.
13501 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13502 /// for details).
13503 pub fn clear_scopes(mut self) -> ProjectInstanceBackupSetIamPolicyCall<'a, C> {
13504 self._scopes.clear();
13505 self
13506 }
13507}
13508
13509/// 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.
13510///
13511/// A builder for the *instances.backups.testIamPermissions* method supported by a *project* resource.
13512/// It is not used directly, but through a [`ProjectMethods`] instance.
13513///
13514/// # Example
13515///
13516/// Instantiate a resource method builder
13517///
13518/// ```test_harness,no_run
13519/// # extern crate hyper;
13520/// # extern crate hyper_rustls;
13521/// # extern crate google_spanner1 as spanner1;
13522/// use spanner1::api::TestIamPermissionsRequest;
13523/// # async fn dox() {
13524/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13525///
13526/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13527/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13528/// # secret,
13529/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13530/// # ).build().await.unwrap();
13531///
13532/// # let client = hyper_util::client::legacy::Client::builder(
13533/// # hyper_util::rt::TokioExecutor::new()
13534/// # )
13535/// # .build(
13536/// # hyper_rustls::HttpsConnectorBuilder::new()
13537/// # .with_native_roots()
13538/// # .unwrap()
13539/// # .https_or_http()
13540/// # .enable_http1()
13541/// # .build()
13542/// # );
13543/// # let mut hub = Spanner::new(client, auth);
13544/// // As the method needs a request, you would usually fill it with the desired information
13545/// // into the respective structure. Some of the parts shown here might not be applicable !
13546/// // Values shown here are possibly random and not representative !
13547/// let mut req = TestIamPermissionsRequest::default();
13548///
13549/// // You can configure optional parameters by calling the respective setters at will, and
13550/// // execute the final call using `doit()`.
13551/// // Values shown here are possibly random and not representative !
13552/// let result = hub.projects().instances_backups_test_iam_permissions(req, "resource")
13553/// .doit().await;
13554/// # }
13555/// ```
13556pub struct ProjectInstanceBackupTestIamPermissionCall<'a, C>
13557where
13558 C: 'a,
13559{
13560 hub: &'a Spanner<C>,
13561 _request: TestIamPermissionsRequest,
13562 _resource: String,
13563 _delegate: Option<&'a mut dyn common::Delegate>,
13564 _additional_params: HashMap<String, String>,
13565 _scopes: BTreeSet<String>,
13566}
13567
13568impl<'a, C> common::CallBuilder for ProjectInstanceBackupTestIamPermissionCall<'a, C> {}
13569
13570impl<'a, C> ProjectInstanceBackupTestIamPermissionCall<'a, C>
13571where
13572 C: common::Connector,
13573{
13574 /// Perform the operation you have build so far.
13575 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
13576 use std::borrow::Cow;
13577 use std::io::{Read, Seek};
13578
13579 use common::{url::Params, ToParts};
13580 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13581
13582 let mut dd = common::DefaultDelegate;
13583 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13584 dlg.begin(common::MethodInfo {
13585 id: "spanner.projects.instances.backups.testIamPermissions",
13586 http_method: hyper::Method::POST,
13587 });
13588
13589 for &field in ["alt", "resource"].iter() {
13590 if self._additional_params.contains_key(field) {
13591 dlg.finished(false);
13592 return Err(common::Error::FieldClash(field));
13593 }
13594 }
13595
13596 let mut params = Params::with_capacity(4 + self._additional_params.len());
13597 params.push("resource", self._resource);
13598
13599 params.extend(self._additional_params.iter());
13600
13601 params.push("alt", "json");
13602 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
13603 if self._scopes.is_empty() {
13604 self._scopes
13605 .insert(Scope::CloudPlatform.as_ref().to_string());
13606 }
13607
13608 #[allow(clippy::single_element_loop)]
13609 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
13610 url = params.uri_replacement(url, param_name, find_this, true);
13611 }
13612 {
13613 let to_remove = ["resource"];
13614 params.remove_params(&to_remove);
13615 }
13616
13617 let url = params.parse_with_url(&url);
13618
13619 let mut json_mime_type = mime::APPLICATION_JSON;
13620 let mut request_value_reader = {
13621 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13622 common::remove_json_null_values(&mut value);
13623 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13624 serde_json::to_writer(&mut dst, &value).unwrap();
13625 dst
13626 };
13627 let request_size = request_value_reader
13628 .seek(std::io::SeekFrom::End(0))
13629 .unwrap();
13630 request_value_reader
13631 .seek(std::io::SeekFrom::Start(0))
13632 .unwrap();
13633
13634 loop {
13635 let token = match self
13636 .hub
13637 .auth
13638 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13639 .await
13640 {
13641 Ok(token) => token,
13642 Err(e) => match dlg.token(e) {
13643 Ok(token) => token,
13644 Err(e) => {
13645 dlg.finished(false);
13646 return Err(common::Error::MissingToken(e));
13647 }
13648 },
13649 };
13650 request_value_reader
13651 .seek(std::io::SeekFrom::Start(0))
13652 .unwrap();
13653 let mut req_result = {
13654 let client = &self.hub.client;
13655 dlg.pre_request();
13656 let mut req_builder = hyper::Request::builder()
13657 .method(hyper::Method::POST)
13658 .uri(url.as_str())
13659 .header(USER_AGENT, self.hub._user_agent.clone());
13660
13661 if let Some(token) = token.as_ref() {
13662 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13663 }
13664
13665 let request = req_builder
13666 .header(CONTENT_TYPE, json_mime_type.to_string())
13667 .header(CONTENT_LENGTH, request_size as u64)
13668 .body(common::to_body(
13669 request_value_reader.get_ref().clone().into(),
13670 ));
13671
13672 client.request(request.unwrap()).await
13673 };
13674
13675 match req_result {
13676 Err(err) => {
13677 if let common::Retry::After(d) = dlg.http_error(&err) {
13678 sleep(d).await;
13679 continue;
13680 }
13681 dlg.finished(false);
13682 return Err(common::Error::HttpError(err));
13683 }
13684 Ok(res) => {
13685 let (mut parts, body) = res.into_parts();
13686 let mut body = common::Body::new(body);
13687 if !parts.status.is_success() {
13688 let bytes = common::to_bytes(body).await.unwrap_or_default();
13689 let error = serde_json::from_str(&common::to_string(&bytes));
13690 let response = common::to_response(parts, bytes.into());
13691
13692 if let common::Retry::After(d) =
13693 dlg.http_failure(&response, error.as_ref().ok())
13694 {
13695 sleep(d).await;
13696 continue;
13697 }
13698
13699 dlg.finished(false);
13700
13701 return Err(match error {
13702 Ok(value) => common::Error::BadRequest(value),
13703 _ => common::Error::Failure(response),
13704 });
13705 }
13706 let response = {
13707 let bytes = common::to_bytes(body).await.unwrap_or_default();
13708 let encoded = common::to_string(&bytes);
13709 match serde_json::from_str(&encoded) {
13710 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13711 Err(error) => {
13712 dlg.response_json_decode_error(&encoded, &error);
13713 return Err(common::Error::JsonDecodeError(
13714 encoded.to_string(),
13715 error,
13716 ));
13717 }
13718 }
13719 };
13720
13721 dlg.finished(true);
13722 return Ok(response);
13723 }
13724 }
13725 }
13726 }
13727
13728 ///
13729 /// Sets the *request* property to the given value.
13730 ///
13731 /// Even though the property as already been set when instantiating this call,
13732 /// we provide this method for API completeness.
13733 pub fn request(
13734 mut self,
13735 new_value: TestIamPermissionsRequest,
13736 ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
13737 self._request = new_value;
13738 self
13739 }
13740 /// 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.
13741 ///
13742 /// Sets the *resource* path property to the given value.
13743 ///
13744 /// Even though the property as already been set when instantiating this call,
13745 /// we provide this method for API completeness.
13746 pub fn resource(
13747 mut self,
13748 new_value: &str,
13749 ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
13750 self._resource = new_value.to_string();
13751 self
13752 }
13753 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13754 /// while executing the actual API request.
13755 ///
13756 /// ````text
13757 /// It should be used to handle progress information, and to implement a certain level of resilience.
13758 /// ````
13759 ///
13760 /// Sets the *delegate* property to the given value.
13761 pub fn delegate(
13762 mut self,
13763 new_value: &'a mut dyn common::Delegate,
13764 ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
13765 self._delegate = Some(new_value);
13766 self
13767 }
13768
13769 /// Set any additional parameter of the query string used in the request.
13770 /// It should be used to set parameters which are not yet available through their own
13771 /// setters.
13772 ///
13773 /// Please note that this method must not be used to set any of the known parameters
13774 /// which have their own setter method. If done anyway, the request will fail.
13775 ///
13776 /// # Additional Parameters
13777 ///
13778 /// * *$.xgafv* (query-string) - V1 error format.
13779 /// * *access_token* (query-string) - OAuth access token.
13780 /// * *alt* (query-string) - Data format for response.
13781 /// * *callback* (query-string) - JSONP
13782 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13783 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13784 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13785 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13786 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13787 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13788 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13789 pub fn param<T>(
13790 mut self,
13791 name: T,
13792 value: T,
13793 ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C>
13794 where
13795 T: AsRef<str>,
13796 {
13797 self._additional_params
13798 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13799 self
13800 }
13801
13802 /// Identifies the authorization scope for the method you are building.
13803 ///
13804 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13805 /// [`Scope::CloudPlatform`].
13806 ///
13807 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13808 /// tokens for more than one scope.
13809 ///
13810 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13811 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13812 /// sufficient, a read-write scope will do as well.
13813 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceBackupTestIamPermissionCall<'a, C>
13814 where
13815 St: AsRef<str>,
13816 {
13817 self._scopes.insert(String::from(scope.as_ref()));
13818 self
13819 }
13820 /// Identifies the authorization scope(s) for the method you are building.
13821 ///
13822 /// See [`Self::add_scope()`] for details.
13823 pub fn add_scopes<I, St>(
13824 mut self,
13825 scopes: I,
13826 ) -> ProjectInstanceBackupTestIamPermissionCall<'a, C>
13827 where
13828 I: IntoIterator<Item = St>,
13829 St: AsRef<str>,
13830 {
13831 self._scopes
13832 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13833 self
13834 }
13835
13836 /// Removes all scopes, and no default scope will be used either.
13837 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13838 /// for details).
13839 pub fn clear_scopes(mut self) -> ProjectInstanceBackupTestIamPermissionCall<'a, C> {
13840 self._scopes.clear();
13841 self
13842 }
13843}
13844
13845/// 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.
13846///
13847/// A builder for the *instances.databaseOperations.list* method supported by a *project* resource.
13848/// It is not used directly, but through a [`ProjectMethods`] instance.
13849///
13850/// # Example
13851///
13852/// Instantiate a resource method builder
13853///
13854/// ```test_harness,no_run
13855/// # extern crate hyper;
13856/// # extern crate hyper_rustls;
13857/// # extern crate google_spanner1 as spanner1;
13858/// # async fn dox() {
13859/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13860///
13861/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13862/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13863/// # secret,
13864/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13865/// # ).build().await.unwrap();
13866///
13867/// # let client = hyper_util::client::legacy::Client::builder(
13868/// # hyper_util::rt::TokioExecutor::new()
13869/// # )
13870/// # .build(
13871/// # hyper_rustls::HttpsConnectorBuilder::new()
13872/// # .with_native_roots()
13873/// # .unwrap()
13874/// # .https_or_http()
13875/// # .enable_http1()
13876/// # .build()
13877/// # );
13878/// # let mut hub = Spanner::new(client, auth);
13879/// // You can configure optional parameters by calling the respective setters at will, and
13880/// // execute the final call using `doit()`.
13881/// // Values shown here are possibly random and not representative !
13882/// let result = hub.projects().instances_database_operations_list("parent")
13883/// .page_token("elitr")
13884/// .page_size(-6)
13885/// .filter("diam")
13886/// .doit().await;
13887/// # }
13888/// ```
13889pub struct ProjectInstanceDatabaseOperationListCall<'a, C>
13890where
13891 C: 'a,
13892{
13893 hub: &'a Spanner<C>,
13894 _parent: String,
13895 _page_token: Option<String>,
13896 _page_size: Option<i32>,
13897 _filter: Option<String>,
13898 _delegate: Option<&'a mut dyn common::Delegate>,
13899 _additional_params: HashMap<String, String>,
13900 _scopes: BTreeSet<String>,
13901}
13902
13903impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationListCall<'a, C> {}
13904
13905impl<'a, C> ProjectInstanceDatabaseOperationListCall<'a, C>
13906where
13907 C: common::Connector,
13908{
13909 /// Perform the operation you have build so far.
13910 pub async fn doit(
13911 mut self,
13912 ) -> common::Result<(common::Response, ListDatabaseOperationsResponse)> {
13913 use std::borrow::Cow;
13914 use std::io::{Read, Seek};
13915
13916 use common::{url::Params, ToParts};
13917 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13918
13919 let mut dd = common::DefaultDelegate;
13920 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13921 dlg.begin(common::MethodInfo {
13922 id: "spanner.projects.instances.databaseOperations.list",
13923 http_method: hyper::Method::GET,
13924 });
13925
13926 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
13927 if self._additional_params.contains_key(field) {
13928 dlg.finished(false);
13929 return Err(common::Error::FieldClash(field));
13930 }
13931 }
13932
13933 let mut params = Params::with_capacity(6 + self._additional_params.len());
13934 params.push("parent", self._parent);
13935 if let Some(value) = self._page_token.as_ref() {
13936 params.push("pageToken", value);
13937 }
13938 if let Some(value) = self._page_size.as_ref() {
13939 params.push("pageSize", value.to_string());
13940 }
13941 if let Some(value) = self._filter.as_ref() {
13942 params.push("filter", value);
13943 }
13944
13945 params.extend(self._additional_params.iter());
13946
13947 params.push("alt", "json");
13948 let mut url = self.hub._base_url.clone() + "v1/{+parent}/databaseOperations";
13949 if self._scopes.is_empty() {
13950 self._scopes
13951 .insert(Scope::CloudPlatform.as_ref().to_string());
13952 }
13953
13954 #[allow(clippy::single_element_loop)]
13955 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13956 url = params.uri_replacement(url, param_name, find_this, true);
13957 }
13958 {
13959 let to_remove = ["parent"];
13960 params.remove_params(&to_remove);
13961 }
13962
13963 let url = params.parse_with_url(&url);
13964
13965 loop {
13966 let token = match self
13967 .hub
13968 .auth
13969 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13970 .await
13971 {
13972 Ok(token) => token,
13973 Err(e) => match dlg.token(e) {
13974 Ok(token) => token,
13975 Err(e) => {
13976 dlg.finished(false);
13977 return Err(common::Error::MissingToken(e));
13978 }
13979 },
13980 };
13981 let mut req_result = {
13982 let client = &self.hub.client;
13983 dlg.pre_request();
13984 let mut req_builder = hyper::Request::builder()
13985 .method(hyper::Method::GET)
13986 .uri(url.as_str())
13987 .header(USER_AGENT, self.hub._user_agent.clone());
13988
13989 if let Some(token) = token.as_ref() {
13990 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13991 }
13992
13993 let request = req_builder
13994 .header(CONTENT_LENGTH, 0_u64)
13995 .body(common::to_body::<String>(None));
13996
13997 client.request(request.unwrap()).await
13998 };
13999
14000 match req_result {
14001 Err(err) => {
14002 if let common::Retry::After(d) = dlg.http_error(&err) {
14003 sleep(d).await;
14004 continue;
14005 }
14006 dlg.finished(false);
14007 return Err(common::Error::HttpError(err));
14008 }
14009 Ok(res) => {
14010 let (mut parts, body) = res.into_parts();
14011 let mut body = common::Body::new(body);
14012 if !parts.status.is_success() {
14013 let bytes = common::to_bytes(body).await.unwrap_or_default();
14014 let error = serde_json::from_str(&common::to_string(&bytes));
14015 let response = common::to_response(parts, bytes.into());
14016
14017 if let common::Retry::After(d) =
14018 dlg.http_failure(&response, error.as_ref().ok())
14019 {
14020 sleep(d).await;
14021 continue;
14022 }
14023
14024 dlg.finished(false);
14025
14026 return Err(match error {
14027 Ok(value) => common::Error::BadRequest(value),
14028 _ => common::Error::Failure(response),
14029 });
14030 }
14031 let response = {
14032 let bytes = common::to_bytes(body).await.unwrap_or_default();
14033 let encoded = common::to_string(&bytes);
14034 match serde_json::from_str(&encoded) {
14035 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14036 Err(error) => {
14037 dlg.response_json_decode_error(&encoded, &error);
14038 return Err(common::Error::JsonDecodeError(
14039 encoded.to_string(),
14040 error,
14041 ));
14042 }
14043 }
14044 };
14045
14046 dlg.finished(true);
14047 return Ok(response);
14048 }
14049 }
14050 }
14051 }
14052
14053 /// Required. The instance of the database operations. Values are of the form `projects//instances/`.
14054 ///
14055 /// Sets the *parent* path property to the given value.
14056 ///
14057 /// Even though the property as already been set when instantiating this call,
14058 /// we provide this method for API completeness.
14059 pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
14060 self._parent = new_value.to_string();
14061 self
14062 }
14063 /// If non-empty, `page_token` should contain a next_page_token from a previous ListDatabaseOperationsResponse to the same `parent` and with the same `filter`.
14064 ///
14065 /// Sets the *page token* query property to the given value.
14066 pub fn page_token(
14067 mut self,
14068 new_value: &str,
14069 ) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
14070 self._page_token = Some(new_value.to_string());
14071 self
14072 }
14073 /// Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
14074 ///
14075 /// Sets the *page size* query property to the given value.
14076 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
14077 self._page_size = Some(new_value);
14078 self
14079 }
14080 /// 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.
14081 ///
14082 /// Sets the *filter* query property to the given value.
14083 pub fn filter(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
14084 self._filter = Some(new_value.to_string());
14085 self
14086 }
14087 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14088 /// while executing the actual API request.
14089 ///
14090 /// ````text
14091 /// It should be used to handle progress information, and to implement a certain level of resilience.
14092 /// ````
14093 ///
14094 /// Sets the *delegate* property to the given value.
14095 pub fn delegate(
14096 mut self,
14097 new_value: &'a mut dyn common::Delegate,
14098 ) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
14099 self._delegate = Some(new_value);
14100 self
14101 }
14102
14103 /// Set any additional parameter of the query string used in the request.
14104 /// It should be used to set parameters which are not yet available through their own
14105 /// setters.
14106 ///
14107 /// Please note that this method must not be used to set any of the known parameters
14108 /// which have their own setter method. If done anyway, the request will fail.
14109 ///
14110 /// # Additional Parameters
14111 ///
14112 /// * *$.xgafv* (query-string) - V1 error format.
14113 /// * *access_token* (query-string) - OAuth access token.
14114 /// * *alt* (query-string) - Data format for response.
14115 /// * *callback* (query-string) - JSONP
14116 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14117 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14118 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14119 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14120 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14121 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14122 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14123 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseOperationListCall<'a, C>
14124 where
14125 T: AsRef<str>,
14126 {
14127 self._additional_params
14128 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14129 self
14130 }
14131
14132 /// Identifies the authorization scope for the method you are building.
14133 ///
14134 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14135 /// [`Scope::CloudPlatform`].
14136 ///
14137 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14138 /// tokens for more than one scope.
14139 ///
14140 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14141 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14142 /// sufficient, a read-write scope will do as well.
14143 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationListCall<'a, C>
14144 where
14145 St: AsRef<str>,
14146 {
14147 self._scopes.insert(String::from(scope.as_ref()));
14148 self
14149 }
14150 /// Identifies the authorization scope(s) for the method you are building.
14151 ///
14152 /// See [`Self::add_scope()`] for details.
14153 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseOperationListCall<'a, C>
14154 where
14155 I: IntoIterator<Item = St>,
14156 St: AsRef<str>,
14157 {
14158 self._scopes
14159 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14160 self
14161 }
14162
14163 /// Removes all scopes, and no default scope will be used either.
14164 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14165 /// for details).
14166 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationListCall<'a, C> {
14167 self._scopes.clear();
14168 self
14169 }
14170}
14171
14172/// Lists Cloud Spanner database roles.
14173///
14174/// A builder for the *instances.databases.databaseRoles.list* method supported by a *project* resource.
14175/// It is not used directly, but through a [`ProjectMethods`] instance.
14176///
14177/// # Example
14178///
14179/// Instantiate a resource method builder
14180///
14181/// ```test_harness,no_run
14182/// # extern crate hyper;
14183/// # extern crate hyper_rustls;
14184/// # extern crate google_spanner1 as spanner1;
14185/// # async fn dox() {
14186/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14187///
14188/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14189/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14190/// # secret,
14191/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14192/// # ).build().await.unwrap();
14193///
14194/// # let client = hyper_util::client::legacy::Client::builder(
14195/// # hyper_util::rt::TokioExecutor::new()
14196/// # )
14197/// # .build(
14198/// # hyper_rustls::HttpsConnectorBuilder::new()
14199/// # .with_native_roots()
14200/// # .unwrap()
14201/// # .https_or_http()
14202/// # .enable_http1()
14203/// # .build()
14204/// # );
14205/// # let mut hub = Spanner::new(client, auth);
14206/// // You can configure optional parameters by calling the respective setters at will, and
14207/// // execute the final call using `doit()`.
14208/// // Values shown here are possibly random and not representative !
14209/// let result = hub.projects().instances_databases_database_roles_list("parent")
14210/// .page_token("ipsum")
14211/// .page_size(-23)
14212/// .doit().await;
14213/// # }
14214/// ```
14215pub struct ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
14216where
14217 C: 'a,
14218{
14219 hub: &'a Spanner<C>,
14220 _parent: String,
14221 _page_token: Option<String>,
14222 _page_size: Option<i32>,
14223 _delegate: Option<&'a mut dyn common::Delegate>,
14224 _additional_params: HashMap<String, String>,
14225 _scopes: BTreeSet<String>,
14226}
14227
14228impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {}
14229
14230impl<'a, C> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
14231where
14232 C: common::Connector,
14233{
14234 /// Perform the operation you have build so far.
14235 pub async fn doit(mut self) -> common::Result<(common::Response, ListDatabaseRolesResponse)> {
14236 use std::borrow::Cow;
14237 use std::io::{Read, Seek};
14238
14239 use common::{url::Params, ToParts};
14240 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14241
14242 let mut dd = common::DefaultDelegate;
14243 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14244 dlg.begin(common::MethodInfo {
14245 id: "spanner.projects.instances.databases.databaseRoles.list",
14246 http_method: hyper::Method::GET,
14247 });
14248
14249 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
14250 if self._additional_params.contains_key(field) {
14251 dlg.finished(false);
14252 return Err(common::Error::FieldClash(field));
14253 }
14254 }
14255
14256 let mut params = Params::with_capacity(5 + self._additional_params.len());
14257 params.push("parent", self._parent);
14258 if let Some(value) = self._page_token.as_ref() {
14259 params.push("pageToken", value);
14260 }
14261 if let Some(value) = self._page_size.as_ref() {
14262 params.push("pageSize", value.to_string());
14263 }
14264
14265 params.extend(self._additional_params.iter());
14266
14267 params.push("alt", "json");
14268 let mut url = self.hub._base_url.clone() + "v1/{+parent}/databaseRoles";
14269 if self._scopes.is_empty() {
14270 self._scopes
14271 .insert(Scope::CloudPlatform.as_ref().to_string());
14272 }
14273
14274 #[allow(clippy::single_element_loop)]
14275 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14276 url = params.uri_replacement(url, param_name, find_this, true);
14277 }
14278 {
14279 let to_remove = ["parent"];
14280 params.remove_params(&to_remove);
14281 }
14282
14283 let url = params.parse_with_url(&url);
14284
14285 loop {
14286 let token = match self
14287 .hub
14288 .auth
14289 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14290 .await
14291 {
14292 Ok(token) => token,
14293 Err(e) => match dlg.token(e) {
14294 Ok(token) => token,
14295 Err(e) => {
14296 dlg.finished(false);
14297 return Err(common::Error::MissingToken(e));
14298 }
14299 },
14300 };
14301 let mut req_result = {
14302 let client = &self.hub.client;
14303 dlg.pre_request();
14304 let mut req_builder = hyper::Request::builder()
14305 .method(hyper::Method::GET)
14306 .uri(url.as_str())
14307 .header(USER_AGENT, self.hub._user_agent.clone());
14308
14309 if let Some(token) = token.as_ref() {
14310 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14311 }
14312
14313 let request = req_builder
14314 .header(CONTENT_LENGTH, 0_u64)
14315 .body(common::to_body::<String>(None));
14316
14317 client.request(request.unwrap()).await
14318 };
14319
14320 match req_result {
14321 Err(err) => {
14322 if let common::Retry::After(d) = dlg.http_error(&err) {
14323 sleep(d).await;
14324 continue;
14325 }
14326 dlg.finished(false);
14327 return Err(common::Error::HttpError(err));
14328 }
14329 Ok(res) => {
14330 let (mut parts, body) = res.into_parts();
14331 let mut body = common::Body::new(body);
14332 if !parts.status.is_success() {
14333 let bytes = common::to_bytes(body).await.unwrap_or_default();
14334 let error = serde_json::from_str(&common::to_string(&bytes));
14335 let response = common::to_response(parts, bytes.into());
14336
14337 if let common::Retry::After(d) =
14338 dlg.http_failure(&response, error.as_ref().ok())
14339 {
14340 sleep(d).await;
14341 continue;
14342 }
14343
14344 dlg.finished(false);
14345
14346 return Err(match error {
14347 Ok(value) => common::Error::BadRequest(value),
14348 _ => common::Error::Failure(response),
14349 });
14350 }
14351 let response = {
14352 let bytes = common::to_bytes(body).await.unwrap_or_default();
14353 let encoded = common::to_string(&bytes);
14354 match serde_json::from_str(&encoded) {
14355 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14356 Err(error) => {
14357 dlg.response_json_decode_error(&encoded, &error);
14358 return Err(common::Error::JsonDecodeError(
14359 encoded.to_string(),
14360 error,
14361 ));
14362 }
14363 }
14364 };
14365
14366 dlg.finished(true);
14367 return Ok(response);
14368 }
14369 }
14370 }
14371 }
14372
14373 /// Required. The database whose roles should be listed. Values are of the form `projects//instances//databases/`.
14374 ///
14375 /// Sets the *parent* path property to the given value.
14376 ///
14377 /// Even though the property as already been set when instantiating this call,
14378 /// we provide this method for API completeness.
14379 pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
14380 self._parent = new_value.to_string();
14381 self
14382 }
14383 /// If non-empty, `page_token` should contain a next_page_token from a previous ListDatabaseRolesResponse.
14384 ///
14385 /// Sets the *page token* query property to the given value.
14386 pub fn page_token(
14387 mut self,
14388 new_value: &str,
14389 ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
14390 self._page_token = Some(new_value.to_string());
14391 self
14392 }
14393 /// Number of database roles to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
14394 ///
14395 /// Sets the *page size* query property to the given value.
14396 pub fn page_size(
14397 mut self,
14398 new_value: i32,
14399 ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
14400 self._page_size = Some(new_value);
14401 self
14402 }
14403 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14404 /// while executing the actual API request.
14405 ///
14406 /// ````text
14407 /// It should be used to handle progress information, and to implement a certain level of resilience.
14408 /// ````
14409 ///
14410 /// Sets the *delegate* property to the given value.
14411 pub fn delegate(
14412 mut self,
14413 new_value: &'a mut dyn common::Delegate,
14414 ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
14415 self._delegate = Some(new_value);
14416 self
14417 }
14418
14419 /// Set any additional parameter of the query string used in the request.
14420 /// It should be used to set parameters which are not yet available through their own
14421 /// setters.
14422 ///
14423 /// Please note that this method must not be used to set any of the known parameters
14424 /// which have their own setter method. If done anyway, the request will fail.
14425 ///
14426 /// # Additional Parameters
14427 ///
14428 /// * *$.xgafv* (query-string) - V1 error format.
14429 /// * *access_token* (query-string) - OAuth access token.
14430 /// * *alt* (query-string) - Data format for response.
14431 /// * *callback* (query-string) - JSONP
14432 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14433 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14434 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14435 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14436 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14437 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14438 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14439 pub fn param<T>(
14440 mut self,
14441 name: T,
14442 value: T,
14443 ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
14444 where
14445 T: AsRef<str>,
14446 {
14447 self._additional_params
14448 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14449 self
14450 }
14451
14452 /// Identifies the authorization scope for the method you are building.
14453 ///
14454 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14455 /// [`Scope::CloudPlatform`].
14456 ///
14457 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14458 /// tokens for more than one scope.
14459 ///
14460 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14461 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14462 /// sufficient, a read-write scope will do as well.
14463 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
14464 where
14465 St: AsRef<str>,
14466 {
14467 self._scopes.insert(String::from(scope.as_ref()));
14468 self
14469 }
14470 /// Identifies the authorization scope(s) for the method you are building.
14471 ///
14472 /// See [`Self::add_scope()`] for details.
14473 pub fn add_scopes<I, St>(
14474 mut self,
14475 scopes: I,
14476 ) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C>
14477 where
14478 I: IntoIterator<Item = St>,
14479 St: AsRef<str>,
14480 {
14481 self._scopes
14482 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14483 self
14484 }
14485
14486 /// Removes all scopes, and no default scope will be used either.
14487 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14488 /// for details).
14489 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseDatabaseRoleListCall<'a, C> {
14490 self._scopes.clear();
14491 self
14492 }
14493}
14494
14495/// 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.
14496///
14497/// A builder for the *instances.databases.databaseRoles.testIamPermissions* method supported by a *project* resource.
14498/// It is not used directly, but through a [`ProjectMethods`] instance.
14499///
14500/// # Example
14501///
14502/// Instantiate a resource method builder
14503///
14504/// ```test_harness,no_run
14505/// # extern crate hyper;
14506/// # extern crate hyper_rustls;
14507/// # extern crate google_spanner1 as spanner1;
14508/// use spanner1::api::TestIamPermissionsRequest;
14509/// # async fn dox() {
14510/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14511///
14512/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14513/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14514/// # secret,
14515/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14516/// # ).build().await.unwrap();
14517///
14518/// # let client = hyper_util::client::legacy::Client::builder(
14519/// # hyper_util::rt::TokioExecutor::new()
14520/// # )
14521/// # .build(
14522/// # hyper_rustls::HttpsConnectorBuilder::new()
14523/// # .with_native_roots()
14524/// # .unwrap()
14525/// # .https_or_http()
14526/// # .enable_http1()
14527/// # .build()
14528/// # );
14529/// # let mut hub = Spanner::new(client, auth);
14530/// // As the method needs a request, you would usually fill it with the desired information
14531/// // into the respective structure. Some of the parts shown here might not be applicable !
14532/// // Values shown here are possibly random and not representative !
14533/// let mut req = TestIamPermissionsRequest::default();
14534///
14535/// // You can configure optional parameters by calling the respective setters at will, and
14536/// // execute the final call using `doit()`.
14537/// // Values shown here are possibly random and not representative !
14538/// let result = hub.projects().instances_databases_database_roles_test_iam_permissions(req, "resource")
14539/// .doit().await;
14540/// # }
14541/// ```
14542pub struct ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
14543where
14544 C: 'a,
14545{
14546 hub: &'a Spanner<C>,
14547 _request: TestIamPermissionsRequest,
14548 _resource: String,
14549 _delegate: Option<&'a mut dyn common::Delegate>,
14550 _additional_params: HashMap<String, String>,
14551 _scopes: BTreeSet<String>,
14552}
14553
14554impl<'a, C> common::CallBuilder
14555 for ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
14556{
14557}
14558
14559impl<'a, C> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
14560where
14561 C: common::Connector,
14562{
14563 /// Perform the operation you have build so far.
14564 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
14565 use std::borrow::Cow;
14566 use std::io::{Read, Seek};
14567
14568 use common::{url::Params, ToParts};
14569 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14570
14571 let mut dd = common::DefaultDelegate;
14572 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14573 dlg.begin(common::MethodInfo {
14574 id: "spanner.projects.instances.databases.databaseRoles.testIamPermissions",
14575 http_method: hyper::Method::POST,
14576 });
14577
14578 for &field in ["alt", "resource"].iter() {
14579 if self._additional_params.contains_key(field) {
14580 dlg.finished(false);
14581 return Err(common::Error::FieldClash(field));
14582 }
14583 }
14584
14585 let mut params = Params::with_capacity(4 + self._additional_params.len());
14586 params.push("resource", self._resource);
14587
14588 params.extend(self._additional_params.iter());
14589
14590 params.push("alt", "json");
14591 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
14592 if self._scopes.is_empty() {
14593 self._scopes
14594 .insert(Scope::CloudPlatform.as_ref().to_string());
14595 }
14596
14597 #[allow(clippy::single_element_loop)]
14598 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
14599 url = params.uri_replacement(url, param_name, find_this, true);
14600 }
14601 {
14602 let to_remove = ["resource"];
14603 params.remove_params(&to_remove);
14604 }
14605
14606 let url = params.parse_with_url(&url);
14607
14608 let mut json_mime_type = mime::APPLICATION_JSON;
14609 let mut request_value_reader = {
14610 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14611 common::remove_json_null_values(&mut value);
14612 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14613 serde_json::to_writer(&mut dst, &value).unwrap();
14614 dst
14615 };
14616 let request_size = request_value_reader
14617 .seek(std::io::SeekFrom::End(0))
14618 .unwrap();
14619 request_value_reader
14620 .seek(std::io::SeekFrom::Start(0))
14621 .unwrap();
14622
14623 loop {
14624 let token = match self
14625 .hub
14626 .auth
14627 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14628 .await
14629 {
14630 Ok(token) => token,
14631 Err(e) => match dlg.token(e) {
14632 Ok(token) => token,
14633 Err(e) => {
14634 dlg.finished(false);
14635 return Err(common::Error::MissingToken(e));
14636 }
14637 },
14638 };
14639 request_value_reader
14640 .seek(std::io::SeekFrom::Start(0))
14641 .unwrap();
14642 let mut req_result = {
14643 let client = &self.hub.client;
14644 dlg.pre_request();
14645 let mut req_builder = hyper::Request::builder()
14646 .method(hyper::Method::POST)
14647 .uri(url.as_str())
14648 .header(USER_AGENT, self.hub._user_agent.clone());
14649
14650 if let Some(token) = token.as_ref() {
14651 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14652 }
14653
14654 let request = req_builder
14655 .header(CONTENT_TYPE, json_mime_type.to_string())
14656 .header(CONTENT_LENGTH, request_size as u64)
14657 .body(common::to_body(
14658 request_value_reader.get_ref().clone().into(),
14659 ));
14660
14661 client.request(request.unwrap()).await
14662 };
14663
14664 match req_result {
14665 Err(err) => {
14666 if let common::Retry::After(d) = dlg.http_error(&err) {
14667 sleep(d).await;
14668 continue;
14669 }
14670 dlg.finished(false);
14671 return Err(common::Error::HttpError(err));
14672 }
14673 Ok(res) => {
14674 let (mut parts, body) = res.into_parts();
14675 let mut body = common::Body::new(body);
14676 if !parts.status.is_success() {
14677 let bytes = common::to_bytes(body).await.unwrap_or_default();
14678 let error = serde_json::from_str(&common::to_string(&bytes));
14679 let response = common::to_response(parts, bytes.into());
14680
14681 if let common::Retry::After(d) =
14682 dlg.http_failure(&response, error.as_ref().ok())
14683 {
14684 sleep(d).await;
14685 continue;
14686 }
14687
14688 dlg.finished(false);
14689
14690 return Err(match error {
14691 Ok(value) => common::Error::BadRequest(value),
14692 _ => common::Error::Failure(response),
14693 });
14694 }
14695 let response = {
14696 let bytes = common::to_bytes(body).await.unwrap_or_default();
14697 let encoded = common::to_string(&bytes);
14698 match serde_json::from_str(&encoded) {
14699 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14700 Err(error) => {
14701 dlg.response_json_decode_error(&encoded, &error);
14702 return Err(common::Error::JsonDecodeError(
14703 encoded.to_string(),
14704 error,
14705 ));
14706 }
14707 }
14708 };
14709
14710 dlg.finished(true);
14711 return Ok(response);
14712 }
14713 }
14714 }
14715 }
14716
14717 ///
14718 /// Sets the *request* property to the given value.
14719 ///
14720 /// Even though the property as already been set when instantiating this call,
14721 /// we provide this method for API completeness.
14722 pub fn request(
14723 mut self,
14724 new_value: TestIamPermissionsRequest,
14725 ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
14726 self._request = new_value;
14727 self
14728 }
14729 /// 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.
14730 ///
14731 /// Sets the *resource* path property to the given value.
14732 ///
14733 /// Even though the property as already been set when instantiating this call,
14734 /// we provide this method for API completeness.
14735 pub fn resource(
14736 mut self,
14737 new_value: &str,
14738 ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
14739 self._resource = new_value.to_string();
14740 self
14741 }
14742 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14743 /// while executing the actual API request.
14744 ///
14745 /// ````text
14746 /// It should be used to handle progress information, and to implement a certain level of resilience.
14747 /// ````
14748 ///
14749 /// Sets the *delegate* property to the given value.
14750 pub fn delegate(
14751 mut self,
14752 new_value: &'a mut dyn common::Delegate,
14753 ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
14754 self._delegate = Some(new_value);
14755 self
14756 }
14757
14758 /// Set any additional parameter of the query string used in the request.
14759 /// It should be used to set parameters which are not yet available through their own
14760 /// setters.
14761 ///
14762 /// Please note that this method must not be used to set any of the known parameters
14763 /// which have their own setter method. If done anyway, the request will fail.
14764 ///
14765 /// # Additional Parameters
14766 ///
14767 /// * *$.xgafv* (query-string) - V1 error format.
14768 /// * *access_token* (query-string) - OAuth access token.
14769 /// * *alt* (query-string) - Data format for response.
14770 /// * *callback* (query-string) - JSONP
14771 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14772 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14773 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14774 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14775 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14776 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14777 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14778 pub fn param<T>(
14779 mut self,
14780 name: T,
14781 value: T,
14782 ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
14783 where
14784 T: AsRef<str>,
14785 {
14786 self._additional_params
14787 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14788 self
14789 }
14790
14791 /// Identifies the authorization scope for the method you are building.
14792 ///
14793 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14794 /// [`Scope::CloudPlatform`].
14795 ///
14796 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14797 /// tokens for more than one scope.
14798 ///
14799 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14800 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14801 /// sufficient, a read-write scope will do as well.
14802 pub fn add_scope<St>(
14803 mut self,
14804 scope: St,
14805 ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
14806 where
14807 St: AsRef<str>,
14808 {
14809 self._scopes.insert(String::from(scope.as_ref()));
14810 self
14811 }
14812 /// Identifies the authorization scope(s) for the method you are building.
14813 ///
14814 /// See [`Self::add_scope()`] for details.
14815 pub fn add_scopes<I, St>(
14816 mut self,
14817 scopes: I,
14818 ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C>
14819 where
14820 I: IntoIterator<Item = St>,
14821 St: AsRef<str>,
14822 {
14823 self._scopes
14824 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14825 self
14826 }
14827
14828 /// Removes all scopes, and no default scope will be used either.
14829 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14830 /// for details).
14831 pub fn clear_scopes(
14832 mut self,
14833 ) -> ProjectInstanceDatabaseDatabaseRoleTestIamPermissionCall<'a, C> {
14834 self._scopes.clear();
14835 self
14836 }
14837}
14838
14839/// 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`.
14840///
14841/// A builder for the *instances.databases.operations.cancel* method supported by a *project* resource.
14842/// It is not used directly, but through a [`ProjectMethods`] instance.
14843///
14844/// # Example
14845///
14846/// Instantiate a resource method builder
14847///
14848/// ```test_harness,no_run
14849/// # extern crate hyper;
14850/// # extern crate hyper_rustls;
14851/// # extern crate google_spanner1 as spanner1;
14852/// # async fn dox() {
14853/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14854///
14855/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14857/// # secret,
14858/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14859/// # ).build().await.unwrap();
14860///
14861/// # let client = hyper_util::client::legacy::Client::builder(
14862/// # hyper_util::rt::TokioExecutor::new()
14863/// # )
14864/// # .build(
14865/// # hyper_rustls::HttpsConnectorBuilder::new()
14866/// # .with_native_roots()
14867/// # .unwrap()
14868/// # .https_or_http()
14869/// # .enable_http1()
14870/// # .build()
14871/// # );
14872/// # let mut hub = Spanner::new(client, auth);
14873/// // You can configure optional parameters by calling the respective setters at will, and
14874/// // execute the final call using `doit()`.
14875/// // Values shown here are possibly random and not representative !
14876/// let result = hub.projects().instances_databases_operations_cancel("name")
14877/// .doit().await;
14878/// # }
14879/// ```
14880pub struct ProjectInstanceDatabaseOperationCancelCall<'a, C>
14881where
14882 C: 'a,
14883{
14884 hub: &'a Spanner<C>,
14885 _name: String,
14886 _delegate: Option<&'a mut dyn common::Delegate>,
14887 _additional_params: HashMap<String, String>,
14888 _scopes: BTreeSet<String>,
14889}
14890
14891impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationCancelCall<'a, C> {}
14892
14893impl<'a, C> ProjectInstanceDatabaseOperationCancelCall<'a, C>
14894where
14895 C: common::Connector,
14896{
14897 /// Perform the operation you have build so far.
14898 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
14899 use std::borrow::Cow;
14900 use std::io::{Read, Seek};
14901
14902 use common::{url::Params, ToParts};
14903 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14904
14905 let mut dd = common::DefaultDelegate;
14906 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14907 dlg.begin(common::MethodInfo {
14908 id: "spanner.projects.instances.databases.operations.cancel",
14909 http_method: hyper::Method::POST,
14910 });
14911
14912 for &field in ["alt", "name"].iter() {
14913 if self._additional_params.contains_key(field) {
14914 dlg.finished(false);
14915 return Err(common::Error::FieldClash(field));
14916 }
14917 }
14918
14919 let mut params = Params::with_capacity(3 + self._additional_params.len());
14920 params.push("name", self._name);
14921
14922 params.extend(self._additional_params.iter());
14923
14924 params.push("alt", "json");
14925 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
14926 if self._scopes.is_empty() {
14927 self._scopes
14928 .insert(Scope::CloudPlatform.as_ref().to_string());
14929 }
14930
14931 #[allow(clippy::single_element_loop)]
14932 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14933 url = params.uri_replacement(url, param_name, find_this, true);
14934 }
14935 {
14936 let to_remove = ["name"];
14937 params.remove_params(&to_remove);
14938 }
14939
14940 let url = params.parse_with_url(&url);
14941
14942 loop {
14943 let token = match self
14944 .hub
14945 .auth
14946 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14947 .await
14948 {
14949 Ok(token) => token,
14950 Err(e) => match dlg.token(e) {
14951 Ok(token) => token,
14952 Err(e) => {
14953 dlg.finished(false);
14954 return Err(common::Error::MissingToken(e));
14955 }
14956 },
14957 };
14958 let mut req_result = {
14959 let client = &self.hub.client;
14960 dlg.pre_request();
14961 let mut req_builder = hyper::Request::builder()
14962 .method(hyper::Method::POST)
14963 .uri(url.as_str())
14964 .header(USER_AGENT, self.hub._user_agent.clone());
14965
14966 if let Some(token) = token.as_ref() {
14967 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14968 }
14969
14970 let request = req_builder
14971 .header(CONTENT_LENGTH, 0_u64)
14972 .body(common::to_body::<String>(None));
14973
14974 client.request(request.unwrap()).await
14975 };
14976
14977 match req_result {
14978 Err(err) => {
14979 if let common::Retry::After(d) = dlg.http_error(&err) {
14980 sleep(d).await;
14981 continue;
14982 }
14983 dlg.finished(false);
14984 return Err(common::Error::HttpError(err));
14985 }
14986 Ok(res) => {
14987 let (mut parts, body) = res.into_parts();
14988 let mut body = common::Body::new(body);
14989 if !parts.status.is_success() {
14990 let bytes = common::to_bytes(body).await.unwrap_or_default();
14991 let error = serde_json::from_str(&common::to_string(&bytes));
14992 let response = common::to_response(parts, bytes.into());
14993
14994 if let common::Retry::After(d) =
14995 dlg.http_failure(&response, error.as_ref().ok())
14996 {
14997 sleep(d).await;
14998 continue;
14999 }
15000
15001 dlg.finished(false);
15002
15003 return Err(match error {
15004 Ok(value) => common::Error::BadRequest(value),
15005 _ => common::Error::Failure(response),
15006 });
15007 }
15008 let response = {
15009 let bytes = common::to_bytes(body).await.unwrap_or_default();
15010 let encoded = common::to_string(&bytes);
15011 match serde_json::from_str(&encoded) {
15012 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15013 Err(error) => {
15014 dlg.response_json_decode_error(&encoded, &error);
15015 return Err(common::Error::JsonDecodeError(
15016 encoded.to_string(),
15017 error,
15018 ));
15019 }
15020 }
15021 };
15022
15023 dlg.finished(true);
15024 return Ok(response);
15025 }
15026 }
15027 }
15028 }
15029
15030 /// The name of the operation resource to be cancelled.
15031 ///
15032 /// Sets the *name* path property to the given value.
15033 ///
15034 /// Even though the property as already been set when instantiating this call,
15035 /// we provide this method for API completeness.
15036 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationCancelCall<'a, C> {
15037 self._name = new_value.to_string();
15038 self
15039 }
15040 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15041 /// while executing the actual API request.
15042 ///
15043 /// ````text
15044 /// It should be used to handle progress information, and to implement a certain level of resilience.
15045 /// ````
15046 ///
15047 /// Sets the *delegate* property to the given value.
15048 pub fn delegate(
15049 mut self,
15050 new_value: &'a mut dyn common::Delegate,
15051 ) -> ProjectInstanceDatabaseOperationCancelCall<'a, C> {
15052 self._delegate = Some(new_value);
15053 self
15054 }
15055
15056 /// Set any additional parameter of the query string used in the request.
15057 /// It should be used to set parameters which are not yet available through their own
15058 /// setters.
15059 ///
15060 /// Please note that this method must not be used to set any of the known parameters
15061 /// which have their own setter method. If done anyway, the request will fail.
15062 ///
15063 /// # Additional Parameters
15064 ///
15065 /// * *$.xgafv* (query-string) - V1 error format.
15066 /// * *access_token* (query-string) - OAuth access token.
15067 /// * *alt* (query-string) - Data format for response.
15068 /// * *callback* (query-string) - JSONP
15069 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15070 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15071 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15072 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15073 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15074 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15075 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15076 pub fn param<T>(
15077 mut self,
15078 name: T,
15079 value: T,
15080 ) -> ProjectInstanceDatabaseOperationCancelCall<'a, C>
15081 where
15082 T: AsRef<str>,
15083 {
15084 self._additional_params
15085 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15086 self
15087 }
15088
15089 /// Identifies the authorization scope for the method you are building.
15090 ///
15091 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15092 /// [`Scope::CloudPlatform`].
15093 ///
15094 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15095 /// tokens for more than one scope.
15096 ///
15097 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15098 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15099 /// sufficient, a read-write scope will do as well.
15100 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationCancelCall<'a, C>
15101 where
15102 St: AsRef<str>,
15103 {
15104 self._scopes.insert(String::from(scope.as_ref()));
15105 self
15106 }
15107 /// Identifies the authorization scope(s) for the method you are building.
15108 ///
15109 /// See [`Self::add_scope()`] for details.
15110 pub fn add_scopes<I, St>(
15111 mut self,
15112 scopes: I,
15113 ) -> ProjectInstanceDatabaseOperationCancelCall<'a, C>
15114 where
15115 I: IntoIterator<Item = St>,
15116 St: AsRef<str>,
15117 {
15118 self._scopes
15119 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15120 self
15121 }
15122
15123 /// Removes all scopes, and no default scope will be used either.
15124 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15125 /// for details).
15126 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationCancelCall<'a, C> {
15127 self._scopes.clear();
15128 self
15129 }
15130}
15131
15132/// 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`.
15133///
15134/// A builder for the *instances.databases.operations.delete* method supported by a *project* resource.
15135/// It is not used directly, but through a [`ProjectMethods`] instance.
15136///
15137/// # Example
15138///
15139/// Instantiate a resource method builder
15140///
15141/// ```test_harness,no_run
15142/// # extern crate hyper;
15143/// # extern crate hyper_rustls;
15144/// # extern crate google_spanner1 as spanner1;
15145/// # async fn dox() {
15146/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15147///
15148/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15149/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15150/// # secret,
15151/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15152/// # ).build().await.unwrap();
15153///
15154/// # let client = hyper_util::client::legacy::Client::builder(
15155/// # hyper_util::rt::TokioExecutor::new()
15156/// # )
15157/// # .build(
15158/// # hyper_rustls::HttpsConnectorBuilder::new()
15159/// # .with_native_roots()
15160/// # .unwrap()
15161/// # .https_or_http()
15162/// # .enable_http1()
15163/// # .build()
15164/// # );
15165/// # let mut hub = Spanner::new(client, auth);
15166/// // You can configure optional parameters by calling the respective setters at will, and
15167/// // execute the final call using `doit()`.
15168/// // Values shown here are possibly random and not representative !
15169/// let result = hub.projects().instances_databases_operations_delete("name")
15170/// .doit().await;
15171/// # }
15172/// ```
15173pub struct ProjectInstanceDatabaseOperationDeleteCall<'a, C>
15174where
15175 C: 'a,
15176{
15177 hub: &'a Spanner<C>,
15178 _name: String,
15179 _delegate: Option<&'a mut dyn common::Delegate>,
15180 _additional_params: HashMap<String, String>,
15181 _scopes: BTreeSet<String>,
15182}
15183
15184impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationDeleteCall<'a, C> {}
15185
15186impl<'a, C> ProjectInstanceDatabaseOperationDeleteCall<'a, C>
15187where
15188 C: common::Connector,
15189{
15190 /// Perform the operation you have build so far.
15191 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15192 use std::borrow::Cow;
15193 use std::io::{Read, Seek};
15194
15195 use common::{url::Params, ToParts};
15196 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15197
15198 let mut dd = common::DefaultDelegate;
15199 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15200 dlg.begin(common::MethodInfo {
15201 id: "spanner.projects.instances.databases.operations.delete",
15202 http_method: hyper::Method::DELETE,
15203 });
15204
15205 for &field in ["alt", "name"].iter() {
15206 if self._additional_params.contains_key(field) {
15207 dlg.finished(false);
15208 return Err(common::Error::FieldClash(field));
15209 }
15210 }
15211
15212 let mut params = Params::with_capacity(3 + self._additional_params.len());
15213 params.push("name", self._name);
15214
15215 params.extend(self._additional_params.iter());
15216
15217 params.push("alt", "json");
15218 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15219 if self._scopes.is_empty() {
15220 self._scopes
15221 .insert(Scope::CloudPlatform.as_ref().to_string());
15222 }
15223
15224 #[allow(clippy::single_element_loop)]
15225 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15226 url = params.uri_replacement(url, param_name, find_this, true);
15227 }
15228 {
15229 let to_remove = ["name"];
15230 params.remove_params(&to_remove);
15231 }
15232
15233 let url = params.parse_with_url(&url);
15234
15235 loop {
15236 let token = match self
15237 .hub
15238 .auth
15239 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15240 .await
15241 {
15242 Ok(token) => token,
15243 Err(e) => match dlg.token(e) {
15244 Ok(token) => token,
15245 Err(e) => {
15246 dlg.finished(false);
15247 return Err(common::Error::MissingToken(e));
15248 }
15249 },
15250 };
15251 let mut req_result = {
15252 let client = &self.hub.client;
15253 dlg.pre_request();
15254 let mut req_builder = hyper::Request::builder()
15255 .method(hyper::Method::DELETE)
15256 .uri(url.as_str())
15257 .header(USER_AGENT, self.hub._user_agent.clone());
15258
15259 if let Some(token) = token.as_ref() {
15260 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15261 }
15262
15263 let request = req_builder
15264 .header(CONTENT_LENGTH, 0_u64)
15265 .body(common::to_body::<String>(None));
15266
15267 client.request(request.unwrap()).await
15268 };
15269
15270 match req_result {
15271 Err(err) => {
15272 if let common::Retry::After(d) = dlg.http_error(&err) {
15273 sleep(d).await;
15274 continue;
15275 }
15276 dlg.finished(false);
15277 return Err(common::Error::HttpError(err));
15278 }
15279 Ok(res) => {
15280 let (mut parts, body) = res.into_parts();
15281 let mut body = common::Body::new(body);
15282 if !parts.status.is_success() {
15283 let bytes = common::to_bytes(body).await.unwrap_or_default();
15284 let error = serde_json::from_str(&common::to_string(&bytes));
15285 let response = common::to_response(parts, bytes.into());
15286
15287 if let common::Retry::After(d) =
15288 dlg.http_failure(&response, error.as_ref().ok())
15289 {
15290 sleep(d).await;
15291 continue;
15292 }
15293
15294 dlg.finished(false);
15295
15296 return Err(match error {
15297 Ok(value) => common::Error::BadRequest(value),
15298 _ => common::Error::Failure(response),
15299 });
15300 }
15301 let response = {
15302 let bytes = common::to_bytes(body).await.unwrap_or_default();
15303 let encoded = common::to_string(&bytes);
15304 match serde_json::from_str(&encoded) {
15305 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15306 Err(error) => {
15307 dlg.response_json_decode_error(&encoded, &error);
15308 return Err(common::Error::JsonDecodeError(
15309 encoded.to_string(),
15310 error,
15311 ));
15312 }
15313 }
15314 };
15315
15316 dlg.finished(true);
15317 return Ok(response);
15318 }
15319 }
15320 }
15321 }
15322
15323 /// The name of the operation resource to be deleted.
15324 ///
15325 /// Sets the *name* path property to the given value.
15326 ///
15327 /// Even though the property as already been set when instantiating this call,
15328 /// we provide this method for API completeness.
15329 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C> {
15330 self._name = new_value.to_string();
15331 self
15332 }
15333 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15334 /// while executing the actual API request.
15335 ///
15336 /// ````text
15337 /// It should be used to handle progress information, and to implement a certain level of resilience.
15338 /// ````
15339 ///
15340 /// Sets the *delegate* property to the given value.
15341 pub fn delegate(
15342 mut self,
15343 new_value: &'a mut dyn common::Delegate,
15344 ) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C> {
15345 self._delegate = Some(new_value);
15346 self
15347 }
15348
15349 /// Set any additional parameter of the query string used in the request.
15350 /// It should be used to set parameters which are not yet available through their own
15351 /// setters.
15352 ///
15353 /// Please note that this method must not be used to set any of the known parameters
15354 /// which have their own setter method. If done anyway, the request will fail.
15355 ///
15356 /// # Additional Parameters
15357 ///
15358 /// * *$.xgafv* (query-string) - V1 error format.
15359 /// * *access_token* (query-string) - OAuth access token.
15360 /// * *alt* (query-string) - Data format for response.
15361 /// * *callback* (query-string) - JSONP
15362 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15363 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15364 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15365 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15366 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15367 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15368 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15369 pub fn param<T>(
15370 mut self,
15371 name: T,
15372 value: T,
15373 ) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C>
15374 where
15375 T: AsRef<str>,
15376 {
15377 self._additional_params
15378 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15379 self
15380 }
15381
15382 /// Identifies the authorization scope for the method you are building.
15383 ///
15384 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15385 /// [`Scope::CloudPlatform`].
15386 ///
15387 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15388 /// tokens for more than one scope.
15389 ///
15390 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15391 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15392 /// sufficient, a read-write scope will do as well.
15393 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C>
15394 where
15395 St: AsRef<str>,
15396 {
15397 self._scopes.insert(String::from(scope.as_ref()));
15398 self
15399 }
15400 /// Identifies the authorization scope(s) for the method you are building.
15401 ///
15402 /// See [`Self::add_scope()`] for details.
15403 pub fn add_scopes<I, St>(
15404 mut self,
15405 scopes: I,
15406 ) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C>
15407 where
15408 I: IntoIterator<Item = St>,
15409 St: AsRef<str>,
15410 {
15411 self._scopes
15412 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15413 self
15414 }
15415
15416 /// Removes all scopes, and no default scope will be used either.
15417 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15418 /// for details).
15419 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationDeleteCall<'a, C> {
15420 self._scopes.clear();
15421 self
15422 }
15423}
15424
15425/// 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.
15426///
15427/// A builder for the *instances.databases.operations.get* method supported by a *project* resource.
15428/// It is not used directly, but through a [`ProjectMethods`] instance.
15429///
15430/// # Example
15431///
15432/// Instantiate a resource method builder
15433///
15434/// ```test_harness,no_run
15435/// # extern crate hyper;
15436/// # extern crate hyper_rustls;
15437/// # extern crate google_spanner1 as spanner1;
15438/// # async fn dox() {
15439/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15440///
15441/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15442/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15443/// # secret,
15444/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15445/// # ).build().await.unwrap();
15446///
15447/// # let client = hyper_util::client::legacy::Client::builder(
15448/// # hyper_util::rt::TokioExecutor::new()
15449/// # )
15450/// # .build(
15451/// # hyper_rustls::HttpsConnectorBuilder::new()
15452/// # .with_native_roots()
15453/// # .unwrap()
15454/// # .https_or_http()
15455/// # .enable_http1()
15456/// # .build()
15457/// # );
15458/// # let mut hub = Spanner::new(client, auth);
15459/// // You can configure optional parameters by calling the respective setters at will, and
15460/// // execute the final call using `doit()`.
15461/// // Values shown here are possibly random and not representative !
15462/// let result = hub.projects().instances_databases_operations_get("name")
15463/// .doit().await;
15464/// # }
15465/// ```
15466pub struct ProjectInstanceDatabaseOperationGetCall<'a, C>
15467where
15468 C: 'a,
15469{
15470 hub: &'a Spanner<C>,
15471 _name: String,
15472 _delegate: Option<&'a mut dyn common::Delegate>,
15473 _additional_params: HashMap<String, String>,
15474 _scopes: BTreeSet<String>,
15475}
15476
15477impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationGetCall<'a, C> {}
15478
15479impl<'a, C> ProjectInstanceDatabaseOperationGetCall<'a, C>
15480where
15481 C: common::Connector,
15482{
15483 /// Perform the operation you have build so far.
15484 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15485 use std::borrow::Cow;
15486 use std::io::{Read, Seek};
15487
15488 use common::{url::Params, ToParts};
15489 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15490
15491 let mut dd = common::DefaultDelegate;
15492 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15493 dlg.begin(common::MethodInfo {
15494 id: "spanner.projects.instances.databases.operations.get",
15495 http_method: hyper::Method::GET,
15496 });
15497
15498 for &field in ["alt", "name"].iter() {
15499 if self._additional_params.contains_key(field) {
15500 dlg.finished(false);
15501 return Err(common::Error::FieldClash(field));
15502 }
15503 }
15504
15505 let mut params = Params::with_capacity(3 + self._additional_params.len());
15506 params.push("name", self._name);
15507
15508 params.extend(self._additional_params.iter());
15509
15510 params.push("alt", "json");
15511 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15512 if self._scopes.is_empty() {
15513 self._scopes
15514 .insert(Scope::CloudPlatform.as_ref().to_string());
15515 }
15516
15517 #[allow(clippy::single_element_loop)]
15518 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15519 url = params.uri_replacement(url, param_name, find_this, true);
15520 }
15521 {
15522 let to_remove = ["name"];
15523 params.remove_params(&to_remove);
15524 }
15525
15526 let url = params.parse_with_url(&url);
15527
15528 loop {
15529 let token = match self
15530 .hub
15531 .auth
15532 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15533 .await
15534 {
15535 Ok(token) => token,
15536 Err(e) => match dlg.token(e) {
15537 Ok(token) => token,
15538 Err(e) => {
15539 dlg.finished(false);
15540 return Err(common::Error::MissingToken(e));
15541 }
15542 },
15543 };
15544 let mut req_result = {
15545 let client = &self.hub.client;
15546 dlg.pre_request();
15547 let mut req_builder = hyper::Request::builder()
15548 .method(hyper::Method::GET)
15549 .uri(url.as_str())
15550 .header(USER_AGENT, self.hub._user_agent.clone());
15551
15552 if let Some(token) = token.as_ref() {
15553 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15554 }
15555
15556 let request = req_builder
15557 .header(CONTENT_LENGTH, 0_u64)
15558 .body(common::to_body::<String>(None));
15559
15560 client.request(request.unwrap()).await
15561 };
15562
15563 match req_result {
15564 Err(err) => {
15565 if let common::Retry::After(d) = dlg.http_error(&err) {
15566 sleep(d).await;
15567 continue;
15568 }
15569 dlg.finished(false);
15570 return Err(common::Error::HttpError(err));
15571 }
15572 Ok(res) => {
15573 let (mut parts, body) = res.into_parts();
15574 let mut body = common::Body::new(body);
15575 if !parts.status.is_success() {
15576 let bytes = common::to_bytes(body).await.unwrap_or_default();
15577 let error = serde_json::from_str(&common::to_string(&bytes));
15578 let response = common::to_response(parts, bytes.into());
15579
15580 if let common::Retry::After(d) =
15581 dlg.http_failure(&response, error.as_ref().ok())
15582 {
15583 sleep(d).await;
15584 continue;
15585 }
15586
15587 dlg.finished(false);
15588
15589 return Err(match error {
15590 Ok(value) => common::Error::BadRequest(value),
15591 _ => common::Error::Failure(response),
15592 });
15593 }
15594 let response = {
15595 let bytes = common::to_bytes(body).await.unwrap_or_default();
15596 let encoded = common::to_string(&bytes);
15597 match serde_json::from_str(&encoded) {
15598 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15599 Err(error) => {
15600 dlg.response_json_decode_error(&encoded, &error);
15601 return Err(common::Error::JsonDecodeError(
15602 encoded.to_string(),
15603 error,
15604 ));
15605 }
15606 }
15607 };
15608
15609 dlg.finished(true);
15610 return Ok(response);
15611 }
15612 }
15613 }
15614 }
15615
15616 /// The name of the operation resource.
15617 ///
15618 /// Sets the *name* path property to the given value.
15619 ///
15620 /// Even though the property as already been set when instantiating this call,
15621 /// we provide this method for API completeness.
15622 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationGetCall<'a, C> {
15623 self._name = new_value.to_string();
15624 self
15625 }
15626 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15627 /// while executing the actual API request.
15628 ///
15629 /// ````text
15630 /// It should be used to handle progress information, and to implement a certain level of resilience.
15631 /// ````
15632 ///
15633 /// Sets the *delegate* property to the given value.
15634 pub fn delegate(
15635 mut self,
15636 new_value: &'a mut dyn common::Delegate,
15637 ) -> ProjectInstanceDatabaseOperationGetCall<'a, C> {
15638 self._delegate = Some(new_value);
15639 self
15640 }
15641
15642 /// Set any additional parameter of the query string used in the request.
15643 /// It should be used to set parameters which are not yet available through their own
15644 /// setters.
15645 ///
15646 /// Please note that this method must not be used to set any of the known parameters
15647 /// which have their own setter method. If done anyway, the request will fail.
15648 ///
15649 /// # Additional Parameters
15650 ///
15651 /// * *$.xgafv* (query-string) - V1 error format.
15652 /// * *access_token* (query-string) - OAuth access token.
15653 /// * *alt* (query-string) - Data format for response.
15654 /// * *callback* (query-string) - JSONP
15655 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15656 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15657 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15658 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15659 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15660 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15661 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15662 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseOperationGetCall<'a, C>
15663 where
15664 T: AsRef<str>,
15665 {
15666 self._additional_params
15667 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15668 self
15669 }
15670
15671 /// Identifies the authorization scope for the method you are building.
15672 ///
15673 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15674 /// [`Scope::CloudPlatform`].
15675 ///
15676 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15677 /// tokens for more than one scope.
15678 ///
15679 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15680 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15681 /// sufficient, a read-write scope will do as well.
15682 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationGetCall<'a, C>
15683 where
15684 St: AsRef<str>,
15685 {
15686 self._scopes.insert(String::from(scope.as_ref()));
15687 self
15688 }
15689 /// Identifies the authorization scope(s) for the method you are building.
15690 ///
15691 /// See [`Self::add_scope()`] for details.
15692 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseOperationGetCall<'a, C>
15693 where
15694 I: IntoIterator<Item = St>,
15695 St: AsRef<str>,
15696 {
15697 self._scopes
15698 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15699 self
15700 }
15701
15702 /// Removes all scopes, and no default scope will be used either.
15703 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15704 /// for details).
15705 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationGetCall<'a, C> {
15706 self._scopes.clear();
15707 self
15708 }
15709}
15710
15711/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
15712///
15713/// A builder for the *instances.databases.operations.list* method supported by a *project* resource.
15714/// It is not used directly, but through a [`ProjectMethods`] instance.
15715///
15716/// # Example
15717///
15718/// Instantiate a resource method builder
15719///
15720/// ```test_harness,no_run
15721/// # extern crate hyper;
15722/// # extern crate hyper_rustls;
15723/// # extern crate google_spanner1 as spanner1;
15724/// # async fn dox() {
15725/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15726///
15727/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15728/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15729/// # secret,
15730/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15731/// # ).build().await.unwrap();
15732///
15733/// # let client = hyper_util::client::legacy::Client::builder(
15734/// # hyper_util::rt::TokioExecutor::new()
15735/// # )
15736/// # .build(
15737/// # hyper_rustls::HttpsConnectorBuilder::new()
15738/// # .with_native_roots()
15739/// # .unwrap()
15740/// # .https_or_http()
15741/// # .enable_http1()
15742/// # .build()
15743/// # );
15744/// # let mut hub = Spanner::new(client, auth);
15745/// // You can configure optional parameters by calling the respective setters at will, and
15746/// // execute the final call using `doit()`.
15747/// // Values shown here are possibly random and not representative !
15748/// let result = hub.projects().instances_databases_operations_list("name")
15749/// .page_token("consetetur")
15750/// .page_size(-2)
15751/// .filter("sed")
15752/// .doit().await;
15753/// # }
15754/// ```
15755pub struct ProjectInstanceDatabaseOperationListCall1<'a, C>
15756where
15757 C: 'a,
15758{
15759 hub: &'a Spanner<C>,
15760 _name: String,
15761 _page_token: Option<String>,
15762 _page_size: Option<i32>,
15763 _filter: Option<String>,
15764 _delegate: Option<&'a mut dyn common::Delegate>,
15765 _additional_params: HashMap<String, String>,
15766 _scopes: BTreeSet<String>,
15767}
15768
15769impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseOperationListCall1<'a, C> {}
15770
15771impl<'a, C> ProjectInstanceDatabaseOperationListCall1<'a, C>
15772where
15773 C: common::Connector,
15774{
15775 /// Perform the operation you have build so far.
15776 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
15777 use std::borrow::Cow;
15778 use std::io::{Read, Seek};
15779
15780 use common::{url::Params, ToParts};
15781 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15782
15783 let mut dd = common::DefaultDelegate;
15784 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15785 dlg.begin(common::MethodInfo {
15786 id: "spanner.projects.instances.databases.operations.list",
15787 http_method: hyper::Method::GET,
15788 });
15789
15790 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
15791 if self._additional_params.contains_key(field) {
15792 dlg.finished(false);
15793 return Err(common::Error::FieldClash(field));
15794 }
15795 }
15796
15797 let mut params = Params::with_capacity(6 + self._additional_params.len());
15798 params.push("name", self._name);
15799 if let Some(value) = self._page_token.as_ref() {
15800 params.push("pageToken", value);
15801 }
15802 if let Some(value) = self._page_size.as_ref() {
15803 params.push("pageSize", value.to_string());
15804 }
15805 if let Some(value) = self._filter.as_ref() {
15806 params.push("filter", value);
15807 }
15808
15809 params.extend(self._additional_params.iter());
15810
15811 params.push("alt", "json");
15812 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15813 if self._scopes.is_empty() {
15814 self._scopes
15815 .insert(Scope::CloudPlatform.as_ref().to_string());
15816 }
15817
15818 #[allow(clippy::single_element_loop)]
15819 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15820 url = params.uri_replacement(url, param_name, find_this, true);
15821 }
15822 {
15823 let to_remove = ["name"];
15824 params.remove_params(&to_remove);
15825 }
15826
15827 let url = params.parse_with_url(&url);
15828
15829 loop {
15830 let token = match self
15831 .hub
15832 .auth
15833 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15834 .await
15835 {
15836 Ok(token) => token,
15837 Err(e) => match dlg.token(e) {
15838 Ok(token) => token,
15839 Err(e) => {
15840 dlg.finished(false);
15841 return Err(common::Error::MissingToken(e));
15842 }
15843 },
15844 };
15845 let mut req_result = {
15846 let client = &self.hub.client;
15847 dlg.pre_request();
15848 let mut req_builder = hyper::Request::builder()
15849 .method(hyper::Method::GET)
15850 .uri(url.as_str())
15851 .header(USER_AGENT, self.hub._user_agent.clone());
15852
15853 if let Some(token) = token.as_ref() {
15854 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15855 }
15856
15857 let request = req_builder
15858 .header(CONTENT_LENGTH, 0_u64)
15859 .body(common::to_body::<String>(None));
15860
15861 client.request(request.unwrap()).await
15862 };
15863
15864 match req_result {
15865 Err(err) => {
15866 if let common::Retry::After(d) = dlg.http_error(&err) {
15867 sleep(d).await;
15868 continue;
15869 }
15870 dlg.finished(false);
15871 return Err(common::Error::HttpError(err));
15872 }
15873 Ok(res) => {
15874 let (mut parts, body) = res.into_parts();
15875 let mut body = common::Body::new(body);
15876 if !parts.status.is_success() {
15877 let bytes = common::to_bytes(body).await.unwrap_or_default();
15878 let error = serde_json::from_str(&common::to_string(&bytes));
15879 let response = common::to_response(parts, bytes.into());
15880
15881 if let common::Retry::After(d) =
15882 dlg.http_failure(&response, error.as_ref().ok())
15883 {
15884 sleep(d).await;
15885 continue;
15886 }
15887
15888 dlg.finished(false);
15889
15890 return Err(match error {
15891 Ok(value) => common::Error::BadRequest(value),
15892 _ => common::Error::Failure(response),
15893 });
15894 }
15895 let response = {
15896 let bytes = common::to_bytes(body).await.unwrap_or_default();
15897 let encoded = common::to_string(&bytes);
15898 match serde_json::from_str(&encoded) {
15899 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15900 Err(error) => {
15901 dlg.response_json_decode_error(&encoded, &error);
15902 return Err(common::Error::JsonDecodeError(
15903 encoded.to_string(),
15904 error,
15905 ));
15906 }
15907 }
15908 };
15909
15910 dlg.finished(true);
15911 return Ok(response);
15912 }
15913 }
15914 }
15915 }
15916
15917 /// The name of the operation's parent resource.
15918 ///
15919 /// Sets the *name* path property to the given value.
15920 ///
15921 /// Even though the property as already been set when instantiating this call,
15922 /// we provide this method for API completeness.
15923 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
15924 self._name = new_value.to_string();
15925 self
15926 }
15927 /// The standard list page token.
15928 ///
15929 /// Sets the *page token* query property to the given value.
15930 pub fn page_token(
15931 mut self,
15932 new_value: &str,
15933 ) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
15934 self._page_token = Some(new_value.to_string());
15935 self
15936 }
15937 /// The standard list page size.
15938 ///
15939 /// Sets the *page size* query property to the given value.
15940 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
15941 self._page_size = Some(new_value);
15942 self
15943 }
15944 /// The standard list filter.
15945 ///
15946 /// Sets the *filter* query property to the given value.
15947 pub fn filter(mut self, new_value: &str) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
15948 self._filter = Some(new_value.to_string());
15949 self
15950 }
15951 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15952 /// while executing the actual API request.
15953 ///
15954 /// ````text
15955 /// It should be used to handle progress information, and to implement a certain level of resilience.
15956 /// ````
15957 ///
15958 /// Sets the *delegate* property to the given value.
15959 pub fn delegate(
15960 mut self,
15961 new_value: &'a mut dyn common::Delegate,
15962 ) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
15963 self._delegate = Some(new_value);
15964 self
15965 }
15966
15967 /// Set any additional parameter of the query string used in the request.
15968 /// It should be used to set parameters which are not yet available through their own
15969 /// setters.
15970 ///
15971 /// Please note that this method must not be used to set any of the known parameters
15972 /// which have their own setter method. If done anyway, the request will fail.
15973 ///
15974 /// # Additional Parameters
15975 ///
15976 /// * *$.xgafv* (query-string) - V1 error format.
15977 /// * *access_token* (query-string) - OAuth access token.
15978 /// * *alt* (query-string) - Data format for response.
15979 /// * *callback* (query-string) - JSONP
15980 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15981 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15982 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15983 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15984 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15985 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15986 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15987 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseOperationListCall1<'a, C>
15988 where
15989 T: AsRef<str>,
15990 {
15991 self._additional_params
15992 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15993 self
15994 }
15995
15996 /// Identifies the authorization scope for the method you are building.
15997 ///
15998 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15999 /// [`Scope::CloudPlatform`].
16000 ///
16001 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16002 /// tokens for more than one scope.
16003 ///
16004 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16005 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16006 /// sufficient, a read-write scope will do as well.
16007 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseOperationListCall1<'a, C>
16008 where
16009 St: AsRef<str>,
16010 {
16011 self._scopes.insert(String::from(scope.as_ref()));
16012 self
16013 }
16014 /// Identifies the authorization scope(s) for the method you are building.
16015 ///
16016 /// See [`Self::add_scope()`] for details.
16017 pub fn add_scopes<I, St>(
16018 mut self,
16019 scopes: I,
16020 ) -> ProjectInstanceDatabaseOperationListCall1<'a, C>
16021 where
16022 I: IntoIterator<Item = St>,
16023 St: AsRef<str>,
16024 {
16025 self._scopes
16026 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16027 self
16028 }
16029
16030 /// Removes all scopes, and no default scope will be used either.
16031 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16032 /// for details).
16033 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseOperationListCall1<'a, C> {
16034 self._scopes.clear();
16035 self
16036 }
16037}
16038
16039/// 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.
16040///
16041/// A builder for the *instances.databases.sessions.batchCreate* method supported by a *project* resource.
16042/// It is not used directly, but through a [`ProjectMethods`] instance.
16043///
16044/// # Example
16045///
16046/// Instantiate a resource method builder
16047///
16048/// ```test_harness,no_run
16049/// # extern crate hyper;
16050/// # extern crate hyper_rustls;
16051/// # extern crate google_spanner1 as spanner1;
16052/// use spanner1::api::BatchCreateSessionsRequest;
16053/// # async fn dox() {
16054/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16055///
16056/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16058/// # secret,
16059/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16060/// # ).build().await.unwrap();
16061///
16062/// # let client = hyper_util::client::legacy::Client::builder(
16063/// # hyper_util::rt::TokioExecutor::new()
16064/// # )
16065/// # .build(
16066/// # hyper_rustls::HttpsConnectorBuilder::new()
16067/// # .with_native_roots()
16068/// # .unwrap()
16069/// # .https_or_http()
16070/// # .enable_http1()
16071/// # .build()
16072/// # );
16073/// # let mut hub = Spanner::new(client, auth);
16074/// // As the method needs a request, you would usually fill it with the desired information
16075/// // into the respective structure. Some of the parts shown here might not be applicable !
16076/// // Values shown here are possibly random and not representative !
16077/// let mut req = BatchCreateSessionsRequest::default();
16078///
16079/// // You can configure optional parameters by calling the respective setters at will, and
16080/// // execute the final call using `doit()`.
16081/// // Values shown here are possibly random and not representative !
16082/// let result = hub.projects().instances_databases_sessions_batch_create(req, "database")
16083/// .doit().await;
16084/// # }
16085/// ```
16086pub struct ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
16087where
16088 C: 'a,
16089{
16090 hub: &'a Spanner<C>,
16091 _request: BatchCreateSessionsRequest,
16092 _database: String,
16093 _delegate: Option<&'a mut dyn common::Delegate>,
16094 _additional_params: HashMap<String, String>,
16095 _scopes: BTreeSet<String>,
16096}
16097
16098impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {}
16099
16100impl<'a, C> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
16101where
16102 C: common::Connector,
16103{
16104 /// Perform the operation you have build so far.
16105 pub async fn doit(mut self) -> common::Result<(common::Response, BatchCreateSessionsResponse)> {
16106 use std::borrow::Cow;
16107 use std::io::{Read, Seek};
16108
16109 use common::{url::Params, ToParts};
16110 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16111
16112 let mut dd = common::DefaultDelegate;
16113 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16114 dlg.begin(common::MethodInfo {
16115 id: "spanner.projects.instances.databases.sessions.batchCreate",
16116 http_method: hyper::Method::POST,
16117 });
16118
16119 for &field in ["alt", "database"].iter() {
16120 if self._additional_params.contains_key(field) {
16121 dlg.finished(false);
16122 return Err(common::Error::FieldClash(field));
16123 }
16124 }
16125
16126 let mut params = Params::with_capacity(4 + self._additional_params.len());
16127 params.push("database", self._database);
16128
16129 params.extend(self._additional_params.iter());
16130
16131 params.push("alt", "json");
16132 let mut url = self.hub._base_url.clone() + "v1/{+database}/sessions:batchCreate";
16133 if self._scopes.is_empty() {
16134 self._scopes
16135 .insert(Scope::CloudPlatform.as_ref().to_string());
16136 }
16137
16138 #[allow(clippy::single_element_loop)]
16139 for &(find_this, param_name) in [("{+database}", "database")].iter() {
16140 url = params.uri_replacement(url, param_name, find_this, true);
16141 }
16142 {
16143 let to_remove = ["database"];
16144 params.remove_params(&to_remove);
16145 }
16146
16147 let url = params.parse_with_url(&url);
16148
16149 let mut json_mime_type = mime::APPLICATION_JSON;
16150 let mut request_value_reader = {
16151 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16152 common::remove_json_null_values(&mut value);
16153 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16154 serde_json::to_writer(&mut dst, &value).unwrap();
16155 dst
16156 };
16157 let request_size = request_value_reader
16158 .seek(std::io::SeekFrom::End(0))
16159 .unwrap();
16160 request_value_reader
16161 .seek(std::io::SeekFrom::Start(0))
16162 .unwrap();
16163
16164 loop {
16165 let token = match self
16166 .hub
16167 .auth
16168 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16169 .await
16170 {
16171 Ok(token) => token,
16172 Err(e) => match dlg.token(e) {
16173 Ok(token) => token,
16174 Err(e) => {
16175 dlg.finished(false);
16176 return Err(common::Error::MissingToken(e));
16177 }
16178 },
16179 };
16180 request_value_reader
16181 .seek(std::io::SeekFrom::Start(0))
16182 .unwrap();
16183 let mut req_result = {
16184 let client = &self.hub.client;
16185 dlg.pre_request();
16186 let mut req_builder = hyper::Request::builder()
16187 .method(hyper::Method::POST)
16188 .uri(url.as_str())
16189 .header(USER_AGENT, self.hub._user_agent.clone());
16190
16191 if let Some(token) = token.as_ref() {
16192 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16193 }
16194
16195 let request = req_builder
16196 .header(CONTENT_TYPE, json_mime_type.to_string())
16197 .header(CONTENT_LENGTH, request_size as u64)
16198 .body(common::to_body(
16199 request_value_reader.get_ref().clone().into(),
16200 ));
16201
16202 client.request(request.unwrap()).await
16203 };
16204
16205 match req_result {
16206 Err(err) => {
16207 if let common::Retry::After(d) = dlg.http_error(&err) {
16208 sleep(d).await;
16209 continue;
16210 }
16211 dlg.finished(false);
16212 return Err(common::Error::HttpError(err));
16213 }
16214 Ok(res) => {
16215 let (mut parts, body) = res.into_parts();
16216 let mut body = common::Body::new(body);
16217 if !parts.status.is_success() {
16218 let bytes = common::to_bytes(body).await.unwrap_or_default();
16219 let error = serde_json::from_str(&common::to_string(&bytes));
16220 let response = common::to_response(parts, bytes.into());
16221
16222 if let common::Retry::After(d) =
16223 dlg.http_failure(&response, error.as_ref().ok())
16224 {
16225 sleep(d).await;
16226 continue;
16227 }
16228
16229 dlg.finished(false);
16230
16231 return Err(match error {
16232 Ok(value) => common::Error::BadRequest(value),
16233 _ => common::Error::Failure(response),
16234 });
16235 }
16236 let response = {
16237 let bytes = common::to_bytes(body).await.unwrap_or_default();
16238 let encoded = common::to_string(&bytes);
16239 match serde_json::from_str(&encoded) {
16240 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16241 Err(error) => {
16242 dlg.response_json_decode_error(&encoded, &error);
16243 return Err(common::Error::JsonDecodeError(
16244 encoded.to_string(),
16245 error,
16246 ));
16247 }
16248 }
16249 };
16250
16251 dlg.finished(true);
16252 return Ok(response);
16253 }
16254 }
16255 }
16256 }
16257
16258 ///
16259 /// Sets the *request* property to the given value.
16260 ///
16261 /// Even though the property as already been set when instantiating this call,
16262 /// we provide this method for API completeness.
16263 pub fn request(
16264 mut self,
16265 new_value: BatchCreateSessionsRequest,
16266 ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
16267 self._request = new_value;
16268 self
16269 }
16270 /// Required. The database in which the new sessions are created.
16271 ///
16272 /// Sets the *database* path property to the given value.
16273 ///
16274 /// Even though the property as already been set when instantiating this call,
16275 /// we provide this method for API completeness.
16276 pub fn database(
16277 mut self,
16278 new_value: &str,
16279 ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
16280 self._database = new_value.to_string();
16281 self
16282 }
16283 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16284 /// while executing the actual API request.
16285 ///
16286 /// ````text
16287 /// It should be used to handle progress information, and to implement a certain level of resilience.
16288 /// ````
16289 ///
16290 /// Sets the *delegate* property to the given value.
16291 pub fn delegate(
16292 mut self,
16293 new_value: &'a mut dyn common::Delegate,
16294 ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
16295 self._delegate = Some(new_value);
16296 self
16297 }
16298
16299 /// Set any additional parameter of the query string used in the request.
16300 /// It should be used to set parameters which are not yet available through their own
16301 /// setters.
16302 ///
16303 /// Please note that this method must not be used to set any of the known parameters
16304 /// which have their own setter method. If done anyway, the request will fail.
16305 ///
16306 /// # Additional Parameters
16307 ///
16308 /// * *$.xgafv* (query-string) - V1 error format.
16309 /// * *access_token* (query-string) - OAuth access token.
16310 /// * *alt* (query-string) - Data format for response.
16311 /// * *callback* (query-string) - JSONP
16312 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16313 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16314 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16315 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16316 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16317 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16318 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16319 pub fn param<T>(
16320 mut self,
16321 name: T,
16322 value: T,
16323 ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
16324 where
16325 T: AsRef<str>,
16326 {
16327 self._additional_params
16328 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16329 self
16330 }
16331
16332 /// Identifies the authorization scope for the method you are building.
16333 ///
16334 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16335 /// [`Scope::CloudPlatform`].
16336 ///
16337 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16338 /// tokens for more than one scope.
16339 ///
16340 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16341 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16342 /// sufficient, a read-write scope will do as well.
16343 pub fn add_scope<St>(
16344 mut self,
16345 scope: St,
16346 ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
16347 where
16348 St: AsRef<str>,
16349 {
16350 self._scopes.insert(String::from(scope.as_ref()));
16351 self
16352 }
16353 /// Identifies the authorization scope(s) for the method you are building.
16354 ///
16355 /// See [`Self::add_scope()`] for details.
16356 pub fn add_scopes<I, St>(
16357 mut self,
16358 scopes: I,
16359 ) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C>
16360 where
16361 I: IntoIterator<Item = St>,
16362 St: AsRef<str>,
16363 {
16364 self._scopes
16365 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16366 self
16367 }
16368
16369 /// Removes all scopes, and no default scope will be used either.
16370 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16371 /// for details).
16372 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionBatchCreateCall<'a, C> {
16373 self._scopes.clear();
16374 self
16375 }
16376}
16377
16378/// 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, i.e., some groups may have been committed successfully, while some may 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 may be applied more than once. Replays of non-idempotent mutations may have undesirable effects. For example, replays of an insert mutation may produce an already exists error or if you use generated or commit timestamp-based keys, it may result in additional rows being added to the mutation's table. We recommend structuring your mutation groups to be idempotent to avoid this issue.
16379///
16380/// A builder for the *instances.databases.sessions.batchWrite* method supported by a *project* resource.
16381/// It is not used directly, but through a [`ProjectMethods`] instance.
16382///
16383/// # Example
16384///
16385/// Instantiate a resource method builder
16386///
16387/// ```test_harness,no_run
16388/// # extern crate hyper;
16389/// # extern crate hyper_rustls;
16390/// # extern crate google_spanner1 as spanner1;
16391/// use spanner1::api::BatchWriteRequest;
16392/// # async fn dox() {
16393/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16394///
16395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16396/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16397/// # secret,
16398/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16399/// # ).build().await.unwrap();
16400///
16401/// # let client = hyper_util::client::legacy::Client::builder(
16402/// # hyper_util::rt::TokioExecutor::new()
16403/// # )
16404/// # .build(
16405/// # hyper_rustls::HttpsConnectorBuilder::new()
16406/// # .with_native_roots()
16407/// # .unwrap()
16408/// # .https_or_http()
16409/// # .enable_http1()
16410/// # .build()
16411/// # );
16412/// # let mut hub = Spanner::new(client, auth);
16413/// // As the method needs a request, you would usually fill it with the desired information
16414/// // into the respective structure. Some of the parts shown here might not be applicable !
16415/// // Values shown here are possibly random and not representative !
16416/// let mut req = BatchWriteRequest::default();
16417///
16418/// // You can configure optional parameters by calling the respective setters at will, and
16419/// // execute the final call using `doit()`.
16420/// // Values shown here are possibly random and not representative !
16421/// let result = hub.projects().instances_databases_sessions_batch_write(req, "session")
16422/// .doit().await;
16423/// # }
16424/// ```
16425pub struct ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
16426where
16427 C: 'a,
16428{
16429 hub: &'a Spanner<C>,
16430 _request: BatchWriteRequest,
16431 _session: String,
16432 _delegate: Option<&'a mut dyn common::Delegate>,
16433 _additional_params: HashMap<String, String>,
16434 _scopes: BTreeSet<String>,
16435}
16436
16437impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {}
16438
16439impl<'a, C> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
16440where
16441 C: common::Connector,
16442{
16443 /// Perform the operation you have build so far.
16444 pub async fn doit(mut self) -> common::Result<(common::Response, BatchWriteResponse)> {
16445 use std::borrow::Cow;
16446 use std::io::{Read, Seek};
16447
16448 use common::{url::Params, ToParts};
16449 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16450
16451 let mut dd = common::DefaultDelegate;
16452 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16453 dlg.begin(common::MethodInfo {
16454 id: "spanner.projects.instances.databases.sessions.batchWrite",
16455 http_method: hyper::Method::POST,
16456 });
16457
16458 for &field in ["alt", "session"].iter() {
16459 if self._additional_params.contains_key(field) {
16460 dlg.finished(false);
16461 return Err(common::Error::FieldClash(field));
16462 }
16463 }
16464
16465 let mut params = Params::with_capacity(4 + self._additional_params.len());
16466 params.push("session", self._session);
16467
16468 params.extend(self._additional_params.iter());
16469
16470 params.push("alt", "json");
16471 let mut url = self.hub._base_url.clone() + "v1/{+session}:batchWrite";
16472 if self._scopes.is_empty() {
16473 self._scopes
16474 .insert(Scope::CloudPlatform.as_ref().to_string());
16475 }
16476
16477 #[allow(clippy::single_element_loop)]
16478 for &(find_this, param_name) in [("{+session}", "session")].iter() {
16479 url = params.uri_replacement(url, param_name, find_this, true);
16480 }
16481 {
16482 let to_remove = ["session"];
16483 params.remove_params(&to_remove);
16484 }
16485
16486 let url = params.parse_with_url(&url);
16487
16488 let mut json_mime_type = mime::APPLICATION_JSON;
16489 let mut request_value_reader = {
16490 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16491 common::remove_json_null_values(&mut value);
16492 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16493 serde_json::to_writer(&mut dst, &value).unwrap();
16494 dst
16495 };
16496 let request_size = request_value_reader
16497 .seek(std::io::SeekFrom::End(0))
16498 .unwrap();
16499 request_value_reader
16500 .seek(std::io::SeekFrom::Start(0))
16501 .unwrap();
16502
16503 loop {
16504 let token = match self
16505 .hub
16506 .auth
16507 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16508 .await
16509 {
16510 Ok(token) => token,
16511 Err(e) => match dlg.token(e) {
16512 Ok(token) => token,
16513 Err(e) => {
16514 dlg.finished(false);
16515 return Err(common::Error::MissingToken(e));
16516 }
16517 },
16518 };
16519 request_value_reader
16520 .seek(std::io::SeekFrom::Start(0))
16521 .unwrap();
16522 let mut req_result = {
16523 let client = &self.hub.client;
16524 dlg.pre_request();
16525 let mut req_builder = hyper::Request::builder()
16526 .method(hyper::Method::POST)
16527 .uri(url.as_str())
16528 .header(USER_AGENT, self.hub._user_agent.clone());
16529
16530 if let Some(token) = token.as_ref() {
16531 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16532 }
16533
16534 let request = req_builder
16535 .header(CONTENT_TYPE, json_mime_type.to_string())
16536 .header(CONTENT_LENGTH, request_size as u64)
16537 .body(common::to_body(
16538 request_value_reader.get_ref().clone().into(),
16539 ));
16540
16541 client.request(request.unwrap()).await
16542 };
16543
16544 match req_result {
16545 Err(err) => {
16546 if let common::Retry::After(d) = dlg.http_error(&err) {
16547 sleep(d).await;
16548 continue;
16549 }
16550 dlg.finished(false);
16551 return Err(common::Error::HttpError(err));
16552 }
16553 Ok(res) => {
16554 let (mut parts, body) = res.into_parts();
16555 let mut body = common::Body::new(body);
16556 if !parts.status.is_success() {
16557 let bytes = common::to_bytes(body).await.unwrap_or_default();
16558 let error = serde_json::from_str(&common::to_string(&bytes));
16559 let response = common::to_response(parts, bytes.into());
16560
16561 if let common::Retry::After(d) =
16562 dlg.http_failure(&response, error.as_ref().ok())
16563 {
16564 sleep(d).await;
16565 continue;
16566 }
16567
16568 dlg.finished(false);
16569
16570 return Err(match error {
16571 Ok(value) => common::Error::BadRequest(value),
16572 _ => common::Error::Failure(response),
16573 });
16574 }
16575 let response = {
16576 let bytes = common::to_bytes(body).await.unwrap_or_default();
16577 let encoded = common::to_string(&bytes);
16578 match serde_json::from_str(&encoded) {
16579 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16580 Err(error) => {
16581 dlg.response_json_decode_error(&encoded, &error);
16582 return Err(common::Error::JsonDecodeError(
16583 encoded.to_string(),
16584 error,
16585 ));
16586 }
16587 }
16588 };
16589
16590 dlg.finished(true);
16591 return Ok(response);
16592 }
16593 }
16594 }
16595 }
16596
16597 ///
16598 /// Sets the *request* property to the given value.
16599 ///
16600 /// Even though the property as already been set when instantiating this call,
16601 /// we provide this method for API completeness.
16602 pub fn request(
16603 mut self,
16604 new_value: BatchWriteRequest,
16605 ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
16606 self._request = new_value;
16607 self
16608 }
16609 /// Required. The session in which the batch request is to be run.
16610 ///
16611 /// Sets the *session* path property to the given value.
16612 ///
16613 /// Even though the property as already been set when instantiating this call,
16614 /// we provide this method for API completeness.
16615 pub fn session(
16616 mut self,
16617 new_value: &str,
16618 ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
16619 self._session = new_value.to_string();
16620 self
16621 }
16622 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16623 /// while executing the actual API request.
16624 ///
16625 /// ````text
16626 /// It should be used to handle progress information, and to implement a certain level of resilience.
16627 /// ````
16628 ///
16629 /// Sets the *delegate* property to the given value.
16630 pub fn delegate(
16631 mut self,
16632 new_value: &'a mut dyn common::Delegate,
16633 ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
16634 self._delegate = Some(new_value);
16635 self
16636 }
16637
16638 /// Set any additional parameter of the query string used in the request.
16639 /// It should be used to set parameters which are not yet available through their own
16640 /// setters.
16641 ///
16642 /// Please note that this method must not be used to set any of the known parameters
16643 /// which have their own setter method. If done anyway, the request will fail.
16644 ///
16645 /// # Additional Parameters
16646 ///
16647 /// * *$.xgafv* (query-string) - V1 error format.
16648 /// * *access_token* (query-string) - OAuth access token.
16649 /// * *alt* (query-string) - Data format for response.
16650 /// * *callback* (query-string) - JSONP
16651 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16652 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16653 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16654 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16655 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16656 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16657 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16658 pub fn param<T>(
16659 mut self,
16660 name: T,
16661 value: T,
16662 ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
16663 where
16664 T: AsRef<str>,
16665 {
16666 self._additional_params
16667 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16668 self
16669 }
16670
16671 /// Identifies the authorization scope for the method you are building.
16672 ///
16673 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16674 /// [`Scope::CloudPlatform`].
16675 ///
16676 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16677 /// tokens for more than one scope.
16678 ///
16679 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16680 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16681 /// sufficient, a read-write scope will do as well.
16682 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
16683 where
16684 St: AsRef<str>,
16685 {
16686 self._scopes.insert(String::from(scope.as_ref()));
16687 self
16688 }
16689 /// Identifies the authorization scope(s) for the method you are building.
16690 ///
16691 /// See [`Self::add_scope()`] for details.
16692 pub fn add_scopes<I, St>(
16693 mut self,
16694 scopes: I,
16695 ) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C>
16696 where
16697 I: IntoIterator<Item = St>,
16698 St: AsRef<str>,
16699 {
16700 self._scopes
16701 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16702 self
16703 }
16704
16705 /// Removes all scopes, and no default scope will be used either.
16706 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16707 /// for details).
16708 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionBatchWriteCall<'a, C> {
16709 self._scopes.clear();
16710 self
16711 }
16712}
16713
16714/// Begins a new transaction. This step can often be skipped: Read, ExecuteSql and Commit can begin a new transaction as a side-effect.
16715///
16716/// A builder for the *instances.databases.sessions.beginTransaction* method supported by a *project* resource.
16717/// It is not used directly, but through a [`ProjectMethods`] instance.
16718///
16719/// # Example
16720///
16721/// Instantiate a resource method builder
16722///
16723/// ```test_harness,no_run
16724/// # extern crate hyper;
16725/// # extern crate hyper_rustls;
16726/// # extern crate google_spanner1 as spanner1;
16727/// use spanner1::api::BeginTransactionRequest;
16728/// # async fn dox() {
16729/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16730///
16731/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16732/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16733/// # secret,
16734/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16735/// # ).build().await.unwrap();
16736///
16737/// # let client = hyper_util::client::legacy::Client::builder(
16738/// # hyper_util::rt::TokioExecutor::new()
16739/// # )
16740/// # .build(
16741/// # hyper_rustls::HttpsConnectorBuilder::new()
16742/// # .with_native_roots()
16743/// # .unwrap()
16744/// # .https_or_http()
16745/// # .enable_http1()
16746/// # .build()
16747/// # );
16748/// # let mut hub = Spanner::new(client, auth);
16749/// // As the method needs a request, you would usually fill it with the desired information
16750/// // into the respective structure. Some of the parts shown here might not be applicable !
16751/// // Values shown here are possibly random and not representative !
16752/// let mut req = BeginTransactionRequest::default();
16753///
16754/// // You can configure optional parameters by calling the respective setters at will, and
16755/// // execute the final call using `doit()`.
16756/// // Values shown here are possibly random and not representative !
16757/// let result = hub.projects().instances_databases_sessions_begin_transaction(req, "session")
16758/// .doit().await;
16759/// # }
16760/// ```
16761pub struct ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
16762where
16763 C: 'a,
16764{
16765 hub: &'a Spanner<C>,
16766 _request: BeginTransactionRequest,
16767 _session: String,
16768 _delegate: Option<&'a mut dyn common::Delegate>,
16769 _additional_params: HashMap<String, String>,
16770 _scopes: BTreeSet<String>,
16771}
16772
16773impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {}
16774
16775impl<'a, C> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
16776where
16777 C: common::Connector,
16778{
16779 /// Perform the operation you have build so far.
16780 pub async fn doit(mut self) -> common::Result<(common::Response, Transaction)> {
16781 use std::borrow::Cow;
16782 use std::io::{Read, Seek};
16783
16784 use common::{url::Params, ToParts};
16785 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16786
16787 let mut dd = common::DefaultDelegate;
16788 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16789 dlg.begin(common::MethodInfo {
16790 id: "spanner.projects.instances.databases.sessions.beginTransaction",
16791 http_method: hyper::Method::POST,
16792 });
16793
16794 for &field in ["alt", "session"].iter() {
16795 if self._additional_params.contains_key(field) {
16796 dlg.finished(false);
16797 return Err(common::Error::FieldClash(field));
16798 }
16799 }
16800
16801 let mut params = Params::with_capacity(4 + self._additional_params.len());
16802 params.push("session", self._session);
16803
16804 params.extend(self._additional_params.iter());
16805
16806 params.push("alt", "json");
16807 let mut url = self.hub._base_url.clone() + "v1/{+session}:beginTransaction";
16808 if self._scopes.is_empty() {
16809 self._scopes
16810 .insert(Scope::CloudPlatform.as_ref().to_string());
16811 }
16812
16813 #[allow(clippy::single_element_loop)]
16814 for &(find_this, param_name) in [("{+session}", "session")].iter() {
16815 url = params.uri_replacement(url, param_name, find_this, true);
16816 }
16817 {
16818 let to_remove = ["session"];
16819 params.remove_params(&to_remove);
16820 }
16821
16822 let url = params.parse_with_url(&url);
16823
16824 let mut json_mime_type = mime::APPLICATION_JSON;
16825 let mut request_value_reader = {
16826 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16827 common::remove_json_null_values(&mut value);
16828 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16829 serde_json::to_writer(&mut dst, &value).unwrap();
16830 dst
16831 };
16832 let request_size = request_value_reader
16833 .seek(std::io::SeekFrom::End(0))
16834 .unwrap();
16835 request_value_reader
16836 .seek(std::io::SeekFrom::Start(0))
16837 .unwrap();
16838
16839 loop {
16840 let token = match self
16841 .hub
16842 .auth
16843 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16844 .await
16845 {
16846 Ok(token) => token,
16847 Err(e) => match dlg.token(e) {
16848 Ok(token) => token,
16849 Err(e) => {
16850 dlg.finished(false);
16851 return Err(common::Error::MissingToken(e));
16852 }
16853 },
16854 };
16855 request_value_reader
16856 .seek(std::io::SeekFrom::Start(0))
16857 .unwrap();
16858 let mut req_result = {
16859 let client = &self.hub.client;
16860 dlg.pre_request();
16861 let mut req_builder = hyper::Request::builder()
16862 .method(hyper::Method::POST)
16863 .uri(url.as_str())
16864 .header(USER_AGENT, self.hub._user_agent.clone());
16865
16866 if let Some(token) = token.as_ref() {
16867 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16868 }
16869
16870 let request = req_builder
16871 .header(CONTENT_TYPE, json_mime_type.to_string())
16872 .header(CONTENT_LENGTH, request_size as u64)
16873 .body(common::to_body(
16874 request_value_reader.get_ref().clone().into(),
16875 ));
16876
16877 client.request(request.unwrap()).await
16878 };
16879
16880 match req_result {
16881 Err(err) => {
16882 if let common::Retry::After(d) = dlg.http_error(&err) {
16883 sleep(d).await;
16884 continue;
16885 }
16886 dlg.finished(false);
16887 return Err(common::Error::HttpError(err));
16888 }
16889 Ok(res) => {
16890 let (mut parts, body) = res.into_parts();
16891 let mut body = common::Body::new(body);
16892 if !parts.status.is_success() {
16893 let bytes = common::to_bytes(body).await.unwrap_or_default();
16894 let error = serde_json::from_str(&common::to_string(&bytes));
16895 let response = common::to_response(parts, bytes.into());
16896
16897 if let common::Retry::After(d) =
16898 dlg.http_failure(&response, error.as_ref().ok())
16899 {
16900 sleep(d).await;
16901 continue;
16902 }
16903
16904 dlg.finished(false);
16905
16906 return Err(match error {
16907 Ok(value) => common::Error::BadRequest(value),
16908 _ => common::Error::Failure(response),
16909 });
16910 }
16911 let response = {
16912 let bytes = common::to_bytes(body).await.unwrap_or_default();
16913 let encoded = common::to_string(&bytes);
16914 match serde_json::from_str(&encoded) {
16915 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16916 Err(error) => {
16917 dlg.response_json_decode_error(&encoded, &error);
16918 return Err(common::Error::JsonDecodeError(
16919 encoded.to_string(),
16920 error,
16921 ));
16922 }
16923 }
16924 };
16925
16926 dlg.finished(true);
16927 return Ok(response);
16928 }
16929 }
16930 }
16931 }
16932
16933 ///
16934 /// Sets the *request* property to the given value.
16935 ///
16936 /// Even though the property as already been set when instantiating this call,
16937 /// we provide this method for API completeness.
16938 pub fn request(
16939 mut self,
16940 new_value: BeginTransactionRequest,
16941 ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
16942 self._request = new_value;
16943 self
16944 }
16945 /// Required. The session in which the transaction runs.
16946 ///
16947 /// Sets the *session* path property to the given value.
16948 ///
16949 /// Even though the property as already been set when instantiating this call,
16950 /// we provide this method for API completeness.
16951 pub fn session(
16952 mut self,
16953 new_value: &str,
16954 ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
16955 self._session = new_value.to_string();
16956 self
16957 }
16958 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16959 /// while executing the actual API request.
16960 ///
16961 /// ````text
16962 /// It should be used to handle progress information, and to implement a certain level of resilience.
16963 /// ````
16964 ///
16965 /// Sets the *delegate* property to the given value.
16966 pub fn delegate(
16967 mut self,
16968 new_value: &'a mut dyn common::Delegate,
16969 ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
16970 self._delegate = Some(new_value);
16971 self
16972 }
16973
16974 /// Set any additional parameter of the query string used in the request.
16975 /// It should be used to set parameters which are not yet available through their own
16976 /// setters.
16977 ///
16978 /// Please note that this method must not be used to set any of the known parameters
16979 /// which have their own setter method. If done anyway, the request will fail.
16980 ///
16981 /// # Additional Parameters
16982 ///
16983 /// * *$.xgafv* (query-string) - V1 error format.
16984 /// * *access_token* (query-string) - OAuth access token.
16985 /// * *alt* (query-string) - Data format for response.
16986 /// * *callback* (query-string) - JSONP
16987 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16988 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16989 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16990 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16991 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16992 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16993 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16994 pub fn param<T>(
16995 mut self,
16996 name: T,
16997 value: T,
16998 ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
16999 where
17000 T: AsRef<str>,
17001 {
17002 self._additional_params
17003 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17004 self
17005 }
17006
17007 /// Identifies the authorization scope for the method you are building.
17008 ///
17009 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17010 /// [`Scope::CloudPlatform`].
17011 ///
17012 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17013 /// tokens for more than one scope.
17014 ///
17015 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17016 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17017 /// sufficient, a read-write scope will do as well.
17018 pub fn add_scope<St>(
17019 mut self,
17020 scope: St,
17021 ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
17022 where
17023 St: AsRef<str>,
17024 {
17025 self._scopes.insert(String::from(scope.as_ref()));
17026 self
17027 }
17028 /// Identifies the authorization scope(s) for the method you are building.
17029 ///
17030 /// See [`Self::add_scope()`] for details.
17031 pub fn add_scopes<I, St>(
17032 mut self,
17033 scopes: I,
17034 ) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C>
17035 where
17036 I: IntoIterator<Item = St>,
17037 St: AsRef<str>,
17038 {
17039 self._scopes
17040 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17041 self
17042 }
17043
17044 /// Removes all scopes, and no default scope will be used either.
17045 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17046 /// for details).
17047 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionBeginTransactionCall<'a, C> {
17048 self._scopes.clear();
17049 self
17050 }
17051}
17052
17053/// 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 re-attempt the transaction from the beginning, re-using 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.
17054///
17055/// A builder for the *instances.databases.sessions.commit* method supported by a *project* resource.
17056/// It is not used directly, but through a [`ProjectMethods`] instance.
17057///
17058/// # Example
17059///
17060/// Instantiate a resource method builder
17061///
17062/// ```test_harness,no_run
17063/// # extern crate hyper;
17064/// # extern crate hyper_rustls;
17065/// # extern crate google_spanner1 as spanner1;
17066/// use spanner1::api::CommitRequest;
17067/// # async fn dox() {
17068/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17069///
17070/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17071/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17072/// # secret,
17073/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17074/// # ).build().await.unwrap();
17075///
17076/// # let client = hyper_util::client::legacy::Client::builder(
17077/// # hyper_util::rt::TokioExecutor::new()
17078/// # )
17079/// # .build(
17080/// # hyper_rustls::HttpsConnectorBuilder::new()
17081/// # .with_native_roots()
17082/// # .unwrap()
17083/// # .https_or_http()
17084/// # .enable_http1()
17085/// # .build()
17086/// # );
17087/// # let mut hub = Spanner::new(client, auth);
17088/// // As the method needs a request, you would usually fill it with the desired information
17089/// // into the respective structure. Some of the parts shown here might not be applicable !
17090/// // Values shown here are possibly random and not representative !
17091/// let mut req = CommitRequest::default();
17092///
17093/// // You can configure optional parameters by calling the respective setters at will, and
17094/// // execute the final call using `doit()`.
17095/// // Values shown here are possibly random and not representative !
17096/// let result = hub.projects().instances_databases_sessions_commit(req, "session")
17097/// .doit().await;
17098/// # }
17099/// ```
17100pub struct ProjectInstanceDatabaseSessionCommitCall<'a, C>
17101where
17102 C: 'a,
17103{
17104 hub: &'a Spanner<C>,
17105 _request: CommitRequest,
17106 _session: String,
17107 _delegate: Option<&'a mut dyn common::Delegate>,
17108 _additional_params: HashMap<String, String>,
17109 _scopes: BTreeSet<String>,
17110}
17111
17112impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionCommitCall<'a, C> {}
17113
17114impl<'a, C> ProjectInstanceDatabaseSessionCommitCall<'a, C>
17115where
17116 C: common::Connector,
17117{
17118 /// Perform the operation you have build so far.
17119 pub async fn doit(mut self) -> common::Result<(common::Response, CommitResponse)> {
17120 use std::borrow::Cow;
17121 use std::io::{Read, Seek};
17122
17123 use common::{url::Params, ToParts};
17124 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17125
17126 let mut dd = common::DefaultDelegate;
17127 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17128 dlg.begin(common::MethodInfo {
17129 id: "spanner.projects.instances.databases.sessions.commit",
17130 http_method: hyper::Method::POST,
17131 });
17132
17133 for &field in ["alt", "session"].iter() {
17134 if self._additional_params.contains_key(field) {
17135 dlg.finished(false);
17136 return Err(common::Error::FieldClash(field));
17137 }
17138 }
17139
17140 let mut params = Params::with_capacity(4 + self._additional_params.len());
17141 params.push("session", self._session);
17142
17143 params.extend(self._additional_params.iter());
17144
17145 params.push("alt", "json");
17146 let mut url = self.hub._base_url.clone() + "v1/{+session}:commit";
17147 if self._scopes.is_empty() {
17148 self._scopes
17149 .insert(Scope::CloudPlatform.as_ref().to_string());
17150 }
17151
17152 #[allow(clippy::single_element_loop)]
17153 for &(find_this, param_name) in [("{+session}", "session")].iter() {
17154 url = params.uri_replacement(url, param_name, find_this, true);
17155 }
17156 {
17157 let to_remove = ["session"];
17158 params.remove_params(&to_remove);
17159 }
17160
17161 let url = params.parse_with_url(&url);
17162
17163 let mut json_mime_type = mime::APPLICATION_JSON;
17164 let mut request_value_reader = {
17165 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17166 common::remove_json_null_values(&mut value);
17167 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17168 serde_json::to_writer(&mut dst, &value).unwrap();
17169 dst
17170 };
17171 let request_size = request_value_reader
17172 .seek(std::io::SeekFrom::End(0))
17173 .unwrap();
17174 request_value_reader
17175 .seek(std::io::SeekFrom::Start(0))
17176 .unwrap();
17177
17178 loop {
17179 let token = match self
17180 .hub
17181 .auth
17182 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17183 .await
17184 {
17185 Ok(token) => token,
17186 Err(e) => match dlg.token(e) {
17187 Ok(token) => token,
17188 Err(e) => {
17189 dlg.finished(false);
17190 return Err(common::Error::MissingToken(e));
17191 }
17192 },
17193 };
17194 request_value_reader
17195 .seek(std::io::SeekFrom::Start(0))
17196 .unwrap();
17197 let mut req_result = {
17198 let client = &self.hub.client;
17199 dlg.pre_request();
17200 let mut req_builder = hyper::Request::builder()
17201 .method(hyper::Method::POST)
17202 .uri(url.as_str())
17203 .header(USER_AGENT, self.hub._user_agent.clone());
17204
17205 if let Some(token) = token.as_ref() {
17206 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17207 }
17208
17209 let request = req_builder
17210 .header(CONTENT_TYPE, json_mime_type.to_string())
17211 .header(CONTENT_LENGTH, request_size as u64)
17212 .body(common::to_body(
17213 request_value_reader.get_ref().clone().into(),
17214 ));
17215
17216 client.request(request.unwrap()).await
17217 };
17218
17219 match req_result {
17220 Err(err) => {
17221 if let common::Retry::After(d) = dlg.http_error(&err) {
17222 sleep(d).await;
17223 continue;
17224 }
17225 dlg.finished(false);
17226 return Err(common::Error::HttpError(err));
17227 }
17228 Ok(res) => {
17229 let (mut parts, body) = res.into_parts();
17230 let mut body = common::Body::new(body);
17231 if !parts.status.is_success() {
17232 let bytes = common::to_bytes(body).await.unwrap_or_default();
17233 let error = serde_json::from_str(&common::to_string(&bytes));
17234 let response = common::to_response(parts, bytes.into());
17235
17236 if let common::Retry::After(d) =
17237 dlg.http_failure(&response, error.as_ref().ok())
17238 {
17239 sleep(d).await;
17240 continue;
17241 }
17242
17243 dlg.finished(false);
17244
17245 return Err(match error {
17246 Ok(value) => common::Error::BadRequest(value),
17247 _ => common::Error::Failure(response),
17248 });
17249 }
17250 let response = {
17251 let bytes = common::to_bytes(body).await.unwrap_or_default();
17252 let encoded = common::to_string(&bytes);
17253 match serde_json::from_str(&encoded) {
17254 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17255 Err(error) => {
17256 dlg.response_json_decode_error(&encoded, &error);
17257 return Err(common::Error::JsonDecodeError(
17258 encoded.to_string(),
17259 error,
17260 ));
17261 }
17262 }
17263 };
17264
17265 dlg.finished(true);
17266 return Ok(response);
17267 }
17268 }
17269 }
17270 }
17271
17272 ///
17273 /// Sets the *request* property to the given value.
17274 ///
17275 /// Even though the property as already been set when instantiating this call,
17276 /// we provide this method for API completeness.
17277 pub fn request(
17278 mut self,
17279 new_value: CommitRequest,
17280 ) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
17281 self._request = new_value;
17282 self
17283 }
17284 /// Required. The session in which the transaction to be committed is running.
17285 ///
17286 /// Sets the *session* path property to the given value.
17287 ///
17288 /// Even though the property as already been set when instantiating this call,
17289 /// we provide this method for API completeness.
17290 pub fn session(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
17291 self._session = new_value.to_string();
17292 self
17293 }
17294 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17295 /// while executing the actual API request.
17296 ///
17297 /// ````text
17298 /// It should be used to handle progress information, and to implement a certain level of resilience.
17299 /// ````
17300 ///
17301 /// Sets the *delegate* property to the given value.
17302 pub fn delegate(
17303 mut self,
17304 new_value: &'a mut dyn common::Delegate,
17305 ) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
17306 self._delegate = Some(new_value);
17307 self
17308 }
17309
17310 /// Set any additional parameter of the query string used in the request.
17311 /// It should be used to set parameters which are not yet available through their own
17312 /// setters.
17313 ///
17314 /// Please note that this method must not be used to set any of the known parameters
17315 /// which have their own setter method. If done anyway, the request will fail.
17316 ///
17317 /// # Additional Parameters
17318 ///
17319 /// * *$.xgafv* (query-string) - V1 error format.
17320 /// * *access_token* (query-string) - OAuth access token.
17321 /// * *alt* (query-string) - Data format for response.
17322 /// * *callback* (query-string) - JSONP
17323 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17324 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17325 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17326 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17327 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17328 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17329 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17330 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionCommitCall<'a, C>
17331 where
17332 T: AsRef<str>,
17333 {
17334 self._additional_params
17335 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17336 self
17337 }
17338
17339 /// Identifies the authorization scope for the method you are building.
17340 ///
17341 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17342 /// [`Scope::CloudPlatform`].
17343 ///
17344 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17345 /// tokens for more than one scope.
17346 ///
17347 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17348 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17349 /// sufficient, a read-write scope will do as well.
17350 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionCommitCall<'a, C>
17351 where
17352 St: AsRef<str>,
17353 {
17354 self._scopes.insert(String::from(scope.as_ref()));
17355 self
17356 }
17357 /// Identifies the authorization scope(s) for the method you are building.
17358 ///
17359 /// See [`Self::add_scope()`] for details.
17360 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionCommitCall<'a, C>
17361 where
17362 I: IntoIterator<Item = St>,
17363 St: AsRef<str>,
17364 {
17365 self._scopes
17366 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17367 self
17368 }
17369
17370 /// Removes all scopes, and no default scope will be used either.
17371 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17372 /// for details).
17373 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionCommitCall<'a, C> {
17374 self._scopes.clear();
17375 self
17376 }
17377}
17378
17379/// 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 is a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner may delete sessions for which 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, e.g., `"SELECT 1"`.
17380///
17381/// A builder for the *instances.databases.sessions.create* method supported by a *project* resource.
17382/// It is not used directly, but through a [`ProjectMethods`] instance.
17383///
17384/// # Example
17385///
17386/// Instantiate a resource method builder
17387///
17388/// ```test_harness,no_run
17389/// # extern crate hyper;
17390/// # extern crate hyper_rustls;
17391/// # extern crate google_spanner1 as spanner1;
17392/// use spanner1::api::CreateSessionRequest;
17393/// # async fn dox() {
17394/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17395///
17396/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17397/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17398/// # secret,
17399/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17400/// # ).build().await.unwrap();
17401///
17402/// # let client = hyper_util::client::legacy::Client::builder(
17403/// # hyper_util::rt::TokioExecutor::new()
17404/// # )
17405/// # .build(
17406/// # hyper_rustls::HttpsConnectorBuilder::new()
17407/// # .with_native_roots()
17408/// # .unwrap()
17409/// # .https_or_http()
17410/// # .enable_http1()
17411/// # .build()
17412/// # );
17413/// # let mut hub = Spanner::new(client, auth);
17414/// // As the method needs a request, you would usually fill it with the desired information
17415/// // into the respective structure. Some of the parts shown here might not be applicable !
17416/// // Values shown here are possibly random and not representative !
17417/// let mut req = CreateSessionRequest::default();
17418///
17419/// // You can configure optional parameters by calling the respective setters at will, and
17420/// // execute the final call using `doit()`.
17421/// // Values shown here are possibly random and not representative !
17422/// let result = hub.projects().instances_databases_sessions_create(req, "database")
17423/// .doit().await;
17424/// # }
17425/// ```
17426pub struct ProjectInstanceDatabaseSessionCreateCall<'a, C>
17427where
17428 C: 'a,
17429{
17430 hub: &'a Spanner<C>,
17431 _request: CreateSessionRequest,
17432 _database: String,
17433 _delegate: Option<&'a mut dyn common::Delegate>,
17434 _additional_params: HashMap<String, String>,
17435 _scopes: BTreeSet<String>,
17436}
17437
17438impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionCreateCall<'a, C> {}
17439
17440impl<'a, C> ProjectInstanceDatabaseSessionCreateCall<'a, C>
17441where
17442 C: common::Connector,
17443{
17444 /// Perform the operation you have build so far.
17445 pub async fn doit(mut self) -> common::Result<(common::Response, Session)> {
17446 use std::borrow::Cow;
17447 use std::io::{Read, Seek};
17448
17449 use common::{url::Params, ToParts};
17450 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17451
17452 let mut dd = common::DefaultDelegate;
17453 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17454 dlg.begin(common::MethodInfo {
17455 id: "spanner.projects.instances.databases.sessions.create",
17456 http_method: hyper::Method::POST,
17457 });
17458
17459 for &field in ["alt", "database"].iter() {
17460 if self._additional_params.contains_key(field) {
17461 dlg.finished(false);
17462 return Err(common::Error::FieldClash(field));
17463 }
17464 }
17465
17466 let mut params = Params::with_capacity(4 + self._additional_params.len());
17467 params.push("database", self._database);
17468
17469 params.extend(self._additional_params.iter());
17470
17471 params.push("alt", "json");
17472 let mut url = self.hub._base_url.clone() + "v1/{+database}/sessions";
17473 if self._scopes.is_empty() {
17474 self._scopes
17475 .insert(Scope::CloudPlatform.as_ref().to_string());
17476 }
17477
17478 #[allow(clippy::single_element_loop)]
17479 for &(find_this, param_name) in [("{+database}", "database")].iter() {
17480 url = params.uri_replacement(url, param_name, find_this, true);
17481 }
17482 {
17483 let to_remove = ["database"];
17484 params.remove_params(&to_remove);
17485 }
17486
17487 let url = params.parse_with_url(&url);
17488
17489 let mut json_mime_type = mime::APPLICATION_JSON;
17490 let mut request_value_reader = {
17491 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17492 common::remove_json_null_values(&mut value);
17493 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17494 serde_json::to_writer(&mut dst, &value).unwrap();
17495 dst
17496 };
17497 let request_size = request_value_reader
17498 .seek(std::io::SeekFrom::End(0))
17499 .unwrap();
17500 request_value_reader
17501 .seek(std::io::SeekFrom::Start(0))
17502 .unwrap();
17503
17504 loop {
17505 let token = match self
17506 .hub
17507 .auth
17508 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17509 .await
17510 {
17511 Ok(token) => token,
17512 Err(e) => match dlg.token(e) {
17513 Ok(token) => token,
17514 Err(e) => {
17515 dlg.finished(false);
17516 return Err(common::Error::MissingToken(e));
17517 }
17518 },
17519 };
17520 request_value_reader
17521 .seek(std::io::SeekFrom::Start(0))
17522 .unwrap();
17523 let mut req_result = {
17524 let client = &self.hub.client;
17525 dlg.pre_request();
17526 let mut req_builder = hyper::Request::builder()
17527 .method(hyper::Method::POST)
17528 .uri(url.as_str())
17529 .header(USER_AGENT, self.hub._user_agent.clone());
17530
17531 if let Some(token) = token.as_ref() {
17532 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17533 }
17534
17535 let request = req_builder
17536 .header(CONTENT_TYPE, json_mime_type.to_string())
17537 .header(CONTENT_LENGTH, request_size as u64)
17538 .body(common::to_body(
17539 request_value_reader.get_ref().clone().into(),
17540 ));
17541
17542 client.request(request.unwrap()).await
17543 };
17544
17545 match req_result {
17546 Err(err) => {
17547 if let common::Retry::After(d) = dlg.http_error(&err) {
17548 sleep(d).await;
17549 continue;
17550 }
17551 dlg.finished(false);
17552 return Err(common::Error::HttpError(err));
17553 }
17554 Ok(res) => {
17555 let (mut parts, body) = res.into_parts();
17556 let mut body = common::Body::new(body);
17557 if !parts.status.is_success() {
17558 let bytes = common::to_bytes(body).await.unwrap_or_default();
17559 let error = serde_json::from_str(&common::to_string(&bytes));
17560 let response = common::to_response(parts, bytes.into());
17561
17562 if let common::Retry::After(d) =
17563 dlg.http_failure(&response, error.as_ref().ok())
17564 {
17565 sleep(d).await;
17566 continue;
17567 }
17568
17569 dlg.finished(false);
17570
17571 return Err(match error {
17572 Ok(value) => common::Error::BadRequest(value),
17573 _ => common::Error::Failure(response),
17574 });
17575 }
17576 let response = {
17577 let bytes = common::to_bytes(body).await.unwrap_or_default();
17578 let encoded = common::to_string(&bytes);
17579 match serde_json::from_str(&encoded) {
17580 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17581 Err(error) => {
17582 dlg.response_json_decode_error(&encoded, &error);
17583 return Err(common::Error::JsonDecodeError(
17584 encoded.to_string(),
17585 error,
17586 ));
17587 }
17588 }
17589 };
17590
17591 dlg.finished(true);
17592 return Ok(response);
17593 }
17594 }
17595 }
17596 }
17597
17598 ///
17599 /// Sets the *request* property to the given value.
17600 ///
17601 /// Even though the property as already been set when instantiating this call,
17602 /// we provide this method for API completeness.
17603 pub fn request(
17604 mut self,
17605 new_value: CreateSessionRequest,
17606 ) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
17607 self._request = new_value;
17608 self
17609 }
17610 /// Required. The database in which the new session is created.
17611 ///
17612 /// Sets the *database* path property to the given value.
17613 ///
17614 /// Even though the property as already been set when instantiating this call,
17615 /// we provide this method for API completeness.
17616 pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
17617 self._database = new_value.to_string();
17618 self
17619 }
17620 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17621 /// while executing the actual API request.
17622 ///
17623 /// ````text
17624 /// It should be used to handle progress information, and to implement a certain level of resilience.
17625 /// ````
17626 ///
17627 /// Sets the *delegate* property to the given value.
17628 pub fn delegate(
17629 mut self,
17630 new_value: &'a mut dyn common::Delegate,
17631 ) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
17632 self._delegate = Some(new_value);
17633 self
17634 }
17635
17636 /// Set any additional parameter of the query string used in the request.
17637 /// It should be used to set parameters which are not yet available through their own
17638 /// setters.
17639 ///
17640 /// Please note that this method must not be used to set any of the known parameters
17641 /// which have their own setter method. If done anyway, the request will fail.
17642 ///
17643 /// # Additional Parameters
17644 ///
17645 /// * *$.xgafv* (query-string) - V1 error format.
17646 /// * *access_token* (query-string) - OAuth access token.
17647 /// * *alt* (query-string) - Data format for response.
17648 /// * *callback* (query-string) - JSONP
17649 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17650 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17651 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17652 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17653 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17654 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17655 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17656 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionCreateCall<'a, C>
17657 where
17658 T: AsRef<str>,
17659 {
17660 self._additional_params
17661 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17662 self
17663 }
17664
17665 /// Identifies the authorization scope for the method you are building.
17666 ///
17667 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17668 /// [`Scope::CloudPlatform`].
17669 ///
17670 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17671 /// tokens for more than one scope.
17672 ///
17673 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17674 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17675 /// sufficient, a read-write scope will do as well.
17676 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionCreateCall<'a, C>
17677 where
17678 St: AsRef<str>,
17679 {
17680 self._scopes.insert(String::from(scope.as_ref()));
17681 self
17682 }
17683 /// Identifies the authorization scope(s) for the method you are building.
17684 ///
17685 /// See [`Self::add_scope()`] for details.
17686 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionCreateCall<'a, C>
17687 where
17688 I: IntoIterator<Item = St>,
17689 St: AsRef<str>,
17690 {
17691 self._scopes
17692 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17693 self
17694 }
17695
17696 /// Removes all scopes, and no default scope will be used either.
17697 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17698 /// for details).
17699 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionCreateCall<'a, C> {
17700 self._scopes.clear();
17701 self
17702 }
17703}
17704
17705/// Ends a session, releasing server resources associated with it. This will asynchronously trigger cancellation of any operations that are running with this session.
17706///
17707/// A builder for the *instances.databases.sessions.delete* method supported by a *project* resource.
17708/// It is not used directly, but through a [`ProjectMethods`] instance.
17709///
17710/// # Example
17711///
17712/// Instantiate a resource method builder
17713///
17714/// ```test_harness,no_run
17715/// # extern crate hyper;
17716/// # extern crate hyper_rustls;
17717/// # extern crate google_spanner1 as spanner1;
17718/// # async fn dox() {
17719/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17720///
17721/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17722/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17723/// # secret,
17724/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17725/// # ).build().await.unwrap();
17726///
17727/// # let client = hyper_util::client::legacy::Client::builder(
17728/// # hyper_util::rt::TokioExecutor::new()
17729/// # )
17730/// # .build(
17731/// # hyper_rustls::HttpsConnectorBuilder::new()
17732/// # .with_native_roots()
17733/// # .unwrap()
17734/// # .https_or_http()
17735/// # .enable_http1()
17736/// # .build()
17737/// # );
17738/// # let mut hub = Spanner::new(client, auth);
17739/// // You can configure optional parameters by calling the respective setters at will, and
17740/// // execute the final call using `doit()`.
17741/// // Values shown here are possibly random and not representative !
17742/// let result = hub.projects().instances_databases_sessions_delete("name")
17743/// .doit().await;
17744/// # }
17745/// ```
17746pub struct ProjectInstanceDatabaseSessionDeleteCall<'a, C>
17747where
17748 C: 'a,
17749{
17750 hub: &'a Spanner<C>,
17751 _name: String,
17752 _delegate: Option<&'a mut dyn common::Delegate>,
17753 _additional_params: HashMap<String, String>,
17754 _scopes: BTreeSet<String>,
17755}
17756
17757impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionDeleteCall<'a, C> {}
17758
17759impl<'a, C> ProjectInstanceDatabaseSessionDeleteCall<'a, C>
17760where
17761 C: common::Connector,
17762{
17763 /// Perform the operation you have build so far.
17764 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
17765 use std::borrow::Cow;
17766 use std::io::{Read, Seek};
17767
17768 use common::{url::Params, ToParts};
17769 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17770
17771 let mut dd = common::DefaultDelegate;
17772 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17773 dlg.begin(common::MethodInfo {
17774 id: "spanner.projects.instances.databases.sessions.delete",
17775 http_method: hyper::Method::DELETE,
17776 });
17777
17778 for &field in ["alt", "name"].iter() {
17779 if self._additional_params.contains_key(field) {
17780 dlg.finished(false);
17781 return Err(common::Error::FieldClash(field));
17782 }
17783 }
17784
17785 let mut params = Params::with_capacity(3 + self._additional_params.len());
17786 params.push("name", self._name);
17787
17788 params.extend(self._additional_params.iter());
17789
17790 params.push("alt", "json");
17791 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17792 if self._scopes.is_empty() {
17793 self._scopes
17794 .insert(Scope::CloudPlatform.as_ref().to_string());
17795 }
17796
17797 #[allow(clippy::single_element_loop)]
17798 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17799 url = params.uri_replacement(url, param_name, find_this, true);
17800 }
17801 {
17802 let to_remove = ["name"];
17803 params.remove_params(&to_remove);
17804 }
17805
17806 let url = params.parse_with_url(&url);
17807
17808 loop {
17809 let token = match self
17810 .hub
17811 .auth
17812 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17813 .await
17814 {
17815 Ok(token) => token,
17816 Err(e) => match dlg.token(e) {
17817 Ok(token) => token,
17818 Err(e) => {
17819 dlg.finished(false);
17820 return Err(common::Error::MissingToken(e));
17821 }
17822 },
17823 };
17824 let mut req_result = {
17825 let client = &self.hub.client;
17826 dlg.pre_request();
17827 let mut req_builder = hyper::Request::builder()
17828 .method(hyper::Method::DELETE)
17829 .uri(url.as_str())
17830 .header(USER_AGENT, self.hub._user_agent.clone());
17831
17832 if let Some(token) = token.as_ref() {
17833 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17834 }
17835
17836 let request = req_builder
17837 .header(CONTENT_LENGTH, 0_u64)
17838 .body(common::to_body::<String>(None));
17839
17840 client.request(request.unwrap()).await
17841 };
17842
17843 match req_result {
17844 Err(err) => {
17845 if let common::Retry::After(d) = dlg.http_error(&err) {
17846 sleep(d).await;
17847 continue;
17848 }
17849 dlg.finished(false);
17850 return Err(common::Error::HttpError(err));
17851 }
17852 Ok(res) => {
17853 let (mut parts, body) = res.into_parts();
17854 let mut body = common::Body::new(body);
17855 if !parts.status.is_success() {
17856 let bytes = common::to_bytes(body).await.unwrap_or_default();
17857 let error = serde_json::from_str(&common::to_string(&bytes));
17858 let response = common::to_response(parts, bytes.into());
17859
17860 if let common::Retry::After(d) =
17861 dlg.http_failure(&response, error.as_ref().ok())
17862 {
17863 sleep(d).await;
17864 continue;
17865 }
17866
17867 dlg.finished(false);
17868
17869 return Err(match error {
17870 Ok(value) => common::Error::BadRequest(value),
17871 _ => common::Error::Failure(response),
17872 });
17873 }
17874 let response = {
17875 let bytes = common::to_bytes(body).await.unwrap_or_default();
17876 let encoded = common::to_string(&bytes);
17877 match serde_json::from_str(&encoded) {
17878 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17879 Err(error) => {
17880 dlg.response_json_decode_error(&encoded, &error);
17881 return Err(common::Error::JsonDecodeError(
17882 encoded.to_string(),
17883 error,
17884 ));
17885 }
17886 }
17887 };
17888
17889 dlg.finished(true);
17890 return Ok(response);
17891 }
17892 }
17893 }
17894 }
17895
17896 /// Required. The name of the session to delete.
17897 ///
17898 /// Sets the *name* path property to the given value.
17899 ///
17900 /// Even though the property as already been set when instantiating this call,
17901 /// we provide this method for API completeness.
17902 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C> {
17903 self._name = new_value.to_string();
17904 self
17905 }
17906 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17907 /// while executing the actual API request.
17908 ///
17909 /// ````text
17910 /// It should be used to handle progress information, and to implement a certain level of resilience.
17911 /// ````
17912 ///
17913 /// Sets the *delegate* property to the given value.
17914 pub fn delegate(
17915 mut self,
17916 new_value: &'a mut dyn common::Delegate,
17917 ) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C> {
17918 self._delegate = Some(new_value);
17919 self
17920 }
17921
17922 /// Set any additional parameter of the query string used in the request.
17923 /// It should be used to set parameters which are not yet available through their own
17924 /// setters.
17925 ///
17926 /// Please note that this method must not be used to set any of the known parameters
17927 /// which have their own setter method. If done anyway, the request will fail.
17928 ///
17929 /// # Additional Parameters
17930 ///
17931 /// * *$.xgafv* (query-string) - V1 error format.
17932 /// * *access_token* (query-string) - OAuth access token.
17933 /// * *alt* (query-string) - Data format for response.
17934 /// * *callback* (query-string) - JSONP
17935 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17936 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17937 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17938 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17939 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17940 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17941 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17942 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C>
17943 where
17944 T: AsRef<str>,
17945 {
17946 self._additional_params
17947 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17948 self
17949 }
17950
17951 /// Identifies the authorization scope for the method you are building.
17952 ///
17953 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17954 /// [`Scope::CloudPlatform`].
17955 ///
17956 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17957 /// tokens for more than one scope.
17958 ///
17959 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17960 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17961 /// sufficient, a read-write scope will do as well.
17962 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C>
17963 where
17964 St: AsRef<str>,
17965 {
17966 self._scopes.insert(String::from(scope.as_ref()));
17967 self
17968 }
17969 /// Identifies the authorization scope(s) for the method you are building.
17970 ///
17971 /// See [`Self::add_scope()`] for details.
17972 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C>
17973 where
17974 I: IntoIterator<Item = St>,
17975 St: AsRef<str>,
17976 {
17977 self._scopes
17978 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17979 self
17980 }
17981
17982 /// Removes all scopes, and no default scope will be used either.
17983 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17984 /// for details).
17985 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionDeleteCall<'a, C> {
17986 self._scopes.clear();
17987 self
17988 }
17989}
17990
17991/// 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.
17992///
17993/// A builder for the *instances.databases.sessions.executeBatchDml* method supported by a *project* resource.
17994/// It is not used directly, but through a [`ProjectMethods`] instance.
17995///
17996/// # Example
17997///
17998/// Instantiate a resource method builder
17999///
18000/// ```test_harness,no_run
18001/// # extern crate hyper;
18002/// # extern crate hyper_rustls;
18003/// # extern crate google_spanner1 as spanner1;
18004/// use spanner1::api::ExecuteBatchDmlRequest;
18005/// # async fn dox() {
18006/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18007///
18008/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18009/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18010/// # secret,
18011/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18012/// # ).build().await.unwrap();
18013///
18014/// # let client = hyper_util::client::legacy::Client::builder(
18015/// # hyper_util::rt::TokioExecutor::new()
18016/// # )
18017/// # .build(
18018/// # hyper_rustls::HttpsConnectorBuilder::new()
18019/// # .with_native_roots()
18020/// # .unwrap()
18021/// # .https_or_http()
18022/// # .enable_http1()
18023/// # .build()
18024/// # );
18025/// # let mut hub = Spanner::new(client, auth);
18026/// // As the method needs a request, you would usually fill it with the desired information
18027/// // into the respective structure. Some of the parts shown here might not be applicable !
18028/// // Values shown here are possibly random and not representative !
18029/// let mut req = ExecuteBatchDmlRequest::default();
18030///
18031/// // You can configure optional parameters by calling the respective setters at will, and
18032/// // execute the final call using `doit()`.
18033/// // Values shown here are possibly random and not representative !
18034/// let result = hub.projects().instances_databases_sessions_execute_batch_dml(req, "session")
18035/// .doit().await;
18036/// # }
18037/// ```
18038pub struct ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
18039where
18040 C: 'a,
18041{
18042 hub: &'a Spanner<C>,
18043 _request: ExecuteBatchDmlRequest,
18044 _session: String,
18045 _delegate: Option<&'a mut dyn common::Delegate>,
18046 _additional_params: HashMap<String, String>,
18047 _scopes: BTreeSet<String>,
18048}
18049
18050impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {}
18051
18052impl<'a, C> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
18053where
18054 C: common::Connector,
18055{
18056 /// Perform the operation you have build so far.
18057 pub async fn doit(mut self) -> common::Result<(common::Response, ExecuteBatchDmlResponse)> {
18058 use std::borrow::Cow;
18059 use std::io::{Read, Seek};
18060
18061 use common::{url::Params, ToParts};
18062 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18063
18064 let mut dd = common::DefaultDelegate;
18065 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18066 dlg.begin(common::MethodInfo {
18067 id: "spanner.projects.instances.databases.sessions.executeBatchDml",
18068 http_method: hyper::Method::POST,
18069 });
18070
18071 for &field in ["alt", "session"].iter() {
18072 if self._additional_params.contains_key(field) {
18073 dlg.finished(false);
18074 return Err(common::Error::FieldClash(field));
18075 }
18076 }
18077
18078 let mut params = Params::with_capacity(4 + self._additional_params.len());
18079 params.push("session", self._session);
18080
18081 params.extend(self._additional_params.iter());
18082
18083 params.push("alt", "json");
18084 let mut url = self.hub._base_url.clone() + "v1/{+session}:executeBatchDml";
18085 if self._scopes.is_empty() {
18086 self._scopes
18087 .insert(Scope::CloudPlatform.as_ref().to_string());
18088 }
18089
18090 #[allow(clippy::single_element_loop)]
18091 for &(find_this, param_name) in [("{+session}", "session")].iter() {
18092 url = params.uri_replacement(url, param_name, find_this, true);
18093 }
18094 {
18095 let to_remove = ["session"];
18096 params.remove_params(&to_remove);
18097 }
18098
18099 let url = params.parse_with_url(&url);
18100
18101 let mut json_mime_type = mime::APPLICATION_JSON;
18102 let mut request_value_reader = {
18103 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18104 common::remove_json_null_values(&mut value);
18105 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18106 serde_json::to_writer(&mut dst, &value).unwrap();
18107 dst
18108 };
18109 let request_size = request_value_reader
18110 .seek(std::io::SeekFrom::End(0))
18111 .unwrap();
18112 request_value_reader
18113 .seek(std::io::SeekFrom::Start(0))
18114 .unwrap();
18115
18116 loop {
18117 let token = match self
18118 .hub
18119 .auth
18120 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18121 .await
18122 {
18123 Ok(token) => token,
18124 Err(e) => match dlg.token(e) {
18125 Ok(token) => token,
18126 Err(e) => {
18127 dlg.finished(false);
18128 return Err(common::Error::MissingToken(e));
18129 }
18130 },
18131 };
18132 request_value_reader
18133 .seek(std::io::SeekFrom::Start(0))
18134 .unwrap();
18135 let mut req_result = {
18136 let client = &self.hub.client;
18137 dlg.pre_request();
18138 let mut req_builder = hyper::Request::builder()
18139 .method(hyper::Method::POST)
18140 .uri(url.as_str())
18141 .header(USER_AGENT, self.hub._user_agent.clone());
18142
18143 if let Some(token) = token.as_ref() {
18144 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18145 }
18146
18147 let request = req_builder
18148 .header(CONTENT_TYPE, json_mime_type.to_string())
18149 .header(CONTENT_LENGTH, request_size as u64)
18150 .body(common::to_body(
18151 request_value_reader.get_ref().clone().into(),
18152 ));
18153
18154 client.request(request.unwrap()).await
18155 };
18156
18157 match req_result {
18158 Err(err) => {
18159 if let common::Retry::After(d) = dlg.http_error(&err) {
18160 sleep(d).await;
18161 continue;
18162 }
18163 dlg.finished(false);
18164 return Err(common::Error::HttpError(err));
18165 }
18166 Ok(res) => {
18167 let (mut parts, body) = res.into_parts();
18168 let mut body = common::Body::new(body);
18169 if !parts.status.is_success() {
18170 let bytes = common::to_bytes(body).await.unwrap_or_default();
18171 let error = serde_json::from_str(&common::to_string(&bytes));
18172 let response = common::to_response(parts, bytes.into());
18173
18174 if let common::Retry::After(d) =
18175 dlg.http_failure(&response, error.as_ref().ok())
18176 {
18177 sleep(d).await;
18178 continue;
18179 }
18180
18181 dlg.finished(false);
18182
18183 return Err(match error {
18184 Ok(value) => common::Error::BadRequest(value),
18185 _ => common::Error::Failure(response),
18186 });
18187 }
18188 let response = {
18189 let bytes = common::to_bytes(body).await.unwrap_or_default();
18190 let encoded = common::to_string(&bytes);
18191 match serde_json::from_str(&encoded) {
18192 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18193 Err(error) => {
18194 dlg.response_json_decode_error(&encoded, &error);
18195 return Err(common::Error::JsonDecodeError(
18196 encoded.to_string(),
18197 error,
18198 ));
18199 }
18200 }
18201 };
18202
18203 dlg.finished(true);
18204 return Ok(response);
18205 }
18206 }
18207 }
18208 }
18209
18210 ///
18211 /// Sets the *request* property to the given value.
18212 ///
18213 /// Even though the property as already been set when instantiating this call,
18214 /// we provide this method for API completeness.
18215 pub fn request(
18216 mut self,
18217 new_value: ExecuteBatchDmlRequest,
18218 ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
18219 self._request = new_value;
18220 self
18221 }
18222 /// Required. The session in which the DML statements should be performed.
18223 ///
18224 /// Sets the *session* path property to the given value.
18225 ///
18226 /// Even though the property as already been set when instantiating this call,
18227 /// we provide this method for API completeness.
18228 pub fn session(
18229 mut self,
18230 new_value: &str,
18231 ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
18232 self._session = new_value.to_string();
18233 self
18234 }
18235 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18236 /// while executing the actual API request.
18237 ///
18238 /// ````text
18239 /// It should be used to handle progress information, and to implement a certain level of resilience.
18240 /// ````
18241 ///
18242 /// Sets the *delegate* property to the given value.
18243 pub fn delegate(
18244 mut self,
18245 new_value: &'a mut dyn common::Delegate,
18246 ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
18247 self._delegate = Some(new_value);
18248 self
18249 }
18250
18251 /// Set any additional parameter of the query string used in the request.
18252 /// It should be used to set parameters which are not yet available through their own
18253 /// setters.
18254 ///
18255 /// Please note that this method must not be used to set any of the known parameters
18256 /// which have their own setter method. If done anyway, the request will fail.
18257 ///
18258 /// # Additional Parameters
18259 ///
18260 /// * *$.xgafv* (query-string) - V1 error format.
18261 /// * *access_token* (query-string) - OAuth access token.
18262 /// * *alt* (query-string) - Data format for response.
18263 /// * *callback* (query-string) - JSONP
18264 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18265 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18266 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18267 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18268 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18269 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18270 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18271 pub fn param<T>(
18272 mut self,
18273 name: T,
18274 value: T,
18275 ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
18276 where
18277 T: AsRef<str>,
18278 {
18279 self._additional_params
18280 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18281 self
18282 }
18283
18284 /// Identifies the authorization scope for the method you are building.
18285 ///
18286 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18287 /// [`Scope::CloudPlatform`].
18288 ///
18289 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18290 /// tokens for more than one scope.
18291 ///
18292 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18293 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18294 /// sufficient, a read-write scope will do as well.
18295 pub fn add_scope<St>(
18296 mut self,
18297 scope: St,
18298 ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
18299 where
18300 St: AsRef<str>,
18301 {
18302 self._scopes.insert(String::from(scope.as_ref()));
18303 self
18304 }
18305 /// Identifies the authorization scope(s) for the method you are building.
18306 ///
18307 /// See [`Self::add_scope()`] for details.
18308 pub fn add_scopes<I, St>(
18309 mut self,
18310 scopes: I,
18311 ) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C>
18312 where
18313 I: IntoIterator<Item = St>,
18314 St: AsRef<str>,
18315 {
18316 self._scopes
18317 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18318 self
18319 }
18320
18321 /// Removes all scopes, and no default scope will be used either.
18322 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18323 /// for details).
18324 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionExecuteBatchDmlCall<'a, C> {
18325 self._scopes.clear();
18326 self
18327 }
18328}
18329
18330/// Executes an SQL statement, returning all results in a single reply. This method cannot 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.
18331///
18332/// A builder for the *instances.databases.sessions.executeSql* method supported by a *project* resource.
18333/// It is not used directly, but through a [`ProjectMethods`] instance.
18334///
18335/// # Example
18336///
18337/// Instantiate a resource method builder
18338///
18339/// ```test_harness,no_run
18340/// # extern crate hyper;
18341/// # extern crate hyper_rustls;
18342/// # extern crate google_spanner1 as spanner1;
18343/// use spanner1::api::ExecuteSqlRequest;
18344/// # async fn dox() {
18345/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18346///
18347/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18348/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18349/// # secret,
18350/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18351/// # ).build().await.unwrap();
18352///
18353/// # let client = hyper_util::client::legacy::Client::builder(
18354/// # hyper_util::rt::TokioExecutor::new()
18355/// # )
18356/// # .build(
18357/// # hyper_rustls::HttpsConnectorBuilder::new()
18358/// # .with_native_roots()
18359/// # .unwrap()
18360/// # .https_or_http()
18361/// # .enable_http1()
18362/// # .build()
18363/// # );
18364/// # let mut hub = Spanner::new(client, auth);
18365/// // As the method needs a request, you would usually fill it with the desired information
18366/// // into the respective structure. Some of the parts shown here might not be applicable !
18367/// // Values shown here are possibly random and not representative !
18368/// let mut req = ExecuteSqlRequest::default();
18369///
18370/// // You can configure optional parameters by calling the respective setters at will, and
18371/// // execute the final call using `doit()`.
18372/// // Values shown here are possibly random and not representative !
18373/// let result = hub.projects().instances_databases_sessions_execute_sql(req, "session")
18374/// .doit().await;
18375/// # }
18376/// ```
18377pub struct ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
18378where
18379 C: 'a,
18380{
18381 hub: &'a Spanner<C>,
18382 _request: ExecuteSqlRequest,
18383 _session: String,
18384 _delegate: Option<&'a mut dyn common::Delegate>,
18385 _additional_params: HashMap<String, String>,
18386 _scopes: BTreeSet<String>,
18387}
18388
18389impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {}
18390
18391impl<'a, C> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
18392where
18393 C: common::Connector,
18394{
18395 /// Perform the operation you have build so far.
18396 pub async fn doit(mut self) -> common::Result<(common::Response, ResultSet)> {
18397 use std::borrow::Cow;
18398 use std::io::{Read, Seek};
18399
18400 use common::{url::Params, ToParts};
18401 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18402
18403 let mut dd = common::DefaultDelegate;
18404 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18405 dlg.begin(common::MethodInfo {
18406 id: "spanner.projects.instances.databases.sessions.executeSql",
18407 http_method: hyper::Method::POST,
18408 });
18409
18410 for &field in ["alt", "session"].iter() {
18411 if self._additional_params.contains_key(field) {
18412 dlg.finished(false);
18413 return Err(common::Error::FieldClash(field));
18414 }
18415 }
18416
18417 let mut params = Params::with_capacity(4 + self._additional_params.len());
18418 params.push("session", self._session);
18419
18420 params.extend(self._additional_params.iter());
18421
18422 params.push("alt", "json");
18423 let mut url = self.hub._base_url.clone() + "v1/{+session}:executeSql";
18424 if self._scopes.is_empty() {
18425 self._scopes
18426 .insert(Scope::CloudPlatform.as_ref().to_string());
18427 }
18428
18429 #[allow(clippy::single_element_loop)]
18430 for &(find_this, param_name) in [("{+session}", "session")].iter() {
18431 url = params.uri_replacement(url, param_name, find_this, true);
18432 }
18433 {
18434 let to_remove = ["session"];
18435 params.remove_params(&to_remove);
18436 }
18437
18438 let url = params.parse_with_url(&url);
18439
18440 let mut json_mime_type = mime::APPLICATION_JSON;
18441 let mut request_value_reader = {
18442 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18443 common::remove_json_null_values(&mut value);
18444 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18445 serde_json::to_writer(&mut dst, &value).unwrap();
18446 dst
18447 };
18448 let request_size = request_value_reader
18449 .seek(std::io::SeekFrom::End(0))
18450 .unwrap();
18451 request_value_reader
18452 .seek(std::io::SeekFrom::Start(0))
18453 .unwrap();
18454
18455 loop {
18456 let token = match self
18457 .hub
18458 .auth
18459 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18460 .await
18461 {
18462 Ok(token) => token,
18463 Err(e) => match dlg.token(e) {
18464 Ok(token) => token,
18465 Err(e) => {
18466 dlg.finished(false);
18467 return Err(common::Error::MissingToken(e));
18468 }
18469 },
18470 };
18471 request_value_reader
18472 .seek(std::io::SeekFrom::Start(0))
18473 .unwrap();
18474 let mut req_result = {
18475 let client = &self.hub.client;
18476 dlg.pre_request();
18477 let mut req_builder = hyper::Request::builder()
18478 .method(hyper::Method::POST)
18479 .uri(url.as_str())
18480 .header(USER_AGENT, self.hub._user_agent.clone());
18481
18482 if let Some(token) = token.as_ref() {
18483 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18484 }
18485
18486 let request = req_builder
18487 .header(CONTENT_TYPE, json_mime_type.to_string())
18488 .header(CONTENT_LENGTH, request_size as u64)
18489 .body(common::to_body(
18490 request_value_reader.get_ref().clone().into(),
18491 ));
18492
18493 client.request(request.unwrap()).await
18494 };
18495
18496 match req_result {
18497 Err(err) => {
18498 if let common::Retry::After(d) = dlg.http_error(&err) {
18499 sleep(d).await;
18500 continue;
18501 }
18502 dlg.finished(false);
18503 return Err(common::Error::HttpError(err));
18504 }
18505 Ok(res) => {
18506 let (mut parts, body) = res.into_parts();
18507 let mut body = common::Body::new(body);
18508 if !parts.status.is_success() {
18509 let bytes = common::to_bytes(body).await.unwrap_or_default();
18510 let error = serde_json::from_str(&common::to_string(&bytes));
18511 let response = common::to_response(parts, bytes.into());
18512
18513 if let common::Retry::After(d) =
18514 dlg.http_failure(&response, error.as_ref().ok())
18515 {
18516 sleep(d).await;
18517 continue;
18518 }
18519
18520 dlg.finished(false);
18521
18522 return Err(match error {
18523 Ok(value) => common::Error::BadRequest(value),
18524 _ => common::Error::Failure(response),
18525 });
18526 }
18527 let response = {
18528 let bytes = common::to_bytes(body).await.unwrap_or_default();
18529 let encoded = common::to_string(&bytes);
18530 match serde_json::from_str(&encoded) {
18531 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18532 Err(error) => {
18533 dlg.response_json_decode_error(&encoded, &error);
18534 return Err(common::Error::JsonDecodeError(
18535 encoded.to_string(),
18536 error,
18537 ));
18538 }
18539 }
18540 };
18541
18542 dlg.finished(true);
18543 return Ok(response);
18544 }
18545 }
18546 }
18547 }
18548
18549 ///
18550 /// Sets the *request* property to the given value.
18551 ///
18552 /// Even though the property as already been set when instantiating this call,
18553 /// we provide this method for API completeness.
18554 pub fn request(
18555 mut self,
18556 new_value: ExecuteSqlRequest,
18557 ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
18558 self._request = new_value;
18559 self
18560 }
18561 /// Required. The session in which the SQL query should be performed.
18562 ///
18563 /// Sets the *session* path property to the given value.
18564 ///
18565 /// Even though the property as already been set when instantiating this call,
18566 /// we provide this method for API completeness.
18567 pub fn session(
18568 mut self,
18569 new_value: &str,
18570 ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
18571 self._session = new_value.to_string();
18572 self
18573 }
18574 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18575 /// while executing the actual API request.
18576 ///
18577 /// ````text
18578 /// It should be used to handle progress information, and to implement a certain level of resilience.
18579 /// ````
18580 ///
18581 /// Sets the *delegate* property to the given value.
18582 pub fn delegate(
18583 mut self,
18584 new_value: &'a mut dyn common::Delegate,
18585 ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
18586 self._delegate = Some(new_value);
18587 self
18588 }
18589
18590 /// Set any additional parameter of the query string used in the request.
18591 /// It should be used to set parameters which are not yet available through their own
18592 /// setters.
18593 ///
18594 /// Please note that this method must not be used to set any of the known parameters
18595 /// which have their own setter method. If done anyway, the request will fail.
18596 ///
18597 /// # Additional Parameters
18598 ///
18599 /// * *$.xgafv* (query-string) - V1 error format.
18600 /// * *access_token* (query-string) - OAuth access token.
18601 /// * *alt* (query-string) - Data format for response.
18602 /// * *callback* (query-string) - JSONP
18603 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18604 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18605 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18606 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18607 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18608 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18609 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18610 pub fn param<T>(
18611 mut self,
18612 name: T,
18613 value: T,
18614 ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
18615 where
18616 T: AsRef<str>,
18617 {
18618 self._additional_params
18619 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18620 self
18621 }
18622
18623 /// Identifies the authorization scope for the method you are building.
18624 ///
18625 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18626 /// [`Scope::CloudPlatform`].
18627 ///
18628 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18629 /// tokens for more than one scope.
18630 ///
18631 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18632 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18633 /// sufficient, a read-write scope will do as well.
18634 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
18635 where
18636 St: AsRef<str>,
18637 {
18638 self._scopes.insert(String::from(scope.as_ref()));
18639 self
18640 }
18641 /// Identifies the authorization scope(s) for the method you are building.
18642 ///
18643 /// See [`Self::add_scope()`] for details.
18644 pub fn add_scopes<I, St>(
18645 mut self,
18646 scopes: I,
18647 ) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C>
18648 where
18649 I: IntoIterator<Item = St>,
18650 St: AsRef<str>,
18651 {
18652 self._scopes
18653 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18654 self
18655 }
18656
18657 /// Removes all scopes, and no default scope will be used either.
18658 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18659 /// for details).
18660 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionExecuteSqlCall<'a, C> {
18661 self._scopes.clear();
18662 self
18663 }
18664}
18665
18666/// 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.
18667///
18668/// A builder for the *instances.databases.sessions.executeStreamingSql* method supported by a *project* resource.
18669/// It is not used directly, but through a [`ProjectMethods`] instance.
18670///
18671/// # Example
18672///
18673/// Instantiate a resource method builder
18674///
18675/// ```test_harness,no_run
18676/// # extern crate hyper;
18677/// # extern crate hyper_rustls;
18678/// # extern crate google_spanner1 as spanner1;
18679/// use spanner1::api::ExecuteSqlRequest;
18680/// # async fn dox() {
18681/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18682///
18683/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18684/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18685/// # secret,
18686/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18687/// # ).build().await.unwrap();
18688///
18689/// # let client = hyper_util::client::legacy::Client::builder(
18690/// # hyper_util::rt::TokioExecutor::new()
18691/// # )
18692/// # .build(
18693/// # hyper_rustls::HttpsConnectorBuilder::new()
18694/// # .with_native_roots()
18695/// # .unwrap()
18696/// # .https_or_http()
18697/// # .enable_http1()
18698/// # .build()
18699/// # );
18700/// # let mut hub = Spanner::new(client, auth);
18701/// // As the method needs a request, you would usually fill it with the desired information
18702/// // into the respective structure. Some of the parts shown here might not be applicable !
18703/// // Values shown here are possibly random and not representative !
18704/// let mut req = ExecuteSqlRequest::default();
18705///
18706/// // You can configure optional parameters by calling the respective setters at will, and
18707/// // execute the final call using `doit()`.
18708/// // Values shown here are possibly random and not representative !
18709/// let result = hub.projects().instances_databases_sessions_execute_streaming_sql(req, "session")
18710/// .doit().await;
18711/// # }
18712/// ```
18713pub struct ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
18714where
18715 C: 'a,
18716{
18717 hub: &'a Spanner<C>,
18718 _request: ExecuteSqlRequest,
18719 _session: String,
18720 _delegate: Option<&'a mut dyn common::Delegate>,
18721 _additional_params: HashMap<String, String>,
18722 _scopes: BTreeSet<String>,
18723}
18724
18725impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {}
18726
18727impl<'a, C> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
18728where
18729 C: common::Connector,
18730{
18731 /// Perform the operation you have build so far.
18732 pub async fn doit(mut self) -> common::Result<(common::Response, PartialResultSet)> {
18733 use std::borrow::Cow;
18734 use std::io::{Read, Seek};
18735
18736 use common::{url::Params, ToParts};
18737 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18738
18739 let mut dd = common::DefaultDelegate;
18740 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18741 dlg.begin(common::MethodInfo {
18742 id: "spanner.projects.instances.databases.sessions.executeStreamingSql",
18743 http_method: hyper::Method::POST,
18744 });
18745
18746 for &field in ["alt", "session"].iter() {
18747 if self._additional_params.contains_key(field) {
18748 dlg.finished(false);
18749 return Err(common::Error::FieldClash(field));
18750 }
18751 }
18752
18753 let mut params = Params::with_capacity(4 + self._additional_params.len());
18754 params.push("session", self._session);
18755
18756 params.extend(self._additional_params.iter());
18757
18758 params.push("alt", "json");
18759 let mut url = self.hub._base_url.clone() + "v1/{+session}:executeStreamingSql";
18760 if self._scopes.is_empty() {
18761 self._scopes
18762 .insert(Scope::CloudPlatform.as_ref().to_string());
18763 }
18764
18765 #[allow(clippy::single_element_loop)]
18766 for &(find_this, param_name) in [("{+session}", "session")].iter() {
18767 url = params.uri_replacement(url, param_name, find_this, true);
18768 }
18769 {
18770 let to_remove = ["session"];
18771 params.remove_params(&to_remove);
18772 }
18773
18774 let url = params.parse_with_url(&url);
18775
18776 let mut json_mime_type = mime::APPLICATION_JSON;
18777 let mut request_value_reader = {
18778 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18779 common::remove_json_null_values(&mut value);
18780 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18781 serde_json::to_writer(&mut dst, &value).unwrap();
18782 dst
18783 };
18784 let request_size = request_value_reader
18785 .seek(std::io::SeekFrom::End(0))
18786 .unwrap();
18787 request_value_reader
18788 .seek(std::io::SeekFrom::Start(0))
18789 .unwrap();
18790
18791 loop {
18792 let token = match self
18793 .hub
18794 .auth
18795 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18796 .await
18797 {
18798 Ok(token) => token,
18799 Err(e) => match dlg.token(e) {
18800 Ok(token) => token,
18801 Err(e) => {
18802 dlg.finished(false);
18803 return Err(common::Error::MissingToken(e));
18804 }
18805 },
18806 };
18807 request_value_reader
18808 .seek(std::io::SeekFrom::Start(0))
18809 .unwrap();
18810 let mut req_result = {
18811 let client = &self.hub.client;
18812 dlg.pre_request();
18813 let mut req_builder = hyper::Request::builder()
18814 .method(hyper::Method::POST)
18815 .uri(url.as_str())
18816 .header(USER_AGENT, self.hub._user_agent.clone());
18817
18818 if let Some(token) = token.as_ref() {
18819 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18820 }
18821
18822 let request = req_builder
18823 .header(CONTENT_TYPE, json_mime_type.to_string())
18824 .header(CONTENT_LENGTH, request_size as u64)
18825 .body(common::to_body(
18826 request_value_reader.get_ref().clone().into(),
18827 ));
18828
18829 client.request(request.unwrap()).await
18830 };
18831
18832 match req_result {
18833 Err(err) => {
18834 if let common::Retry::After(d) = dlg.http_error(&err) {
18835 sleep(d).await;
18836 continue;
18837 }
18838 dlg.finished(false);
18839 return Err(common::Error::HttpError(err));
18840 }
18841 Ok(res) => {
18842 let (mut parts, body) = res.into_parts();
18843 let mut body = common::Body::new(body);
18844 if !parts.status.is_success() {
18845 let bytes = common::to_bytes(body).await.unwrap_or_default();
18846 let error = serde_json::from_str(&common::to_string(&bytes));
18847 let response = common::to_response(parts, bytes.into());
18848
18849 if let common::Retry::After(d) =
18850 dlg.http_failure(&response, error.as_ref().ok())
18851 {
18852 sleep(d).await;
18853 continue;
18854 }
18855
18856 dlg.finished(false);
18857
18858 return Err(match error {
18859 Ok(value) => common::Error::BadRequest(value),
18860 _ => common::Error::Failure(response),
18861 });
18862 }
18863 let response = {
18864 let bytes = common::to_bytes(body).await.unwrap_or_default();
18865 let encoded = common::to_string(&bytes);
18866 match serde_json::from_str(&encoded) {
18867 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18868 Err(error) => {
18869 dlg.response_json_decode_error(&encoded, &error);
18870 return Err(common::Error::JsonDecodeError(
18871 encoded.to_string(),
18872 error,
18873 ));
18874 }
18875 }
18876 };
18877
18878 dlg.finished(true);
18879 return Ok(response);
18880 }
18881 }
18882 }
18883 }
18884
18885 ///
18886 /// Sets the *request* property to the given value.
18887 ///
18888 /// Even though the property as already been set when instantiating this call,
18889 /// we provide this method for API completeness.
18890 pub fn request(
18891 mut self,
18892 new_value: ExecuteSqlRequest,
18893 ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
18894 self._request = new_value;
18895 self
18896 }
18897 /// Required. The session in which the SQL query should be performed.
18898 ///
18899 /// Sets the *session* path property to the given value.
18900 ///
18901 /// Even though the property as already been set when instantiating this call,
18902 /// we provide this method for API completeness.
18903 pub fn session(
18904 mut self,
18905 new_value: &str,
18906 ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
18907 self._session = new_value.to_string();
18908 self
18909 }
18910 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18911 /// while executing the actual API request.
18912 ///
18913 /// ````text
18914 /// It should be used to handle progress information, and to implement a certain level of resilience.
18915 /// ````
18916 ///
18917 /// Sets the *delegate* property to the given value.
18918 pub fn delegate(
18919 mut self,
18920 new_value: &'a mut dyn common::Delegate,
18921 ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
18922 self._delegate = Some(new_value);
18923 self
18924 }
18925
18926 /// Set any additional parameter of the query string used in the request.
18927 /// It should be used to set parameters which are not yet available through their own
18928 /// setters.
18929 ///
18930 /// Please note that this method must not be used to set any of the known parameters
18931 /// which have their own setter method. If done anyway, the request will fail.
18932 ///
18933 /// # Additional Parameters
18934 ///
18935 /// * *$.xgafv* (query-string) - V1 error format.
18936 /// * *access_token* (query-string) - OAuth access token.
18937 /// * *alt* (query-string) - Data format for response.
18938 /// * *callback* (query-string) - JSONP
18939 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18940 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18941 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18942 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18943 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18944 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18945 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18946 pub fn param<T>(
18947 mut self,
18948 name: T,
18949 value: T,
18950 ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
18951 where
18952 T: AsRef<str>,
18953 {
18954 self._additional_params
18955 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18956 self
18957 }
18958
18959 /// Identifies the authorization scope for the method you are building.
18960 ///
18961 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18962 /// [`Scope::CloudPlatform`].
18963 ///
18964 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18965 /// tokens for more than one scope.
18966 ///
18967 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18968 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18969 /// sufficient, a read-write scope will do as well.
18970 pub fn add_scope<St>(
18971 mut self,
18972 scope: St,
18973 ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
18974 where
18975 St: AsRef<str>,
18976 {
18977 self._scopes.insert(String::from(scope.as_ref()));
18978 self
18979 }
18980 /// Identifies the authorization scope(s) for the method you are building.
18981 ///
18982 /// See [`Self::add_scope()`] for details.
18983 pub fn add_scopes<I, St>(
18984 mut self,
18985 scopes: I,
18986 ) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C>
18987 where
18988 I: IntoIterator<Item = St>,
18989 St: AsRef<str>,
18990 {
18991 self._scopes
18992 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18993 self
18994 }
18995
18996 /// Removes all scopes, and no default scope will be used either.
18997 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18998 /// for details).
18999 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionExecuteStreamingSqlCall<'a, C> {
19000 self._scopes.clear();
19001 self
19002 }
19003}
19004
19005/// Gets a session. Returns `NOT_FOUND` if the session does not exist. This is mainly useful for determining whether a session is still alive.
19006///
19007/// A builder for the *instances.databases.sessions.get* method supported by a *project* resource.
19008/// It is not used directly, but through a [`ProjectMethods`] instance.
19009///
19010/// # Example
19011///
19012/// Instantiate a resource method builder
19013///
19014/// ```test_harness,no_run
19015/// # extern crate hyper;
19016/// # extern crate hyper_rustls;
19017/// # extern crate google_spanner1 as spanner1;
19018/// # async fn dox() {
19019/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19020///
19021/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19022/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19023/// # secret,
19024/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19025/// # ).build().await.unwrap();
19026///
19027/// # let client = hyper_util::client::legacy::Client::builder(
19028/// # hyper_util::rt::TokioExecutor::new()
19029/// # )
19030/// # .build(
19031/// # hyper_rustls::HttpsConnectorBuilder::new()
19032/// # .with_native_roots()
19033/// # .unwrap()
19034/// # .https_or_http()
19035/// # .enable_http1()
19036/// # .build()
19037/// # );
19038/// # let mut hub = Spanner::new(client, auth);
19039/// // You can configure optional parameters by calling the respective setters at will, and
19040/// // execute the final call using `doit()`.
19041/// // Values shown here are possibly random and not representative !
19042/// let result = hub.projects().instances_databases_sessions_get("name")
19043/// .doit().await;
19044/// # }
19045/// ```
19046pub struct ProjectInstanceDatabaseSessionGetCall<'a, C>
19047where
19048 C: 'a,
19049{
19050 hub: &'a Spanner<C>,
19051 _name: String,
19052 _delegate: Option<&'a mut dyn common::Delegate>,
19053 _additional_params: HashMap<String, String>,
19054 _scopes: BTreeSet<String>,
19055}
19056
19057impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionGetCall<'a, C> {}
19058
19059impl<'a, C> ProjectInstanceDatabaseSessionGetCall<'a, C>
19060where
19061 C: common::Connector,
19062{
19063 /// Perform the operation you have build so far.
19064 pub async fn doit(mut self) -> common::Result<(common::Response, Session)> {
19065 use std::borrow::Cow;
19066 use std::io::{Read, Seek};
19067
19068 use common::{url::Params, ToParts};
19069 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19070
19071 let mut dd = common::DefaultDelegate;
19072 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19073 dlg.begin(common::MethodInfo {
19074 id: "spanner.projects.instances.databases.sessions.get",
19075 http_method: hyper::Method::GET,
19076 });
19077
19078 for &field in ["alt", "name"].iter() {
19079 if self._additional_params.contains_key(field) {
19080 dlg.finished(false);
19081 return Err(common::Error::FieldClash(field));
19082 }
19083 }
19084
19085 let mut params = Params::with_capacity(3 + self._additional_params.len());
19086 params.push("name", self._name);
19087
19088 params.extend(self._additional_params.iter());
19089
19090 params.push("alt", "json");
19091 let mut url = self.hub._base_url.clone() + "v1/{+name}";
19092 if self._scopes.is_empty() {
19093 self._scopes
19094 .insert(Scope::CloudPlatform.as_ref().to_string());
19095 }
19096
19097 #[allow(clippy::single_element_loop)]
19098 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19099 url = params.uri_replacement(url, param_name, find_this, true);
19100 }
19101 {
19102 let to_remove = ["name"];
19103 params.remove_params(&to_remove);
19104 }
19105
19106 let url = params.parse_with_url(&url);
19107
19108 loop {
19109 let token = match self
19110 .hub
19111 .auth
19112 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19113 .await
19114 {
19115 Ok(token) => token,
19116 Err(e) => match dlg.token(e) {
19117 Ok(token) => token,
19118 Err(e) => {
19119 dlg.finished(false);
19120 return Err(common::Error::MissingToken(e));
19121 }
19122 },
19123 };
19124 let mut req_result = {
19125 let client = &self.hub.client;
19126 dlg.pre_request();
19127 let mut req_builder = hyper::Request::builder()
19128 .method(hyper::Method::GET)
19129 .uri(url.as_str())
19130 .header(USER_AGENT, self.hub._user_agent.clone());
19131
19132 if let Some(token) = token.as_ref() {
19133 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19134 }
19135
19136 let request = req_builder
19137 .header(CONTENT_LENGTH, 0_u64)
19138 .body(common::to_body::<String>(None));
19139
19140 client.request(request.unwrap()).await
19141 };
19142
19143 match req_result {
19144 Err(err) => {
19145 if let common::Retry::After(d) = dlg.http_error(&err) {
19146 sleep(d).await;
19147 continue;
19148 }
19149 dlg.finished(false);
19150 return Err(common::Error::HttpError(err));
19151 }
19152 Ok(res) => {
19153 let (mut parts, body) = res.into_parts();
19154 let mut body = common::Body::new(body);
19155 if !parts.status.is_success() {
19156 let bytes = common::to_bytes(body).await.unwrap_or_default();
19157 let error = serde_json::from_str(&common::to_string(&bytes));
19158 let response = common::to_response(parts, bytes.into());
19159
19160 if let common::Retry::After(d) =
19161 dlg.http_failure(&response, error.as_ref().ok())
19162 {
19163 sleep(d).await;
19164 continue;
19165 }
19166
19167 dlg.finished(false);
19168
19169 return Err(match error {
19170 Ok(value) => common::Error::BadRequest(value),
19171 _ => common::Error::Failure(response),
19172 });
19173 }
19174 let response = {
19175 let bytes = common::to_bytes(body).await.unwrap_or_default();
19176 let encoded = common::to_string(&bytes);
19177 match serde_json::from_str(&encoded) {
19178 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19179 Err(error) => {
19180 dlg.response_json_decode_error(&encoded, &error);
19181 return Err(common::Error::JsonDecodeError(
19182 encoded.to_string(),
19183 error,
19184 ));
19185 }
19186 }
19187 };
19188
19189 dlg.finished(true);
19190 return Ok(response);
19191 }
19192 }
19193 }
19194 }
19195
19196 /// Required. The name of the session to retrieve.
19197 ///
19198 /// Sets the *name* path property to the given value.
19199 ///
19200 /// Even though the property as already been set when instantiating this call,
19201 /// we provide this method for API completeness.
19202 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionGetCall<'a, C> {
19203 self._name = new_value.to_string();
19204 self
19205 }
19206 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19207 /// while executing the actual API request.
19208 ///
19209 /// ````text
19210 /// It should be used to handle progress information, and to implement a certain level of resilience.
19211 /// ````
19212 ///
19213 /// Sets the *delegate* property to the given value.
19214 pub fn delegate(
19215 mut self,
19216 new_value: &'a mut dyn common::Delegate,
19217 ) -> ProjectInstanceDatabaseSessionGetCall<'a, C> {
19218 self._delegate = Some(new_value);
19219 self
19220 }
19221
19222 /// Set any additional parameter of the query string used in the request.
19223 /// It should be used to set parameters which are not yet available through their own
19224 /// setters.
19225 ///
19226 /// Please note that this method must not be used to set any of the known parameters
19227 /// which have their own setter method. If done anyway, the request will fail.
19228 ///
19229 /// # Additional Parameters
19230 ///
19231 /// * *$.xgafv* (query-string) - V1 error format.
19232 /// * *access_token* (query-string) - OAuth access token.
19233 /// * *alt* (query-string) - Data format for response.
19234 /// * *callback* (query-string) - JSONP
19235 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19236 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19237 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19238 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19239 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19240 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19241 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19242 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionGetCall<'a, C>
19243 where
19244 T: AsRef<str>,
19245 {
19246 self._additional_params
19247 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19248 self
19249 }
19250
19251 /// Identifies the authorization scope for the method you are building.
19252 ///
19253 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19254 /// [`Scope::CloudPlatform`].
19255 ///
19256 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19257 /// tokens for more than one scope.
19258 ///
19259 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19260 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19261 /// sufficient, a read-write scope will do as well.
19262 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionGetCall<'a, C>
19263 where
19264 St: AsRef<str>,
19265 {
19266 self._scopes.insert(String::from(scope.as_ref()));
19267 self
19268 }
19269 /// Identifies the authorization scope(s) for the method you are building.
19270 ///
19271 /// See [`Self::add_scope()`] for details.
19272 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionGetCall<'a, C>
19273 where
19274 I: IntoIterator<Item = St>,
19275 St: AsRef<str>,
19276 {
19277 self._scopes
19278 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19279 self
19280 }
19281
19282 /// Removes all scopes, and no default scope will be used either.
19283 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19284 /// for details).
19285 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionGetCall<'a, C> {
19286 self._scopes.clear();
19287 self
19288 }
19289}
19290
19291/// Lists all sessions in a given database.
19292///
19293/// A builder for the *instances.databases.sessions.list* method supported by a *project* resource.
19294/// It is not used directly, but through a [`ProjectMethods`] instance.
19295///
19296/// # Example
19297///
19298/// Instantiate a resource method builder
19299///
19300/// ```test_harness,no_run
19301/// # extern crate hyper;
19302/// # extern crate hyper_rustls;
19303/// # extern crate google_spanner1 as spanner1;
19304/// # async fn dox() {
19305/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19306///
19307/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19308/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19309/// # secret,
19310/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19311/// # ).build().await.unwrap();
19312///
19313/// # let client = hyper_util::client::legacy::Client::builder(
19314/// # hyper_util::rt::TokioExecutor::new()
19315/// # )
19316/// # .build(
19317/// # hyper_rustls::HttpsConnectorBuilder::new()
19318/// # .with_native_roots()
19319/// # .unwrap()
19320/// # .https_or_http()
19321/// # .enable_http1()
19322/// # .build()
19323/// # );
19324/// # let mut hub = Spanner::new(client, auth);
19325/// // You can configure optional parameters by calling the respective setters at will, and
19326/// // execute the final call using `doit()`.
19327/// // Values shown here are possibly random and not representative !
19328/// let result = hub.projects().instances_databases_sessions_list("database")
19329/// .page_token("ea")
19330/// .page_size(-95)
19331/// .filter("Lorem")
19332/// .doit().await;
19333/// # }
19334/// ```
19335pub struct ProjectInstanceDatabaseSessionListCall<'a, C>
19336where
19337 C: 'a,
19338{
19339 hub: &'a Spanner<C>,
19340 _database: String,
19341 _page_token: Option<String>,
19342 _page_size: Option<i32>,
19343 _filter: Option<String>,
19344 _delegate: Option<&'a mut dyn common::Delegate>,
19345 _additional_params: HashMap<String, String>,
19346 _scopes: BTreeSet<String>,
19347}
19348
19349impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionListCall<'a, C> {}
19350
19351impl<'a, C> ProjectInstanceDatabaseSessionListCall<'a, C>
19352where
19353 C: common::Connector,
19354{
19355 /// Perform the operation you have build so far.
19356 pub async fn doit(mut self) -> common::Result<(common::Response, ListSessionsResponse)> {
19357 use std::borrow::Cow;
19358 use std::io::{Read, Seek};
19359
19360 use common::{url::Params, ToParts};
19361 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19362
19363 let mut dd = common::DefaultDelegate;
19364 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19365 dlg.begin(common::MethodInfo {
19366 id: "spanner.projects.instances.databases.sessions.list",
19367 http_method: hyper::Method::GET,
19368 });
19369
19370 for &field in ["alt", "database", "pageToken", "pageSize", "filter"].iter() {
19371 if self._additional_params.contains_key(field) {
19372 dlg.finished(false);
19373 return Err(common::Error::FieldClash(field));
19374 }
19375 }
19376
19377 let mut params = Params::with_capacity(6 + self._additional_params.len());
19378 params.push("database", self._database);
19379 if let Some(value) = self._page_token.as_ref() {
19380 params.push("pageToken", value);
19381 }
19382 if let Some(value) = self._page_size.as_ref() {
19383 params.push("pageSize", value.to_string());
19384 }
19385 if let Some(value) = self._filter.as_ref() {
19386 params.push("filter", value);
19387 }
19388
19389 params.extend(self._additional_params.iter());
19390
19391 params.push("alt", "json");
19392 let mut url = self.hub._base_url.clone() + "v1/{+database}/sessions";
19393 if self._scopes.is_empty() {
19394 self._scopes
19395 .insert(Scope::CloudPlatform.as_ref().to_string());
19396 }
19397
19398 #[allow(clippy::single_element_loop)]
19399 for &(find_this, param_name) in [("{+database}", "database")].iter() {
19400 url = params.uri_replacement(url, param_name, find_this, true);
19401 }
19402 {
19403 let to_remove = ["database"];
19404 params.remove_params(&to_remove);
19405 }
19406
19407 let url = params.parse_with_url(&url);
19408
19409 loop {
19410 let token = match self
19411 .hub
19412 .auth
19413 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19414 .await
19415 {
19416 Ok(token) => token,
19417 Err(e) => match dlg.token(e) {
19418 Ok(token) => token,
19419 Err(e) => {
19420 dlg.finished(false);
19421 return Err(common::Error::MissingToken(e));
19422 }
19423 },
19424 };
19425 let mut req_result = {
19426 let client = &self.hub.client;
19427 dlg.pre_request();
19428 let mut req_builder = hyper::Request::builder()
19429 .method(hyper::Method::GET)
19430 .uri(url.as_str())
19431 .header(USER_AGENT, self.hub._user_agent.clone());
19432
19433 if let Some(token) = token.as_ref() {
19434 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19435 }
19436
19437 let request = req_builder
19438 .header(CONTENT_LENGTH, 0_u64)
19439 .body(common::to_body::<String>(None));
19440
19441 client.request(request.unwrap()).await
19442 };
19443
19444 match req_result {
19445 Err(err) => {
19446 if let common::Retry::After(d) = dlg.http_error(&err) {
19447 sleep(d).await;
19448 continue;
19449 }
19450 dlg.finished(false);
19451 return Err(common::Error::HttpError(err));
19452 }
19453 Ok(res) => {
19454 let (mut parts, body) = res.into_parts();
19455 let mut body = common::Body::new(body);
19456 if !parts.status.is_success() {
19457 let bytes = common::to_bytes(body).await.unwrap_or_default();
19458 let error = serde_json::from_str(&common::to_string(&bytes));
19459 let response = common::to_response(parts, bytes.into());
19460
19461 if let common::Retry::After(d) =
19462 dlg.http_failure(&response, error.as_ref().ok())
19463 {
19464 sleep(d).await;
19465 continue;
19466 }
19467
19468 dlg.finished(false);
19469
19470 return Err(match error {
19471 Ok(value) => common::Error::BadRequest(value),
19472 _ => common::Error::Failure(response),
19473 });
19474 }
19475 let response = {
19476 let bytes = common::to_bytes(body).await.unwrap_or_default();
19477 let encoded = common::to_string(&bytes);
19478 match serde_json::from_str(&encoded) {
19479 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19480 Err(error) => {
19481 dlg.response_json_decode_error(&encoded, &error);
19482 return Err(common::Error::JsonDecodeError(
19483 encoded.to_string(),
19484 error,
19485 ));
19486 }
19487 }
19488 };
19489
19490 dlg.finished(true);
19491 return Ok(response);
19492 }
19493 }
19494 }
19495 }
19496
19497 /// Required. The database in which to list sessions.
19498 ///
19499 /// Sets the *database* path property to the given value.
19500 ///
19501 /// Even though the property as already been set when instantiating this call,
19502 /// we provide this method for API completeness.
19503 pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
19504 self._database = new_value.to_string();
19505 self
19506 }
19507 /// If non-empty, `page_token` should contain a next_page_token from a previous ListSessionsResponse.
19508 ///
19509 /// Sets the *page token* query property to the given value.
19510 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
19511 self._page_token = Some(new_value.to_string());
19512 self
19513 }
19514 /// Number of sessions to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
19515 ///
19516 /// Sets the *page size* query property to the given value.
19517 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
19518 self._page_size = Some(new_value);
19519 self
19520 }
19521 /// 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".
19522 ///
19523 /// Sets the *filter* query property to the given value.
19524 pub fn filter(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
19525 self._filter = Some(new_value.to_string());
19526 self
19527 }
19528 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19529 /// while executing the actual API request.
19530 ///
19531 /// ````text
19532 /// It should be used to handle progress information, and to implement a certain level of resilience.
19533 /// ````
19534 ///
19535 /// Sets the *delegate* property to the given value.
19536 pub fn delegate(
19537 mut self,
19538 new_value: &'a mut dyn common::Delegate,
19539 ) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
19540 self._delegate = Some(new_value);
19541 self
19542 }
19543
19544 /// Set any additional parameter of the query string used in the request.
19545 /// It should be used to set parameters which are not yet available through their own
19546 /// setters.
19547 ///
19548 /// Please note that this method must not be used to set any of the known parameters
19549 /// which have their own setter method. If done anyway, the request will fail.
19550 ///
19551 /// # Additional Parameters
19552 ///
19553 /// * *$.xgafv* (query-string) - V1 error format.
19554 /// * *access_token* (query-string) - OAuth access token.
19555 /// * *alt* (query-string) - Data format for response.
19556 /// * *callback* (query-string) - JSONP
19557 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19558 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19559 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19560 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19561 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19562 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19563 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19564 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionListCall<'a, C>
19565 where
19566 T: AsRef<str>,
19567 {
19568 self._additional_params
19569 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19570 self
19571 }
19572
19573 /// Identifies the authorization scope for the method you are building.
19574 ///
19575 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19576 /// [`Scope::CloudPlatform`].
19577 ///
19578 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19579 /// tokens for more than one scope.
19580 ///
19581 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19582 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19583 /// sufficient, a read-write scope will do as well.
19584 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionListCall<'a, C>
19585 where
19586 St: AsRef<str>,
19587 {
19588 self._scopes.insert(String::from(scope.as_ref()));
19589 self
19590 }
19591 /// Identifies the authorization scope(s) for the method you are building.
19592 ///
19593 /// See [`Self::add_scope()`] for details.
19594 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionListCall<'a, C>
19595 where
19596 I: IntoIterator<Item = St>,
19597 St: AsRef<str>,
19598 {
19599 self._scopes
19600 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19601 self
19602 }
19603
19604 /// Removes all scopes, and no default scope will be used either.
19605 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19606 /// for details).
19607 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionListCall<'a, C> {
19608 self._scopes.clear();
19609 self
19610 }
19611}
19612
19613/// 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 is not possible to resume the query, and the whole operation must be restarted from the beginning.
19614///
19615/// A builder for the *instances.databases.sessions.partitionQuery* method supported by a *project* resource.
19616/// It is not used directly, but through a [`ProjectMethods`] instance.
19617///
19618/// # Example
19619///
19620/// Instantiate a resource method builder
19621///
19622/// ```test_harness,no_run
19623/// # extern crate hyper;
19624/// # extern crate hyper_rustls;
19625/// # extern crate google_spanner1 as spanner1;
19626/// use spanner1::api::PartitionQueryRequest;
19627/// # async fn dox() {
19628/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19629///
19630/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19631/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19632/// # secret,
19633/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19634/// # ).build().await.unwrap();
19635///
19636/// # let client = hyper_util::client::legacy::Client::builder(
19637/// # hyper_util::rt::TokioExecutor::new()
19638/// # )
19639/// # .build(
19640/// # hyper_rustls::HttpsConnectorBuilder::new()
19641/// # .with_native_roots()
19642/// # .unwrap()
19643/// # .https_or_http()
19644/// # .enable_http1()
19645/// # .build()
19646/// # );
19647/// # let mut hub = Spanner::new(client, auth);
19648/// // As the method needs a request, you would usually fill it with the desired information
19649/// // into the respective structure. Some of the parts shown here might not be applicable !
19650/// // Values shown here are possibly random and not representative !
19651/// let mut req = PartitionQueryRequest::default();
19652///
19653/// // You can configure optional parameters by calling the respective setters at will, and
19654/// // execute the final call using `doit()`.
19655/// // Values shown here are possibly random and not representative !
19656/// let result = hub.projects().instances_databases_sessions_partition_query(req, "session")
19657/// .doit().await;
19658/// # }
19659/// ```
19660pub struct ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
19661where
19662 C: 'a,
19663{
19664 hub: &'a Spanner<C>,
19665 _request: PartitionQueryRequest,
19666 _session: String,
19667 _delegate: Option<&'a mut dyn common::Delegate>,
19668 _additional_params: HashMap<String, String>,
19669 _scopes: BTreeSet<String>,
19670}
19671
19672impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {}
19673
19674impl<'a, C> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
19675where
19676 C: common::Connector,
19677{
19678 /// Perform the operation you have build so far.
19679 pub async fn doit(mut self) -> common::Result<(common::Response, PartitionResponse)> {
19680 use std::borrow::Cow;
19681 use std::io::{Read, Seek};
19682
19683 use common::{url::Params, ToParts};
19684 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19685
19686 let mut dd = common::DefaultDelegate;
19687 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19688 dlg.begin(common::MethodInfo {
19689 id: "spanner.projects.instances.databases.sessions.partitionQuery",
19690 http_method: hyper::Method::POST,
19691 });
19692
19693 for &field in ["alt", "session"].iter() {
19694 if self._additional_params.contains_key(field) {
19695 dlg.finished(false);
19696 return Err(common::Error::FieldClash(field));
19697 }
19698 }
19699
19700 let mut params = Params::with_capacity(4 + self._additional_params.len());
19701 params.push("session", self._session);
19702
19703 params.extend(self._additional_params.iter());
19704
19705 params.push("alt", "json");
19706 let mut url = self.hub._base_url.clone() + "v1/{+session}:partitionQuery";
19707 if self._scopes.is_empty() {
19708 self._scopes
19709 .insert(Scope::CloudPlatform.as_ref().to_string());
19710 }
19711
19712 #[allow(clippy::single_element_loop)]
19713 for &(find_this, param_name) in [("{+session}", "session")].iter() {
19714 url = params.uri_replacement(url, param_name, find_this, true);
19715 }
19716 {
19717 let to_remove = ["session"];
19718 params.remove_params(&to_remove);
19719 }
19720
19721 let url = params.parse_with_url(&url);
19722
19723 let mut json_mime_type = mime::APPLICATION_JSON;
19724 let mut request_value_reader = {
19725 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19726 common::remove_json_null_values(&mut value);
19727 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19728 serde_json::to_writer(&mut dst, &value).unwrap();
19729 dst
19730 };
19731 let request_size = request_value_reader
19732 .seek(std::io::SeekFrom::End(0))
19733 .unwrap();
19734 request_value_reader
19735 .seek(std::io::SeekFrom::Start(0))
19736 .unwrap();
19737
19738 loop {
19739 let token = match self
19740 .hub
19741 .auth
19742 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19743 .await
19744 {
19745 Ok(token) => token,
19746 Err(e) => match dlg.token(e) {
19747 Ok(token) => token,
19748 Err(e) => {
19749 dlg.finished(false);
19750 return Err(common::Error::MissingToken(e));
19751 }
19752 },
19753 };
19754 request_value_reader
19755 .seek(std::io::SeekFrom::Start(0))
19756 .unwrap();
19757 let mut req_result = {
19758 let client = &self.hub.client;
19759 dlg.pre_request();
19760 let mut req_builder = hyper::Request::builder()
19761 .method(hyper::Method::POST)
19762 .uri(url.as_str())
19763 .header(USER_AGENT, self.hub._user_agent.clone());
19764
19765 if let Some(token) = token.as_ref() {
19766 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19767 }
19768
19769 let request = req_builder
19770 .header(CONTENT_TYPE, json_mime_type.to_string())
19771 .header(CONTENT_LENGTH, request_size as u64)
19772 .body(common::to_body(
19773 request_value_reader.get_ref().clone().into(),
19774 ));
19775
19776 client.request(request.unwrap()).await
19777 };
19778
19779 match req_result {
19780 Err(err) => {
19781 if let common::Retry::After(d) = dlg.http_error(&err) {
19782 sleep(d).await;
19783 continue;
19784 }
19785 dlg.finished(false);
19786 return Err(common::Error::HttpError(err));
19787 }
19788 Ok(res) => {
19789 let (mut parts, body) = res.into_parts();
19790 let mut body = common::Body::new(body);
19791 if !parts.status.is_success() {
19792 let bytes = common::to_bytes(body).await.unwrap_or_default();
19793 let error = serde_json::from_str(&common::to_string(&bytes));
19794 let response = common::to_response(parts, bytes.into());
19795
19796 if let common::Retry::After(d) =
19797 dlg.http_failure(&response, error.as_ref().ok())
19798 {
19799 sleep(d).await;
19800 continue;
19801 }
19802
19803 dlg.finished(false);
19804
19805 return Err(match error {
19806 Ok(value) => common::Error::BadRequest(value),
19807 _ => common::Error::Failure(response),
19808 });
19809 }
19810 let response = {
19811 let bytes = common::to_bytes(body).await.unwrap_or_default();
19812 let encoded = common::to_string(&bytes);
19813 match serde_json::from_str(&encoded) {
19814 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19815 Err(error) => {
19816 dlg.response_json_decode_error(&encoded, &error);
19817 return Err(common::Error::JsonDecodeError(
19818 encoded.to_string(),
19819 error,
19820 ));
19821 }
19822 }
19823 };
19824
19825 dlg.finished(true);
19826 return Ok(response);
19827 }
19828 }
19829 }
19830 }
19831
19832 ///
19833 /// Sets the *request* property to the given value.
19834 ///
19835 /// Even though the property as already been set when instantiating this call,
19836 /// we provide this method for API completeness.
19837 pub fn request(
19838 mut self,
19839 new_value: PartitionQueryRequest,
19840 ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
19841 self._request = new_value;
19842 self
19843 }
19844 /// Required. The session used to create the partitions.
19845 ///
19846 /// Sets the *session* path property to the given value.
19847 ///
19848 /// Even though the property as already been set when instantiating this call,
19849 /// we provide this method for API completeness.
19850 pub fn session(
19851 mut self,
19852 new_value: &str,
19853 ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
19854 self._session = new_value.to_string();
19855 self
19856 }
19857 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19858 /// while executing the actual API request.
19859 ///
19860 /// ````text
19861 /// It should be used to handle progress information, and to implement a certain level of resilience.
19862 /// ````
19863 ///
19864 /// Sets the *delegate* property to the given value.
19865 pub fn delegate(
19866 mut self,
19867 new_value: &'a mut dyn common::Delegate,
19868 ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
19869 self._delegate = Some(new_value);
19870 self
19871 }
19872
19873 /// Set any additional parameter of the query string used in the request.
19874 /// It should be used to set parameters which are not yet available through their own
19875 /// setters.
19876 ///
19877 /// Please note that this method must not be used to set any of the known parameters
19878 /// which have their own setter method. If done anyway, the request will fail.
19879 ///
19880 /// # Additional Parameters
19881 ///
19882 /// * *$.xgafv* (query-string) - V1 error format.
19883 /// * *access_token* (query-string) - OAuth access token.
19884 /// * *alt* (query-string) - Data format for response.
19885 /// * *callback* (query-string) - JSONP
19886 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19887 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19888 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19889 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19890 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19891 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19892 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19893 pub fn param<T>(
19894 mut self,
19895 name: T,
19896 value: T,
19897 ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
19898 where
19899 T: AsRef<str>,
19900 {
19901 self._additional_params
19902 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19903 self
19904 }
19905
19906 /// Identifies the authorization scope for the method you are building.
19907 ///
19908 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19909 /// [`Scope::CloudPlatform`].
19910 ///
19911 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19912 /// tokens for more than one scope.
19913 ///
19914 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19915 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19916 /// sufficient, a read-write scope will do as well.
19917 pub fn add_scope<St>(
19918 mut self,
19919 scope: St,
19920 ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
19921 where
19922 St: AsRef<str>,
19923 {
19924 self._scopes.insert(String::from(scope.as_ref()));
19925 self
19926 }
19927 /// Identifies the authorization scope(s) for the method you are building.
19928 ///
19929 /// See [`Self::add_scope()`] for details.
19930 pub fn add_scopes<I, St>(
19931 mut self,
19932 scopes: I,
19933 ) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C>
19934 where
19935 I: IntoIterator<Item = St>,
19936 St: AsRef<str>,
19937 {
19938 self._scopes
19939 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19940 self
19941 }
19942
19943 /// Removes all scopes, and no default scope will be used either.
19944 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19945 /// for details).
19946 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionPartitionQueryCall<'a, C> {
19947 self._scopes.clear();
19948 self
19949 }
19950}
19951
19952/// 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 is not possible to resume the read, and the whole operation must be restarted from the beginning.
19953///
19954/// A builder for the *instances.databases.sessions.partitionRead* method supported by a *project* resource.
19955/// It is not used directly, but through a [`ProjectMethods`] instance.
19956///
19957/// # Example
19958///
19959/// Instantiate a resource method builder
19960///
19961/// ```test_harness,no_run
19962/// # extern crate hyper;
19963/// # extern crate hyper_rustls;
19964/// # extern crate google_spanner1 as spanner1;
19965/// use spanner1::api::PartitionReadRequest;
19966/// # async fn dox() {
19967/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19968///
19969/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19970/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19971/// # secret,
19972/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19973/// # ).build().await.unwrap();
19974///
19975/// # let client = hyper_util::client::legacy::Client::builder(
19976/// # hyper_util::rt::TokioExecutor::new()
19977/// # )
19978/// # .build(
19979/// # hyper_rustls::HttpsConnectorBuilder::new()
19980/// # .with_native_roots()
19981/// # .unwrap()
19982/// # .https_or_http()
19983/// # .enable_http1()
19984/// # .build()
19985/// # );
19986/// # let mut hub = Spanner::new(client, auth);
19987/// // As the method needs a request, you would usually fill it with the desired information
19988/// // into the respective structure. Some of the parts shown here might not be applicable !
19989/// // Values shown here are possibly random and not representative !
19990/// let mut req = PartitionReadRequest::default();
19991///
19992/// // You can configure optional parameters by calling the respective setters at will, and
19993/// // execute the final call using `doit()`.
19994/// // Values shown here are possibly random and not representative !
19995/// let result = hub.projects().instances_databases_sessions_partition_read(req, "session")
19996/// .doit().await;
19997/// # }
19998/// ```
19999pub struct ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
20000where
20001 C: 'a,
20002{
20003 hub: &'a Spanner<C>,
20004 _request: PartitionReadRequest,
20005 _session: String,
20006 _delegate: Option<&'a mut dyn common::Delegate>,
20007 _additional_params: HashMap<String, String>,
20008 _scopes: BTreeSet<String>,
20009}
20010
20011impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {}
20012
20013impl<'a, C> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
20014where
20015 C: common::Connector,
20016{
20017 /// Perform the operation you have build so far.
20018 pub async fn doit(mut self) -> common::Result<(common::Response, PartitionResponse)> {
20019 use std::borrow::Cow;
20020 use std::io::{Read, Seek};
20021
20022 use common::{url::Params, ToParts};
20023 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20024
20025 let mut dd = common::DefaultDelegate;
20026 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20027 dlg.begin(common::MethodInfo {
20028 id: "spanner.projects.instances.databases.sessions.partitionRead",
20029 http_method: hyper::Method::POST,
20030 });
20031
20032 for &field in ["alt", "session"].iter() {
20033 if self._additional_params.contains_key(field) {
20034 dlg.finished(false);
20035 return Err(common::Error::FieldClash(field));
20036 }
20037 }
20038
20039 let mut params = Params::with_capacity(4 + self._additional_params.len());
20040 params.push("session", self._session);
20041
20042 params.extend(self._additional_params.iter());
20043
20044 params.push("alt", "json");
20045 let mut url = self.hub._base_url.clone() + "v1/{+session}:partitionRead";
20046 if self._scopes.is_empty() {
20047 self._scopes
20048 .insert(Scope::CloudPlatform.as_ref().to_string());
20049 }
20050
20051 #[allow(clippy::single_element_loop)]
20052 for &(find_this, param_name) in [("{+session}", "session")].iter() {
20053 url = params.uri_replacement(url, param_name, find_this, true);
20054 }
20055 {
20056 let to_remove = ["session"];
20057 params.remove_params(&to_remove);
20058 }
20059
20060 let url = params.parse_with_url(&url);
20061
20062 let mut json_mime_type = mime::APPLICATION_JSON;
20063 let mut request_value_reader = {
20064 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20065 common::remove_json_null_values(&mut value);
20066 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20067 serde_json::to_writer(&mut dst, &value).unwrap();
20068 dst
20069 };
20070 let request_size = request_value_reader
20071 .seek(std::io::SeekFrom::End(0))
20072 .unwrap();
20073 request_value_reader
20074 .seek(std::io::SeekFrom::Start(0))
20075 .unwrap();
20076
20077 loop {
20078 let token = match self
20079 .hub
20080 .auth
20081 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20082 .await
20083 {
20084 Ok(token) => token,
20085 Err(e) => match dlg.token(e) {
20086 Ok(token) => token,
20087 Err(e) => {
20088 dlg.finished(false);
20089 return Err(common::Error::MissingToken(e));
20090 }
20091 },
20092 };
20093 request_value_reader
20094 .seek(std::io::SeekFrom::Start(0))
20095 .unwrap();
20096 let mut req_result = {
20097 let client = &self.hub.client;
20098 dlg.pre_request();
20099 let mut req_builder = hyper::Request::builder()
20100 .method(hyper::Method::POST)
20101 .uri(url.as_str())
20102 .header(USER_AGENT, self.hub._user_agent.clone());
20103
20104 if let Some(token) = token.as_ref() {
20105 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20106 }
20107
20108 let request = req_builder
20109 .header(CONTENT_TYPE, json_mime_type.to_string())
20110 .header(CONTENT_LENGTH, request_size as u64)
20111 .body(common::to_body(
20112 request_value_reader.get_ref().clone().into(),
20113 ));
20114
20115 client.request(request.unwrap()).await
20116 };
20117
20118 match req_result {
20119 Err(err) => {
20120 if let common::Retry::After(d) = dlg.http_error(&err) {
20121 sleep(d).await;
20122 continue;
20123 }
20124 dlg.finished(false);
20125 return Err(common::Error::HttpError(err));
20126 }
20127 Ok(res) => {
20128 let (mut parts, body) = res.into_parts();
20129 let mut body = common::Body::new(body);
20130 if !parts.status.is_success() {
20131 let bytes = common::to_bytes(body).await.unwrap_or_default();
20132 let error = serde_json::from_str(&common::to_string(&bytes));
20133 let response = common::to_response(parts, bytes.into());
20134
20135 if let common::Retry::After(d) =
20136 dlg.http_failure(&response, error.as_ref().ok())
20137 {
20138 sleep(d).await;
20139 continue;
20140 }
20141
20142 dlg.finished(false);
20143
20144 return Err(match error {
20145 Ok(value) => common::Error::BadRequest(value),
20146 _ => common::Error::Failure(response),
20147 });
20148 }
20149 let response = {
20150 let bytes = common::to_bytes(body).await.unwrap_or_default();
20151 let encoded = common::to_string(&bytes);
20152 match serde_json::from_str(&encoded) {
20153 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20154 Err(error) => {
20155 dlg.response_json_decode_error(&encoded, &error);
20156 return Err(common::Error::JsonDecodeError(
20157 encoded.to_string(),
20158 error,
20159 ));
20160 }
20161 }
20162 };
20163
20164 dlg.finished(true);
20165 return Ok(response);
20166 }
20167 }
20168 }
20169 }
20170
20171 ///
20172 /// Sets the *request* property to the given value.
20173 ///
20174 /// Even though the property as already been set when instantiating this call,
20175 /// we provide this method for API completeness.
20176 pub fn request(
20177 mut self,
20178 new_value: PartitionReadRequest,
20179 ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
20180 self._request = new_value;
20181 self
20182 }
20183 /// Required. The session used to create the partitions.
20184 ///
20185 /// Sets the *session* path property to the given value.
20186 ///
20187 /// Even though the property as already been set when instantiating this call,
20188 /// we provide this method for API completeness.
20189 pub fn session(
20190 mut self,
20191 new_value: &str,
20192 ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
20193 self._session = new_value.to_string();
20194 self
20195 }
20196 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20197 /// while executing the actual API request.
20198 ///
20199 /// ````text
20200 /// It should be used to handle progress information, and to implement a certain level of resilience.
20201 /// ````
20202 ///
20203 /// Sets the *delegate* property to the given value.
20204 pub fn delegate(
20205 mut self,
20206 new_value: &'a mut dyn common::Delegate,
20207 ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
20208 self._delegate = Some(new_value);
20209 self
20210 }
20211
20212 /// Set any additional parameter of the query string used in the request.
20213 /// It should be used to set parameters which are not yet available through their own
20214 /// setters.
20215 ///
20216 /// Please note that this method must not be used to set any of the known parameters
20217 /// which have their own setter method. If done anyway, the request will fail.
20218 ///
20219 /// # Additional Parameters
20220 ///
20221 /// * *$.xgafv* (query-string) - V1 error format.
20222 /// * *access_token* (query-string) - OAuth access token.
20223 /// * *alt* (query-string) - Data format for response.
20224 /// * *callback* (query-string) - JSONP
20225 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20226 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20227 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20228 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20229 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20230 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20231 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20232 pub fn param<T>(
20233 mut self,
20234 name: T,
20235 value: T,
20236 ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
20237 where
20238 T: AsRef<str>,
20239 {
20240 self._additional_params
20241 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20242 self
20243 }
20244
20245 /// Identifies the authorization scope for the method you are building.
20246 ///
20247 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20248 /// [`Scope::CloudPlatform`].
20249 ///
20250 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20251 /// tokens for more than one scope.
20252 ///
20253 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20254 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20255 /// sufficient, a read-write scope will do as well.
20256 pub fn add_scope<St>(
20257 mut self,
20258 scope: St,
20259 ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
20260 where
20261 St: AsRef<str>,
20262 {
20263 self._scopes.insert(String::from(scope.as_ref()));
20264 self
20265 }
20266 /// Identifies the authorization scope(s) for the method you are building.
20267 ///
20268 /// See [`Self::add_scope()`] for details.
20269 pub fn add_scopes<I, St>(
20270 mut self,
20271 scopes: I,
20272 ) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C>
20273 where
20274 I: IntoIterator<Item = St>,
20275 St: AsRef<str>,
20276 {
20277 self._scopes
20278 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20279 self
20280 }
20281
20282 /// Removes all scopes, and no default scope will be used either.
20283 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20284 /// for details).
20285 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionPartitionReadCall<'a, C> {
20286 self._scopes.clear();
20287 self
20288 }
20289}
20290
20291/// Reads rows from the database using key lookups and scans, as a simple key/value style alternative to ExecuteSql. This method cannot 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.
20292///
20293/// A builder for the *instances.databases.sessions.read* method supported by a *project* resource.
20294/// It is not used directly, but through a [`ProjectMethods`] instance.
20295///
20296/// # Example
20297///
20298/// Instantiate a resource method builder
20299///
20300/// ```test_harness,no_run
20301/// # extern crate hyper;
20302/// # extern crate hyper_rustls;
20303/// # extern crate google_spanner1 as spanner1;
20304/// use spanner1::api::ReadRequest;
20305/// # async fn dox() {
20306/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20307///
20308/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20309/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20310/// # secret,
20311/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20312/// # ).build().await.unwrap();
20313///
20314/// # let client = hyper_util::client::legacy::Client::builder(
20315/// # hyper_util::rt::TokioExecutor::new()
20316/// # )
20317/// # .build(
20318/// # hyper_rustls::HttpsConnectorBuilder::new()
20319/// # .with_native_roots()
20320/// # .unwrap()
20321/// # .https_or_http()
20322/// # .enable_http1()
20323/// # .build()
20324/// # );
20325/// # let mut hub = Spanner::new(client, auth);
20326/// // As the method needs a request, you would usually fill it with the desired information
20327/// // into the respective structure. Some of the parts shown here might not be applicable !
20328/// // Values shown here are possibly random and not representative !
20329/// let mut req = ReadRequest::default();
20330///
20331/// // You can configure optional parameters by calling the respective setters at will, and
20332/// // execute the final call using `doit()`.
20333/// // Values shown here are possibly random and not representative !
20334/// let result = hub.projects().instances_databases_sessions_read(req, "session")
20335/// .doit().await;
20336/// # }
20337/// ```
20338pub struct ProjectInstanceDatabaseSessionReadCall<'a, C>
20339where
20340 C: 'a,
20341{
20342 hub: &'a Spanner<C>,
20343 _request: ReadRequest,
20344 _session: String,
20345 _delegate: Option<&'a mut dyn common::Delegate>,
20346 _additional_params: HashMap<String, String>,
20347 _scopes: BTreeSet<String>,
20348}
20349
20350impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionReadCall<'a, C> {}
20351
20352impl<'a, C> ProjectInstanceDatabaseSessionReadCall<'a, C>
20353where
20354 C: common::Connector,
20355{
20356 /// Perform the operation you have build so far.
20357 pub async fn doit(mut self) -> common::Result<(common::Response, ResultSet)> {
20358 use std::borrow::Cow;
20359 use std::io::{Read, Seek};
20360
20361 use common::{url::Params, ToParts};
20362 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20363
20364 let mut dd = common::DefaultDelegate;
20365 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20366 dlg.begin(common::MethodInfo {
20367 id: "spanner.projects.instances.databases.sessions.read",
20368 http_method: hyper::Method::POST,
20369 });
20370
20371 for &field in ["alt", "session"].iter() {
20372 if self._additional_params.contains_key(field) {
20373 dlg.finished(false);
20374 return Err(common::Error::FieldClash(field));
20375 }
20376 }
20377
20378 let mut params = Params::with_capacity(4 + self._additional_params.len());
20379 params.push("session", self._session);
20380
20381 params.extend(self._additional_params.iter());
20382
20383 params.push("alt", "json");
20384 let mut url = self.hub._base_url.clone() + "v1/{+session}:read";
20385 if self._scopes.is_empty() {
20386 self._scopes
20387 .insert(Scope::CloudPlatform.as_ref().to_string());
20388 }
20389
20390 #[allow(clippy::single_element_loop)]
20391 for &(find_this, param_name) in [("{+session}", "session")].iter() {
20392 url = params.uri_replacement(url, param_name, find_this, true);
20393 }
20394 {
20395 let to_remove = ["session"];
20396 params.remove_params(&to_remove);
20397 }
20398
20399 let url = params.parse_with_url(&url);
20400
20401 let mut json_mime_type = mime::APPLICATION_JSON;
20402 let mut request_value_reader = {
20403 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20404 common::remove_json_null_values(&mut value);
20405 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20406 serde_json::to_writer(&mut dst, &value).unwrap();
20407 dst
20408 };
20409 let request_size = request_value_reader
20410 .seek(std::io::SeekFrom::End(0))
20411 .unwrap();
20412 request_value_reader
20413 .seek(std::io::SeekFrom::Start(0))
20414 .unwrap();
20415
20416 loop {
20417 let token = match self
20418 .hub
20419 .auth
20420 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20421 .await
20422 {
20423 Ok(token) => token,
20424 Err(e) => match dlg.token(e) {
20425 Ok(token) => token,
20426 Err(e) => {
20427 dlg.finished(false);
20428 return Err(common::Error::MissingToken(e));
20429 }
20430 },
20431 };
20432 request_value_reader
20433 .seek(std::io::SeekFrom::Start(0))
20434 .unwrap();
20435 let mut req_result = {
20436 let client = &self.hub.client;
20437 dlg.pre_request();
20438 let mut req_builder = hyper::Request::builder()
20439 .method(hyper::Method::POST)
20440 .uri(url.as_str())
20441 .header(USER_AGENT, self.hub._user_agent.clone());
20442
20443 if let Some(token) = token.as_ref() {
20444 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20445 }
20446
20447 let request = req_builder
20448 .header(CONTENT_TYPE, json_mime_type.to_string())
20449 .header(CONTENT_LENGTH, request_size as u64)
20450 .body(common::to_body(
20451 request_value_reader.get_ref().clone().into(),
20452 ));
20453
20454 client.request(request.unwrap()).await
20455 };
20456
20457 match req_result {
20458 Err(err) => {
20459 if let common::Retry::After(d) = dlg.http_error(&err) {
20460 sleep(d).await;
20461 continue;
20462 }
20463 dlg.finished(false);
20464 return Err(common::Error::HttpError(err));
20465 }
20466 Ok(res) => {
20467 let (mut parts, body) = res.into_parts();
20468 let mut body = common::Body::new(body);
20469 if !parts.status.is_success() {
20470 let bytes = common::to_bytes(body).await.unwrap_or_default();
20471 let error = serde_json::from_str(&common::to_string(&bytes));
20472 let response = common::to_response(parts, bytes.into());
20473
20474 if let common::Retry::After(d) =
20475 dlg.http_failure(&response, error.as_ref().ok())
20476 {
20477 sleep(d).await;
20478 continue;
20479 }
20480
20481 dlg.finished(false);
20482
20483 return Err(match error {
20484 Ok(value) => common::Error::BadRequest(value),
20485 _ => common::Error::Failure(response),
20486 });
20487 }
20488 let response = {
20489 let bytes = common::to_bytes(body).await.unwrap_or_default();
20490 let encoded = common::to_string(&bytes);
20491 match serde_json::from_str(&encoded) {
20492 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20493 Err(error) => {
20494 dlg.response_json_decode_error(&encoded, &error);
20495 return Err(common::Error::JsonDecodeError(
20496 encoded.to_string(),
20497 error,
20498 ));
20499 }
20500 }
20501 };
20502
20503 dlg.finished(true);
20504 return Ok(response);
20505 }
20506 }
20507 }
20508 }
20509
20510 ///
20511 /// Sets the *request* property to the given value.
20512 ///
20513 /// Even though the property as already been set when instantiating this call,
20514 /// we provide this method for API completeness.
20515 pub fn request(
20516 mut self,
20517 new_value: ReadRequest,
20518 ) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
20519 self._request = new_value;
20520 self
20521 }
20522 /// Required. The session in which the read should be performed.
20523 ///
20524 /// Sets the *session* path property to the given value.
20525 ///
20526 /// Even though the property as already been set when instantiating this call,
20527 /// we provide this method for API completeness.
20528 pub fn session(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
20529 self._session = new_value.to_string();
20530 self
20531 }
20532 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20533 /// while executing the actual API request.
20534 ///
20535 /// ````text
20536 /// It should be used to handle progress information, and to implement a certain level of resilience.
20537 /// ````
20538 ///
20539 /// Sets the *delegate* property to the given value.
20540 pub fn delegate(
20541 mut self,
20542 new_value: &'a mut dyn common::Delegate,
20543 ) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
20544 self._delegate = Some(new_value);
20545 self
20546 }
20547
20548 /// Set any additional parameter of the query string used in the request.
20549 /// It should be used to set parameters which are not yet available through their own
20550 /// setters.
20551 ///
20552 /// Please note that this method must not be used to set any of the known parameters
20553 /// which have their own setter method. If done anyway, the request will fail.
20554 ///
20555 /// # Additional Parameters
20556 ///
20557 /// * *$.xgafv* (query-string) - V1 error format.
20558 /// * *access_token* (query-string) - OAuth access token.
20559 /// * *alt* (query-string) - Data format for response.
20560 /// * *callback* (query-string) - JSONP
20561 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20562 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20563 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20564 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20565 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20566 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20567 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20568 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSessionReadCall<'a, C>
20569 where
20570 T: AsRef<str>,
20571 {
20572 self._additional_params
20573 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20574 self
20575 }
20576
20577 /// Identifies the authorization scope for the method you are building.
20578 ///
20579 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20580 /// [`Scope::CloudPlatform`].
20581 ///
20582 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20583 /// tokens for more than one scope.
20584 ///
20585 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20586 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20587 /// sufficient, a read-write scope will do as well.
20588 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionReadCall<'a, C>
20589 where
20590 St: AsRef<str>,
20591 {
20592 self._scopes.insert(String::from(scope.as_ref()));
20593 self
20594 }
20595 /// Identifies the authorization scope(s) for the method you are building.
20596 ///
20597 /// See [`Self::add_scope()`] for details.
20598 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSessionReadCall<'a, C>
20599 where
20600 I: IntoIterator<Item = St>,
20601 St: AsRef<str>,
20602 {
20603 self._scopes
20604 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20605 self
20606 }
20607
20608 /// Removes all scopes, and no default scope will be used either.
20609 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20610 /// for details).
20611 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionReadCall<'a, C> {
20612 self._scopes.clear();
20613 self
20614 }
20615}
20616
20617/// Rolls back a transaction, releasing any locks it holds. It is 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 is not found. `Rollback` never returns `ABORTED`.
20618///
20619/// A builder for the *instances.databases.sessions.rollback* method supported by a *project* resource.
20620/// It is not used directly, but through a [`ProjectMethods`] instance.
20621///
20622/// # Example
20623///
20624/// Instantiate a resource method builder
20625///
20626/// ```test_harness,no_run
20627/// # extern crate hyper;
20628/// # extern crate hyper_rustls;
20629/// # extern crate google_spanner1 as spanner1;
20630/// use spanner1::api::RollbackRequest;
20631/// # async fn dox() {
20632/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20633///
20634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20635/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20636/// # secret,
20637/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20638/// # ).build().await.unwrap();
20639///
20640/// # let client = hyper_util::client::legacy::Client::builder(
20641/// # hyper_util::rt::TokioExecutor::new()
20642/// # )
20643/// # .build(
20644/// # hyper_rustls::HttpsConnectorBuilder::new()
20645/// # .with_native_roots()
20646/// # .unwrap()
20647/// # .https_or_http()
20648/// # .enable_http1()
20649/// # .build()
20650/// # );
20651/// # let mut hub = Spanner::new(client, auth);
20652/// // As the method needs a request, you would usually fill it with the desired information
20653/// // into the respective structure. Some of the parts shown here might not be applicable !
20654/// // Values shown here are possibly random and not representative !
20655/// let mut req = RollbackRequest::default();
20656///
20657/// // You can configure optional parameters by calling the respective setters at will, and
20658/// // execute the final call using `doit()`.
20659/// // Values shown here are possibly random and not representative !
20660/// let result = hub.projects().instances_databases_sessions_rollback(req, "session")
20661/// .doit().await;
20662/// # }
20663/// ```
20664pub struct ProjectInstanceDatabaseSessionRollbackCall<'a, C>
20665where
20666 C: 'a,
20667{
20668 hub: &'a Spanner<C>,
20669 _request: RollbackRequest,
20670 _session: String,
20671 _delegate: Option<&'a mut dyn common::Delegate>,
20672 _additional_params: HashMap<String, String>,
20673 _scopes: BTreeSet<String>,
20674}
20675
20676impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionRollbackCall<'a, C> {}
20677
20678impl<'a, C> ProjectInstanceDatabaseSessionRollbackCall<'a, C>
20679where
20680 C: common::Connector,
20681{
20682 /// Perform the operation you have build so far.
20683 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
20684 use std::borrow::Cow;
20685 use std::io::{Read, Seek};
20686
20687 use common::{url::Params, ToParts};
20688 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20689
20690 let mut dd = common::DefaultDelegate;
20691 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20692 dlg.begin(common::MethodInfo {
20693 id: "spanner.projects.instances.databases.sessions.rollback",
20694 http_method: hyper::Method::POST,
20695 });
20696
20697 for &field in ["alt", "session"].iter() {
20698 if self._additional_params.contains_key(field) {
20699 dlg.finished(false);
20700 return Err(common::Error::FieldClash(field));
20701 }
20702 }
20703
20704 let mut params = Params::with_capacity(4 + self._additional_params.len());
20705 params.push("session", self._session);
20706
20707 params.extend(self._additional_params.iter());
20708
20709 params.push("alt", "json");
20710 let mut url = self.hub._base_url.clone() + "v1/{+session}:rollback";
20711 if self._scopes.is_empty() {
20712 self._scopes
20713 .insert(Scope::CloudPlatform.as_ref().to_string());
20714 }
20715
20716 #[allow(clippy::single_element_loop)]
20717 for &(find_this, param_name) in [("{+session}", "session")].iter() {
20718 url = params.uri_replacement(url, param_name, find_this, true);
20719 }
20720 {
20721 let to_remove = ["session"];
20722 params.remove_params(&to_remove);
20723 }
20724
20725 let url = params.parse_with_url(&url);
20726
20727 let mut json_mime_type = mime::APPLICATION_JSON;
20728 let mut request_value_reader = {
20729 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20730 common::remove_json_null_values(&mut value);
20731 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20732 serde_json::to_writer(&mut dst, &value).unwrap();
20733 dst
20734 };
20735 let request_size = request_value_reader
20736 .seek(std::io::SeekFrom::End(0))
20737 .unwrap();
20738 request_value_reader
20739 .seek(std::io::SeekFrom::Start(0))
20740 .unwrap();
20741
20742 loop {
20743 let token = match self
20744 .hub
20745 .auth
20746 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20747 .await
20748 {
20749 Ok(token) => token,
20750 Err(e) => match dlg.token(e) {
20751 Ok(token) => token,
20752 Err(e) => {
20753 dlg.finished(false);
20754 return Err(common::Error::MissingToken(e));
20755 }
20756 },
20757 };
20758 request_value_reader
20759 .seek(std::io::SeekFrom::Start(0))
20760 .unwrap();
20761 let mut req_result = {
20762 let client = &self.hub.client;
20763 dlg.pre_request();
20764 let mut req_builder = hyper::Request::builder()
20765 .method(hyper::Method::POST)
20766 .uri(url.as_str())
20767 .header(USER_AGENT, self.hub._user_agent.clone());
20768
20769 if let Some(token) = token.as_ref() {
20770 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20771 }
20772
20773 let request = req_builder
20774 .header(CONTENT_TYPE, json_mime_type.to_string())
20775 .header(CONTENT_LENGTH, request_size as u64)
20776 .body(common::to_body(
20777 request_value_reader.get_ref().clone().into(),
20778 ));
20779
20780 client.request(request.unwrap()).await
20781 };
20782
20783 match req_result {
20784 Err(err) => {
20785 if let common::Retry::After(d) = dlg.http_error(&err) {
20786 sleep(d).await;
20787 continue;
20788 }
20789 dlg.finished(false);
20790 return Err(common::Error::HttpError(err));
20791 }
20792 Ok(res) => {
20793 let (mut parts, body) = res.into_parts();
20794 let mut body = common::Body::new(body);
20795 if !parts.status.is_success() {
20796 let bytes = common::to_bytes(body).await.unwrap_or_default();
20797 let error = serde_json::from_str(&common::to_string(&bytes));
20798 let response = common::to_response(parts, bytes.into());
20799
20800 if let common::Retry::After(d) =
20801 dlg.http_failure(&response, error.as_ref().ok())
20802 {
20803 sleep(d).await;
20804 continue;
20805 }
20806
20807 dlg.finished(false);
20808
20809 return Err(match error {
20810 Ok(value) => common::Error::BadRequest(value),
20811 _ => common::Error::Failure(response),
20812 });
20813 }
20814 let response = {
20815 let bytes = common::to_bytes(body).await.unwrap_or_default();
20816 let encoded = common::to_string(&bytes);
20817 match serde_json::from_str(&encoded) {
20818 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20819 Err(error) => {
20820 dlg.response_json_decode_error(&encoded, &error);
20821 return Err(common::Error::JsonDecodeError(
20822 encoded.to_string(),
20823 error,
20824 ));
20825 }
20826 }
20827 };
20828
20829 dlg.finished(true);
20830 return Ok(response);
20831 }
20832 }
20833 }
20834 }
20835
20836 ///
20837 /// Sets the *request* property to the given value.
20838 ///
20839 /// Even though the property as already been set when instantiating this call,
20840 /// we provide this method for API completeness.
20841 pub fn request(
20842 mut self,
20843 new_value: RollbackRequest,
20844 ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
20845 self._request = new_value;
20846 self
20847 }
20848 /// Required. The session in which the transaction to roll back is running.
20849 ///
20850 /// Sets the *session* path property to the given value.
20851 ///
20852 /// Even though the property as already been set when instantiating this call,
20853 /// we provide this method for API completeness.
20854 pub fn session(mut self, new_value: &str) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
20855 self._session = new_value.to_string();
20856 self
20857 }
20858 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20859 /// while executing the actual API request.
20860 ///
20861 /// ````text
20862 /// It should be used to handle progress information, and to implement a certain level of resilience.
20863 /// ````
20864 ///
20865 /// Sets the *delegate* property to the given value.
20866 pub fn delegate(
20867 mut self,
20868 new_value: &'a mut dyn common::Delegate,
20869 ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
20870 self._delegate = Some(new_value);
20871 self
20872 }
20873
20874 /// Set any additional parameter of the query string used in the request.
20875 /// It should be used to set parameters which are not yet available through their own
20876 /// setters.
20877 ///
20878 /// Please note that this method must not be used to set any of the known parameters
20879 /// which have their own setter method. If done anyway, the request will fail.
20880 ///
20881 /// # Additional Parameters
20882 ///
20883 /// * *$.xgafv* (query-string) - V1 error format.
20884 /// * *access_token* (query-string) - OAuth access token.
20885 /// * *alt* (query-string) - Data format for response.
20886 /// * *callback* (query-string) - JSONP
20887 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20888 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20889 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20890 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20891 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20892 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20893 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20894 pub fn param<T>(
20895 mut self,
20896 name: T,
20897 value: T,
20898 ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C>
20899 where
20900 T: AsRef<str>,
20901 {
20902 self._additional_params
20903 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20904 self
20905 }
20906
20907 /// Identifies the authorization scope for the method you are building.
20908 ///
20909 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20910 /// [`Scope::CloudPlatform`].
20911 ///
20912 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20913 /// tokens for more than one scope.
20914 ///
20915 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20916 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20917 /// sufficient, a read-write scope will do as well.
20918 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C>
20919 where
20920 St: AsRef<str>,
20921 {
20922 self._scopes.insert(String::from(scope.as_ref()));
20923 self
20924 }
20925 /// Identifies the authorization scope(s) for the method you are building.
20926 ///
20927 /// See [`Self::add_scope()`] for details.
20928 pub fn add_scopes<I, St>(
20929 mut self,
20930 scopes: I,
20931 ) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C>
20932 where
20933 I: IntoIterator<Item = St>,
20934 St: AsRef<str>,
20935 {
20936 self._scopes
20937 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20938 self
20939 }
20940
20941 /// Removes all scopes, and no default scope will be used either.
20942 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20943 /// for details).
20944 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionRollbackCall<'a, C> {
20945 self._scopes.clear();
20946 self
20947 }
20948}
20949
20950/// 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.
20951///
20952/// A builder for the *instances.databases.sessions.streamingRead* method supported by a *project* resource.
20953/// It is not used directly, but through a [`ProjectMethods`] instance.
20954///
20955/// # Example
20956///
20957/// Instantiate a resource method builder
20958///
20959/// ```test_harness,no_run
20960/// # extern crate hyper;
20961/// # extern crate hyper_rustls;
20962/// # extern crate google_spanner1 as spanner1;
20963/// use spanner1::api::ReadRequest;
20964/// # async fn dox() {
20965/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20966///
20967/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20968/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20969/// # secret,
20970/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20971/// # ).build().await.unwrap();
20972///
20973/// # let client = hyper_util::client::legacy::Client::builder(
20974/// # hyper_util::rt::TokioExecutor::new()
20975/// # )
20976/// # .build(
20977/// # hyper_rustls::HttpsConnectorBuilder::new()
20978/// # .with_native_roots()
20979/// # .unwrap()
20980/// # .https_or_http()
20981/// # .enable_http1()
20982/// # .build()
20983/// # );
20984/// # let mut hub = Spanner::new(client, auth);
20985/// // As the method needs a request, you would usually fill it with the desired information
20986/// // into the respective structure. Some of the parts shown here might not be applicable !
20987/// // Values shown here are possibly random and not representative !
20988/// let mut req = ReadRequest::default();
20989///
20990/// // You can configure optional parameters by calling the respective setters at will, and
20991/// // execute the final call using `doit()`.
20992/// // Values shown here are possibly random and not representative !
20993/// let result = hub.projects().instances_databases_sessions_streaming_read(req, "session")
20994/// .doit().await;
20995/// # }
20996/// ```
20997pub struct ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
20998where
20999 C: 'a,
21000{
21001 hub: &'a Spanner<C>,
21002 _request: ReadRequest,
21003 _session: String,
21004 _delegate: Option<&'a mut dyn common::Delegate>,
21005 _additional_params: HashMap<String, String>,
21006 _scopes: BTreeSet<String>,
21007}
21008
21009impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {}
21010
21011impl<'a, C> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
21012where
21013 C: common::Connector,
21014{
21015 /// Perform the operation you have build so far.
21016 pub async fn doit(mut self) -> common::Result<(common::Response, PartialResultSet)> {
21017 use std::borrow::Cow;
21018 use std::io::{Read, Seek};
21019
21020 use common::{url::Params, ToParts};
21021 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21022
21023 let mut dd = common::DefaultDelegate;
21024 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21025 dlg.begin(common::MethodInfo {
21026 id: "spanner.projects.instances.databases.sessions.streamingRead",
21027 http_method: hyper::Method::POST,
21028 });
21029
21030 for &field in ["alt", "session"].iter() {
21031 if self._additional_params.contains_key(field) {
21032 dlg.finished(false);
21033 return Err(common::Error::FieldClash(field));
21034 }
21035 }
21036
21037 let mut params = Params::with_capacity(4 + self._additional_params.len());
21038 params.push("session", self._session);
21039
21040 params.extend(self._additional_params.iter());
21041
21042 params.push("alt", "json");
21043 let mut url = self.hub._base_url.clone() + "v1/{+session}:streamingRead";
21044 if self._scopes.is_empty() {
21045 self._scopes
21046 .insert(Scope::CloudPlatform.as_ref().to_string());
21047 }
21048
21049 #[allow(clippy::single_element_loop)]
21050 for &(find_this, param_name) in [("{+session}", "session")].iter() {
21051 url = params.uri_replacement(url, param_name, find_this, true);
21052 }
21053 {
21054 let to_remove = ["session"];
21055 params.remove_params(&to_remove);
21056 }
21057
21058 let url = params.parse_with_url(&url);
21059
21060 let mut json_mime_type = mime::APPLICATION_JSON;
21061 let mut request_value_reader = {
21062 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21063 common::remove_json_null_values(&mut value);
21064 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21065 serde_json::to_writer(&mut dst, &value).unwrap();
21066 dst
21067 };
21068 let request_size = request_value_reader
21069 .seek(std::io::SeekFrom::End(0))
21070 .unwrap();
21071 request_value_reader
21072 .seek(std::io::SeekFrom::Start(0))
21073 .unwrap();
21074
21075 loop {
21076 let token = match self
21077 .hub
21078 .auth
21079 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21080 .await
21081 {
21082 Ok(token) => token,
21083 Err(e) => match dlg.token(e) {
21084 Ok(token) => token,
21085 Err(e) => {
21086 dlg.finished(false);
21087 return Err(common::Error::MissingToken(e));
21088 }
21089 },
21090 };
21091 request_value_reader
21092 .seek(std::io::SeekFrom::Start(0))
21093 .unwrap();
21094 let mut req_result = {
21095 let client = &self.hub.client;
21096 dlg.pre_request();
21097 let mut req_builder = hyper::Request::builder()
21098 .method(hyper::Method::POST)
21099 .uri(url.as_str())
21100 .header(USER_AGENT, self.hub._user_agent.clone());
21101
21102 if let Some(token) = token.as_ref() {
21103 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21104 }
21105
21106 let request = req_builder
21107 .header(CONTENT_TYPE, json_mime_type.to_string())
21108 .header(CONTENT_LENGTH, request_size as u64)
21109 .body(common::to_body(
21110 request_value_reader.get_ref().clone().into(),
21111 ));
21112
21113 client.request(request.unwrap()).await
21114 };
21115
21116 match req_result {
21117 Err(err) => {
21118 if let common::Retry::After(d) = dlg.http_error(&err) {
21119 sleep(d).await;
21120 continue;
21121 }
21122 dlg.finished(false);
21123 return Err(common::Error::HttpError(err));
21124 }
21125 Ok(res) => {
21126 let (mut parts, body) = res.into_parts();
21127 let mut body = common::Body::new(body);
21128 if !parts.status.is_success() {
21129 let bytes = common::to_bytes(body).await.unwrap_or_default();
21130 let error = serde_json::from_str(&common::to_string(&bytes));
21131 let response = common::to_response(parts, bytes.into());
21132
21133 if let common::Retry::After(d) =
21134 dlg.http_failure(&response, error.as_ref().ok())
21135 {
21136 sleep(d).await;
21137 continue;
21138 }
21139
21140 dlg.finished(false);
21141
21142 return Err(match error {
21143 Ok(value) => common::Error::BadRequest(value),
21144 _ => common::Error::Failure(response),
21145 });
21146 }
21147 let response = {
21148 let bytes = common::to_bytes(body).await.unwrap_or_default();
21149 let encoded = common::to_string(&bytes);
21150 match serde_json::from_str(&encoded) {
21151 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21152 Err(error) => {
21153 dlg.response_json_decode_error(&encoded, &error);
21154 return Err(common::Error::JsonDecodeError(
21155 encoded.to_string(),
21156 error,
21157 ));
21158 }
21159 }
21160 };
21161
21162 dlg.finished(true);
21163 return Ok(response);
21164 }
21165 }
21166 }
21167 }
21168
21169 ///
21170 /// Sets the *request* property to the given value.
21171 ///
21172 /// Even though the property as already been set when instantiating this call,
21173 /// we provide this method for API completeness.
21174 pub fn request(
21175 mut self,
21176 new_value: ReadRequest,
21177 ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
21178 self._request = new_value;
21179 self
21180 }
21181 /// Required. The session in which the read should be performed.
21182 ///
21183 /// Sets the *session* path property to the given value.
21184 ///
21185 /// Even though the property as already been set when instantiating this call,
21186 /// we provide this method for API completeness.
21187 pub fn session(
21188 mut self,
21189 new_value: &str,
21190 ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
21191 self._session = new_value.to_string();
21192 self
21193 }
21194 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21195 /// while executing the actual API request.
21196 ///
21197 /// ````text
21198 /// It should be used to handle progress information, and to implement a certain level of resilience.
21199 /// ````
21200 ///
21201 /// Sets the *delegate* property to the given value.
21202 pub fn delegate(
21203 mut self,
21204 new_value: &'a mut dyn common::Delegate,
21205 ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
21206 self._delegate = Some(new_value);
21207 self
21208 }
21209
21210 /// Set any additional parameter of the query string used in the request.
21211 /// It should be used to set parameters which are not yet available through their own
21212 /// setters.
21213 ///
21214 /// Please note that this method must not be used to set any of the known parameters
21215 /// which have their own setter method. If done anyway, the request will fail.
21216 ///
21217 /// # Additional Parameters
21218 ///
21219 /// * *$.xgafv* (query-string) - V1 error format.
21220 /// * *access_token* (query-string) - OAuth access token.
21221 /// * *alt* (query-string) - Data format for response.
21222 /// * *callback* (query-string) - JSONP
21223 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21224 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21225 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21226 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21227 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21228 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21229 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21230 pub fn param<T>(
21231 mut self,
21232 name: T,
21233 value: T,
21234 ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
21235 where
21236 T: AsRef<str>,
21237 {
21238 self._additional_params
21239 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21240 self
21241 }
21242
21243 /// Identifies the authorization scope for the method you are building.
21244 ///
21245 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21246 /// [`Scope::CloudPlatform`].
21247 ///
21248 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21249 /// tokens for more than one scope.
21250 ///
21251 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21252 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21253 /// sufficient, a read-write scope will do as well.
21254 pub fn add_scope<St>(
21255 mut self,
21256 scope: St,
21257 ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
21258 where
21259 St: AsRef<str>,
21260 {
21261 self._scopes.insert(String::from(scope.as_ref()));
21262 self
21263 }
21264 /// Identifies the authorization scope(s) for the method you are building.
21265 ///
21266 /// See [`Self::add_scope()`] for details.
21267 pub fn add_scopes<I, St>(
21268 mut self,
21269 scopes: I,
21270 ) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C>
21271 where
21272 I: IntoIterator<Item = St>,
21273 St: AsRef<str>,
21274 {
21275 self._scopes
21276 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21277 self
21278 }
21279
21280 /// Removes all scopes, and no default scope will be used either.
21281 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21282 /// for details).
21283 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSessionStreamingReadCall<'a, C> {
21284 self._scopes.clear();
21285 self
21286 }
21287}
21288
21289/// ChangeQuorum is strictly restricted to databases that use dual region instance configurations. Initiates a background operation to change quorum a database from dual-region mode to single-region mode and vice versa. The returned long-running operation will have 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.
21290///
21291/// A builder for the *instances.databases.changequorum* method supported by a *project* resource.
21292/// It is not used directly, but through a [`ProjectMethods`] instance.
21293///
21294/// # Example
21295///
21296/// Instantiate a resource method builder
21297///
21298/// ```test_harness,no_run
21299/// # extern crate hyper;
21300/// # extern crate hyper_rustls;
21301/// # extern crate google_spanner1 as spanner1;
21302/// use spanner1::api::ChangeQuorumRequest;
21303/// # async fn dox() {
21304/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21305///
21306/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21307/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21308/// # secret,
21309/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21310/// # ).build().await.unwrap();
21311///
21312/// # let client = hyper_util::client::legacy::Client::builder(
21313/// # hyper_util::rt::TokioExecutor::new()
21314/// # )
21315/// # .build(
21316/// # hyper_rustls::HttpsConnectorBuilder::new()
21317/// # .with_native_roots()
21318/// # .unwrap()
21319/// # .https_or_http()
21320/// # .enable_http1()
21321/// # .build()
21322/// # );
21323/// # let mut hub = Spanner::new(client, auth);
21324/// // As the method needs a request, you would usually fill it with the desired information
21325/// // into the respective structure. Some of the parts shown here might not be applicable !
21326/// // Values shown here are possibly random and not representative !
21327/// let mut req = ChangeQuorumRequest::default();
21328///
21329/// // You can configure optional parameters by calling the respective setters at will, and
21330/// // execute the final call using `doit()`.
21331/// // Values shown here are possibly random and not representative !
21332/// let result = hub.projects().instances_databases_changequorum(req, "name")
21333/// .doit().await;
21334/// # }
21335/// ```
21336pub struct ProjectInstanceDatabaseChangequorumCall<'a, C>
21337where
21338 C: 'a,
21339{
21340 hub: &'a Spanner<C>,
21341 _request: ChangeQuorumRequest,
21342 _name: String,
21343 _delegate: Option<&'a mut dyn common::Delegate>,
21344 _additional_params: HashMap<String, String>,
21345 _scopes: BTreeSet<String>,
21346}
21347
21348impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseChangequorumCall<'a, C> {}
21349
21350impl<'a, C> ProjectInstanceDatabaseChangequorumCall<'a, C>
21351where
21352 C: common::Connector,
21353{
21354 /// Perform the operation you have build so far.
21355 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21356 use std::borrow::Cow;
21357 use std::io::{Read, Seek};
21358
21359 use common::{url::Params, ToParts};
21360 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21361
21362 let mut dd = common::DefaultDelegate;
21363 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21364 dlg.begin(common::MethodInfo {
21365 id: "spanner.projects.instances.databases.changequorum",
21366 http_method: hyper::Method::POST,
21367 });
21368
21369 for &field in ["alt", "name"].iter() {
21370 if self._additional_params.contains_key(field) {
21371 dlg.finished(false);
21372 return Err(common::Error::FieldClash(field));
21373 }
21374 }
21375
21376 let mut params = Params::with_capacity(4 + self._additional_params.len());
21377 params.push("name", self._name);
21378
21379 params.extend(self._additional_params.iter());
21380
21381 params.push("alt", "json");
21382 let mut url = self.hub._base_url.clone() + "v1/{+name}:changequorum";
21383 if self._scopes.is_empty() {
21384 self._scopes
21385 .insert(Scope::CloudPlatform.as_ref().to_string());
21386 }
21387
21388 #[allow(clippy::single_element_loop)]
21389 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21390 url = params.uri_replacement(url, param_name, find_this, true);
21391 }
21392 {
21393 let to_remove = ["name"];
21394 params.remove_params(&to_remove);
21395 }
21396
21397 let url = params.parse_with_url(&url);
21398
21399 let mut json_mime_type = mime::APPLICATION_JSON;
21400 let mut request_value_reader = {
21401 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21402 common::remove_json_null_values(&mut value);
21403 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21404 serde_json::to_writer(&mut dst, &value).unwrap();
21405 dst
21406 };
21407 let request_size = request_value_reader
21408 .seek(std::io::SeekFrom::End(0))
21409 .unwrap();
21410 request_value_reader
21411 .seek(std::io::SeekFrom::Start(0))
21412 .unwrap();
21413
21414 loop {
21415 let token = match self
21416 .hub
21417 .auth
21418 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21419 .await
21420 {
21421 Ok(token) => token,
21422 Err(e) => match dlg.token(e) {
21423 Ok(token) => token,
21424 Err(e) => {
21425 dlg.finished(false);
21426 return Err(common::Error::MissingToken(e));
21427 }
21428 },
21429 };
21430 request_value_reader
21431 .seek(std::io::SeekFrom::Start(0))
21432 .unwrap();
21433 let mut req_result = {
21434 let client = &self.hub.client;
21435 dlg.pre_request();
21436 let mut req_builder = hyper::Request::builder()
21437 .method(hyper::Method::POST)
21438 .uri(url.as_str())
21439 .header(USER_AGENT, self.hub._user_agent.clone());
21440
21441 if let Some(token) = token.as_ref() {
21442 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21443 }
21444
21445 let request = req_builder
21446 .header(CONTENT_TYPE, json_mime_type.to_string())
21447 .header(CONTENT_LENGTH, request_size as u64)
21448 .body(common::to_body(
21449 request_value_reader.get_ref().clone().into(),
21450 ));
21451
21452 client.request(request.unwrap()).await
21453 };
21454
21455 match req_result {
21456 Err(err) => {
21457 if let common::Retry::After(d) = dlg.http_error(&err) {
21458 sleep(d).await;
21459 continue;
21460 }
21461 dlg.finished(false);
21462 return Err(common::Error::HttpError(err));
21463 }
21464 Ok(res) => {
21465 let (mut parts, body) = res.into_parts();
21466 let mut body = common::Body::new(body);
21467 if !parts.status.is_success() {
21468 let bytes = common::to_bytes(body).await.unwrap_or_default();
21469 let error = serde_json::from_str(&common::to_string(&bytes));
21470 let response = common::to_response(parts, bytes.into());
21471
21472 if let common::Retry::After(d) =
21473 dlg.http_failure(&response, error.as_ref().ok())
21474 {
21475 sleep(d).await;
21476 continue;
21477 }
21478
21479 dlg.finished(false);
21480
21481 return Err(match error {
21482 Ok(value) => common::Error::BadRequest(value),
21483 _ => common::Error::Failure(response),
21484 });
21485 }
21486 let response = {
21487 let bytes = common::to_bytes(body).await.unwrap_or_default();
21488 let encoded = common::to_string(&bytes);
21489 match serde_json::from_str(&encoded) {
21490 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21491 Err(error) => {
21492 dlg.response_json_decode_error(&encoded, &error);
21493 return Err(common::Error::JsonDecodeError(
21494 encoded.to_string(),
21495 error,
21496 ));
21497 }
21498 }
21499 };
21500
21501 dlg.finished(true);
21502 return Ok(response);
21503 }
21504 }
21505 }
21506 }
21507
21508 ///
21509 /// Sets the *request* property to the given value.
21510 ///
21511 /// Even though the property as already been set when instantiating this call,
21512 /// we provide this method for API completeness.
21513 pub fn request(
21514 mut self,
21515 new_value: ChangeQuorumRequest,
21516 ) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
21517 self._request = new_value;
21518 self
21519 }
21520 /// Required. Name of the database in which to apply the ChangeQuorum. Values are of the form `projects//instances//databases/`.
21521 ///
21522 /// Sets the *name* path property to the given value.
21523 ///
21524 /// Even though the property as already been set when instantiating this call,
21525 /// we provide this method for API completeness.
21526 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
21527 self._name = new_value.to_string();
21528 self
21529 }
21530 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21531 /// while executing the actual API request.
21532 ///
21533 /// ````text
21534 /// It should be used to handle progress information, and to implement a certain level of resilience.
21535 /// ````
21536 ///
21537 /// Sets the *delegate* property to the given value.
21538 pub fn delegate(
21539 mut self,
21540 new_value: &'a mut dyn common::Delegate,
21541 ) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
21542 self._delegate = Some(new_value);
21543 self
21544 }
21545
21546 /// Set any additional parameter of the query string used in the request.
21547 /// It should be used to set parameters which are not yet available through their own
21548 /// setters.
21549 ///
21550 /// Please note that this method must not be used to set any of the known parameters
21551 /// which have their own setter method. If done anyway, the request will fail.
21552 ///
21553 /// # Additional Parameters
21554 ///
21555 /// * *$.xgafv* (query-string) - V1 error format.
21556 /// * *access_token* (query-string) - OAuth access token.
21557 /// * *alt* (query-string) - Data format for response.
21558 /// * *callback* (query-string) - JSONP
21559 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21560 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21561 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21562 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21563 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21564 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21565 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21566 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseChangequorumCall<'a, C>
21567 where
21568 T: AsRef<str>,
21569 {
21570 self._additional_params
21571 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21572 self
21573 }
21574
21575 /// Identifies the authorization scope for the method you are building.
21576 ///
21577 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21578 /// [`Scope::CloudPlatform`].
21579 ///
21580 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21581 /// tokens for more than one scope.
21582 ///
21583 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21584 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21585 /// sufficient, a read-write scope will do as well.
21586 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseChangequorumCall<'a, C>
21587 where
21588 St: AsRef<str>,
21589 {
21590 self._scopes.insert(String::from(scope.as_ref()));
21591 self
21592 }
21593 /// Identifies the authorization scope(s) for the method you are building.
21594 ///
21595 /// See [`Self::add_scope()`] for details.
21596 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseChangequorumCall<'a, C>
21597 where
21598 I: IntoIterator<Item = St>,
21599 St: AsRef<str>,
21600 {
21601 self._scopes
21602 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21603 self
21604 }
21605
21606 /// Removes all scopes, and no default scope will be used either.
21607 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21608 /// for details).
21609 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseChangequorumCall<'a, C> {
21610 self._scopes.clear();
21611 self
21612 }
21613}
21614
21615/// Creates a new Cloud 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.
21616///
21617/// A builder for the *instances.databases.create* method supported by a *project* resource.
21618/// It is not used directly, but through a [`ProjectMethods`] instance.
21619///
21620/// # Example
21621///
21622/// Instantiate a resource method builder
21623///
21624/// ```test_harness,no_run
21625/// # extern crate hyper;
21626/// # extern crate hyper_rustls;
21627/// # extern crate google_spanner1 as spanner1;
21628/// use spanner1::api::CreateDatabaseRequest;
21629/// # async fn dox() {
21630/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21631///
21632/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21633/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21634/// # secret,
21635/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21636/// # ).build().await.unwrap();
21637///
21638/// # let client = hyper_util::client::legacy::Client::builder(
21639/// # hyper_util::rt::TokioExecutor::new()
21640/// # )
21641/// # .build(
21642/// # hyper_rustls::HttpsConnectorBuilder::new()
21643/// # .with_native_roots()
21644/// # .unwrap()
21645/// # .https_or_http()
21646/// # .enable_http1()
21647/// # .build()
21648/// # );
21649/// # let mut hub = Spanner::new(client, auth);
21650/// // As the method needs a request, you would usually fill it with the desired information
21651/// // into the respective structure. Some of the parts shown here might not be applicable !
21652/// // Values shown here are possibly random and not representative !
21653/// let mut req = CreateDatabaseRequest::default();
21654///
21655/// // You can configure optional parameters by calling the respective setters at will, and
21656/// // execute the final call using `doit()`.
21657/// // Values shown here are possibly random and not representative !
21658/// let result = hub.projects().instances_databases_create(req, "parent")
21659/// .doit().await;
21660/// # }
21661/// ```
21662pub struct ProjectInstanceDatabaseCreateCall<'a, C>
21663where
21664 C: 'a,
21665{
21666 hub: &'a Spanner<C>,
21667 _request: CreateDatabaseRequest,
21668 _parent: String,
21669 _delegate: Option<&'a mut dyn common::Delegate>,
21670 _additional_params: HashMap<String, String>,
21671 _scopes: BTreeSet<String>,
21672}
21673
21674impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseCreateCall<'a, C> {}
21675
21676impl<'a, C> ProjectInstanceDatabaseCreateCall<'a, C>
21677where
21678 C: common::Connector,
21679{
21680 /// Perform the operation you have build so far.
21681 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21682 use std::borrow::Cow;
21683 use std::io::{Read, Seek};
21684
21685 use common::{url::Params, ToParts};
21686 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21687
21688 let mut dd = common::DefaultDelegate;
21689 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21690 dlg.begin(common::MethodInfo {
21691 id: "spanner.projects.instances.databases.create",
21692 http_method: hyper::Method::POST,
21693 });
21694
21695 for &field in ["alt", "parent"].iter() {
21696 if self._additional_params.contains_key(field) {
21697 dlg.finished(false);
21698 return Err(common::Error::FieldClash(field));
21699 }
21700 }
21701
21702 let mut params = Params::with_capacity(4 + self._additional_params.len());
21703 params.push("parent", self._parent);
21704
21705 params.extend(self._additional_params.iter());
21706
21707 params.push("alt", "json");
21708 let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases";
21709 if self._scopes.is_empty() {
21710 self._scopes
21711 .insert(Scope::CloudPlatform.as_ref().to_string());
21712 }
21713
21714 #[allow(clippy::single_element_loop)]
21715 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21716 url = params.uri_replacement(url, param_name, find_this, true);
21717 }
21718 {
21719 let to_remove = ["parent"];
21720 params.remove_params(&to_remove);
21721 }
21722
21723 let url = params.parse_with_url(&url);
21724
21725 let mut json_mime_type = mime::APPLICATION_JSON;
21726 let mut request_value_reader = {
21727 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21728 common::remove_json_null_values(&mut value);
21729 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21730 serde_json::to_writer(&mut dst, &value).unwrap();
21731 dst
21732 };
21733 let request_size = request_value_reader
21734 .seek(std::io::SeekFrom::End(0))
21735 .unwrap();
21736 request_value_reader
21737 .seek(std::io::SeekFrom::Start(0))
21738 .unwrap();
21739
21740 loop {
21741 let token = match self
21742 .hub
21743 .auth
21744 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21745 .await
21746 {
21747 Ok(token) => token,
21748 Err(e) => match dlg.token(e) {
21749 Ok(token) => token,
21750 Err(e) => {
21751 dlg.finished(false);
21752 return Err(common::Error::MissingToken(e));
21753 }
21754 },
21755 };
21756 request_value_reader
21757 .seek(std::io::SeekFrom::Start(0))
21758 .unwrap();
21759 let mut req_result = {
21760 let client = &self.hub.client;
21761 dlg.pre_request();
21762 let mut req_builder = hyper::Request::builder()
21763 .method(hyper::Method::POST)
21764 .uri(url.as_str())
21765 .header(USER_AGENT, self.hub._user_agent.clone());
21766
21767 if let Some(token) = token.as_ref() {
21768 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21769 }
21770
21771 let request = req_builder
21772 .header(CONTENT_TYPE, json_mime_type.to_string())
21773 .header(CONTENT_LENGTH, request_size as u64)
21774 .body(common::to_body(
21775 request_value_reader.get_ref().clone().into(),
21776 ));
21777
21778 client.request(request.unwrap()).await
21779 };
21780
21781 match req_result {
21782 Err(err) => {
21783 if let common::Retry::After(d) = dlg.http_error(&err) {
21784 sleep(d).await;
21785 continue;
21786 }
21787 dlg.finished(false);
21788 return Err(common::Error::HttpError(err));
21789 }
21790 Ok(res) => {
21791 let (mut parts, body) = res.into_parts();
21792 let mut body = common::Body::new(body);
21793 if !parts.status.is_success() {
21794 let bytes = common::to_bytes(body).await.unwrap_or_default();
21795 let error = serde_json::from_str(&common::to_string(&bytes));
21796 let response = common::to_response(parts, bytes.into());
21797
21798 if let common::Retry::After(d) =
21799 dlg.http_failure(&response, error.as_ref().ok())
21800 {
21801 sleep(d).await;
21802 continue;
21803 }
21804
21805 dlg.finished(false);
21806
21807 return Err(match error {
21808 Ok(value) => common::Error::BadRequest(value),
21809 _ => common::Error::Failure(response),
21810 });
21811 }
21812 let response = {
21813 let bytes = common::to_bytes(body).await.unwrap_or_default();
21814 let encoded = common::to_string(&bytes);
21815 match serde_json::from_str(&encoded) {
21816 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21817 Err(error) => {
21818 dlg.response_json_decode_error(&encoded, &error);
21819 return Err(common::Error::JsonDecodeError(
21820 encoded.to_string(),
21821 error,
21822 ));
21823 }
21824 }
21825 };
21826
21827 dlg.finished(true);
21828 return Ok(response);
21829 }
21830 }
21831 }
21832 }
21833
21834 ///
21835 /// Sets the *request* property to the given value.
21836 ///
21837 /// Even though the property as already been set when instantiating this call,
21838 /// we provide this method for API completeness.
21839 pub fn request(
21840 mut self,
21841 new_value: CreateDatabaseRequest,
21842 ) -> ProjectInstanceDatabaseCreateCall<'a, C> {
21843 self._request = new_value;
21844 self
21845 }
21846 /// Required. The name of the instance that will serve the new database. Values are of the form `projects//instances/`.
21847 ///
21848 /// Sets the *parent* path property to the given value.
21849 ///
21850 /// Even though the property as already been set when instantiating this call,
21851 /// we provide this method for API completeness.
21852 pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseCreateCall<'a, C> {
21853 self._parent = new_value.to_string();
21854 self
21855 }
21856 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21857 /// while executing the actual API request.
21858 ///
21859 /// ````text
21860 /// It should be used to handle progress information, and to implement a certain level of resilience.
21861 /// ````
21862 ///
21863 /// Sets the *delegate* property to the given value.
21864 pub fn delegate(
21865 mut self,
21866 new_value: &'a mut dyn common::Delegate,
21867 ) -> ProjectInstanceDatabaseCreateCall<'a, C> {
21868 self._delegate = Some(new_value);
21869 self
21870 }
21871
21872 /// Set any additional parameter of the query string used in the request.
21873 /// It should be used to set parameters which are not yet available through their own
21874 /// setters.
21875 ///
21876 /// Please note that this method must not be used to set any of the known parameters
21877 /// which have their own setter method. If done anyway, the request will fail.
21878 ///
21879 /// # Additional Parameters
21880 ///
21881 /// * *$.xgafv* (query-string) - V1 error format.
21882 /// * *access_token* (query-string) - OAuth access token.
21883 /// * *alt* (query-string) - Data format for response.
21884 /// * *callback* (query-string) - JSONP
21885 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21886 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21887 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21888 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21889 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21890 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21891 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21892 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseCreateCall<'a, C>
21893 where
21894 T: AsRef<str>,
21895 {
21896 self._additional_params
21897 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21898 self
21899 }
21900
21901 /// Identifies the authorization scope for the method you are building.
21902 ///
21903 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21904 /// [`Scope::CloudPlatform`].
21905 ///
21906 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21907 /// tokens for more than one scope.
21908 ///
21909 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21910 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21911 /// sufficient, a read-write scope will do as well.
21912 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseCreateCall<'a, C>
21913 where
21914 St: AsRef<str>,
21915 {
21916 self._scopes.insert(String::from(scope.as_ref()));
21917 self
21918 }
21919 /// Identifies the authorization scope(s) for the method you are building.
21920 ///
21921 /// See [`Self::add_scope()`] for details.
21922 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseCreateCall<'a, C>
21923 where
21924 I: IntoIterator<Item = St>,
21925 St: AsRef<str>,
21926 {
21927 self._scopes
21928 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21929 self
21930 }
21931
21932 /// Removes all scopes, and no default scope will be used either.
21933 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21934 /// for details).
21935 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseCreateCall<'a, C> {
21936 self._scopes.clear();
21937 self
21938 }
21939}
21940
21941/// 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.
21942///
21943/// A builder for the *instances.databases.dropDatabase* method supported by a *project* resource.
21944/// It is not used directly, but through a [`ProjectMethods`] instance.
21945///
21946/// # Example
21947///
21948/// Instantiate a resource method builder
21949///
21950/// ```test_harness,no_run
21951/// # extern crate hyper;
21952/// # extern crate hyper_rustls;
21953/// # extern crate google_spanner1 as spanner1;
21954/// # async fn dox() {
21955/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21956///
21957/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21958/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21959/// # secret,
21960/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21961/// # ).build().await.unwrap();
21962///
21963/// # let client = hyper_util::client::legacy::Client::builder(
21964/// # hyper_util::rt::TokioExecutor::new()
21965/// # )
21966/// # .build(
21967/// # hyper_rustls::HttpsConnectorBuilder::new()
21968/// # .with_native_roots()
21969/// # .unwrap()
21970/// # .https_or_http()
21971/// # .enable_http1()
21972/// # .build()
21973/// # );
21974/// # let mut hub = Spanner::new(client, auth);
21975/// // You can configure optional parameters by calling the respective setters at will, and
21976/// // execute the final call using `doit()`.
21977/// // Values shown here are possibly random and not representative !
21978/// let result = hub.projects().instances_databases_drop_database("database")
21979/// .doit().await;
21980/// # }
21981/// ```
21982pub struct ProjectInstanceDatabaseDropDatabaseCall<'a, C>
21983where
21984 C: 'a,
21985{
21986 hub: &'a Spanner<C>,
21987 _database: String,
21988 _delegate: Option<&'a mut dyn common::Delegate>,
21989 _additional_params: HashMap<String, String>,
21990 _scopes: BTreeSet<String>,
21991}
21992
21993impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseDropDatabaseCall<'a, C> {}
21994
21995impl<'a, C> ProjectInstanceDatabaseDropDatabaseCall<'a, C>
21996where
21997 C: common::Connector,
21998{
21999 /// Perform the operation you have build so far.
22000 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
22001 use std::borrow::Cow;
22002 use std::io::{Read, Seek};
22003
22004 use common::{url::Params, ToParts};
22005 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22006
22007 let mut dd = common::DefaultDelegate;
22008 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22009 dlg.begin(common::MethodInfo {
22010 id: "spanner.projects.instances.databases.dropDatabase",
22011 http_method: hyper::Method::DELETE,
22012 });
22013
22014 for &field in ["alt", "database"].iter() {
22015 if self._additional_params.contains_key(field) {
22016 dlg.finished(false);
22017 return Err(common::Error::FieldClash(field));
22018 }
22019 }
22020
22021 let mut params = Params::with_capacity(3 + self._additional_params.len());
22022 params.push("database", self._database);
22023
22024 params.extend(self._additional_params.iter());
22025
22026 params.push("alt", "json");
22027 let mut url = self.hub._base_url.clone() + "v1/{+database}";
22028 if self._scopes.is_empty() {
22029 self._scopes
22030 .insert(Scope::CloudPlatform.as_ref().to_string());
22031 }
22032
22033 #[allow(clippy::single_element_loop)]
22034 for &(find_this, param_name) in [("{+database}", "database")].iter() {
22035 url = params.uri_replacement(url, param_name, find_this, true);
22036 }
22037 {
22038 let to_remove = ["database"];
22039 params.remove_params(&to_remove);
22040 }
22041
22042 let url = params.parse_with_url(&url);
22043
22044 loop {
22045 let token = match self
22046 .hub
22047 .auth
22048 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22049 .await
22050 {
22051 Ok(token) => token,
22052 Err(e) => match dlg.token(e) {
22053 Ok(token) => token,
22054 Err(e) => {
22055 dlg.finished(false);
22056 return Err(common::Error::MissingToken(e));
22057 }
22058 },
22059 };
22060 let mut req_result = {
22061 let client = &self.hub.client;
22062 dlg.pre_request();
22063 let mut req_builder = hyper::Request::builder()
22064 .method(hyper::Method::DELETE)
22065 .uri(url.as_str())
22066 .header(USER_AGENT, self.hub._user_agent.clone());
22067
22068 if let Some(token) = token.as_ref() {
22069 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22070 }
22071
22072 let request = req_builder
22073 .header(CONTENT_LENGTH, 0_u64)
22074 .body(common::to_body::<String>(None));
22075
22076 client.request(request.unwrap()).await
22077 };
22078
22079 match req_result {
22080 Err(err) => {
22081 if let common::Retry::After(d) = dlg.http_error(&err) {
22082 sleep(d).await;
22083 continue;
22084 }
22085 dlg.finished(false);
22086 return Err(common::Error::HttpError(err));
22087 }
22088 Ok(res) => {
22089 let (mut parts, body) = res.into_parts();
22090 let mut body = common::Body::new(body);
22091 if !parts.status.is_success() {
22092 let bytes = common::to_bytes(body).await.unwrap_or_default();
22093 let error = serde_json::from_str(&common::to_string(&bytes));
22094 let response = common::to_response(parts, bytes.into());
22095
22096 if let common::Retry::After(d) =
22097 dlg.http_failure(&response, error.as_ref().ok())
22098 {
22099 sleep(d).await;
22100 continue;
22101 }
22102
22103 dlg.finished(false);
22104
22105 return Err(match error {
22106 Ok(value) => common::Error::BadRequest(value),
22107 _ => common::Error::Failure(response),
22108 });
22109 }
22110 let response = {
22111 let bytes = common::to_bytes(body).await.unwrap_or_default();
22112 let encoded = common::to_string(&bytes);
22113 match serde_json::from_str(&encoded) {
22114 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22115 Err(error) => {
22116 dlg.response_json_decode_error(&encoded, &error);
22117 return Err(common::Error::JsonDecodeError(
22118 encoded.to_string(),
22119 error,
22120 ));
22121 }
22122 }
22123 };
22124
22125 dlg.finished(true);
22126 return Ok(response);
22127 }
22128 }
22129 }
22130 }
22131
22132 /// Required. The database to be dropped.
22133 ///
22134 /// Sets the *database* path property to the given value.
22135 ///
22136 /// Even though the property as already been set when instantiating this call,
22137 /// we provide this method for API completeness.
22138 pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C> {
22139 self._database = new_value.to_string();
22140 self
22141 }
22142 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22143 /// while executing the actual API request.
22144 ///
22145 /// ````text
22146 /// It should be used to handle progress information, and to implement a certain level of resilience.
22147 /// ````
22148 ///
22149 /// Sets the *delegate* property to the given value.
22150 pub fn delegate(
22151 mut self,
22152 new_value: &'a mut dyn common::Delegate,
22153 ) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C> {
22154 self._delegate = Some(new_value);
22155 self
22156 }
22157
22158 /// Set any additional parameter of the query string used in the request.
22159 /// It should be used to set parameters which are not yet available through their own
22160 /// setters.
22161 ///
22162 /// Please note that this method must not be used to set any of the known parameters
22163 /// which have their own setter method. If done anyway, the request will fail.
22164 ///
22165 /// # Additional Parameters
22166 ///
22167 /// * *$.xgafv* (query-string) - V1 error format.
22168 /// * *access_token* (query-string) - OAuth access token.
22169 /// * *alt* (query-string) - Data format for response.
22170 /// * *callback* (query-string) - JSONP
22171 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22172 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22173 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22174 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22175 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
22176 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22177 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22178 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C>
22179 where
22180 T: AsRef<str>,
22181 {
22182 self._additional_params
22183 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22184 self
22185 }
22186
22187 /// Identifies the authorization scope for the method you are building.
22188 ///
22189 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22190 /// [`Scope::CloudPlatform`].
22191 ///
22192 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22193 /// tokens for more than one scope.
22194 ///
22195 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22196 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22197 /// sufficient, a read-write scope will do as well.
22198 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C>
22199 where
22200 St: AsRef<str>,
22201 {
22202 self._scopes.insert(String::from(scope.as_ref()));
22203 self
22204 }
22205 /// Identifies the authorization scope(s) for the method you are building.
22206 ///
22207 /// See [`Self::add_scope()`] for details.
22208 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C>
22209 where
22210 I: IntoIterator<Item = St>,
22211 St: AsRef<str>,
22212 {
22213 self._scopes
22214 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22215 self
22216 }
22217
22218 /// Removes all scopes, and no default scope will be used either.
22219 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22220 /// for details).
22221 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseDropDatabaseCall<'a, C> {
22222 self._scopes.clear();
22223 self
22224 }
22225}
22226
22227/// Gets the state of a Cloud Spanner database.
22228///
22229/// A builder for the *instances.databases.get* method supported by a *project* resource.
22230/// It is not used directly, but through a [`ProjectMethods`] instance.
22231///
22232/// # Example
22233///
22234/// Instantiate a resource method builder
22235///
22236/// ```test_harness,no_run
22237/// # extern crate hyper;
22238/// # extern crate hyper_rustls;
22239/// # extern crate google_spanner1 as spanner1;
22240/// # async fn dox() {
22241/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22242///
22243/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22244/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22245/// # secret,
22246/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22247/// # ).build().await.unwrap();
22248///
22249/// # let client = hyper_util::client::legacy::Client::builder(
22250/// # hyper_util::rt::TokioExecutor::new()
22251/// # )
22252/// # .build(
22253/// # hyper_rustls::HttpsConnectorBuilder::new()
22254/// # .with_native_roots()
22255/// # .unwrap()
22256/// # .https_or_http()
22257/// # .enable_http1()
22258/// # .build()
22259/// # );
22260/// # let mut hub = Spanner::new(client, auth);
22261/// // You can configure optional parameters by calling the respective setters at will, and
22262/// // execute the final call using `doit()`.
22263/// // Values shown here are possibly random and not representative !
22264/// let result = hub.projects().instances_databases_get("name")
22265/// .doit().await;
22266/// # }
22267/// ```
22268pub struct ProjectInstanceDatabaseGetCall<'a, C>
22269where
22270 C: 'a,
22271{
22272 hub: &'a Spanner<C>,
22273 _name: String,
22274 _delegate: Option<&'a mut dyn common::Delegate>,
22275 _additional_params: HashMap<String, String>,
22276 _scopes: BTreeSet<String>,
22277}
22278
22279impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseGetCall<'a, C> {}
22280
22281impl<'a, C> ProjectInstanceDatabaseGetCall<'a, C>
22282where
22283 C: common::Connector,
22284{
22285 /// Perform the operation you have build so far.
22286 pub async fn doit(mut self) -> common::Result<(common::Response, Database)> {
22287 use std::borrow::Cow;
22288 use std::io::{Read, Seek};
22289
22290 use common::{url::Params, ToParts};
22291 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22292
22293 let mut dd = common::DefaultDelegate;
22294 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22295 dlg.begin(common::MethodInfo {
22296 id: "spanner.projects.instances.databases.get",
22297 http_method: hyper::Method::GET,
22298 });
22299
22300 for &field in ["alt", "name"].iter() {
22301 if self._additional_params.contains_key(field) {
22302 dlg.finished(false);
22303 return Err(common::Error::FieldClash(field));
22304 }
22305 }
22306
22307 let mut params = Params::with_capacity(3 + self._additional_params.len());
22308 params.push("name", self._name);
22309
22310 params.extend(self._additional_params.iter());
22311
22312 params.push("alt", "json");
22313 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22314 if self._scopes.is_empty() {
22315 self._scopes
22316 .insert(Scope::CloudPlatform.as_ref().to_string());
22317 }
22318
22319 #[allow(clippy::single_element_loop)]
22320 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22321 url = params.uri_replacement(url, param_name, find_this, true);
22322 }
22323 {
22324 let to_remove = ["name"];
22325 params.remove_params(&to_remove);
22326 }
22327
22328 let url = params.parse_with_url(&url);
22329
22330 loop {
22331 let token = match self
22332 .hub
22333 .auth
22334 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22335 .await
22336 {
22337 Ok(token) => token,
22338 Err(e) => match dlg.token(e) {
22339 Ok(token) => token,
22340 Err(e) => {
22341 dlg.finished(false);
22342 return Err(common::Error::MissingToken(e));
22343 }
22344 },
22345 };
22346 let mut req_result = {
22347 let client = &self.hub.client;
22348 dlg.pre_request();
22349 let mut req_builder = hyper::Request::builder()
22350 .method(hyper::Method::GET)
22351 .uri(url.as_str())
22352 .header(USER_AGENT, self.hub._user_agent.clone());
22353
22354 if let Some(token) = token.as_ref() {
22355 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22356 }
22357
22358 let request = req_builder
22359 .header(CONTENT_LENGTH, 0_u64)
22360 .body(common::to_body::<String>(None));
22361
22362 client.request(request.unwrap()).await
22363 };
22364
22365 match req_result {
22366 Err(err) => {
22367 if let common::Retry::After(d) = dlg.http_error(&err) {
22368 sleep(d).await;
22369 continue;
22370 }
22371 dlg.finished(false);
22372 return Err(common::Error::HttpError(err));
22373 }
22374 Ok(res) => {
22375 let (mut parts, body) = res.into_parts();
22376 let mut body = common::Body::new(body);
22377 if !parts.status.is_success() {
22378 let bytes = common::to_bytes(body).await.unwrap_or_default();
22379 let error = serde_json::from_str(&common::to_string(&bytes));
22380 let response = common::to_response(parts, bytes.into());
22381
22382 if let common::Retry::After(d) =
22383 dlg.http_failure(&response, error.as_ref().ok())
22384 {
22385 sleep(d).await;
22386 continue;
22387 }
22388
22389 dlg.finished(false);
22390
22391 return Err(match error {
22392 Ok(value) => common::Error::BadRequest(value),
22393 _ => common::Error::Failure(response),
22394 });
22395 }
22396 let response = {
22397 let bytes = common::to_bytes(body).await.unwrap_or_default();
22398 let encoded = common::to_string(&bytes);
22399 match serde_json::from_str(&encoded) {
22400 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22401 Err(error) => {
22402 dlg.response_json_decode_error(&encoded, &error);
22403 return Err(common::Error::JsonDecodeError(
22404 encoded.to_string(),
22405 error,
22406 ));
22407 }
22408 }
22409 };
22410
22411 dlg.finished(true);
22412 return Ok(response);
22413 }
22414 }
22415 }
22416 }
22417
22418 /// Required. The name of the requested database. Values are of the form `projects//instances//databases/`.
22419 ///
22420 /// Sets the *name* path property to the given value.
22421 ///
22422 /// Even though the property as already been set when instantiating this call,
22423 /// we provide this method for API completeness.
22424 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseGetCall<'a, C> {
22425 self._name = new_value.to_string();
22426 self
22427 }
22428 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22429 /// while executing the actual API request.
22430 ///
22431 /// ````text
22432 /// It should be used to handle progress information, and to implement a certain level of resilience.
22433 /// ````
22434 ///
22435 /// Sets the *delegate* property to the given value.
22436 pub fn delegate(
22437 mut self,
22438 new_value: &'a mut dyn common::Delegate,
22439 ) -> ProjectInstanceDatabaseGetCall<'a, C> {
22440 self._delegate = Some(new_value);
22441 self
22442 }
22443
22444 /// Set any additional parameter of the query string used in the request.
22445 /// It should be used to set parameters which are not yet available through their own
22446 /// setters.
22447 ///
22448 /// Please note that this method must not be used to set any of the known parameters
22449 /// which have their own setter method. If done anyway, the request will fail.
22450 ///
22451 /// # Additional Parameters
22452 ///
22453 /// * *$.xgafv* (query-string) - V1 error format.
22454 /// * *access_token* (query-string) - OAuth access token.
22455 /// * *alt* (query-string) - Data format for response.
22456 /// * *callback* (query-string) - JSONP
22457 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22458 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22459 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22460 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22461 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
22462 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22463 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22464 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseGetCall<'a, C>
22465 where
22466 T: AsRef<str>,
22467 {
22468 self._additional_params
22469 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22470 self
22471 }
22472
22473 /// Identifies the authorization scope for the method you are building.
22474 ///
22475 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22476 /// [`Scope::CloudPlatform`].
22477 ///
22478 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22479 /// tokens for more than one scope.
22480 ///
22481 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22482 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22483 /// sufficient, a read-write scope will do as well.
22484 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseGetCall<'a, C>
22485 where
22486 St: AsRef<str>,
22487 {
22488 self._scopes.insert(String::from(scope.as_ref()));
22489 self
22490 }
22491 /// Identifies the authorization scope(s) for the method you are building.
22492 ///
22493 /// See [`Self::add_scope()`] for details.
22494 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseGetCall<'a, C>
22495 where
22496 I: IntoIterator<Item = St>,
22497 St: AsRef<str>,
22498 {
22499 self._scopes
22500 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22501 self
22502 }
22503
22504 /// Removes all scopes, and no default scope will be used either.
22505 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22506 /// for details).
22507 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseGetCall<'a, C> {
22508 self._scopes.clear();
22509 self
22510 }
22511}
22512
22513/// 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.
22514///
22515/// A builder for the *instances.databases.getDdl* method supported by a *project* resource.
22516/// It is not used directly, but through a [`ProjectMethods`] instance.
22517///
22518/// # Example
22519///
22520/// Instantiate a resource method builder
22521///
22522/// ```test_harness,no_run
22523/// # extern crate hyper;
22524/// # extern crate hyper_rustls;
22525/// # extern crate google_spanner1 as spanner1;
22526/// # async fn dox() {
22527/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22528///
22529/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22530/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22531/// # secret,
22532/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22533/// # ).build().await.unwrap();
22534///
22535/// # let client = hyper_util::client::legacy::Client::builder(
22536/// # hyper_util::rt::TokioExecutor::new()
22537/// # )
22538/// # .build(
22539/// # hyper_rustls::HttpsConnectorBuilder::new()
22540/// # .with_native_roots()
22541/// # .unwrap()
22542/// # .https_or_http()
22543/// # .enable_http1()
22544/// # .build()
22545/// # );
22546/// # let mut hub = Spanner::new(client, auth);
22547/// // You can configure optional parameters by calling the respective setters at will, and
22548/// // execute the final call using `doit()`.
22549/// // Values shown here are possibly random and not representative !
22550/// let result = hub.projects().instances_databases_get_ddl("database")
22551/// .doit().await;
22552/// # }
22553/// ```
22554pub struct ProjectInstanceDatabaseGetDdlCall<'a, C>
22555where
22556 C: 'a,
22557{
22558 hub: &'a Spanner<C>,
22559 _database: String,
22560 _delegate: Option<&'a mut dyn common::Delegate>,
22561 _additional_params: HashMap<String, String>,
22562 _scopes: BTreeSet<String>,
22563}
22564
22565impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseGetDdlCall<'a, C> {}
22566
22567impl<'a, C> ProjectInstanceDatabaseGetDdlCall<'a, C>
22568where
22569 C: common::Connector,
22570{
22571 /// Perform the operation you have build so far.
22572 pub async fn doit(mut self) -> common::Result<(common::Response, GetDatabaseDdlResponse)> {
22573 use std::borrow::Cow;
22574 use std::io::{Read, Seek};
22575
22576 use common::{url::Params, ToParts};
22577 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22578
22579 let mut dd = common::DefaultDelegate;
22580 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22581 dlg.begin(common::MethodInfo {
22582 id: "spanner.projects.instances.databases.getDdl",
22583 http_method: hyper::Method::GET,
22584 });
22585
22586 for &field in ["alt", "database"].iter() {
22587 if self._additional_params.contains_key(field) {
22588 dlg.finished(false);
22589 return Err(common::Error::FieldClash(field));
22590 }
22591 }
22592
22593 let mut params = Params::with_capacity(3 + self._additional_params.len());
22594 params.push("database", self._database);
22595
22596 params.extend(self._additional_params.iter());
22597
22598 params.push("alt", "json");
22599 let mut url = self.hub._base_url.clone() + "v1/{+database}/ddl";
22600 if self._scopes.is_empty() {
22601 self._scopes
22602 .insert(Scope::CloudPlatform.as_ref().to_string());
22603 }
22604
22605 #[allow(clippy::single_element_loop)]
22606 for &(find_this, param_name) in [("{+database}", "database")].iter() {
22607 url = params.uri_replacement(url, param_name, find_this, true);
22608 }
22609 {
22610 let to_remove = ["database"];
22611 params.remove_params(&to_remove);
22612 }
22613
22614 let url = params.parse_with_url(&url);
22615
22616 loop {
22617 let token = match self
22618 .hub
22619 .auth
22620 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22621 .await
22622 {
22623 Ok(token) => token,
22624 Err(e) => match dlg.token(e) {
22625 Ok(token) => token,
22626 Err(e) => {
22627 dlg.finished(false);
22628 return Err(common::Error::MissingToken(e));
22629 }
22630 },
22631 };
22632 let mut req_result = {
22633 let client = &self.hub.client;
22634 dlg.pre_request();
22635 let mut req_builder = hyper::Request::builder()
22636 .method(hyper::Method::GET)
22637 .uri(url.as_str())
22638 .header(USER_AGENT, self.hub._user_agent.clone());
22639
22640 if let Some(token) = token.as_ref() {
22641 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22642 }
22643
22644 let request = req_builder
22645 .header(CONTENT_LENGTH, 0_u64)
22646 .body(common::to_body::<String>(None));
22647
22648 client.request(request.unwrap()).await
22649 };
22650
22651 match req_result {
22652 Err(err) => {
22653 if let common::Retry::After(d) = dlg.http_error(&err) {
22654 sleep(d).await;
22655 continue;
22656 }
22657 dlg.finished(false);
22658 return Err(common::Error::HttpError(err));
22659 }
22660 Ok(res) => {
22661 let (mut parts, body) = res.into_parts();
22662 let mut body = common::Body::new(body);
22663 if !parts.status.is_success() {
22664 let bytes = common::to_bytes(body).await.unwrap_or_default();
22665 let error = serde_json::from_str(&common::to_string(&bytes));
22666 let response = common::to_response(parts, bytes.into());
22667
22668 if let common::Retry::After(d) =
22669 dlg.http_failure(&response, error.as_ref().ok())
22670 {
22671 sleep(d).await;
22672 continue;
22673 }
22674
22675 dlg.finished(false);
22676
22677 return Err(match error {
22678 Ok(value) => common::Error::BadRequest(value),
22679 _ => common::Error::Failure(response),
22680 });
22681 }
22682 let response = {
22683 let bytes = common::to_bytes(body).await.unwrap_or_default();
22684 let encoded = common::to_string(&bytes);
22685 match serde_json::from_str(&encoded) {
22686 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22687 Err(error) => {
22688 dlg.response_json_decode_error(&encoded, &error);
22689 return Err(common::Error::JsonDecodeError(
22690 encoded.to_string(),
22691 error,
22692 ));
22693 }
22694 }
22695 };
22696
22697 dlg.finished(true);
22698 return Ok(response);
22699 }
22700 }
22701 }
22702 }
22703
22704 /// Required. The database whose schema we wish to get. Values are of the form `projects//instances//databases/`
22705 ///
22706 /// Sets the *database* path property to the given value.
22707 ///
22708 /// Even though the property as already been set when instantiating this call,
22709 /// we provide this method for API completeness.
22710 pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseGetDdlCall<'a, C> {
22711 self._database = new_value.to_string();
22712 self
22713 }
22714 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22715 /// while executing the actual API request.
22716 ///
22717 /// ````text
22718 /// It should be used to handle progress information, and to implement a certain level of resilience.
22719 /// ````
22720 ///
22721 /// Sets the *delegate* property to the given value.
22722 pub fn delegate(
22723 mut self,
22724 new_value: &'a mut dyn common::Delegate,
22725 ) -> ProjectInstanceDatabaseGetDdlCall<'a, C> {
22726 self._delegate = Some(new_value);
22727 self
22728 }
22729
22730 /// Set any additional parameter of the query string used in the request.
22731 /// It should be used to set parameters which are not yet available through their own
22732 /// setters.
22733 ///
22734 /// Please note that this method must not be used to set any of the known parameters
22735 /// which have their own setter method. If done anyway, the request will fail.
22736 ///
22737 /// # Additional Parameters
22738 ///
22739 /// * *$.xgafv* (query-string) - V1 error format.
22740 /// * *access_token* (query-string) - OAuth access token.
22741 /// * *alt* (query-string) - Data format for response.
22742 /// * *callback* (query-string) - JSONP
22743 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22744 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22745 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22746 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22747 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
22748 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22749 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22750 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseGetDdlCall<'a, C>
22751 where
22752 T: AsRef<str>,
22753 {
22754 self._additional_params
22755 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22756 self
22757 }
22758
22759 /// Identifies the authorization scope for the method you are building.
22760 ///
22761 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22762 /// [`Scope::CloudPlatform`].
22763 ///
22764 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22765 /// tokens for more than one scope.
22766 ///
22767 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22768 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22769 /// sufficient, a read-write scope will do as well.
22770 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseGetDdlCall<'a, C>
22771 where
22772 St: AsRef<str>,
22773 {
22774 self._scopes.insert(String::from(scope.as_ref()));
22775 self
22776 }
22777 /// Identifies the authorization scope(s) for the method you are building.
22778 ///
22779 /// See [`Self::add_scope()`] for details.
22780 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseGetDdlCall<'a, C>
22781 where
22782 I: IntoIterator<Item = St>,
22783 St: AsRef<str>,
22784 {
22785 self._scopes
22786 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22787 self
22788 }
22789
22790 /// Removes all scopes, and no default scope will be used either.
22791 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22792 /// for details).
22793 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseGetDdlCall<'a, C> {
22794 self._scopes.clear();
22795 self
22796 }
22797}
22798
22799/// 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.
22800///
22801/// A builder for the *instances.databases.getIamPolicy* method supported by a *project* resource.
22802/// It is not used directly, but through a [`ProjectMethods`] instance.
22803///
22804/// # Example
22805///
22806/// Instantiate a resource method builder
22807///
22808/// ```test_harness,no_run
22809/// # extern crate hyper;
22810/// # extern crate hyper_rustls;
22811/// # extern crate google_spanner1 as spanner1;
22812/// use spanner1::api::GetIamPolicyRequest;
22813/// # async fn dox() {
22814/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22815///
22816/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22817/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22818/// # secret,
22819/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22820/// # ).build().await.unwrap();
22821///
22822/// # let client = hyper_util::client::legacy::Client::builder(
22823/// # hyper_util::rt::TokioExecutor::new()
22824/// # )
22825/// # .build(
22826/// # hyper_rustls::HttpsConnectorBuilder::new()
22827/// # .with_native_roots()
22828/// # .unwrap()
22829/// # .https_or_http()
22830/// # .enable_http1()
22831/// # .build()
22832/// # );
22833/// # let mut hub = Spanner::new(client, auth);
22834/// // As the method needs a request, you would usually fill it with the desired information
22835/// // into the respective structure. Some of the parts shown here might not be applicable !
22836/// // Values shown here are possibly random and not representative !
22837/// let mut req = GetIamPolicyRequest::default();
22838///
22839/// // You can configure optional parameters by calling the respective setters at will, and
22840/// // execute the final call using `doit()`.
22841/// // Values shown here are possibly random and not representative !
22842/// let result = hub.projects().instances_databases_get_iam_policy(req, "resource")
22843/// .doit().await;
22844/// # }
22845/// ```
22846pub struct ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
22847where
22848 C: 'a,
22849{
22850 hub: &'a Spanner<C>,
22851 _request: GetIamPolicyRequest,
22852 _resource: String,
22853 _delegate: Option<&'a mut dyn common::Delegate>,
22854 _additional_params: HashMap<String, String>,
22855 _scopes: BTreeSet<String>,
22856}
22857
22858impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {}
22859
22860impl<'a, C> ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
22861where
22862 C: common::Connector,
22863{
22864 /// Perform the operation you have build so far.
22865 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
22866 use std::borrow::Cow;
22867 use std::io::{Read, Seek};
22868
22869 use common::{url::Params, ToParts};
22870 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22871
22872 let mut dd = common::DefaultDelegate;
22873 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22874 dlg.begin(common::MethodInfo {
22875 id: "spanner.projects.instances.databases.getIamPolicy",
22876 http_method: hyper::Method::POST,
22877 });
22878
22879 for &field in ["alt", "resource"].iter() {
22880 if self._additional_params.contains_key(field) {
22881 dlg.finished(false);
22882 return Err(common::Error::FieldClash(field));
22883 }
22884 }
22885
22886 let mut params = Params::with_capacity(4 + self._additional_params.len());
22887 params.push("resource", self._resource);
22888
22889 params.extend(self._additional_params.iter());
22890
22891 params.push("alt", "json");
22892 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
22893 if self._scopes.is_empty() {
22894 self._scopes
22895 .insert(Scope::CloudPlatform.as_ref().to_string());
22896 }
22897
22898 #[allow(clippy::single_element_loop)]
22899 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
22900 url = params.uri_replacement(url, param_name, find_this, true);
22901 }
22902 {
22903 let to_remove = ["resource"];
22904 params.remove_params(&to_remove);
22905 }
22906
22907 let url = params.parse_with_url(&url);
22908
22909 let mut json_mime_type = mime::APPLICATION_JSON;
22910 let mut request_value_reader = {
22911 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22912 common::remove_json_null_values(&mut value);
22913 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22914 serde_json::to_writer(&mut dst, &value).unwrap();
22915 dst
22916 };
22917 let request_size = request_value_reader
22918 .seek(std::io::SeekFrom::End(0))
22919 .unwrap();
22920 request_value_reader
22921 .seek(std::io::SeekFrom::Start(0))
22922 .unwrap();
22923
22924 loop {
22925 let token = match self
22926 .hub
22927 .auth
22928 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22929 .await
22930 {
22931 Ok(token) => token,
22932 Err(e) => match dlg.token(e) {
22933 Ok(token) => token,
22934 Err(e) => {
22935 dlg.finished(false);
22936 return Err(common::Error::MissingToken(e));
22937 }
22938 },
22939 };
22940 request_value_reader
22941 .seek(std::io::SeekFrom::Start(0))
22942 .unwrap();
22943 let mut req_result = {
22944 let client = &self.hub.client;
22945 dlg.pre_request();
22946 let mut req_builder = hyper::Request::builder()
22947 .method(hyper::Method::POST)
22948 .uri(url.as_str())
22949 .header(USER_AGENT, self.hub._user_agent.clone());
22950
22951 if let Some(token) = token.as_ref() {
22952 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22953 }
22954
22955 let request = req_builder
22956 .header(CONTENT_TYPE, json_mime_type.to_string())
22957 .header(CONTENT_LENGTH, request_size as u64)
22958 .body(common::to_body(
22959 request_value_reader.get_ref().clone().into(),
22960 ));
22961
22962 client.request(request.unwrap()).await
22963 };
22964
22965 match req_result {
22966 Err(err) => {
22967 if let common::Retry::After(d) = dlg.http_error(&err) {
22968 sleep(d).await;
22969 continue;
22970 }
22971 dlg.finished(false);
22972 return Err(common::Error::HttpError(err));
22973 }
22974 Ok(res) => {
22975 let (mut parts, body) = res.into_parts();
22976 let mut body = common::Body::new(body);
22977 if !parts.status.is_success() {
22978 let bytes = common::to_bytes(body).await.unwrap_or_default();
22979 let error = serde_json::from_str(&common::to_string(&bytes));
22980 let response = common::to_response(parts, bytes.into());
22981
22982 if let common::Retry::After(d) =
22983 dlg.http_failure(&response, error.as_ref().ok())
22984 {
22985 sleep(d).await;
22986 continue;
22987 }
22988
22989 dlg.finished(false);
22990
22991 return Err(match error {
22992 Ok(value) => common::Error::BadRequest(value),
22993 _ => common::Error::Failure(response),
22994 });
22995 }
22996 let response = {
22997 let bytes = common::to_bytes(body).await.unwrap_or_default();
22998 let encoded = common::to_string(&bytes);
22999 match serde_json::from_str(&encoded) {
23000 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23001 Err(error) => {
23002 dlg.response_json_decode_error(&encoded, &error);
23003 return Err(common::Error::JsonDecodeError(
23004 encoded.to_string(),
23005 error,
23006 ));
23007 }
23008 }
23009 };
23010
23011 dlg.finished(true);
23012 return Ok(response);
23013 }
23014 }
23015 }
23016 }
23017
23018 ///
23019 /// Sets the *request* property to the given value.
23020 ///
23021 /// Even though the property as already been set when instantiating this call,
23022 /// we provide this method for API completeness.
23023 pub fn request(
23024 mut self,
23025 new_value: GetIamPolicyRequest,
23026 ) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
23027 self._request = new_value;
23028 self
23029 }
23030 /// 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.
23031 ///
23032 /// Sets the *resource* path property to the given value.
23033 ///
23034 /// Even though the property as already been set when instantiating this call,
23035 /// we provide this method for API completeness.
23036 pub fn resource(mut self, new_value: &str) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
23037 self._resource = new_value.to_string();
23038 self
23039 }
23040 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23041 /// while executing the actual API request.
23042 ///
23043 /// ````text
23044 /// It should be used to handle progress information, and to implement a certain level of resilience.
23045 /// ````
23046 ///
23047 /// Sets the *delegate* property to the given value.
23048 pub fn delegate(
23049 mut self,
23050 new_value: &'a mut dyn common::Delegate,
23051 ) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
23052 self._delegate = Some(new_value);
23053 self
23054 }
23055
23056 /// Set any additional parameter of the query string used in the request.
23057 /// It should be used to set parameters which are not yet available through their own
23058 /// setters.
23059 ///
23060 /// Please note that this method must not be used to set any of the known parameters
23061 /// which have their own setter method. If done anyway, the request will fail.
23062 ///
23063 /// # Additional Parameters
23064 ///
23065 /// * *$.xgafv* (query-string) - V1 error format.
23066 /// * *access_token* (query-string) - OAuth access token.
23067 /// * *alt* (query-string) - Data format for response.
23068 /// * *callback* (query-string) - JSONP
23069 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23070 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23071 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23072 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23073 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
23074 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23075 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23076 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
23077 where
23078 T: AsRef<str>,
23079 {
23080 self._additional_params
23081 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23082 self
23083 }
23084
23085 /// Identifies the authorization scope for the method you are building.
23086 ///
23087 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23088 /// [`Scope::CloudPlatform`].
23089 ///
23090 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23091 /// tokens for more than one scope.
23092 ///
23093 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23094 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23095 /// sufficient, a read-write scope will do as well.
23096 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
23097 where
23098 St: AsRef<str>,
23099 {
23100 self._scopes.insert(String::from(scope.as_ref()));
23101 self
23102 }
23103 /// Identifies the authorization scope(s) for the method you are building.
23104 ///
23105 /// See [`Self::add_scope()`] for details.
23106 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C>
23107 where
23108 I: IntoIterator<Item = St>,
23109 St: AsRef<str>,
23110 {
23111 self._scopes
23112 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23113 self
23114 }
23115
23116 /// Removes all scopes, and no default scope will be used either.
23117 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23118 /// for details).
23119 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseGetIamPolicyCall<'a, C> {
23120 self._scopes.clear();
23121 self
23122 }
23123}
23124
23125/// Request a specific scan with Database-specific data for Cloud Key Visualizer.
23126///
23127/// A builder for the *instances.databases.getScans* method supported by a *project* resource.
23128/// It is not used directly, but through a [`ProjectMethods`] instance.
23129///
23130/// # Example
23131///
23132/// Instantiate a resource method builder
23133///
23134/// ```test_harness,no_run
23135/// # extern crate hyper;
23136/// # extern crate hyper_rustls;
23137/// # extern crate google_spanner1 as spanner1;
23138/// # async fn dox() {
23139/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23140///
23141/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23142/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23143/// # secret,
23144/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23145/// # ).build().await.unwrap();
23146///
23147/// # let client = hyper_util::client::legacy::Client::builder(
23148/// # hyper_util::rt::TokioExecutor::new()
23149/// # )
23150/// # .build(
23151/// # hyper_rustls::HttpsConnectorBuilder::new()
23152/// # .with_native_roots()
23153/// # .unwrap()
23154/// # .https_or_http()
23155/// # .enable_http1()
23156/// # .build()
23157/// # );
23158/// # let mut hub = Spanner::new(client, auth);
23159/// // You can configure optional parameters by calling the respective setters at will, and
23160/// // execute the final call using `doit()`.
23161/// // Values shown here are possibly random and not representative !
23162/// let result = hub.projects().instances_databases_get_scans("name")
23163/// .view("Lorem")
23164/// .start_time(chrono::Utc::now())
23165/// .end_time(chrono::Utc::now())
23166/// .doit().await;
23167/// # }
23168/// ```
23169pub struct ProjectInstanceDatabaseGetScanCall<'a, C>
23170where
23171 C: 'a,
23172{
23173 hub: &'a Spanner<C>,
23174 _name: String,
23175 _view: Option<String>,
23176 _start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
23177 _end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
23178 _delegate: Option<&'a mut dyn common::Delegate>,
23179 _additional_params: HashMap<String, String>,
23180 _scopes: BTreeSet<String>,
23181}
23182
23183impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseGetScanCall<'a, C> {}
23184
23185impl<'a, C> ProjectInstanceDatabaseGetScanCall<'a, C>
23186where
23187 C: common::Connector,
23188{
23189 /// Perform the operation you have build so far.
23190 pub async fn doit(mut self) -> common::Result<(common::Response, Scan)> {
23191 use std::borrow::Cow;
23192 use std::io::{Read, Seek};
23193
23194 use common::{url::Params, ToParts};
23195 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23196
23197 let mut dd = common::DefaultDelegate;
23198 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23199 dlg.begin(common::MethodInfo {
23200 id: "spanner.projects.instances.databases.getScans",
23201 http_method: hyper::Method::GET,
23202 });
23203
23204 for &field in ["alt", "name", "view", "startTime", "endTime"].iter() {
23205 if self._additional_params.contains_key(field) {
23206 dlg.finished(false);
23207 return Err(common::Error::FieldClash(field));
23208 }
23209 }
23210
23211 let mut params = Params::with_capacity(6 + self._additional_params.len());
23212 params.push("name", self._name);
23213 if let Some(value) = self._view.as_ref() {
23214 params.push("view", value);
23215 }
23216 if let Some(value) = self._start_time.as_ref() {
23217 params.push("startTime", common::serde::datetime_to_string(&value));
23218 }
23219 if let Some(value) = self._end_time.as_ref() {
23220 params.push("endTime", common::serde::datetime_to_string(&value));
23221 }
23222
23223 params.extend(self._additional_params.iter());
23224
23225 params.push("alt", "json");
23226 let mut url = self.hub._base_url.clone() + "v1/{+name}/scans";
23227 if self._scopes.is_empty() {
23228 self._scopes
23229 .insert(Scope::CloudPlatform.as_ref().to_string());
23230 }
23231
23232 #[allow(clippy::single_element_loop)]
23233 for &(find_this, param_name) in [("{+name}", "name")].iter() {
23234 url = params.uri_replacement(url, param_name, find_this, true);
23235 }
23236 {
23237 let to_remove = ["name"];
23238 params.remove_params(&to_remove);
23239 }
23240
23241 let url = params.parse_with_url(&url);
23242
23243 loop {
23244 let token = match self
23245 .hub
23246 .auth
23247 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23248 .await
23249 {
23250 Ok(token) => token,
23251 Err(e) => match dlg.token(e) {
23252 Ok(token) => token,
23253 Err(e) => {
23254 dlg.finished(false);
23255 return Err(common::Error::MissingToken(e));
23256 }
23257 },
23258 };
23259 let mut req_result = {
23260 let client = &self.hub.client;
23261 dlg.pre_request();
23262 let mut req_builder = hyper::Request::builder()
23263 .method(hyper::Method::GET)
23264 .uri(url.as_str())
23265 .header(USER_AGENT, self.hub._user_agent.clone());
23266
23267 if let Some(token) = token.as_ref() {
23268 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23269 }
23270
23271 let request = req_builder
23272 .header(CONTENT_LENGTH, 0_u64)
23273 .body(common::to_body::<String>(None));
23274
23275 client.request(request.unwrap()).await
23276 };
23277
23278 match req_result {
23279 Err(err) => {
23280 if let common::Retry::After(d) = dlg.http_error(&err) {
23281 sleep(d).await;
23282 continue;
23283 }
23284 dlg.finished(false);
23285 return Err(common::Error::HttpError(err));
23286 }
23287 Ok(res) => {
23288 let (mut parts, body) = res.into_parts();
23289 let mut body = common::Body::new(body);
23290 if !parts.status.is_success() {
23291 let bytes = common::to_bytes(body).await.unwrap_or_default();
23292 let error = serde_json::from_str(&common::to_string(&bytes));
23293 let response = common::to_response(parts, bytes.into());
23294
23295 if let common::Retry::After(d) =
23296 dlg.http_failure(&response, error.as_ref().ok())
23297 {
23298 sleep(d).await;
23299 continue;
23300 }
23301
23302 dlg.finished(false);
23303
23304 return Err(match error {
23305 Ok(value) => common::Error::BadRequest(value),
23306 _ => common::Error::Failure(response),
23307 });
23308 }
23309 let response = {
23310 let bytes = common::to_bytes(body).await.unwrap_or_default();
23311 let encoded = common::to_string(&bytes);
23312 match serde_json::from_str(&encoded) {
23313 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23314 Err(error) => {
23315 dlg.response_json_decode_error(&encoded, &error);
23316 return Err(common::Error::JsonDecodeError(
23317 encoded.to_string(),
23318 error,
23319 ));
23320 }
23321 }
23322 };
23323
23324 dlg.finished(true);
23325 return Ok(response);
23326 }
23327 }
23328 }
23329 }
23330
23331 /// Required. The unique name of the scan containing the requested information, specific to the Database service implementing this interface.
23332 ///
23333 /// Sets the *name* path property to the given value.
23334 ///
23335 /// Even though the property as already been set when instantiating this call,
23336 /// we provide this method for API completeness.
23337 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
23338 self._name = new_value.to_string();
23339 self
23340 }
23341 /// Specifies which parts of the Scan should be returned in the response. Note, if left unspecified, the FULL view is assumed.
23342 ///
23343 /// Sets the *view* query property to the given value.
23344 pub fn view(mut self, new_value: &str) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
23345 self._view = Some(new_value.to_string());
23346 self
23347 }
23348 /// 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.
23349 ///
23350 /// Sets the *start time* query property to the given value.
23351 pub fn start_time(
23352 mut self,
23353 new_value: chrono::DateTime<chrono::offset::Utc>,
23354 ) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
23355 self._start_time = Some(new_value);
23356 self
23357 }
23358 /// The upper bound for the time range to retrieve Scan data for.
23359 ///
23360 /// Sets the *end time* query property to the given value.
23361 pub fn end_time(
23362 mut self,
23363 new_value: chrono::DateTime<chrono::offset::Utc>,
23364 ) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
23365 self._end_time = Some(new_value);
23366 self
23367 }
23368 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23369 /// while executing the actual API request.
23370 ///
23371 /// ````text
23372 /// It should be used to handle progress information, and to implement a certain level of resilience.
23373 /// ````
23374 ///
23375 /// Sets the *delegate* property to the given value.
23376 pub fn delegate(
23377 mut self,
23378 new_value: &'a mut dyn common::Delegate,
23379 ) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
23380 self._delegate = Some(new_value);
23381 self
23382 }
23383
23384 /// Set any additional parameter of the query string used in the request.
23385 /// It should be used to set parameters which are not yet available through their own
23386 /// setters.
23387 ///
23388 /// Please note that this method must not be used to set any of the known parameters
23389 /// which have their own setter method. If done anyway, the request will fail.
23390 ///
23391 /// # Additional Parameters
23392 ///
23393 /// * *$.xgafv* (query-string) - V1 error format.
23394 /// * *access_token* (query-string) - OAuth access token.
23395 /// * *alt* (query-string) - Data format for response.
23396 /// * *callback* (query-string) - JSONP
23397 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23398 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23399 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23400 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23401 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
23402 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23403 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23404 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseGetScanCall<'a, C>
23405 where
23406 T: AsRef<str>,
23407 {
23408 self._additional_params
23409 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23410 self
23411 }
23412
23413 /// Identifies the authorization scope for the method you are building.
23414 ///
23415 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23416 /// [`Scope::CloudPlatform`].
23417 ///
23418 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23419 /// tokens for more than one scope.
23420 ///
23421 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23422 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23423 /// sufficient, a read-write scope will do as well.
23424 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseGetScanCall<'a, C>
23425 where
23426 St: AsRef<str>,
23427 {
23428 self._scopes.insert(String::from(scope.as_ref()));
23429 self
23430 }
23431 /// Identifies the authorization scope(s) for the method you are building.
23432 ///
23433 /// See [`Self::add_scope()`] for details.
23434 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseGetScanCall<'a, C>
23435 where
23436 I: IntoIterator<Item = St>,
23437 St: AsRef<str>,
23438 {
23439 self._scopes
23440 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23441 self
23442 }
23443
23444 /// Removes all scopes, and no default scope will be used either.
23445 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23446 /// for details).
23447 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseGetScanCall<'a, C> {
23448 self._scopes.clear();
23449 self
23450 }
23451}
23452
23453/// Lists Cloud Spanner databases.
23454///
23455/// A builder for the *instances.databases.list* method supported by a *project* resource.
23456/// It is not used directly, but through a [`ProjectMethods`] instance.
23457///
23458/// # Example
23459///
23460/// Instantiate a resource method builder
23461///
23462/// ```test_harness,no_run
23463/// # extern crate hyper;
23464/// # extern crate hyper_rustls;
23465/// # extern crate google_spanner1 as spanner1;
23466/// # async fn dox() {
23467/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23468///
23469/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23470/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23471/// # secret,
23472/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23473/// # ).build().await.unwrap();
23474///
23475/// # let client = hyper_util::client::legacy::Client::builder(
23476/// # hyper_util::rt::TokioExecutor::new()
23477/// # )
23478/// # .build(
23479/// # hyper_rustls::HttpsConnectorBuilder::new()
23480/// # .with_native_roots()
23481/// # .unwrap()
23482/// # .https_or_http()
23483/// # .enable_http1()
23484/// # .build()
23485/// # );
23486/// # let mut hub = Spanner::new(client, auth);
23487/// // You can configure optional parameters by calling the respective setters at will, and
23488/// // execute the final call using `doit()`.
23489/// // Values shown here are possibly random and not representative !
23490/// let result = hub.projects().instances_databases_list("parent")
23491/// .page_token("sed")
23492/// .page_size(-29)
23493/// .doit().await;
23494/// # }
23495/// ```
23496pub struct ProjectInstanceDatabaseListCall<'a, C>
23497where
23498 C: 'a,
23499{
23500 hub: &'a Spanner<C>,
23501 _parent: String,
23502 _page_token: Option<String>,
23503 _page_size: Option<i32>,
23504 _delegate: Option<&'a mut dyn common::Delegate>,
23505 _additional_params: HashMap<String, String>,
23506 _scopes: BTreeSet<String>,
23507}
23508
23509impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseListCall<'a, C> {}
23510
23511impl<'a, C> ProjectInstanceDatabaseListCall<'a, C>
23512where
23513 C: common::Connector,
23514{
23515 /// Perform the operation you have build so far.
23516 pub async fn doit(mut self) -> common::Result<(common::Response, ListDatabasesResponse)> {
23517 use std::borrow::Cow;
23518 use std::io::{Read, Seek};
23519
23520 use common::{url::Params, ToParts};
23521 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23522
23523 let mut dd = common::DefaultDelegate;
23524 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23525 dlg.begin(common::MethodInfo {
23526 id: "spanner.projects.instances.databases.list",
23527 http_method: hyper::Method::GET,
23528 });
23529
23530 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
23531 if self._additional_params.contains_key(field) {
23532 dlg.finished(false);
23533 return Err(common::Error::FieldClash(field));
23534 }
23535 }
23536
23537 let mut params = Params::with_capacity(5 + self._additional_params.len());
23538 params.push("parent", self._parent);
23539 if let Some(value) = self._page_token.as_ref() {
23540 params.push("pageToken", value);
23541 }
23542 if let Some(value) = self._page_size.as_ref() {
23543 params.push("pageSize", value.to_string());
23544 }
23545
23546 params.extend(self._additional_params.iter());
23547
23548 params.push("alt", "json");
23549 let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases";
23550 if self._scopes.is_empty() {
23551 self._scopes
23552 .insert(Scope::CloudPlatform.as_ref().to_string());
23553 }
23554
23555 #[allow(clippy::single_element_loop)]
23556 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
23557 url = params.uri_replacement(url, param_name, find_this, true);
23558 }
23559 {
23560 let to_remove = ["parent"];
23561 params.remove_params(&to_remove);
23562 }
23563
23564 let url = params.parse_with_url(&url);
23565
23566 loop {
23567 let token = match self
23568 .hub
23569 .auth
23570 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23571 .await
23572 {
23573 Ok(token) => token,
23574 Err(e) => match dlg.token(e) {
23575 Ok(token) => token,
23576 Err(e) => {
23577 dlg.finished(false);
23578 return Err(common::Error::MissingToken(e));
23579 }
23580 },
23581 };
23582 let mut req_result = {
23583 let client = &self.hub.client;
23584 dlg.pre_request();
23585 let mut req_builder = hyper::Request::builder()
23586 .method(hyper::Method::GET)
23587 .uri(url.as_str())
23588 .header(USER_AGENT, self.hub._user_agent.clone());
23589
23590 if let Some(token) = token.as_ref() {
23591 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23592 }
23593
23594 let request = req_builder
23595 .header(CONTENT_LENGTH, 0_u64)
23596 .body(common::to_body::<String>(None));
23597
23598 client.request(request.unwrap()).await
23599 };
23600
23601 match req_result {
23602 Err(err) => {
23603 if let common::Retry::After(d) = dlg.http_error(&err) {
23604 sleep(d).await;
23605 continue;
23606 }
23607 dlg.finished(false);
23608 return Err(common::Error::HttpError(err));
23609 }
23610 Ok(res) => {
23611 let (mut parts, body) = res.into_parts();
23612 let mut body = common::Body::new(body);
23613 if !parts.status.is_success() {
23614 let bytes = common::to_bytes(body).await.unwrap_or_default();
23615 let error = serde_json::from_str(&common::to_string(&bytes));
23616 let response = common::to_response(parts, bytes.into());
23617
23618 if let common::Retry::After(d) =
23619 dlg.http_failure(&response, error.as_ref().ok())
23620 {
23621 sleep(d).await;
23622 continue;
23623 }
23624
23625 dlg.finished(false);
23626
23627 return Err(match error {
23628 Ok(value) => common::Error::BadRequest(value),
23629 _ => common::Error::Failure(response),
23630 });
23631 }
23632 let response = {
23633 let bytes = common::to_bytes(body).await.unwrap_or_default();
23634 let encoded = common::to_string(&bytes);
23635 match serde_json::from_str(&encoded) {
23636 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23637 Err(error) => {
23638 dlg.response_json_decode_error(&encoded, &error);
23639 return Err(common::Error::JsonDecodeError(
23640 encoded.to_string(),
23641 error,
23642 ));
23643 }
23644 }
23645 };
23646
23647 dlg.finished(true);
23648 return Ok(response);
23649 }
23650 }
23651 }
23652 }
23653
23654 /// Required. The instance whose databases should be listed. Values are of the form `projects//instances/`.
23655 ///
23656 /// Sets the *parent* path property to the given value.
23657 ///
23658 /// Even though the property as already been set when instantiating this call,
23659 /// we provide this method for API completeness.
23660 pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseListCall<'a, C> {
23661 self._parent = new_value.to_string();
23662 self
23663 }
23664 /// If non-empty, `page_token` should contain a next_page_token from a previous ListDatabasesResponse.
23665 ///
23666 /// Sets the *page token* query property to the given value.
23667 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceDatabaseListCall<'a, C> {
23668 self._page_token = Some(new_value.to_string());
23669 self
23670 }
23671 /// Number of databases to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
23672 ///
23673 /// Sets the *page size* query property to the given value.
23674 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceDatabaseListCall<'a, C> {
23675 self._page_size = Some(new_value);
23676 self
23677 }
23678 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23679 /// while executing the actual API request.
23680 ///
23681 /// ````text
23682 /// It should be used to handle progress information, and to implement a certain level of resilience.
23683 /// ````
23684 ///
23685 /// Sets the *delegate* property to the given value.
23686 pub fn delegate(
23687 mut self,
23688 new_value: &'a mut dyn common::Delegate,
23689 ) -> ProjectInstanceDatabaseListCall<'a, C> {
23690 self._delegate = Some(new_value);
23691 self
23692 }
23693
23694 /// Set any additional parameter of the query string used in the request.
23695 /// It should be used to set parameters which are not yet available through their own
23696 /// setters.
23697 ///
23698 /// Please note that this method must not be used to set any of the known parameters
23699 /// which have their own setter method. If done anyway, the request will fail.
23700 ///
23701 /// # Additional Parameters
23702 ///
23703 /// * *$.xgafv* (query-string) - V1 error format.
23704 /// * *access_token* (query-string) - OAuth access token.
23705 /// * *alt* (query-string) - Data format for response.
23706 /// * *callback* (query-string) - JSONP
23707 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23708 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23709 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23710 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23711 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
23712 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23713 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23714 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseListCall<'a, C>
23715 where
23716 T: AsRef<str>,
23717 {
23718 self._additional_params
23719 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23720 self
23721 }
23722
23723 /// Identifies the authorization scope for the method you are building.
23724 ///
23725 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23726 /// [`Scope::CloudPlatform`].
23727 ///
23728 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23729 /// tokens for more than one scope.
23730 ///
23731 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23732 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23733 /// sufficient, a read-write scope will do as well.
23734 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseListCall<'a, C>
23735 where
23736 St: AsRef<str>,
23737 {
23738 self._scopes.insert(String::from(scope.as_ref()));
23739 self
23740 }
23741 /// Identifies the authorization scope(s) for the method you are building.
23742 ///
23743 /// See [`Self::add_scope()`] for details.
23744 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseListCall<'a, C>
23745 where
23746 I: IntoIterator<Item = St>,
23747 St: AsRef<str>,
23748 {
23749 self._scopes
23750 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23751 self
23752 }
23753
23754 /// Removes all scopes, and no default scope will be used either.
23755 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23756 /// for details).
23757 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseListCall<'a, C> {
23758 self._scopes.clear();
23759 self
23760 }
23761}
23762
23763/// 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.
23764///
23765/// A builder for the *instances.databases.patch* method supported by a *project* resource.
23766/// It is not used directly, but through a [`ProjectMethods`] instance.
23767///
23768/// # Example
23769///
23770/// Instantiate a resource method builder
23771///
23772/// ```test_harness,no_run
23773/// # extern crate hyper;
23774/// # extern crate hyper_rustls;
23775/// # extern crate google_spanner1 as spanner1;
23776/// use spanner1::api::Database;
23777/// # async fn dox() {
23778/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23779///
23780/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23781/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23782/// # secret,
23783/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23784/// # ).build().await.unwrap();
23785///
23786/// # let client = hyper_util::client::legacy::Client::builder(
23787/// # hyper_util::rt::TokioExecutor::new()
23788/// # )
23789/// # .build(
23790/// # hyper_rustls::HttpsConnectorBuilder::new()
23791/// # .with_native_roots()
23792/// # .unwrap()
23793/// # .https_or_http()
23794/// # .enable_http1()
23795/// # .build()
23796/// # );
23797/// # let mut hub = Spanner::new(client, auth);
23798/// // As the method needs a request, you would usually fill it with the desired information
23799/// // into the respective structure. Some of the parts shown here might not be applicable !
23800/// // Values shown here are possibly random and not representative !
23801/// let mut req = Database::default();
23802///
23803/// // You can configure optional parameters by calling the respective setters at will, and
23804/// // execute the final call using `doit()`.
23805/// // Values shown here are possibly random and not representative !
23806/// let result = hub.projects().instances_databases_patch(req, "name")
23807/// .update_mask(FieldMask::new::<&str>(&[]))
23808/// .doit().await;
23809/// # }
23810/// ```
23811pub struct ProjectInstanceDatabasePatchCall<'a, C>
23812where
23813 C: 'a,
23814{
23815 hub: &'a Spanner<C>,
23816 _request: Database,
23817 _name: String,
23818 _update_mask: Option<common::FieldMask>,
23819 _delegate: Option<&'a mut dyn common::Delegate>,
23820 _additional_params: HashMap<String, String>,
23821 _scopes: BTreeSet<String>,
23822}
23823
23824impl<'a, C> common::CallBuilder for ProjectInstanceDatabasePatchCall<'a, C> {}
23825
23826impl<'a, C> ProjectInstanceDatabasePatchCall<'a, C>
23827where
23828 C: common::Connector,
23829{
23830 /// Perform the operation you have build so far.
23831 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
23832 use std::borrow::Cow;
23833 use std::io::{Read, Seek};
23834
23835 use common::{url::Params, ToParts};
23836 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23837
23838 let mut dd = common::DefaultDelegate;
23839 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23840 dlg.begin(common::MethodInfo {
23841 id: "spanner.projects.instances.databases.patch",
23842 http_method: hyper::Method::PATCH,
23843 });
23844
23845 for &field in ["alt", "name", "updateMask"].iter() {
23846 if self._additional_params.contains_key(field) {
23847 dlg.finished(false);
23848 return Err(common::Error::FieldClash(field));
23849 }
23850 }
23851
23852 let mut params = Params::with_capacity(5 + self._additional_params.len());
23853 params.push("name", self._name);
23854 if let Some(value) = self._update_mask.as_ref() {
23855 params.push("updateMask", value.to_string());
23856 }
23857
23858 params.extend(self._additional_params.iter());
23859
23860 params.push("alt", "json");
23861 let mut url = self.hub._base_url.clone() + "v1/{+name}";
23862 if self._scopes.is_empty() {
23863 self._scopes
23864 .insert(Scope::CloudPlatform.as_ref().to_string());
23865 }
23866
23867 #[allow(clippy::single_element_loop)]
23868 for &(find_this, param_name) in [("{+name}", "name")].iter() {
23869 url = params.uri_replacement(url, param_name, find_this, true);
23870 }
23871 {
23872 let to_remove = ["name"];
23873 params.remove_params(&to_remove);
23874 }
23875
23876 let url = params.parse_with_url(&url);
23877
23878 let mut json_mime_type = mime::APPLICATION_JSON;
23879 let mut request_value_reader = {
23880 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23881 common::remove_json_null_values(&mut value);
23882 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23883 serde_json::to_writer(&mut dst, &value).unwrap();
23884 dst
23885 };
23886 let request_size = request_value_reader
23887 .seek(std::io::SeekFrom::End(0))
23888 .unwrap();
23889 request_value_reader
23890 .seek(std::io::SeekFrom::Start(0))
23891 .unwrap();
23892
23893 loop {
23894 let token = match self
23895 .hub
23896 .auth
23897 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23898 .await
23899 {
23900 Ok(token) => token,
23901 Err(e) => match dlg.token(e) {
23902 Ok(token) => token,
23903 Err(e) => {
23904 dlg.finished(false);
23905 return Err(common::Error::MissingToken(e));
23906 }
23907 },
23908 };
23909 request_value_reader
23910 .seek(std::io::SeekFrom::Start(0))
23911 .unwrap();
23912 let mut req_result = {
23913 let client = &self.hub.client;
23914 dlg.pre_request();
23915 let mut req_builder = hyper::Request::builder()
23916 .method(hyper::Method::PATCH)
23917 .uri(url.as_str())
23918 .header(USER_AGENT, self.hub._user_agent.clone());
23919
23920 if let Some(token) = token.as_ref() {
23921 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23922 }
23923
23924 let request = req_builder
23925 .header(CONTENT_TYPE, json_mime_type.to_string())
23926 .header(CONTENT_LENGTH, request_size as u64)
23927 .body(common::to_body(
23928 request_value_reader.get_ref().clone().into(),
23929 ));
23930
23931 client.request(request.unwrap()).await
23932 };
23933
23934 match req_result {
23935 Err(err) => {
23936 if let common::Retry::After(d) = dlg.http_error(&err) {
23937 sleep(d).await;
23938 continue;
23939 }
23940 dlg.finished(false);
23941 return Err(common::Error::HttpError(err));
23942 }
23943 Ok(res) => {
23944 let (mut parts, body) = res.into_parts();
23945 let mut body = common::Body::new(body);
23946 if !parts.status.is_success() {
23947 let bytes = common::to_bytes(body).await.unwrap_or_default();
23948 let error = serde_json::from_str(&common::to_string(&bytes));
23949 let response = common::to_response(parts, bytes.into());
23950
23951 if let common::Retry::After(d) =
23952 dlg.http_failure(&response, error.as_ref().ok())
23953 {
23954 sleep(d).await;
23955 continue;
23956 }
23957
23958 dlg.finished(false);
23959
23960 return Err(match error {
23961 Ok(value) => common::Error::BadRequest(value),
23962 _ => common::Error::Failure(response),
23963 });
23964 }
23965 let response = {
23966 let bytes = common::to_bytes(body).await.unwrap_or_default();
23967 let encoded = common::to_string(&bytes);
23968 match serde_json::from_str(&encoded) {
23969 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23970 Err(error) => {
23971 dlg.response_json_decode_error(&encoded, &error);
23972 return Err(common::Error::JsonDecodeError(
23973 encoded.to_string(),
23974 error,
23975 ));
23976 }
23977 }
23978 };
23979
23980 dlg.finished(true);
23981 return Ok(response);
23982 }
23983 }
23984 }
23985 }
23986
23987 ///
23988 /// Sets the *request* property to the given value.
23989 ///
23990 /// Even though the property as already been set when instantiating this call,
23991 /// we provide this method for API completeness.
23992 pub fn request(mut self, new_value: Database) -> ProjectInstanceDatabasePatchCall<'a, C> {
23993 self._request = new_value;
23994 self
23995 }
23996 /// 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.
23997 ///
23998 /// Sets the *name* path property to the given value.
23999 ///
24000 /// Even though the property as already been set when instantiating this call,
24001 /// we provide this method for API completeness.
24002 pub fn name(mut self, new_value: &str) -> ProjectInstanceDatabasePatchCall<'a, C> {
24003 self._name = new_value.to_string();
24004 self
24005 }
24006 /// Required. The list of fields to update. Currently, only `enable_drop_protection` field can be updated.
24007 ///
24008 /// Sets the *update mask* query property to the given value.
24009 pub fn update_mask(
24010 mut self,
24011 new_value: common::FieldMask,
24012 ) -> ProjectInstanceDatabasePatchCall<'a, C> {
24013 self._update_mask = Some(new_value);
24014 self
24015 }
24016 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24017 /// while executing the actual API request.
24018 ///
24019 /// ````text
24020 /// It should be used to handle progress information, and to implement a certain level of resilience.
24021 /// ````
24022 ///
24023 /// Sets the *delegate* property to the given value.
24024 pub fn delegate(
24025 mut self,
24026 new_value: &'a mut dyn common::Delegate,
24027 ) -> ProjectInstanceDatabasePatchCall<'a, C> {
24028 self._delegate = Some(new_value);
24029 self
24030 }
24031
24032 /// Set any additional parameter of the query string used in the request.
24033 /// It should be used to set parameters which are not yet available through their own
24034 /// setters.
24035 ///
24036 /// Please note that this method must not be used to set any of the known parameters
24037 /// which have their own setter method. If done anyway, the request will fail.
24038 ///
24039 /// # Additional Parameters
24040 ///
24041 /// * *$.xgafv* (query-string) - V1 error format.
24042 /// * *access_token* (query-string) - OAuth access token.
24043 /// * *alt* (query-string) - Data format for response.
24044 /// * *callback* (query-string) - JSONP
24045 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24046 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24047 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24048 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24049 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
24050 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24051 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24052 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabasePatchCall<'a, C>
24053 where
24054 T: AsRef<str>,
24055 {
24056 self._additional_params
24057 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24058 self
24059 }
24060
24061 /// Identifies the authorization scope for the method you are building.
24062 ///
24063 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24064 /// [`Scope::CloudPlatform`].
24065 ///
24066 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24067 /// tokens for more than one scope.
24068 ///
24069 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24070 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24071 /// sufficient, a read-write scope will do as well.
24072 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabasePatchCall<'a, C>
24073 where
24074 St: AsRef<str>,
24075 {
24076 self._scopes.insert(String::from(scope.as_ref()));
24077 self
24078 }
24079 /// Identifies the authorization scope(s) for the method you are building.
24080 ///
24081 /// See [`Self::add_scope()`] for details.
24082 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabasePatchCall<'a, C>
24083 where
24084 I: IntoIterator<Item = St>,
24085 St: AsRef<str>,
24086 {
24087 self._scopes
24088 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24089 self
24090 }
24091
24092 /// Removes all scopes, and no default scope will be used either.
24093 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24094 /// for details).
24095 pub fn clear_scopes(mut self) -> ProjectInstanceDatabasePatchCall<'a, C> {
24096 self._scopes.clear();
24097 self
24098 }
24099}
24100
24101/// 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.
24102///
24103/// A builder for the *instances.databases.restore* method supported by a *project* resource.
24104/// It is not used directly, but through a [`ProjectMethods`] instance.
24105///
24106/// # Example
24107///
24108/// Instantiate a resource method builder
24109///
24110/// ```test_harness,no_run
24111/// # extern crate hyper;
24112/// # extern crate hyper_rustls;
24113/// # extern crate google_spanner1 as spanner1;
24114/// use spanner1::api::RestoreDatabaseRequest;
24115/// # async fn dox() {
24116/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24117///
24118/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24119/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24120/// # secret,
24121/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24122/// # ).build().await.unwrap();
24123///
24124/// # let client = hyper_util::client::legacy::Client::builder(
24125/// # hyper_util::rt::TokioExecutor::new()
24126/// # )
24127/// # .build(
24128/// # hyper_rustls::HttpsConnectorBuilder::new()
24129/// # .with_native_roots()
24130/// # .unwrap()
24131/// # .https_or_http()
24132/// # .enable_http1()
24133/// # .build()
24134/// # );
24135/// # let mut hub = Spanner::new(client, auth);
24136/// // As the method needs a request, you would usually fill it with the desired information
24137/// // into the respective structure. Some of the parts shown here might not be applicable !
24138/// // Values shown here are possibly random and not representative !
24139/// let mut req = RestoreDatabaseRequest::default();
24140///
24141/// // You can configure optional parameters by calling the respective setters at will, and
24142/// // execute the final call using `doit()`.
24143/// // Values shown here are possibly random and not representative !
24144/// let result = hub.projects().instances_databases_restore(req, "parent")
24145/// .doit().await;
24146/// # }
24147/// ```
24148pub struct ProjectInstanceDatabaseRestoreCall<'a, C>
24149where
24150 C: 'a,
24151{
24152 hub: &'a Spanner<C>,
24153 _request: RestoreDatabaseRequest,
24154 _parent: String,
24155 _delegate: Option<&'a mut dyn common::Delegate>,
24156 _additional_params: HashMap<String, String>,
24157 _scopes: BTreeSet<String>,
24158}
24159
24160impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseRestoreCall<'a, C> {}
24161
24162impl<'a, C> ProjectInstanceDatabaseRestoreCall<'a, C>
24163where
24164 C: common::Connector,
24165{
24166 /// Perform the operation you have build so far.
24167 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
24168 use std::borrow::Cow;
24169 use std::io::{Read, Seek};
24170
24171 use common::{url::Params, ToParts};
24172 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24173
24174 let mut dd = common::DefaultDelegate;
24175 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24176 dlg.begin(common::MethodInfo {
24177 id: "spanner.projects.instances.databases.restore",
24178 http_method: hyper::Method::POST,
24179 });
24180
24181 for &field in ["alt", "parent"].iter() {
24182 if self._additional_params.contains_key(field) {
24183 dlg.finished(false);
24184 return Err(common::Error::FieldClash(field));
24185 }
24186 }
24187
24188 let mut params = Params::with_capacity(4 + self._additional_params.len());
24189 params.push("parent", self._parent);
24190
24191 params.extend(self._additional_params.iter());
24192
24193 params.push("alt", "json");
24194 let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases:restore";
24195 if self._scopes.is_empty() {
24196 self._scopes
24197 .insert(Scope::CloudPlatform.as_ref().to_string());
24198 }
24199
24200 #[allow(clippy::single_element_loop)]
24201 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
24202 url = params.uri_replacement(url, param_name, find_this, true);
24203 }
24204 {
24205 let to_remove = ["parent"];
24206 params.remove_params(&to_remove);
24207 }
24208
24209 let url = params.parse_with_url(&url);
24210
24211 let mut json_mime_type = mime::APPLICATION_JSON;
24212 let mut request_value_reader = {
24213 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24214 common::remove_json_null_values(&mut value);
24215 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24216 serde_json::to_writer(&mut dst, &value).unwrap();
24217 dst
24218 };
24219 let request_size = request_value_reader
24220 .seek(std::io::SeekFrom::End(0))
24221 .unwrap();
24222 request_value_reader
24223 .seek(std::io::SeekFrom::Start(0))
24224 .unwrap();
24225
24226 loop {
24227 let token = match self
24228 .hub
24229 .auth
24230 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24231 .await
24232 {
24233 Ok(token) => token,
24234 Err(e) => match dlg.token(e) {
24235 Ok(token) => token,
24236 Err(e) => {
24237 dlg.finished(false);
24238 return Err(common::Error::MissingToken(e));
24239 }
24240 },
24241 };
24242 request_value_reader
24243 .seek(std::io::SeekFrom::Start(0))
24244 .unwrap();
24245 let mut req_result = {
24246 let client = &self.hub.client;
24247 dlg.pre_request();
24248 let mut req_builder = hyper::Request::builder()
24249 .method(hyper::Method::POST)
24250 .uri(url.as_str())
24251 .header(USER_AGENT, self.hub._user_agent.clone());
24252
24253 if let Some(token) = token.as_ref() {
24254 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24255 }
24256
24257 let request = req_builder
24258 .header(CONTENT_TYPE, json_mime_type.to_string())
24259 .header(CONTENT_LENGTH, request_size as u64)
24260 .body(common::to_body(
24261 request_value_reader.get_ref().clone().into(),
24262 ));
24263
24264 client.request(request.unwrap()).await
24265 };
24266
24267 match req_result {
24268 Err(err) => {
24269 if let common::Retry::After(d) = dlg.http_error(&err) {
24270 sleep(d).await;
24271 continue;
24272 }
24273 dlg.finished(false);
24274 return Err(common::Error::HttpError(err));
24275 }
24276 Ok(res) => {
24277 let (mut parts, body) = res.into_parts();
24278 let mut body = common::Body::new(body);
24279 if !parts.status.is_success() {
24280 let bytes = common::to_bytes(body).await.unwrap_or_default();
24281 let error = serde_json::from_str(&common::to_string(&bytes));
24282 let response = common::to_response(parts, bytes.into());
24283
24284 if let common::Retry::After(d) =
24285 dlg.http_failure(&response, error.as_ref().ok())
24286 {
24287 sleep(d).await;
24288 continue;
24289 }
24290
24291 dlg.finished(false);
24292
24293 return Err(match error {
24294 Ok(value) => common::Error::BadRequest(value),
24295 _ => common::Error::Failure(response),
24296 });
24297 }
24298 let response = {
24299 let bytes = common::to_bytes(body).await.unwrap_or_default();
24300 let encoded = common::to_string(&bytes);
24301 match serde_json::from_str(&encoded) {
24302 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24303 Err(error) => {
24304 dlg.response_json_decode_error(&encoded, &error);
24305 return Err(common::Error::JsonDecodeError(
24306 encoded.to_string(),
24307 error,
24308 ));
24309 }
24310 }
24311 };
24312
24313 dlg.finished(true);
24314 return Ok(response);
24315 }
24316 }
24317 }
24318 }
24319
24320 ///
24321 /// Sets the *request* property to the given value.
24322 ///
24323 /// Even though the property as already been set when instantiating this call,
24324 /// we provide this method for API completeness.
24325 pub fn request(
24326 mut self,
24327 new_value: RestoreDatabaseRequest,
24328 ) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
24329 self._request = new_value;
24330 self
24331 }
24332 /// 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/`.
24333 ///
24334 /// Sets the *parent* path property to the given value.
24335 ///
24336 /// Even though the property as already been set when instantiating this call,
24337 /// we provide this method for API completeness.
24338 pub fn parent(mut self, new_value: &str) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
24339 self._parent = new_value.to_string();
24340 self
24341 }
24342 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24343 /// while executing the actual API request.
24344 ///
24345 /// ````text
24346 /// It should be used to handle progress information, and to implement a certain level of resilience.
24347 /// ````
24348 ///
24349 /// Sets the *delegate* property to the given value.
24350 pub fn delegate(
24351 mut self,
24352 new_value: &'a mut dyn common::Delegate,
24353 ) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
24354 self._delegate = Some(new_value);
24355 self
24356 }
24357
24358 /// Set any additional parameter of the query string used in the request.
24359 /// It should be used to set parameters which are not yet available through their own
24360 /// setters.
24361 ///
24362 /// Please note that this method must not be used to set any of the known parameters
24363 /// which have their own setter method. If done anyway, the request will fail.
24364 ///
24365 /// # Additional Parameters
24366 ///
24367 /// * *$.xgafv* (query-string) - V1 error format.
24368 /// * *access_token* (query-string) - OAuth access token.
24369 /// * *alt* (query-string) - Data format for response.
24370 /// * *callback* (query-string) - JSONP
24371 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24372 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24373 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24374 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24375 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
24376 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24377 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24378 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseRestoreCall<'a, C>
24379 where
24380 T: AsRef<str>,
24381 {
24382 self._additional_params
24383 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24384 self
24385 }
24386
24387 /// Identifies the authorization scope for the method you are building.
24388 ///
24389 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24390 /// [`Scope::CloudPlatform`].
24391 ///
24392 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24393 /// tokens for more than one scope.
24394 ///
24395 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24396 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24397 /// sufficient, a read-write scope will do as well.
24398 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseRestoreCall<'a, C>
24399 where
24400 St: AsRef<str>,
24401 {
24402 self._scopes.insert(String::from(scope.as_ref()));
24403 self
24404 }
24405 /// Identifies the authorization scope(s) for the method you are building.
24406 ///
24407 /// See [`Self::add_scope()`] for details.
24408 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseRestoreCall<'a, C>
24409 where
24410 I: IntoIterator<Item = St>,
24411 St: AsRef<str>,
24412 {
24413 self._scopes
24414 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24415 self
24416 }
24417
24418 /// Removes all scopes, and no default scope will be used either.
24419 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24420 /// for details).
24421 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseRestoreCall<'a, C> {
24422 self._scopes.clear();
24423 self
24424 }
24425}
24426
24427/// 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.
24428///
24429/// A builder for the *instances.databases.setIamPolicy* method supported by a *project* resource.
24430/// It is not used directly, but through a [`ProjectMethods`] instance.
24431///
24432/// # Example
24433///
24434/// Instantiate a resource method builder
24435///
24436/// ```test_harness,no_run
24437/// # extern crate hyper;
24438/// # extern crate hyper_rustls;
24439/// # extern crate google_spanner1 as spanner1;
24440/// use spanner1::api::SetIamPolicyRequest;
24441/// # async fn dox() {
24442/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24443///
24444/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24445/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24446/// # secret,
24447/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24448/// # ).build().await.unwrap();
24449///
24450/// # let client = hyper_util::client::legacy::Client::builder(
24451/// # hyper_util::rt::TokioExecutor::new()
24452/// # )
24453/// # .build(
24454/// # hyper_rustls::HttpsConnectorBuilder::new()
24455/// # .with_native_roots()
24456/// # .unwrap()
24457/// # .https_or_http()
24458/// # .enable_http1()
24459/// # .build()
24460/// # );
24461/// # let mut hub = Spanner::new(client, auth);
24462/// // As the method needs a request, you would usually fill it with the desired information
24463/// // into the respective structure. Some of the parts shown here might not be applicable !
24464/// // Values shown here are possibly random and not representative !
24465/// let mut req = SetIamPolicyRequest::default();
24466///
24467/// // You can configure optional parameters by calling the respective setters at will, and
24468/// // execute the final call using `doit()`.
24469/// // Values shown here are possibly random and not representative !
24470/// let result = hub.projects().instances_databases_set_iam_policy(req, "resource")
24471/// .doit().await;
24472/// # }
24473/// ```
24474pub struct ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
24475where
24476 C: 'a,
24477{
24478 hub: &'a Spanner<C>,
24479 _request: SetIamPolicyRequest,
24480 _resource: String,
24481 _delegate: Option<&'a mut dyn common::Delegate>,
24482 _additional_params: HashMap<String, String>,
24483 _scopes: BTreeSet<String>,
24484}
24485
24486impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {}
24487
24488impl<'a, C> ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
24489where
24490 C: common::Connector,
24491{
24492 /// Perform the operation you have build so far.
24493 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
24494 use std::borrow::Cow;
24495 use std::io::{Read, Seek};
24496
24497 use common::{url::Params, ToParts};
24498 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24499
24500 let mut dd = common::DefaultDelegate;
24501 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24502 dlg.begin(common::MethodInfo {
24503 id: "spanner.projects.instances.databases.setIamPolicy",
24504 http_method: hyper::Method::POST,
24505 });
24506
24507 for &field in ["alt", "resource"].iter() {
24508 if self._additional_params.contains_key(field) {
24509 dlg.finished(false);
24510 return Err(common::Error::FieldClash(field));
24511 }
24512 }
24513
24514 let mut params = Params::with_capacity(4 + self._additional_params.len());
24515 params.push("resource", self._resource);
24516
24517 params.extend(self._additional_params.iter());
24518
24519 params.push("alt", "json");
24520 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
24521 if self._scopes.is_empty() {
24522 self._scopes
24523 .insert(Scope::CloudPlatform.as_ref().to_string());
24524 }
24525
24526 #[allow(clippy::single_element_loop)]
24527 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
24528 url = params.uri_replacement(url, param_name, find_this, true);
24529 }
24530 {
24531 let to_remove = ["resource"];
24532 params.remove_params(&to_remove);
24533 }
24534
24535 let url = params.parse_with_url(&url);
24536
24537 let mut json_mime_type = mime::APPLICATION_JSON;
24538 let mut request_value_reader = {
24539 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24540 common::remove_json_null_values(&mut value);
24541 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24542 serde_json::to_writer(&mut dst, &value).unwrap();
24543 dst
24544 };
24545 let request_size = request_value_reader
24546 .seek(std::io::SeekFrom::End(0))
24547 .unwrap();
24548 request_value_reader
24549 .seek(std::io::SeekFrom::Start(0))
24550 .unwrap();
24551
24552 loop {
24553 let token = match self
24554 .hub
24555 .auth
24556 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24557 .await
24558 {
24559 Ok(token) => token,
24560 Err(e) => match dlg.token(e) {
24561 Ok(token) => token,
24562 Err(e) => {
24563 dlg.finished(false);
24564 return Err(common::Error::MissingToken(e));
24565 }
24566 },
24567 };
24568 request_value_reader
24569 .seek(std::io::SeekFrom::Start(0))
24570 .unwrap();
24571 let mut req_result = {
24572 let client = &self.hub.client;
24573 dlg.pre_request();
24574 let mut req_builder = hyper::Request::builder()
24575 .method(hyper::Method::POST)
24576 .uri(url.as_str())
24577 .header(USER_AGENT, self.hub._user_agent.clone());
24578
24579 if let Some(token) = token.as_ref() {
24580 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24581 }
24582
24583 let request = req_builder
24584 .header(CONTENT_TYPE, json_mime_type.to_string())
24585 .header(CONTENT_LENGTH, request_size as u64)
24586 .body(common::to_body(
24587 request_value_reader.get_ref().clone().into(),
24588 ));
24589
24590 client.request(request.unwrap()).await
24591 };
24592
24593 match req_result {
24594 Err(err) => {
24595 if let common::Retry::After(d) = dlg.http_error(&err) {
24596 sleep(d).await;
24597 continue;
24598 }
24599 dlg.finished(false);
24600 return Err(common::Error::HttpError(err));
24601 }
24602 Ok(res) => {
24603 let (mut parts, body) = res.into_parts();
24604 let mut body = common::Body::new(body);
24605 if !parts.status.is_success() {
24606 let bytes = common::to_bytes(body).await.unwrap_or_default();
24607 let error = serde_json::from_str(&common::to_string(&bytes));
24608 let response = common::to_response(parts, bytes.into());
24609
24610 if let common::Retry::After(d) =
24611 dlg.http_failure(&response, error.as_ref().ok())
24612 {
24613 sleep(d).await;
24614 continue;
24615 }
24616
24617 dlg.finished(false);
24618
24619 return Err(match error {
24620 Ok(value) => common::Error::BadRequest(value),
24621 _ => common::Error::Failure(response),
24622 });
24623 }
24624 let response = {
24625 let bytes = common::to_bytes(body).await.unwrap_or_default();
24626 let encoded = common::to_string(&bytes);
24627 match serde_json::from_str(&encoded) {
24628 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24629 Err(error) => {
24630 dlg.response_json_decode_error(&encoded, &error);
24631 return Err(common::Error::JsonDecodeError(
24632 encoded.to_string(),
24633 error,
24634 ));
24635 }
24636 }
24637 };
24638
24639 dlg.finished(true);
24640 return Ok(response);
24641 }
24642 }
24643 }
24644 }
24645
24646 ///
24647 /// Sets the *request* property to the given value.
24648 ///
24649 /// Even though the property as already been set when instantiating this call,
24650 /// we provide this method for API completeness.
24651 pub fn request(
24652 mut self,
24653 new_value: SetIamPolicyRequest,
24654 ) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
24655 self._request = new_value;
24656 self
24657 }
24658 /// 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.
24659 ///
24660 /// Sets the *resource* path property to the given value.
24661 ///
24662 /// Even though the property as already been set when instantiating this call,
24663 /// we provide this method for API completeness.
24664 pub fn resource(mut self, new_value: &str) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
24665 self._resource = new_value.to_string();
24666 self
24667 }
24668 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24669 /// while executing the actual API request.
24670 ///
24671 /// ````text
24672 /// It should be used to handle progress information, and to implement a certain level of resilience.
24673 /// ````
24674 ///
24675 /// Sets the *delegate* property to the given value.
24676 pub fn delegate(
24677 mut self,
24678 new_value: &'a mut dyn common::Delegate,
24679 ) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
24680 self._delegate = Some(new_value);
24681 self
24682 }
24683
24684 /// Set any additional parameter of the query string used in the request.
24685 /// It should be used to set parameters which are not yet available through their own
24686 /// setters.
24687 ///
24688 /// Please note that this method must not be used to set any of the known parameters
24689 /// which have their own setter method. If done anyway, the request will fail.
24690 ///
24691 /// # Additional Parameters
24692 ///
24693 /// * *$.xgafv* (query-string) - V1 error format.
24694 /// * *access_token* (query-string) - OAuth access token.
24695 /// * *alt* (query-string) - Data format for response.
24696 /// * *callback* (query-string) - JSONP
24697 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24698 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24699 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24700 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24701 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
24702 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24703 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24704 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
24705 where
24706 T: AsRef<str>,
24707 {
24708 self._additional_params
24709 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24710 self
24711 }
24712
24713 /// Identifies the authorization scope for the method you are building.
24714 ///
24715 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24716 /// [`Scope::CloudPlatform`].
24717 ///
24718 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24719 /// tokens for more than one scope.
24720 ///
24721 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24722 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24723 /// sufficient, a read-write scope will do as well.
24724 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
24725 where
24726 St: AsRef<str>,
24727 {
24728 self._scopes.insert(String::from(scope.as_ref()));
24729 self
24730 }
24731 /// Identifies the authorization scope(s) for the method you are building.
24732 ///
24733 /// See [`Self::add_scope()`] for details.
24734 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C>
24735 where
24736 I: IntoIterator<Item = St>,
24737 St: AsRef<str>,
24738 {
24739 self._scopes
24740 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24741 self
24742 }
24743
24744 /// Removes all scopes, and no default scope will be used either.
24745 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24746 /// for details).
24747 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseSetIamPolicyCall<'a, C> {
24748 self._scopes.clear();
24749 self
24750 }
24751}
24752
24753/// 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.
24754///
24755/// A builder for the *instances.databases.testIamPermissions* method supported by a *project* resource.
24756/// It is not used directly, but through a [`ProjectMethods`] instance.
24757///
24758/// # Example
24759///
24760/// Instantiate a resource method builder
24761///
24762/// ```test_harness,no_run
24763/// # extern crate hyper;
24764/// # extern crate hyper_rustls;
24765/// # extern crate google_spanner1 as spanner1;
24766/// use spanner1::api::TestIamPermissionsRequest;
24767/// # async fn dox() {
24768/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24769///
24770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24771/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24772/// # secret,
24773/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24774/// # ).build().await.unwrap();
24775///
24776/// # let client = hyper_util::client::legacy::Client::builder(
24777/// # hyper_util::rt::TokioExecutor::new()
24778/// # )
24779/// # .build(
24780/// # hyper_rustls::HttpsConnectorBuilder::new()
24781/// # .with_native_roots()
24782/// # .unwrap()
24783/// # .https_or_http()
24784/// # .enable_http1()
24785/// # .build()
24786/// # );
24787/// # let mut hub = Spanner::new(client, auth);
24788/// // As the method needs a request, you would usually fill it with the desired information
24789/// // into the respective structure. Some of the parts shown here might not be applicable !
24790/// // Values shown here are possibly random and not representative !
24791/// let mut req = TestIamPermissionsRequest::default();
24792///
24793/// // You can configure optional parameters by calling the respective setters at will, and
24794/// // execute the final call using `doit()`.
24795/// // Values shown here are possibly random and not representative !
24796/// let result = hub.projects().instances_databases_test_iam_permissions(req, "resource")
24797/// .doit().await;
24798/// # }
24799/// ```
24800pub struct ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
24801where
24802 C: 'a,
24803{
24804 hub: &'a Spanner<C>,
24805 _request: TestIamPermissionsRequest,
24806 _resource: String,
24807 _delegate: Option<&'a mut dyn common::Delegate>,
24808 _additional_params: HashMap<String, String>,
24809 _scopes: BTreeSet<String>,
24810}
24811
24812impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {}
24813
24814impl<'a, C> ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
24815where
24816 C: common::Connector,
24817{
24818 /// Perform the operation you have build so far.
24819 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
24820 use std::borrow::Cow;
24821 use std::io::{Read, Seek};
24822
24823 use common::{url::Params, ToParts};
24824 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24825
24826 let mut dd = common::DefaultDelegate;
24827 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24828 dlg.begin(common::MethodInfo {
24829 id: "spanner.projects.instances.databases.testIamPermissions",
24830 http_method: hyper::Method::POST,
24831 });
24832
24833 for &field in ["alt", "resource"].iter() {
24834 if self._additional_params.contains_key(field) {
24835 dlg.finished(false);
24836 return Err(common::Error::FieldClash(field));
24837 }
24838 }
24839
24840 let mut params = Params::with_capacity(4 + self._additional_params.len());
24841 params.push("resource", self._resource);
24842
24843 params.extend(self._additional_params.iter());
24844
24845 params.push("alt", "json");
24846 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
24847 if self._scopes.is_empty() {
24848 self._scopes
24849 .insert(Scope::CloudPlatform.as_ref().to_string());
24850 }
24851
24852 #[allow(clippy::single_element_loop)]
24853 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
24854 url = params.uri_replacement(url, param_name, find_this, true);
24855 }
24856 {
24857 let to_remove = ["resource"];
24858 params.remove_params(&to_remove);
24859 }
24860
24861 let url = params.parse_with_url(&url);
24862
24863 let mut json_mime_type = mime::APPLICATION_JSON;
24864 let mut request_value_reader = {
24865 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24866 common::remove_json_null_values(&mut value);
24867 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24868 serde_json::to_writer(&mut dst, &value).unwrap();
24869 dst
24870 };
24871 let request_size = request_value_reader
24872 .seek(std::io::SeekFrom::End(0))
24873 .unwrap();
24874 request_value_reader
24875 .seek(std::io::SeekFrom::Start(0))
24876 .unwrap();
24877
24878 loop {
24879 let token = match self
24880 .hub
24881 .auth
24882 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24883 .await
24884 {
24885 Ok(token) => token,
24886 Err(e) => match dlg.token(e) {
24887 Ok(token) => token,
24888 Err(e) => {
24889 dlg.finished(false);
24890 return Err(common::Error::MissingToken(e));
24891 }
24892 },
24893 };
24894 request_value_reader
24895 .seek(std::io::SeekFrom::Start(0))
24896 .unwrap();
24897 let mut req_result = {
24898 let client = &self.hub.client;
24899 dlg.pre_request();
24900 let mut req_builder = hyper::Request::builder()
24901 .method(hyper::Method::POST)
24902 .uri(url.as_str())
24903 .header(USER_AGENT, self.hub._user_agent.clone());
24904
24905 if let Some(token) = token.as_ref() {
24906 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24907 }
24908
24909 let request = req_builder
24910 .header(CONTENT_TYPE, json_mime_type.to_string())
24911 .header(CONTENT_LENGTH, request_size as u64)
24912 .body(common::to_body(
24913 request_value_reader.get_ref().clone().into(),
24914 ));
24915
24916 client.request(request.unwrap()).await
24917 };
24918
24919 match req_result {
24920 Err(err) => {
24921 if let common::Retry::After(d) = dlg.http_error(&err) {
24922 sleep(d).await;
24923 continue;
24924 }
24925 dlg.finished(false);
24926 return Err(common::Error::HttpError(err));
24927 }
24928 Ok(res) => {
24929 let (mut parts, body) = res.into_parts();
24930 let mut body = common::Body::new(body);
24931 if !parts.status.is_success() {
24932 let bytes = common::to_bytes(body).await.unwrap_or_default();
24933 let error = serde_json::from_str(&common::to_string(&bytes));
24934 let response = common::to_response(parts, bytes.into());
24935
24936 if let common::Retry::After(d) =
24937 dlg.http_failure(&response, error.as_ref().ok())
24938 {
24939 sleep(d).await;
24940 continue;
24941 }
24942
24943 dlg.finished(false);
24944
24945 return Err(match error {
24946 Ok(value) => common::Error::BadRequest(value),
24947 _ => common::Error::Failure(response),
24948 });
24949 }
24950 let response = {
24951 let bytes = common::to_bytes(body).await.unwrap_or_default();
24952 let encoded = common::to_string(&bytes);
24953 match serde_json::from_str(&encoded) {
24954 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24955 Err(error) => {
24956 dlg.response_json_decode_error(&encoded, &error);
24957 return Err(common::Error::JsonDecodeError(
24958 encoded.to_string(),
24959 error,
24960 ));
24961 }
24962 }
24963 };
24964
24965 dlg.finished(true);
24966 return Ok(response);
24967 }
24968 }
24969 }
24970 }
24971
24972 ///
24973 /// Sets the *request* property to the given value.
24974 ///
24975 /// Even though the property as already been set when instantiating this call,
24976 /// we provide this method for API completeness.
24977 pub fn request(
24978 mut self,
24979 new_value: TestIamPermissionsRequest,
24980 ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
24981 self._request = new_value;
24982 self
24983 }
24984 /// 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.
24985 ///
24986 /// Sets the *resource* path property to the given value.
24987 ///
24988 /// Even though the property as already been set when instantiating this call,
24989 /// we provide this method for API completeness.
24990 pub fn resource(
24991 mut self,
24992 new_value: &str,
24993 ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
24994 self._resource = new_value.to_string();
24995 self
24996 }
24997 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24998 /// while executing the actual API request.
24999 ///
25000 /// ````text
25001 /// It should be used to handle progress information, and to implement a certain level of resilience.
25002 /// ````
25003 ///
25004 /// Sets the *delegate* property to the given value.
25005 pub fn delegate(
25006 mut self,
25007 new_value: &'a mut dyn common::Delegate,
25008 ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
25009 self._delegate = Some(new_value);
25010 self
25011 }
25012
25013 /// Set any additional parameter of the query string used in the request.
25014 /// It should be used to set parameters which are not yet available through their own
25015 /// setters.
25016 ///
25017 /// Please note that this method must not be used to set any of the known parameters
25018 /// which have their own setter method. If done anyway, the request will fail.
25019 ///
25020 /// # Additional Parameters
25021 ///
25022 /// * *$.xgafv* (query-string) - V1 error format.
25023 /// * *access_token* (query-string) - OAuth access token.
25024 /// * *alt* (query-string) - Data format for response.
25025 /// * *callback* (query-string) - JSONP
25026 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25027 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
25028 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25029 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25030 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
25031 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25032 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25033 pub fn param<T>(
25034 mut self,
25035 name: T,
25036 value: T,
25037 ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
25038 where
25039 T: AsRef<str>,
25040 {
25041 self._additional_params
25042 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25043 self
25044 }
25045
25046 /// Identifies the authorization scope for the method you are building.
25047 ///
25048 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25049 /// [`Scope::CloudPlatform`].
25050 ///
25051 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25052 /// tokens for more than one scope.
25053 ///
25054 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25055 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25056 /// sufficient, a read-write scope will do as well.
25057 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
25058 where
25059 St: AsRef<str>,
25060 {
25061 self._scopes.insert(String::from(scope.as_ref()));
25062 self
25063 }
25064 /// Identifies the authorization scope(s) for the method you are building.
25065 ///
25066 /// See [`Self::add_scope()`] for details.
25067 pub fn add_scopes<I, St>(
25068 mut self,
25069 scopes: I,
25070 ) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C>
25071 where
25072 I: IntoIterator<Item = St>,
25073 St: AsRef<str>,
25074 {
25075 self._scopes
25076 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25077 self
25078 }
25079
25080 /// Removes all scopes, and no default scope will be used either.
25081 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25082 /// for details).
25083 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseTestIamPermissionCall<'a, C> {
25084 self._scopes.clear();
25085 self
25086 }
25087}
25088
25089/// 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 change(s). The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response.
25090///
25091/// A builder for the *instances.databases.updateDdl* method supported by a *project* resource.
25092/// It is not used directly, but through a [`ProjectMethods`] instance.
25093///
25094/// # Example
25095///
25096/// Instantiate a resource method builder
25097///
25098/// ```test_harness,no_run
25099/// # extern crate hyper;
25100/// # extern crate hyper_rustls;
25101/// # extern crate google_spanner1 as spanner1;
25102/// use spanner1::api::UpdateDatabaseDdlRequest;
25103/// # async fn dox() {
25104/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25105///
25106/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25107/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25108/// # secret,
25109/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25110/// # ).build().await.unwrap();
25111///
25112/// # let client = hyper_util::client::legacy::Client::builder(
25113/// # hyper_util::rt::TokioExecutor::new()
25114/// # )
25115/// # .build(
25116/// # hyper_rustls::HttpsConnectorBuilder::new()
25117/// # .with_native_roots()
25118/// # .unwrap()
25119/// # .https_or_http()
25120/// # .enable_http1()
25121/// # .build()
25122/// # );
25123/// # let mut hub = Spanner::new(client, auth);
25124/// // As the method needs a request, you would usually fill it with the desired information
25125/// // into the respective structure. Some of the parts shown here might not be applicable !
25126/// // Values shown here are possibly random and not representative !
25127/// let mut req = UpdateDatabaseDdlRequest::default();
25128///
25129/// // You can configure optional parameters by calling the respective setters at will, and
25130/// // execute the final call using `doit()`.
25131/// // Values shown here are possibly random and not representative !
25132/// let result = hub.projects().instances_databases_update_ddl(req, "database")
25133/// .doit().await;
25134/// # }
25135/// ```
25136pub struct ProjectInstanceDatabaseUpdateDdlCall<'a, C>
25137where
25138 C: 'a,
25139{
25140 hub: &'a Spanner<C>,
25141 _request: UpdateDatabaseDdlRequest,
25142 _database: String,
25143 _delegate: Option<&'a mut dyn common::Delegate>,
25144 _additional_params: HashMap<String, String>,
25145 _scopes: BTreeSet<String>,
25146}
25147
25148impl<'a, C> common::CallBuilder for ProjectInstanceDatabaseUpdateDdlCall<'a, C> {}
25149
25150impl<'a, C> ProjectInstanceDatabaseUpdateDdlCall<'a, C>
25151where
25152 C: common::Connector,
25153{
25154 /// Perform the operation you have build so far.
25155 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
25156 use std::borrow::Cow;
25157 use std::io::{Read, Seek};
25158
25159 use common::{url::Params, ToParts};
25160 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25161
25162 let mut dd = common::DefaultDelegate;
25163 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25164 dlg.begin(common::MethodInfo {
25165 id: "spanner.projects.instances.databases.updateDdl",
25166 http_method: hyper::Method::PATCH,
25167 });
25168
25169 for &field in ["alt", "database"].iter() {
25170 if self._additional_params.contains_key(field) {
25171 dlg.finished(false);
25172 return Err(common::Error::FieldClash(field));
25173 }
25174 }
25175
25176 let mut params = Params::with_capacity(4 + self._additional_params.len());
25177 params.push("database", self._database);
25178
25179 params.extend(self._additional_params.iter());
25180
25181 params.push("alt", "json");
25182 let mut url = self.hub._base_url.clone() + "v1/{+database}/ddl";
25183 if self._scopes.is_empty() {
25184 self._scopes
25185 .insert(Scope::CloudPlatform.as_ref().to_string());
25186 }
25187
25188 #[allow(clippy::single_element_loop)]
25189 for &(find_this, param_name) in [("{+database}", "database")].iter() {
25190 url = params.uri_replacement(url, param_name, find_this, true);
25191 }
25192 {
25193 let to_remove = ["database"];
25194 params.remove_params(&to_remove);
25195 }
25196
25197 let url = params.parse_with_url(&url);
25198
25199 let mut json_mime_type = mime::APPLICATION_JSON;
25200 let mut request_value_reader = {
25201 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25202 common::remove_json_null_values(&mut value);
25203 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25204 serde_json::to_writer(&mut dst, &value).unwrap();
25205 dst
25206 };
25207 let request_size = request_value_reader
25208 .seek(std::io::SeekFrom::End(0))
25209 .unwrap();
25210 request_value_reader
25211 .seek(std::io::SeekFrom::Start(0))
25212 .unwrap();
25213
25214 loop {
25215 let token = match self
25216 .hub
25217 .auth
25218 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25219 .await
25220 {
25221 Ok(token) => token,
25222 Err(e) => match dlg.token(e) {
25223 Ok(token) => token,
25224 Err(e) => {
25225 dlg.finished(false);
25226 return Err(common::Error::MissingToken(e));
25227 }
25228 },
25229 };
25230 request_value_reader
25231 .seek(std::io::SeekFrom::Start(0))
25232 .unwrap();
25233 let mut req_result = {
25234 let client = &self.hub.client;
25235 dlg.pre_request();
25236 let mut req_builder = hyper::Request::builder()
25237 .method(hyper::Method::PATCH)
25238 .uri(url.as_str())
25239 .header(USER_AGENT, self.hub._user_agent.clone());
25240
25241 if let Some(token) = token.as_ref() {
25242 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25243 }
25244
25245 let request = req_builder
25246 .header(CONTENT_TYPE, json_mime_type.to_string())
25247 .header(CONTENT_LENGTH, request_size as u64)
25248 .body(common::to_body(
25249 request_value_reader.get_ref().clone().into(),
25250 ));
25251
25252 client.request(request.unwrap()).await
25253 };
25254
25255 match req_result {
25256 Err(err) => {
25257 if let common::Retry::After(d) = dlg.http_error(&err) {
25258 sleep(d).await;
25259 continue;
25260 }
25261 dlg.finished(false);
25262 return Err(common::Error::HttpError(err));
25263 }
25264 Ok(res) => {
25265 let (mut parts, body) = res.into_parts();
25266 let mut body = common::Body::new(body);
25267 if !parts.status.is_success() {
25268 let bytes = common::to_bytes(body).await.unwrap_or_default();
25269 let error = serde_json::from_str(&common::to_string(&bytes));
25270 let response = common::to_response(parts, bytes.into());
25271
25272 if let common::Retry::After(d) =
25273 dlg.http_failure(&response, error.as_ref().ok())
25274 {
25275 sleep(d).await;
25276 continue;
25277 }
25278
25279 dlg.finished(false);
25280
25281 return Err(match error {
25282 Ok(value) => common::Error::BadRequest(value),
25283 _ => common::Error::Failure(response),
25284 });
25285 }
25286 let response = {
25287 let bytes = common::to_bytes(body).await.unwrap_or_default();
25288 let encoded = common::to_string(&bytes);
25289 match serde_json::from_str(&encoded) {
25290 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25291 Err(error) => {
25292 dlg.response_json_decode_error(&encoded, &error);
25293 return Err(common::Error::JsonDecodeError(
25294 encoded.to_string(),
25295 error,
25296 ));
25297 }
25298 }
25299 };
25300
25301 dlg.finished(true);
25302 return Ok(response);
25303 }
25304 }
25305 }
25306 }
25307
25308 ///
25309 /// Sets the *request* property to the given value.
25310 ///
25311 /// Even though the property as already been set when instantiating this call,
25312 /// we provide this method for API completeness.
25313 pub fn request(
25314 mut self,
25315 new_value: UpdateDatabaseDdlRequest,
25316 ) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
25317 self._request = new_value;
25318 self
25319 }
25320 /// Required. The database to update.
25321 ///
25322 /// Sets the *database* path property to the given value.
25323 ///
25324 /// Even though the property as already been set when instantiating this call,
25325 /// we provide this method for API completeness.
25326 pub fn database(mut self, new_value: &str) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
25327 self._database = new_value.to_string();
25328 self
25329 }
25330 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25331 /// while executing the actual API request.
25332 ///
25333 /// ````text
25334 /// It should be used to handle progress information, and to implement a certain level of resilience.
25335 /// ````
25336 ///
25337 /// Sets the *delegate* property to the given value.
25338 pub fn delegate(
25339 mut self,
25340 new_value: &'a mut dyn common::Delegate,
25341 ) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
25342 self._delegate = Some(new_value);
25343 self
25344 }
25345
25346 /// Set any additional parameter of the query string used in the request.
25347 /// It should be used to set parameters which are not yet available through their own
25348 /// setters.
25349 ///
25350 /// Please note that this method must not be used to set any of the known parameters
25351 /// which have their own setter method. If done anyway, the request will fail.
25352 ///
25353 /// # Additional Parameters
25354 ///
25355 /// * *$.xgafv* (query-string) - V1 error format.
25356 /// * *access_token* (query-string) - OAuth access token.
25357 /// * *alt* (query-string) - Data format for response.
25358 /// * *callback* (query-string) - JSONP
25359 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25360 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
25361 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25362 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25363 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
25364 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25365 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25366 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C>
25367 where
25368 T: AsRef<str>,
25369 {
25370 self._additional_params
25371 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25372 self
25373 }
25374
25375 /// Identifies the authorization scope for the method you are building.
25376 ///
25377 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25378 /// [`Scope::CloudPlatform`].
25379 ///
25380 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25381 /// tokens for more than one scope.
25382 ///
25383 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25384 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25385 /// sufficient, a read-write scope will do as well.
25386 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C>
25387 where
25388 St: AsRef<str>,
25389 {
25390 self._scopes.insert(String::from(scope.as_ref()));
25391 self
25392 }
25393 /// Identifies the authorization scope(s) for the method you are building.
25394 ///
25395 /// See [`Self::add_scope()`] for details.
25396 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C>
25397 where
25398 I: IntoIterator<Item = St>,
25399 St: AsRef<str>,
25400 {
25401 self._scopes
25402 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25403 self
25404 }
25405
25406 /// Removes all scopes, and no default scope will be used either.
25407 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25408 /// for details).
25409 pub fn clear_scopes(mut self) -> ProjectInstanceDatabaseUpdateDdlCall<'a, C> {
25410 self._scopes.clear();
25411 self
25412 }
25413}
25414
25415/// 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.
25416///
25417/// A builder for the *instances.instancePartitionOperations.list* method supported by a *project* resource.
25418/// It is not used directly, but through a [`ProjectMethods`] instance.
25419///
25420/// # Example
25421///
25422/// Instantiate a resource method builder
25423///
25424/// ```test_harness,no_run
25425/// # extern crate hyper;
25426/// # extern crate hyper_rustls;
25427/// # extern crate google_spanner1 as spanner1;
25428/// # async fn dox() {
25429/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25430///
25431/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25432/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25433/// # secret,
25434/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25435/// # ).build().await.unwrap();
25436///
25437/// # let client = hyper_util::client::legacy::Client::builder(
25438/// # hyper_util::rt::TokioExecutor::new()
25439/// # )
25440/// # .build(
25441/// # hyper_rustls::HttpsConnectorBuilder::new()
25442/// # .with_native_roots()
25443/// # .unwrap()
25444/// # .https_or_http()
25445/// # .enable_http1()
25446/// # .build()
25447/// # );
25448/// # let mut hub = Spanner::new(client, auth);
25449/// // You can configure optional parameters by calling the respective setters at will, and
25450/// // execute the final call using `doit()`.
25451/// // Values shown here are possibly random and not representative !
25452/// let result = hub.projects().instances_instance_partition_operations_list("parent")
25453/// .page_token("elitr")
25454/// .page_size(-80)
25455/// .instance_partition_deadline(chrono::Utc::now())
25456/// .filter("no")
25457/// .doit().await;
25458/// # }
25459/// ```
25460pub struct ProjectInstanceInstancePartitionOperationListCall<'a, C>
25461where
25462 C: 'a,
25463{
25464 hub: &'a Spanner<C>,
25465 _parent: String,
25466 _page_token: Option<String>,
25467 _page_size: Option<i32>,
25468 _instance_partition_deadline: Option<chrono::DateTime<chrono::offset::Utc>>,
25469 _filter: Option<String>,
25470 _delegate: Option<&'a mut dyn common::Delegate>,
25471 _additional_params: HashMap<String, String>,
25472 _scopes: BTreeSet<String>,
25473}
25474
25475impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationListCall<'a, C> {}
25476
25477impl<'a, C> ProjectInstanceInstancePartitionOperationListCall<'a, C>
25478where
25479 C: common::Connector,
25480{
25481 /// Perform the operation you have build so far.
25482 pub async fn doit(
25483 mut self,
25484 ) -> common::Result<(common::Response, ListInstancePartitionOperationsResponse)> {
25485 use std::borrow::Cow;
25486 use std::io::{Read, Seek};
25487
25488 use common::{url::Params, ToParts};
25489 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25490
25491 let mut dd = common::DefaultDelegate;
25492 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25493 dlg.begin(common::MethodInfo {
25494 id: "spanner.projects.instances.instancePartitionOperations.list",
25495 http_method: hyper::Method::GET,
25496 });
25497
25498 for &field in [
25499 "alt",
25500 "parent",
25501 "pageToken",
25502 "pageSize",
25503 "instancePartitionDeadline",
25504 "filter",
25505 ]
25506 .iter()
25507 {
25508 if self._additional_params.contains_key(field) {
25509 dlg.finished(false);
25510 return Err(common::Error::FieldClash(field));
25511 }
25512 }
25513
25514 let mut params = Params::with_capacity(7 + self._additional_params.len());
25515 params.push("parent", self._parent);
25516 if let Some(value) = self._page_token.as_ref() {
25517 params.push("pageToken", value);
25518 }
25519 if let Some(value) = self._page_size.as_ref() {
25520 params.push("pageSize", value.to_string());
25521 }
25522 if let Some(value) = self._instance_partition_deadline.as_ref() {
25523 params.push(
25524 "instancePartitionDeadline",
25525 common::serde::datetime_to_string(&value),
25526 );
25527 }
25528 if let Some(value) = self._filter.as_ref() {
25529 params.push("filter", value);
25530 }
25531
25532 params.extend(self._additional_params.iter());
25533
25534 params.push("alt", "json");
25535 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instancePartitionOperations";
25536 if self._scopes.is_empty() {
25537 self._scopes
25538 .insert(Scope::CloudPlatform.as_ref().to_string());
25539 }
25540
25541 #[allow(clippy::single_element_loop)]
25542 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
25543 url = params.uri_replacement(url, param_name, find_this, true);
25544 }
25545 {
25546 let to_remove = ["parent"];
25547 params.remove_params(&to_remove);
25548 }
25549
25550 let url = params.parse_with_url(&url);
25551
25552 loop {
25553 let token = match self
25554 .hub
25555 .auth
25556 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25557 .await
25558 {
25559 Ok(token) => token,
25560 Err(e) => match dlg.token(e) {
25561 Ok(token) => token,
25562 Err(e) => {
25563 dlg.finished(false);
25564 return Err(common::Error::MissingToken(e));
25565 }
25566 },
25567 };
25568 let mut req_result = {
25569 let client = &self.hub.client;
25570 dlg.pre_request();
25571 let mut req_builder = hyper::Request::builder()
25572 .method(hyper::Method::GET)
25573 .uri(url.as_str())
25574 .header(USER_AGENT, self.hub._user_agent.clone());
25575
25576 if let Some(token) = token.as_ref() {
25577 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25578 }
25579
25580 let request = req_builder
25581 .header(CONTENT_LENGTH, 0_u64)
25582 .body(common::to_body::<String>(None));
25583
25584 client.request(request.unwrap()).await
25585 };
25586
25587 match req_result {
25588 Err(err) => {
25589 if let common::Retry::After(d) = dlg.http_error(&err) {
25590 sleep(d).await;
25591 continue;
25592 }
25593 dlg.finished(false);
25594 return Err(common::Error::HttpError(err));
25595 }
25596 Ok(res) => {
25597 let (mut parts, body) = res.into_parts();
25598 let mut body = common::Body::new(body);
25599 if !parts.status.is_success() {
25600 let bytes = common::to_bytes(body).await.unwrap_or_default();
25601 let error = serde_json::from_str(&common::to_string(&bytes));
25602 let response = common::to_response(parts, bytes.into());
25603
25604 if let common::Retry::After(d) =
25605 dlg.http_failure(&response, error.as_ref().ok())
25606 {
25607 sleep(d).await;
25608 continue;
25609 }
25610
25611 dlg.finished(false);
25612
25613 return Err(match error {
25614 Ok(value) => common::Error::BadRequest(value),
25615 _ => common::Error::Failure(response),
25616 });
25617 }
25618 let response = {
25619 let bytes = common::to_bytes(body).await.unwrap_or_default();
25620 let encoded = common::to_string(&bytes);
25621 match serde_json::from_str(&encoded) {
25622 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25623 Err(error) => {
25624 dlg.response_json_decode_error(&encoded, &error);
25625 return Err(common::Error::JsonDecodeError(
25626 encoded.to_string(),
25627 error,
25628 ));
25629 }
25630 }
25631 };
25632
25633 dlg.finished(true);
25634 return Ok(response);
25635 }
25636 }
25637 }
25638 }
25639
25640 /// Required. The parent instance of the instance partition operations. Values are of the form `projects//instances/`.
25641 ///
25642 /// Sets the *parent* path property to the given value.
25643 ///
25644 /// Even though the property as already been set when instantiating this call,
25645 /// we provide this method for API completeness.
25646 pub fn parent(
25647 mut self,
25648 new_value: &str,
25649 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
25650 self._parent = new_value.to_string();
25651 self
25652 }
25653 /// 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`.
25654 ///
25655 /// Sets the *page token* query property to the given value.
25656 pub fn page_token(
25657 mut self,
25658 new_value: &str,
25659 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
25660 self._page_token = Some(new_value.to_string());
25661 self
25662 }
25663 /// Optional. Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
25664 ///
25665 /// Sets the *page size* query property to the given value.
25666 pub fn page_size(
25667 mut self,
25668 new_value: i32,
25669 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
25670 self._page_size = Some(new_value);
25671 self
25672 }
25673 /// 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 in ListInstancePartitionOperationsResponse.
25674 ///
25675 /// Sets the *instance partition deadline* query property to the given value.
25676 pub fn instance_partition_deadline(
25677 mut self,
25678 new_value: chrono::DateTime<chrono::offset::Utc>,
25679 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
25680 self._instance_partition_deadline = Some(new_value);
25681 self
25682 }
25683 /// 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.
25684 ///
25685 /// Sets the *filter* query property to the given value.
25686 pub fn filter(
25687 mut self,
25688 new_value: &str,
25689 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
25690 self._filter = Some(new_value.to_string());
25691 self
25692 }
25693 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25694 /// while executing the actual API request.
25695 ///
25696 /// ````text
25697 /// It should be used to handle progress information, and to implement a certain level of resilience.
25698 /// ````
25699 ///
25700 /// Sets the *delegate* property to the given value.
25701 pub fn delegate(
25702 mut self,
25703 new_value: &'a mut dyn common::Delegate,
25704 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
25705 self._delegate = Some(new_value);
25706 self
25707 }
25708
25709 /// Set any additional parameter of the query string used in the request.
25710 /// It should be used to set parameters which are not yet available through their own
25711 /// setters.
25712 ///
25713 /// Please note that this method must not be used to set any of the known parameters
25714 /// which have their own setter method. If done anyway, the request will fail.
25715 ///
25716 /// # Additional Parameters
25717 ///
25718 /// * *$.xgafv* (query-string) - V1 error format.
25719 /// * *access_token* (query-string) - OAuth access token.
25720 /// * *alt* (query-string) - Data format for response.
25721 /// * *callback* (query-string) - JSONP
25722 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25723 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
25724 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25725 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25726 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
25727 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25728 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25729 pub fn param<T>(
25730 mut self,
25731 name: T,
25732 value: T,
25733 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C>
25734 where
25735 T: AsRef<str>,
25736 {
25737 self._additional_params
25738 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25739 self
25740 }
25741
25742 /// Identifies the authorization scope for the method you are building.
25743 ///
25744 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25745 /// [`Scope::CloudPlatform`].
25746 ///
25747 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25748 /// tokens for more than one scope.
25749 ///
25750 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25751 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25752 /// sufficient, a read-write scope will do as well.
25753 pub fn add_scope<St>(
25754 mut self,
25755 scope: St,
25756 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C>
25757 where
25758 St: AsRef<str>,
25759 {
25760 self._scopes.insert(String::from(scope.as_ref()));
25761 self
25762 }
25763 /// Identifies the authorization scope(s) for the method you are building.
25764 ///
25765 /// See [`Self::add_scope()`] for details.
25766 pub fn add_scopes<I, St>(
25767 mut self,
25768 scopes: I,
25769 ) -> ProjectInstanceInstancePartitionOperationListCall<'a, C>
25770 where
25771 I: IntoIterator<Item = St>,
25772 St: AsRef<str>,
25773 {
25774 self._scopes
25775 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25776 self
25777 }
25778
25779 /// Removes all scopes, and no default scope will be used either.
25780 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25781 /// for details).
25782 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationListCall<'a, C> {
25783 self._scopes.clear();
25784 self
25785 }
25786}
25787
25788/// 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`.
25789///
25790/// A builder for the *instances.instancePartitions.operations.cancel* method supported by a *project* resource.
25791/// It is not used directly, but through a [`ProjectMethods`] instance.
25792///
25793/// # Example
25794///
25795/// Instantiate a resource method builder
25796///
25797/// ```test_harness,no_run
25798/// # extern crate hyper;
25799/// # extern crate hyper_rustls;
25800/// # extern crate google_spanner1 as spanner1;
25801/// # async fn dox() {
25802/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25803///
25804/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25805/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25806/// # secret,
25807/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25808/// # ).build().await.unwrap();
25809///
25810/// # let client = hyper_util::client::legacy::Client::builder(
25811/// # hyper_util::rt::TokioExecutor::new()
25812/// # )
25813/// # .build(
25814/// # hyper_rustls::HttpsConnectorBuilder::new()
25815/// # .with_native_roots()
25816/// # .unwrap()
25817/// # .https_or_http()
25818/// # .enable_http1()
25819/// # .build()
25820/// # );
25821/// # let mut hub = Spanner::new(client, auth);
25822/// // You can configure optional parameters by calling the respective setters at will, and
25823/// // execute the final call using `doit()`.
25824/// // Values shown here are possibly random and not representative !
25825/// let result = hub.projects().instances_instance_partitions_operations_cancel("name")
25826/// .doit().await;
25827/// # }
25828/// ```
25829pub struct ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
25830where
25831 C: 'a,
25832{
25833 hub: &'a Spanner<C>,
25834 _name: String,
25835 _delegate: Option<&'a mut dyn common::Delegate>,
25836 _additional_params: HashMap<String, String>,
25837 _scopes: BTreeSet<String>,
25838}
25839
25840impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {}
25841
25842impl<'a, C> ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
25843where
25844 C: common::Connector,
25845{
25846 /// Perform the operation you have build so far.
25847 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
25848 use std::borrow::Cow;
25849 use std::io::{Read, Seek};
25850
25851 use common::{url::Params, ToParts};
25852 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25853
25854 let mut dd = common::DefaultDelegate;
25855 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25856 dlg.begin(common::MethodInfo {
25857 id: "spanner.projects.instances.instancePartitions.operations.cancel",
25858 http_method: hyper::Method::POST,
25859 });
25860
25861 for &field in ["alt", "name"].iter() {
25862 if self._additional_params.contains_key(field) {
25863 dlg.finished(false);
25864 return Err(common::Error::FieldClash(field));
25865 }
25866 }
25867
25868 let mut params = Params::with_capacity(3 + self._additional_params.len());
25869 params.push("name", self._name);
25870
25871 params.extend(self._additional_params.iter());
25872
25873 params.push("alt", "json");
25874 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
25875 if self._scopes.is_empty() {
25876 self._scopes
25877 .insert(Scope::CloudPlatform.as_ref().to_string());
25878 }
25879
25880 #[allow(clippy::single_element_loop)]
25881 for &(find_this, param_name) in [("{+name}", "name")].iter() {
25882 url = params.uri_replacement(url, param_name, find_this, true);
25883 }
25884 {
25885 let to_remove = ["name"];
25886 params.remove_params(&to_remove);
25887 }
25888
25889 let url = params.parse_with_url(&url);
25890
25891 loop {
25892 let token = match self
25893 .hub
25894 .auth
25895 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25896 .await
25897 {
25898 Ok(token) => token,
25899 Err(e) => match dlg.token(e) {
25900 Ok(token) => token,
25901 Err(e) => {
25902 dlg.finished(false);
25903 return Err(common::Error::MissingToken(e));
25904 }
25905 },
25906 };
25907 let mut req_result = {
25908 let client = &self.hub.client;
25909 dlg.pre_request();
25910 let mut req_builder = hyper::Request::builder()
25911 .method(hyper::Method::POST)
25912 .uri(url.as_str())
25913 .header(USER_AGENT, self.hub._user_agent.clone());
25914
25915 if let Some(token) = token.as_ref() {
25916 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25917 }
25918
25919 let request = req_builder
25920 .header(CONTENT_LENGTH, 0_u64)
25921 .body(common::to_body::<String>(None));
25922
25923 client.request(request.unwrap()).await
25924 };
25925
25926 match req_result {
25927 Err(err) => {
25928 if let common::Retry::After(d) = dlg.http_error(&err) {
25929 sleep(d).await;
25930 continue;
25931 }
25932 dlg.finished(false);
25933 return Err(common::Error::HttpError(err));
25934 }
25935 Ok(res) => {
25936 let (mut parts, body) = res.into_parts();
25937 let mut body = common::Body::new(body);
25938 if !parts.status.is_success() {
25939 let bytes = common::to_bytes(body).await.unwrap_or_default();
25940 let error = serde_json::from_str(&common::to_string(&bytes));
25941 let response = common::to_response(parts, bytes.into());
25942
25943 if let common::Retry::After(d) =
25944 dlg.http_failure(&response, error.as_ref().ok())
25945 {
25946 sleep(d).await;
25947 continue;
25948 }
25949
25950 dlg.finished(false);
25951
25952 return Err(match error {
25953 Ok(value) => common::Error::BadRequest(value),
25954 _ => common::Error::Failure(response),
25955 });
25956 }
25957 let response = {
25958 let bytes = common::to_bytes(body).await.unwrap_or_default();
25959 let encoded = common::to_string(&bytes);
25960 match serde_json::from_str(&encoded) {
25961 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25962 Err(error) => {
25963 dlg.response_json_decode_error(&encoded, &error);
25964 return Err(common::Error::JsonDecodeError(
25965 encoded.to_string(),
25966 error,
25967 ));
25968 }
25969 }
25970 };
25971
25972 dlg.finished(true);
25973 return Ok(response);
25974 }
25975 }
25976 }
25977 }
25978
25979 /// The name of the operation resource to be cancelled.
25980 ///
25981 /// Sets the *name* path property to the given value.
25982 ///
25983 /// Even though the property as already been set when instantiating this call,
25984 /// we provide this method for API completeness.
25985 pub fn name(
25986 mut self,
25987 new_value: &str,
25988 ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {
25989 self._name = new_value.to_string();
25990 self
25991 }
25992 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25993 /// while executing the actual API request.
25994 ///
25995 /// ````text
25996 /// It should be used to handle progress information, and to implement a certain level of resilience.
25997 /// ````
25998 ///
25999 /// Sets the *delegate* property to the given value.
26000 pub fn delegate(
26001 mut self,
26002 new_value: &'a mut dyn common::Delegate,
26003 ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {
26004 self._delegate = Some(new_value);
26005 self
26006 }
26007
26008 /// Set any additional parameter of the query string used in the request.
26009 /// It should be used to set parameters which are not yet available through their own
26010 /// setters.
26011 ///
26012 /// Please note that this method must not be used to set any of the known parameters
26013 /// which have their own setter method. If done anyway, the request will fail.
26014 ///
26015 /// # Additional Parameters
26016 ///
26017 /// * *$.xgafv* (query-string) - V1 error format.
26018 /// * *access_token* (query-string) - OAuth access token.
26019 /// * *alt* (query-string) - Data format for response.
26020 /// * *callback* (query-string) - JSONP
26021 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26022 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26023 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26024 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26025 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
26026 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26027 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26028 pub fn param<T>(
26029 mut self,
26030 name: T,
26031 value: T,
26032 ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
26033 where
26034 T: AsRef<str>,
26035 {
26036 self._additional_params
26037 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26038 self
26039 }
26040
26041 /// Identifies the authorization scope for the method you are building.
26042 ///
26043 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26044 /// [`Scope::CloudPlatform`].
26045 ///
26046 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26047 /// tokens for more than one scope.
26048 ///
26049 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26050 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26051 /// sufficient, a read-write scope will do as well.
26052 pub fn add_scope<St>(
26053 mut self,
26054 scope: St,
26055 ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
26056 where
26057 St: AsRef<str>,
26058 {
26059 self._scopes.insert(String::from(scope.as_ref()));
26060 self
26061 }
26062 /// Identifies the authorization scope(s) for the method you are building.
26063 ///
26064 /// See [`Self::add_scope()`] for details.
26065 pub fn add_scopes<I, St>(
26066 mut self,
26067 scopes: I,
26068 ) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C>
26069 where
26070 I: IntoIterator<Item = St>,
26071 St: AsRef<str>,
26072 {
26073 self._scopes
26074 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26075 self
26076 }
26077
26078 /// Removes all scopes, and no default scope will be used either.
26079 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26080 /// for details).
26081 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationCancelCall<'a, C> {
26082 self._scopes.clear();
26083 self
26084 }
26085}
26086
26087/// 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`.
26088///
26089/// A builder for the *instances.instancePartitions.operations.delete* method supported by a *project* resource.
26090/// It is not used directly, but through a [`ProjectMethods`] instance.
26091///
26092/// # Example
26093///
26094/// Instantiate a resource method builder
26095///
26096/// ```test_harness,no_run
26097/// # extern crate hyper;
26098/// # extern crate hyper_rustls;
26099/// # extern crate google_spanner1 as spanner1;
26100/// # async fn dox() {
26101/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26102///
26103/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26104/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26105/// # secret,
26106/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26107/// # ).build().await.unwrap();
26108///
26109/// # let client = hyper_util::client::legacy::Client::builder(
26110/// # hyper_util::rt::TokioExecutor::new()
26111/// # )
26112/// # .build(
26113/// # hyper_rustls::HttpsConnectorBuilder::new()
26114/// # .with_native_roots()
26115/// # .unwrap()
26116/// # .https_or_http()
26117/// # .enable_http1()
26118/// # .build()
26119/// # );
26120/// # let mut hub = Spanner::new(client, auth);
26121/// // You can configure optional parameters by calling the respective setters at will, and
26122/// // execute the final call using `doit()`.
26123/// // Values shown here are possibly random and not representative !
26124/// let result = hub.projects().instances_instance_partitions_operations_delete("name")
26125/// .doit().await;
26126/// # }
26127/// ```
26128pub struct ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
26129where
26130 C: 'a,
26131{
26132 hub: &'a Spanner<C>,
26133 _name: String,
26134 _delegate: Option<&'a mut dyn common::Delegate>,
26135 _additional_params: HashMap<String, String>,
26136 _scopes: BTreeSet<String>,
26137}
26138
26139impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {}
26140
26141impl<'a, C> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
26142where
26143 C: common::Connector,
26144{
26145 /// Perform the operation you have build so far.
26146 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
26147 use std::borrow::Cow;
26148 use std::io::{Read, Seek};
26149
26150 use common::{url::Params, ToParts};
26151 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26152
26153 let mut dd = common::DefaultDelegate;
26154 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26155 dlg.begin(common::MethodInfo {
26156 id: "spanner.projects.instances.instancePartitions.operations.delete",
26157 http_method: hyper::Method::DELETE,
26158 });
26159
26160 for &field in ["alt", "name"].iter() {
26161 if self._additional_params.contains_key(field) {
26162 dlg.finished(false);
26163 return Err(common::Error::FieldClash(field));
26164 }
26165 }
26166
26167 let mut params = Params::with_capacity(3 + self._additional_params.len());
26168 params.push("name", self._name);
26169
26170 params.extend(self._additional_params.iter());
26171
26172 params.push("alt", "json");
26173 let mut url = self.hub._base_url.clone() + "v1/{+name}";
26174 if self._scopes.is_empty() {
26175 self._scopes
26176 .insert(Scope::CloudPlatform.as_ref().to_string());
26177 }
26178
26179 #[allow(clippy::single_element_loop)]
26180 for &(find_this, param_name) in [("{+name}", "name")].iter() {
26181 url = params.uri_replacement(url, param_name, find_this, true);
26182 }
26183 {
26184 let to_remove = ["name"];
26185 params.remove_params(&to_remove);
26186 }
26187
26188 let url = params.parse_with_url(&url);
26189
26190 loop {
26191 let token = match self
26192 .hub
26193 .auth
26194 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26195 .await
26196 {
26197 Ok(token) => token,
26198 Err(e) => match dlg.token(e) {
26199 Ok(token) => token,
26200 Err(e) => {
26201 dlg.finished(false);
26202 return Err(common::Error::MissingToken(e));
26203 }
26204 },
26205 };
26206 let mut req_result = {
26207 let client = &self.hub.client;
26208 dlg.pre_request();
26209 let mut req_builder = hyper::Request::builder()
26210 .method(hyper::Method::DELETE)
26211 .uri(url.as_str())
26212 .header(USER_AGENT, self.hub._user_agent.clone());
26213
26214 if let Some(token) = token.as_ref() {
26215 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26216 }
26217
26218 let request = req_builder
26219 .header(CONTENT_LENGTH, 0_u64)
26220 .body(common::to_body::<String>(None));
26221
26222 client.request(request.unwrap()).await
26223 };
26224
26225 match req_result {
26226 Err(err) => {
26227 if let common::Retry::After(d) = dlg.http_error(&err) {
26228 sleep(d).await;
26229 continue;
26230 }
26231 dlg.finished(false);
26232 return Err(common::Error::HttpError(err));
26233 }
26234 Ok(res) => {
26235 let (mut parts, body) = res.into_parts();
26236 let mut body = common::Body::new(body);
26237 if !parts.status.is_success() {
26238 let bytes = common::to_bytes(body).await.unwrap_or_default();
26239 let error = serde_json::from_str(&common::to_string(&bytes));
26240 let response = common::to_response(parts, bytes.into());
26241
26242 if let common::Retry::After(d) =
26243 dlg.http_failure(&response, error.as_ref().ok())
26244 {
26245 sleep(d).await;
26246 continue;
26247 }
26248
26249 dlg.finished(false);
26250
26251 return Err(match error {
26252 Ok(value) => common::Error::BadRequest(value),
26253 _ => common::Error::Failure(response),
26254 });
26255 }
26256 let response = {
26257 let bytes = common::to_bytes(body).await.unwrap_or_default();
26258 let encoded = common::to_string(&bytes);
26259 match serde_json::from_str(&encoded) {
26260 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26261 Err(error) => {
26262 dlg.response_json_decode_error(&encoded, &error);
26263 return Err(common::Error::JsonDecodeError(
26264 encoded.to_string(),
26265 error,
26266 ));
26267 }
26268 }
26269 };
26270
26271 dlg.finished(true);
26272 return Ok(response);
26273 }
26274 }
26275 }
26276 }
26277
26278 /// The name of the operation resource to be deleted.
26279 ///
26280 /// Sets the *name* path property to the given value.
26281 ///
26282 /// Even though the property as already been set when instantiating this call,
26283 /// we provide this method for API completeness.
26284 pub fn name(
26285 mut self,
26286 new_value: &str,
26287 ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {
26288 self._name = new_value.to_string();
26289 self
26290 }
26291 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26292 /// while executing the actual API request.
26293 ///
26294 /// ````text
26295 /// It should be used to handle progress information, and to implement a certain level of resilience.
26296 /// ````
26297 ///
26298 /// Sets the *delegate* property to the given value.
26299 pub fn delegate(
26300 mut self,
26301 new_value: &'a mut dyn common::Delegate,
26302 ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {
26303 self._delegate = Some(new_value);
26304 self
26305 }
26306
26307 /// Set any additional parameter of the query string used in the request.
26308 /// It should be used to set parameters which are not yet available through their own
26309 /// setters.
26310 ///
26311 /// Please note that this method must not be used to set any of the known parameters
26312 /// which have their own setter method. If done anyway, the request will fail.
26313 ///
26314 /// # Additional Parameters
26315 ///
26316 /// * *$.xgafv* (query-string) - V1 error format.
26317 /// * *access_token* (query-string) - OAuth access token.
26318 /// * *alt* (query-string) - Data format for response.
26319 /// * *callback* (query-string) - JSONP
26320 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26321 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26322 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26323 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26324 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
26325 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26326 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26327 pub fn param<T>(
26328 mut self,
26329 name: T,
26330 value: T,
26331 ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
26332 where
26333 T: AsRef<str>,
26334 {
26335 self._additional_params
26336 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26337 self
26338 }
26339
26340 /// Identifies the authorization scope for the method you are building.
26341 ///
26342 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26343 /// [`Scope::CloudPlatform`].
26344 ///
26345 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26346 /// tokens for more than one scope.
26347 ///
26348 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26349 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26350 /// sufficient, a read-write scope will do as well.
26351 pub fn add_scope<St>(
26352 mut self,
26353 scope: St,
26354 ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
26355 where
26356 St: AsRef<str>,
26357 {
26358 self._scopes.insert(String::from(scope.as_ref()));
26359 self
26360 }
26361 /// Identifies the authorization scope(s) for the method you are building.
26362 ///
26363 /// See [`Self::add_scope()`] for details.
26364 pub fn add_scopes<I, St>(
26365 mut self,
26366 scopes: I,
26367 ) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C>
26368 where
26369 I: IntoIterator<Item = St>,
26370 St: AsRef<str>,
26371 {
26372 self._scopes
26373 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26374 self
26375 }
26376
26377 /// Removes all scopes, and no default scope will be used either.
26378 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26379 /// for details).
26380 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationDeleteCall<'a, C> {
26381 self._scopes.clear();
26382 self
26383 }
26384}
26385
26386/// 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.
26387///
26388/// A builder for the *instances.instancePartitions.operations.get* method supported by a *project* resource.
26389/// It is not used directly, but through a [`ProjectMethods`] instance.
26390///
26391/// # Example
26392///
26393/// Instantiate a resource method builder
26394///
26395/// ```test_harness,no_run
26396/// # extern crate hyper;
26397/// # extern crate hyper_rustls;
26398/// # extern crate google_spanner1 as spanner1;
26399/// # async fn dox() {
26400/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26401///
26402/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26403/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26404/// # secret,
26405/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26406/// # ).build().await.unwrap();
26407///
26408/// # let client = hyper_util::client::legacy::Client::builder(
26409/// # hyper_util::rt::TokioExecutor::new()
26410/// # )
26411/// # .build(
26412/// # hyper_rustls::HttpsConnectorBuilder::new()
26413/// # .with_native_roots()
26414/// # .unwrap()
26415/// # .https_or_http()
26416/// # .enable_http1()
26417/// # .build()
26418/// # );
26419/// # let mut hub = Spanner::new(client, auth);
26420/// // You can configure optional parameters by calling the respective setters at will, and
26421/// // execute the final call using `doit()`.
26422/// // Values shown here are possibly random and not representative !
26423/// let result = hub.projects().instances_instance_partitions_operations_get("name")
26424/// .doit().await;
26425/// # }
26426/// ```
26427pub struct ProjectInstanceInstancePartitionOperationGetCall<'a, C>
26428where
26429 C: 'a,
26430{
26431 hub: &'a Spanner<C>,
26432 _name: String,
26433 _delegate: Option<&'a mut dyn common::Delegate>,
26434 _additional_params: HashMap<String, String>,
26435 _scopes: BTreeSet<String>,
26436}
26437
26438impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationGetCall<'a, C> {}
26439
26440impl<'a, C> ProjectInstanceInstancePartitionOperationGetCall<'a, C>
26441where
26442 C: common::Connector,
26443{
26444 /// Perform the operation you have build so far.
26445 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
26446 use std::borrow::Cow;
26447 use std::io::{Read, Seek};
26448
26449 use common::{url::Params, ToParts};
26450 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26451
26452 let mut dd = common::DefaultDelegate;
26453 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26454 dlg.begin(common::MethodInfo {
26455 id: "spanner.projects.instances.instancePartitions.operations.get",
26456 http_method: hyper::Method::GET,
26457 });
26458
26459 for &field in ["alt", "name"].iter() {
26460 if self._additional_params.contains_key(field) {
26461 dlg.finished(false);
26462 return Err(common::Error::FieldClash(field));
26463 }
26464 }
26465
26466 let mut params = Params::with_capacity(3 + self._additional_params.len());
26467 params.push("name", self._name);
26468
26469 params.extend(self._additional_params.iter());
26470
26471 params.push("alt", "json");
26472 let mut url = self.hub._base_url.clone() + "v1/{+name}";
26473 if self._scopes.is_empty() {
26474 self._scopes
26475 .insert(Scope::CloudPlatform.as_ref().to_string());
26476 }
26477
26478 #[allow(clippy::single_element_loop)]
26479 for &(find_this, param_name) in [("{+name}", "name")].iter() {
26480 url = params.uri_replacement(url, param_name, find_this, true);
26481 }
26482 {
26483 let to_remove = ["name"];
26484 params.remove_params(&to_remove);
26485 }
26486
26487 let url = params.parse_with_url(&url);
26488
26489 loop {
26490 let token = match self
26491 .hub
26492 .auth
26493 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26494 .await
26495 {
26496 Ok(token) => token,
26497 Err(e) => match dlg.token(e) {
26498 Ok(token) => token,
26499 Err(e) => {
26500 dlg.finished(false);
26501 return Err(common::Error::MissingToken(e));
26502 }
26503 },
26504 };
26505 let mut req_result = {
26506 let client = &self.hub.client;
26507 dlg.pre_request();
26508 let mut req_builder = hyper::Request::builder()
26509 .method(hyper::Method::GET)
26510 .uri(url.as_str())
26511 .header(USER_AGENT, self.hub._user_agent.clone());
26512
26513 if let Some(token) = token.as_ref() {
26514 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26515 }
26516
26517 let request = req_builder
26518 .header(CONTENT_LENGTH, 0_u64)
26519 .body(common::to_body::<String>(None));
26520
26521 client.request(request.unwrap()).await
26522 };
26523
26524 match req_result {
26525 Err(err) => {
26526 if let common::Retry::After(d) = dlg.http_error(&err) {
26527 sleep(d).await;
26528 continue;
26529 }
26530 dlg.finished(false);
26531 return Err(common::Error::HttpError(err));
26532 }
26533 Ok(res) => {
26534 let (mut parts, body) = res.into_parts();
26535 let mut body = common::Body::new(body);
26536 if !parts.status.is_success() {
26537 let bytes = common::to_bytes(body).await.unwrap_or_default();
26538 let error = serde_json::from_str(&common::to_string(&bytes));
26539 let response = common::to_response(parts, bytes.into());
26540
26541 if let common::Retry::After(d) =
26542 dlg.http_failure(&response, error.as_ref().ok())
26543 {
26544 sleep(d).await;
26545 continue;
26546 }
26547
26548 dlg.finished(false);
26549
26550 return Err(match error {
26551 Ok(value) => common::Error::BadRequest(value),
26552 _ => common::Error::Failure(response),
26553 });
26554 }
26555 let response = {
26556 let bytes = common::to_bytes(body).await.unwrap_or_default();
26557 let encoded = common::to_string(&bytes);
26558 match serde_json::from_str(&encoded) {
26559 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26560 Err(error) => {
26561 dlg.response_json_decode_error(&encoded, &error);
26562 return Err(common::Error::JsonDecodeError(
26563 encoded.to_string(),
26564 error,
26565 ));
26566 }
26567 }
26568 };
26569
26570 dlg.finished(true);
26571 return Ok(response);
26572 }
26573 }
26574 }
26575 }
26576
26577 /// The name of the operation resource.
26578 ///
26579 /// Sets the *name* path property to the given value.
26580 ///
26581 /// Even though the property as already been set when instantiating this call,
26582 /// we provide this method for API completeness.
26583 pub fn name(
26584 mut self,
26585 new_value: &str,
26586 ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C> {
26587 self._name = new_value.to_string();
26588 self
26589 }
26590 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26591 /// while executing the actual API request.
26592 ///
26593 /// ````text
26594 /// It should be used to handle progress information, and to implement a certain level of resilience.
26595 /// ````
26596 ///
26597 /// Sets the *delegate* property to the given value.
26598 pub fn delegate(
26599 mut self,
26600 new_value: &'a mut dyn common::Delegate,
26601 ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C> {
26602 self._delegate = Some(new_value);
26603 self
26604 }
26605
26606 /// Set any additional parameter of the query string used in the request.
26607 /// It should be used to set parameters which are not yet available through their own
26608 /// setters.
26609 ///
26610 /// Please note that this method must not be used to set any of the known parameters
26611 /// which have their own setter method. If done anyway, the request will fail.
26612 ///
26613 /// # Additional Parameters
26614 ///
26615 /// * *$.xgafv* (query-string) - V1 error format.
26616 /// * *access_token* (query-string) - OAuth access token.
26617 /// * *alt* (query-string) - Data format for response.
26618 /// * *callback* (query-string) - JSONP
26619 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26620 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26621 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26622 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26623 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
26624 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26625 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26626 pub fn param<T>(
26627 mut self,
26628 name: T,
26629 value: T,
26630 ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C>
26631 where
26632 T: AsRef<str>,
26633 {
26634 self._additional_params
26635 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26636 self
26637 }
26638
26639 /// Identifies the authorization scope for the method you are building.
26640 ///
26641 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26642 /// [`Scope::CloudPlatform`].
26643 ///
26644 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26645 /// tokens for more than one scope.
26646 ///
26647 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26648 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26649 /// sufficient, a read-write scope will do as well.
26650 pub fn add_scope<St>(
26651 mut self,
26652 scope: St,
26653 ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C>
26654 where
26655 St: AsRef<str>,
26656 {
26657 self._scopes.insert(String::from(scope.as_ref()));
26658 self
26659 }
26660 /// Identifies the authorization scope(s) for the method you are building.
26661 ///
26662 /// See [`Self::add_scope()`] for details.
26663 pub fn add_scopes<I, St>(
26664 mut self,
26665 scopes: I,
26666 ) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C>
26667 where
26668 I: IntoIterator<Item = St>,
26669 St: AsRef<str>,
26670 {
26671 self._scopes
26672 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26673 self
26674 }
26675
26676 /// Removes all scopes, and no default scope will be used either.
26677 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26678 /// for details).
26679 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationGetCall<'a, C> {
26680 self._scopes.clear();
26681 self
26682 }
26683}
26684
26685/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
26686///
26687/// A builder for the *instances.instancePartitions.operations.list* method supported by a *project* resource.
26688/// It is not used directly, but through a [`ProjectMethods`] instance.
26689///
26690/// # Example
26691///
26692/// Instantiate a resource method builder
26693///
26694/// ```test_harness,no_run
26695/// # extern crate hyper;
26696/// # extern crate hyper_rustls;
26697/// # extern crate google_spanner1 as spanner1;
26698/// # async fn dox() {
26699/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26700///
26701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26702/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26703/// # secret,
26704/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26705/// # ).build().await.unwrap();
26706///
26707/// # let client = hyper_util::client::legacy::Client::builder(
26708/// # hyper_util::rt::TokioExecutor::new()
26709/// # )
26710/// # .build(
26711/// # hyper_rustls::HttpsConnectorBuilder::new()
26712/// # .with_native_roots()
26713/// # .unwrap()
26714/// # .https_or_http()
26715/// # .enable_http1()
26716/// # .build()
26717/// # );
26718/// # let mut hub = Spanner::new(client, auth);
26719/// // You can configure optional parameters by calling the respective setters at will, and
26720/// // execute the final call using `doit()`.
26721/// // Values shown here are possibly random and not representative !
26722/// let result = hub.projects().instances_instance_partitions_operations_list("name")
26723/// .page_token("dolores")
26724/// .page_size(-95)
26725/// .filter("erat")
26726/// .doit().await;
26727/// # }
26728/// ```
26729pub struct ProjectInstanceInstancePartitionOperationListCall1<'a, C>
26730where
26731 C: 'a,
26732{
26733 hub: &'a Spanner<C>,
26734 _name: String,
26735 _page_token: Option<String>,
26736 _page_size: Option<i32>,
26737 _filter: Option<String>,
26738 _delegate: Option<&'a mut dyn common::Delegate>,
26739 _additional_params: HashMap<String, String>,
26740 _scopes: BTreeSet<String>,
26741}
26742
26743impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionOperationListCall1<'a, C> {}
26744
26745impl<'a, C> ProjectInstanceInstancePartitionOperationListCall1<'a, C>
26746where
26747 C: common::Connector,
26748{
26749 /// Perform the operation you have build so far.
26750 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
26751 use std::borrow::Cow;
26752 use std::io::{Read, Seek};
26753
26754 use common::{url::Params, ToParts};
26755 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26756
26757 let mut dd = common::DefaultDelegate;
26758 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26759 dlg.begin(common::MethodInfo {
26760 id: "spanner.projects.instances.instancePartitions.operations.list",
26761 http_method: hyper::Method::GET,
26762 });
26763
26764 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
26765 if self._additional_params.contains_key(field) {
26766 dlg.finished(false);
26767 return Err(common::Error::FieldClash(field));
26768 }
26769 }
26770
26771 let mut params = Params::with_capacity(6 + self._additional_params.len());
26772 params.push("name", self._name);
26773 if let Some(value) = self._page_token.as_ref() {
26774 params.push("pageToken", value);
26775 }
26776 if let Some(value) = self._page_size.as_ref() {
26777 params.push("pageSize", value.to_string());
26778 }
26779 if let Some(value) = self._filter.as_ref() {
26780 params.push("filter", value);
26781 }
26782
26783 params.extend(self._additional_params.iter());
26784
26785 params.push("alt", "json");
26786 let mut url = self.hub._base_url.clone() + "v1/{+name}";
26787 if self._scopes.is_empty() {
26788 self._scopes
26789 .insert(Scope::CloudPlatform.as_ref().to_string());
26790 }
26791
26792 #[allow(clippy::single_element_loop)]
26793 for &(find_this, param_name) in [("{+name}", "name")].iter() {
26794 url = params.uri_replacement(url, param_name, find_this, true);
26795 }
26796 {
26797 let to_remove = ["name"];
26798 params.remove_params(&to_remove);
26799 }
26800
26801 let url = params.parse_with_url(&url);
26802
26803 loop {
26804 let token = match self
26805 .hub
26806 .auth
26807 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26808 .await
26809 {
26810 Ok(token) => token,
26811 Err(e) => match dlg.token(e) {
26812 Ok(token) => token,
26813 Err(e) => {
26814 dlg.finished(false);
26815 return Err(common::Error::MissingToken(e));
26816 }
26817 },
26818 };
26819 let mut req_result = {
26820 let client = &self.hub.client;
26821 dlg.pre_request();
26822 let mut req_builder = hyper::Request::builder()
26823 .method(hyper::Method::GET)
26824 .uri(url.as_str())
26825 .header(USER_AGENT, self.hub._user_agent.clone());
26826
26827 if let Some(token) = token.as_ref() {
26828 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26829 }
26830
26831 let request = req_builder
26832 .header(CONTENT_LENGTH, 0_u64)
26833 .body(common::to_body::<String>(None));
26834
26835 client.request(request.unwrap()).await
26836 };
26837
26838 match req_result {
26839 Err(err) => {
26840 if let common::Retry::After(d) = dlg.http_error(&err) {
26841 sleep(d).await;
26842 continue;
26843 }
26844 dlg.finished(false);
26845 return Err(common::Error::HttpError(err));
26846 }
26847 Ok(res) => {
26848 let (mut parts, body) = res.into_parts();
26849 let mut body = common::Body::new(body);
26850 if !parts.status.is_success() {
26851 let bytes = common::to_bytes(body).await.unwrap_or_default();
26852 let error = serde_json::from_str(&common::to_string(&bytes));
26853 let response = common::to_response(parts, bytes.into());
26854
26855 if let common::Retry::After(d) =
26856 dlg.http_failure(&response, error.as_ref().ok())
26857 {
26858 sleep(d).await;
26859 continue;
26860 }
26861
26862 dlg.finished(false);
26863
26864 return Err(match error {
26865 Ok(value) => common::Error::BadRequest(value),
26866 _ => common::Error::Failure(response),
26867 });
26868 }
26869 let response = {
26870 let bytes = common::to_bytes(body).await.unwrap_or_default();
26871 let encoded = common::to_string(&bytes);
26872 match serde_json::from_str(&encoded) {
26873 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26874 Err(error) => {
26875 dlg.response_json_decode_error(&encoded, &error);
26876 return Err(common::Error::JsonDecodeError(
26877 encoded.to_string(),
26878 error,
26879 ));
26880 }
26881 }
26882 };
26883
26884 dlg.finished(true);
26885 return Ok(response);
26886 }
26887 }
26888 }
26889 }
26890
26891 /// The name of the operation's parent resource.
26892 ///
26893 /// Sets the *name* path property to the given value.
26894 ///
26895 /// Even though the property as already been set when instantiating this call,
26896 /// we provide this method for API completeness.
26897 pub fn name(
26898 mut self,
26899 new_value: &str,
26900 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
26901 self._name = new_value.to_string();
26902 self
26903 }
26904 /// The standard list page token.
26905 ///
26906 /// Sets the *page token* query property to the given value.
26907 pub fn page_token(
26908 mut self,
26909 new_value: &str,
26910 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
26911 self._page_token = Some(new_value.to_string());
26912 self
26913 }
26914 /// The standard list page size.
26915 ///
26916 /// Sets the *page size* query property to the given value.
26917 pub fn page_size(
26918 mut self,
26919 new_value: i32,
26920 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
26921 self._page_size = Some(new_value);
26922 self
26923 }
26924 /// The standard list filter.
26925 ///
26926 /// Sets the *filter* query property to the given value.
26927 pub fn filter(
26928 mut self,
26929 new_value: &str,
26930 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
26931 self._filter = Some(new_value.to_string());
26932 self
26933 }
26934 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26935 /// while executing the actual API request.
26936 ///
26937 /// ````text
26938 /// It should be used to handle progress information, and to implement a certain level of resilience.
26939 /// ````
26940 ///
26941 /// Sets the *delegate* property to the given value.
26942 pub fn delegate(
26943 mut self,
26944 new_value: &'a mut dyn common::Delegate,
26945 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
26946 self._delegate = Some(new_value);
26947 self
26948 }
26949
26950 /// Set any additional parameter of the query string used in the request.
26951 /// It should be used to set parameters which are not yet available through their own
26952 /// setters.
26953 ///
26954 /// Please note that this method must not be used to set any of the known parameters
26955 /// which have their own setter method. If done anyway, the request will fail.
26956 ///
26957 /// # Additional Parameters
26958 ///
26959 /// * *$.xgafv* (query-string) - V1 error format.
26960 /// * *access_token* (query-string) - OAuth access token.
26961 /// * *alt* (query-string) - Data format for response.
26962 /// * *callback* (query-string) - JSONP
26963 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26964 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26965 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26966 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26967 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
26968 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26969 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26970 pub fn param<T>(
26971 mut self,
26972 name: T,
26973 value: T,
26974 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C>
26975 where
26976 T: AsRef<str>,
26977 {
26978 self._additional_params
26979 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26980 self
26981 }
26982
26983 /// Identifies the authorization scope for the method you are building.
26984 ///
26985 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26986 /// [`Scope::CloudPlatform`].
26987 ///
26988 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26989 /// tokens for more than one scope.
26990 ///
26991 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26992 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26993 /// sufficient, a read-write scope will do as well.
26994 pub fn add_scope<St>(
26995 mut self,
26996 scope: St,
26997 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C>
26998 where
26999 St: AsRef<str>,
27000 {
27001 self._scopes.insert(String::from(scope.as_ref()));
27002 self
27003 }
27004 /// Identifies the authorization scope(s) for the method you are building.
27005 ///
27006 /// See [`Self::add_scope()`] for details.
27007 pub fn add_scopes<I, St>(
27008 mut self,
27009 scopes: I,
27010 ) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C>
27011 where
27012 I: IntoIterator<Item = St>,
27013 St: AsRef<str>,
27014 {
27015 self._scopes
27016 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27017 self
27018 }
27019
27020 /// Removes all scopes, and no default scope will be used either.
27021 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27022 /// for details).
27023 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionOperationListCall1<'a, C> {
27024 self._scopes.clear();
27025 self
27026 }
27027}
27028
27029/// 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.
27030///
27031/// A builder for the *instances.instancePartitions.create* method supported by a *project* resource.
27032/// It is not used directly, but through a [`ProjectMethods`] instance.
27033///
27034/// # Example
27035///
27036/// Instantiate a resource method builder
27037///
27038/// ```test_harness,no_run
27039/// # extern crate hyper;
27040/// # extern crate hyper_rustls;
27041/// # extern crate google_spanner1 as spanner1;
27042/// use spanner1::api::CreateInstancePartitionRequest;
27043/// # async fn dox() {
27044/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27045///
27046/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27047/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27048/// # secret,
27049/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27050/// # ).build().await.unwrap();
27051///
27052/// # let client = hyper_util::client::legacy::Client::builder(
27053/// # hyper_util::rt::TokioExecutor::new()
27054/// # )
27055/// # .build(
27056/// # hyper_rustls::HttpsConnectorBuilder::new()
27057/// # .with_native_roots()
27058/// # .unwrap()
27059/// # .https_or_http()
27060/// # .enable_http1()
27061/// # .build()
27062/// # );
27063/// # let mut hub = Spanner::new(client, auth);
27064/// // As the method needs a request, you would usually fill it with the desired information
27065/// // into the respective structure. Some of the parts shown here might not be applicable !
27066/// // Values shown here are possibly random and not representative !
27067/// let mut req = CreateInstancePartitionRequest::default();
27068///
27069/// // You can configure optional parameters by calling the respective setters at will, and
27070/// // execute the final call using `doit()`.
27071/// // Values shown here are possibly random and not representative !
27072/// let result = hub.projects().instances_instance_partitions_create(req, "parent")
27073/// .doit().await;
27074/// # }
27075/// ```
27076pub struct ProjectInstanceInstancePartitionCreateCall<'a, C>
27077where
27078 C: 'a,
27079{
27080 hub: &'a Spanner<C>,
27081 _request: CreateInstancePartitionRequest,
27082 _parent: String,
27083 _delegate: Option<&'a mut dyn common::Delegate>,
27084 _additional_params: HashMap<String, String>,
27085 _scopes: BTreeSet<String>,
27086}
27087
27088impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionCreateCall<'a, C> {}
27089
27090impl<'a, C> ProjectInstanceInstancePartitionCreateCall<'a, C>
27091where
27092 C: common::Connector,
27093{
27094 /// Perform the operation you have build so far.
27095 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
27096 use std::borrow::Cow;
27097 use std::io::{Read, Seek};
27098
27099 use common::{url::Params, ToParts};
27100 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27101
27102 let mut dd = common::DefaultDelegate;
27103 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27104 dlg.begin(common::MethodInfo {
27105 id: "spanner.projects.instances.instancePartitions.create",
27106 http_method: hyper::Method::POST,
27107 });
27108
27109 for &field in ["alt", "parent"].iter() {
27110 if self._additional_params.contains_key(field) {
27111 dlg.finished(false);
27112 return Err(common::Error::FieldClash(field));
27113 }
27114 }
27115
27116 let mut params = Params::with_capacity(4 + self._additional_params.len());
27117 params.push("parent", self._parent);
27118
27119 params.extend(self._additional_params.iter());
27120
27121 params.push("alt", "json");
27122 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instancePartitions";
27123 if self._scopes.is_empty() {
27124 self._scopes
27125 .insert(Scope::CloudPlatform.as_ref().to_string());
27126 }
27127
27128 #[allow(clippy::single_element_loop)]
27129 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
27130 url = params.uri_replacement(url, param_name, find_this, true);
27131 }
27132 {
27133 let to_remove = ["parent"];
27134 params.remove_params(&to_remove);
27135 }
27136
27137 let url = params.parse_with_url(&url);
27138
27139 let mut json_mime_type = mime::APPLICATION_JSON;
27140 let mut request_value_reader = {
27141 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27142 common::remove_json_null_values(&mut value);
27143 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27144 serde_json::to_writer(&mut dst, &value).unwrap();
27145 dst
27146 };
27147 let request_size = request_value_reader
27148 .seek(std::io::SeekFrom::End(0))
27149 .unwrap();
27150 request_value_reader
27151 .seek(std::io::SeekFrom::Start(0))
27152 .unwrap();
27153
27154 loop {
27155 let token = match self
27156 .hub
27157 .auth
27158 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27159 .await
27160 {
27161 Ok(token) => token,
27162 Err(e) => match dlg.token(e) {
27163 Ok(token) => token,
27164 Err(e) => {
27165 dlg.finished(false);
27166 return Err(common::Error::MissingToken(e));
27167 }
27168 },
27169 };
27170 request_value_reader
27171 .seek(std::io::SeekFrom::Start(0))
27172 .unwrap();
27173 let mut req_result = {
27174 let client = &self.hub.client;
27175 dlg.pre_request();
27176 let mut req_builder = hyper::Request::builder()
27177 .method(hyper::Method::POST)
27178 .uri(url.as_str())
27179 .header(USER_AGENT, self.hub._user_agent.clone());
27180
27181 if let Some(token) = token.as_ref() {
27182 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27183 }
27184
27185 let request = req_builder
27186 .header(CONTENT_TYPE, json_mime_type.to_string())
27187 .header(CONTENT_LENGTH, request_size as u64)
27188 .body(common::to_body(
27189 request_value_reader.get_ref().clone().into(),
27190 ));
27191
27192 client.request(request.unwrap()).await
27193 };
27194
27195 match req_result {
27196 Err(err) => {
27197 if let common::Retry::After(d) = dlg.http_error(&err) {
27198 sleep(d).await;
27199 continue;
27200 }
27201 dlg.finished(false);
27202 return Err(common::Error::HttpError(err));
27203 }
27204 Ok(res) => {
27205 let (mut parts, body) = res.into_parts();
27206 let mut body = common::Body::new(body);
27207 if !parts.status.is_success() {
27208 let bytes = common::to_bytes(body).await.unwrap_or_default();
27209 let error = serde_json::from_str(&common::to_string(&bytes));
27210 let response = common::to_response(parts, bytes.into());
27211
27212 if let common::Retry::After(d) =
27213 dlg.http_failure(&response, error.as_ref().ok())
27214 {
27215 sleep(d).await;
27216 continue;
27217 }
27218
27219 dlg.finished(false);
27220
27221 return Err(match error {
27222 Ok(value) => common::Error::BadRequest(value),
27223 _ => common::Error::Failure(response),
27224 });
27225 }
27226 let response = {
27227 let bytes = common::to_bytes(body).await.unwrap_or_default();
27228 let encoded = common::to_string(&bytes);
27229 match serde_json::from_str(&encoded) {
27230 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27231 Err(error) => {
27232 dlg.response_json_decode_error(&encoded, &error);
27233 return Err(common::Error::JsonDecodeError(
27234 encoded.to_string(),
27235 error,
27236 ));
27237 }
27238 }
27239 };
27240
27241 dlg.finished(true);
27242 return Ok(response);
27243 }
27244 }
27245 }
27246 }
27247
27248 ///
27249 /// Sets the *request* property to the given value.
27250 ///
27251 /// Even though the property as already been set when instantiating this call,
27252 /// we provide this method for API completeness.
27253 pub fn request(
27254 mut self,
27255 new_value: CreateInstancePartitionRequest,
27256 ) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
27257 self._request = new_value;
27258 self
27259 }
27260 /// Required. The name of the instance in which to create the instance partition. Values are of the form `projects//instances/`.
27261 ///
27262 /// Sets the *parent* path property to the given value.
27263 ///
27264 /// Even though the property as already been set when instantiating this call,
27265 /// we provide this method for API completeness.
27266 pub fn parent(mut self, new_value: &str) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
27267 self._parent = new_value.to_string();
27268 self
27269 }
27270 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27271 /// while executing the actual API request.
27272 ///
27273 /// ````text
27274 /// It should be used to handle progress information, and to implement a certain level of resilience.
27275 /// ````
27276 ///
27277 /// Sets the *delegate* property to the given value.
27278 pub fn delegate(
27279 mut self,
27280 new_value: &'a mut dyn common::Delegate,
27281 ) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
27282 self._delegate = Some(new_value);
27283 self
27284 }
27285
27286 /// Set any additional parameter of the query string used in the request.
27287 /// It should be used to set parameters which are not yet available through their own
27288 /// setters.
27289 ///
27290 /// Please note that this method must not be used to set any of the known parameters
27291 /// which have their own setter method. If done anyway, the request will fail.
27292 ///
27293 /// # Additional Parameters
27294 ///
27295 /// * *$.xgafv* (query-string) - V1 error format.
27296 /// * *access_token* (query-string) - OAuth access token.
27297 /// * *alt* (query-string) - Data format for response.
27298 /// * *callback* (query-string) - JSONP
27299 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27300 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
27301 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27302 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27303 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
27304 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27305 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27306 pub fn param<T>(
27307 mut self,
27308 name: T,
27309 value: T,
27310 ) -> ProjectInstanceInstancePartitionCreateCall<'a, C>
27311 where
27312 T: AsRef<str>,
27313 {
27314 self._additional_params
27315 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27316 self
27317 }
27318
27319 /// Identifies the authorization scope for the method you are building.
27320 ///
27321 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27322 /// [`Scope::CloudPlatform`].
27323 ///
27324 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27325 /// tokens for more than one scope.
27326 ///
27327 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27328 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27329 /// sufficient, a read-write scope will do as well.
27330 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionCreateCall<'a, C>
27331 where
27332 St: AsRef<str>,
27333 {
27334 self._scopes.insert(String::from(scope.as_ref()));
27335 self
27336 }
27337 /// Identifies the authorization scope(s) for the method you are building.
27338 ///
27339 /// See [`Self::add_scope()`] for details.
27340 pub fn add_scopes<I, St>(
27341 mut self,
27342 scopes: I,
27343 ) -> ProjectInstanceInstancePartitionCreateCall<'a, C>
27344 where
27345 I: IntoIterator<Item = St>,
27346 St: AsRef<str>,
27347 {
27348 self._scopes
27349 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27350 self
27351 }
27352
27353 /// Removes all scopes, and no default scope will be used either.
27354 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27355 /// for details).
27356 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionCreateCall<'a, C> {
27357 self._scopes.clear();
27358 self
27359 }
27360}
27361
27362/// 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.
27363///
27364/// A builder for the *instances.instancePartitions.delete* method supported by a *project* resource.
27365/// It is not used directly, but through a [`ProjectMethods`] instance.
27366///
27367/// # Example
27368///
27369/// Instantiate a resource method builder
27370///
27371/// ```test_harness,no_run
27372/// # extern crate hyper;
27373/// # extern crate hyper_rustls;
27374/// # extern crate google_spanner1 as spanner1;
27375/// # async fn dox() {
27376/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27377///
27378/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27379/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27380/// # secret,
27381/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27382/// # ).build().await.unwrap();
27383///
27384/// # let client = hyper_util::client::legacy::Client::builder(
27385/// # hyper_util::rt::TokioExecutor::new()
27386/// # )
27387/// # .build(
27388/// # hyper_rustls::HttpsConnectorBuilder::new()
27389/// # .with_native_roots()
27390/// # .unwrap()
27391/// # .https_or_http()
27392/// # .enable_http1()
27393/// # .build()
27394/// # );
27395/// # let mut hub = Spanner::new(client, auth);
27396/// // You can configure optional parameters by calling the respective setters at will, and
27397/// // execute the final call using `doit()`.
27398/// // Values shown here are possibly random and not representative !
27399/// let result = hub.projects().instances_instance_partitions_delete("name")
27400/// .etag("est")
27401/// .doit().await;
27402/// # }
27403/// ```
27404pub struct ProjectInstanceInstancePartitionDeleteCall<'a, C>
27405where
27406 C: 'a,
27407{
27408 hub: &'a Spanner<C>,
27409 _name: String,
27410 _etag: Option<String>,
27411 _delegate: Option<&'a mut dyn common::Delegate>,
27412 _additional_params: HashMap<String, String>,
27413 _scopes: BTreeSet<String>,
27414}
27415
27416impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionDeleteCall<'a, C> {}
27417
27418impl<'a, C> ProjectInstanceInstancePartitionDeleteCall<'a, C>
27419where
27420 C: common::Connector,
27421{
27422 /// Perform the operation you have build so far.
27423 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
27424 use std::borrow::Cow;
27425 use std::io::{Read, Seek};
27426
27427 use common::{url::Params, ToParts};
27428 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27429
27430 let mut dd = common::DefaultDelegate;
27431 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27432 dlg.begin(common::MethodInfo {
27433 id: "spanner.projects.instances.instancePartitions.delete",
27434 http_method: hyper::Method::DELETE,
27435 });
27436
27437 for &field in ["alt", "name", "etag"].iter() {
27438 if self._additional_params.contains_key(field) {
27439 dlg.finished(false);
27440 return Err(common::Error::FieldClash(field));
27441 }
27442 }
27443
27444 let mut params = Params::with_capacity(4 + self._additional_params.len());
27445 params.push("name", self._name);
27446 if let Some(value) = self._etag.as_ref() {
27447 params.push("etag", value);
27448 }
27449
27450 params.extend(self._additional_params.iter());
27451
27452 params.push("alt", "json");
27453 let mut url = self.hub._base_url.clone() + "v1/{+name}";
27454 if self._scopes.is_empty() {
27455 self._scopes
27456 .insert(Scope::CloudPlatform.as_ref().to_string());
27457 }
27458
27459 #[allow(clippy::single_element_loop)]
27460 for &(find_this, param_name) in [("{+name}", "name")].iter() {
27461 url = params.uri_replacement(url, param_name, find_this, true);
27462 }
27463 {
27464 let to_remove = ["name"];
27465 params.remove_params(&to_remove);
27466 }
27467
27468 let url = params.parse_with_url(&url);
27469
27470 loop {
27471 let token = match self
27472 .hub
27473 .auth
27474 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27475 .await
27476 {
27477 Ok(token) => token,
27478 Err(e) => match dlg.token(e) {
27479 Ok(token) => token,
27480 Err(e) => {
27481 dlg.finished(false);
27482 return Err(common::Error::MissingToken(e));
27483 }
27484 },
27485 };
27486 let mut req_result = {
27487 let client = &self.hub.client;
27488 dlg.pre_request();
27489 let mut req_builder = hyper::Request::builder()
27490 .method(hyper::Method::DELETE)
27491 .uri(url.as_str())
27492 .header(USER_AGENT, self.hub._user_agent.clone());
27493
27494 if let Some(token) = token.as_ref() {
27495 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27496 }
27497
27498 let request = req_builder
27499 .header(CONTENT_LENGTH, 0_u64)
27500 .body(common::to_body::<String>(None));
27501
27502 client.request(request.unwrap()).await
27503 };
27504
27505 match req_result {
27506 Err(err) => {
27507 if let common::Retry::After(d) = dlg.http_error(&err) {
27508 sleep(d).await;
27509 continue;
27510 }
27511 dlg.finished(false);
27512 return Err(common::Error::HttpError(err));
27513 }
27514 Ok(res) => {
27515 let (mut parts, body) = res.into_parts();
27516 let mut body = common::Body::new(body);
27517 if !parts.status.is_success() {
27518 let bytes = common::to_bytes(body).await.unwrap_or_default();
27519 let error = serde_json::from_str(&common::to_string(&bytes));
27520 let response = common::to_response(parts, bytes.into());
27521
27522 if let common::Retry::After(d) =
27523 dlg.http_failure(&response, error.as_ref().ok())
27524 {
27525 sleep(d).await;
27526 continue;
27527 }
27528
27529 dlg.finished(false);
27530
27531 return Err(match error {
27532 Ok(value) => common::Error::BadRequest(value),
27533 _ => common::Error::Failure(response),
27534 });
27535 }
27536 let response = {
27537 let bytes = common::to_bytes(body).await.unwrap_or_default();
27538 let encoded = common::to_string(&bytes);
27539 match serde_json::from_str(&encoded) {
27540 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27541 Err(error) => {
27542 dlg.response_json_decode_error(&encoded, &error);
27543 return Err(common::Error::JsonDecodeError(
27544 encoded.to_string(),
27545 error,
27546 ));
27547 }
27548 }
27549 };
27550
27551 dlg.finished(true);
27552 return Ok(response);
27553 }
27554 }
27555 }
27556 }
27557
27558 /// Required. The name of the instance partition to be deleted. Values are of the form `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`
27559 ///
27560 /// Sets the *name* path property to the given value.
27561 ///
27562 /// Even though the property as already been set when instantiating this call,
27563 /// we provide this method for API completeness.
27564 pub fn name(mut self, new_value: &str) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
27565 self._name = new_value.to_string();
27566 self
27567 }
27568 /// 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.
27569 ///
27570 /// Sets the *etag* query property to the given value.
27571 pub fn etag(mut self, new_value: &str) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
27572 self._etag = Some(new_value.to_string());
27573 self
27574 }
27575 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27576 /// while executing the actual API request.
27577 ///
27578 /// ````text
27579 /// It should be used to handle progress information, and to implement a certain level of resilience.
27580 /// ````
27581 ///
27582 /// Sets the *delegate* property to the given value.
27583 pub fn delegate(
27584 mut self,
27585 new_value: &'a mut dyn common::Delegate,
27586 ) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
27587 self._delegate = Some(new_value);
27588 self
27589 }
27590
27591 /// Set any additional parameter of the query string used in the request.
27592 /// It should be used to set parameters which are not yet available through their own
27593 /// setters.
27594 ///
27595 /// Please note that this method must not be used to set any of the known parameters
27596 /// which have their own setter method. If done anyway, the request will fail.
27597 ///
27598 /// # Additional Parameters
27599 ///
27600 /// * *$.xgafv* (query-string) - V1 error format.
27601 /// * *access_token* (query-string) - OAuth access token.
27602 /// * *alt* (query-string) - Data format for response.
27603 /// * *callback* (query-string) - JSONP
27604 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27605 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
27606 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27607 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27608 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
27609 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27610 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27611 pub fn param<T>(
27612 mut self,
27613 name: T,
27614 value: T,
27615 ) -> ProjectInstanceInstancePartitionDeleteCall<'a, C>
27616 where
27617 T: AsRef<str>,
27618 {
27619 self._additional_params
27620 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27621 self
27622 }
27623
27624 /// Identifies the authorization scope for the method you are building.
27625 ///
27626 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27627 /// [`Scope::CloudPlatform`].
27628 ///
27629 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27630 /// tokens for more than one scope.
27631 ///
27632 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27633 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27634 /// sufficient, a read-write scope will do as well.
27635 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionDeleteCall<'a, C>
27636 where
27637 St: AsRef<str>,
27638 {
27639 self._scopes.insert(String::from(scope.as_ref()));
27640 self
27641 }
27642 /// Identifies the authorization scope(s) for the method you are building.
27643 ///
27644 /// See [`Self::add_scope()`] for details.
27645 pub fn add_scopes<I, St>(
27646 mut self,
27647 scopes: I,
27648 ) -> ProjectInstanceInstancePartitionDeleteCall<'a, C>
27649 where
27650 I: IntoIterator<Item = St>,
27651 St: AsRef<str>,
27652 {
27653 self._scopes
27654 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27655 self
27656 }
27657
27658 /// Removes all scopes, and no default scope will be used either.
27659 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27660 /// for details).
27661 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionDeleteCall<'a, C> {
27662 self._scopes.clear();
27663 self
27664 }
27665}
27666
27667/// Gets information about a particular instance partition.
27668///
27669/// A builder for the *instances.instancePartitions.get* method supported by a *project* resource.
27670/// It is not used directly, but through a [`ProjectMethods`] instance.
27671///
27672/// # Example
27673///
27674/// Instantiate a resource method builder
27675///
27676/// ```test_harness,no_run
27677/// # extern crate hyper;
27678/// # extern crate hyper_rustls;
27679/// # extern crate google_spanner1 as spanner1;
27680/// # async fn dox() {
27681/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27682///
27683/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27684/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27685/// # secret,
27686/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27687/// # ).build().await.unwrap();
27688///
27689/// # let client = hyper_util::client::legacy::Client::builder(
27690/// # hyper_util::rt::TokioExecutor::new()
27691/// # )
27692/// # .build(
27693/// # hyper_rustls::HttpsConnectorBuilder::new()
27694/// # .with_native_roots()
27695/// # .unwrap()
27696/// # .https_or_http()
27697/// # .enable_http1()
27698/// # .build()
27699/// # );
27700/// # let mut hub = Spanner::new(client, auth);
27701/// // You can configure optional parameters by calling the respective setters at will, and
27702/// // execute the final call using `doit()`.
27703/// // Values shown here are possibly random and not representative !
27704/// let result = hub.projects().instances_instance_partitions_get("name")
27705/// .doit().await;
27706/// # }
27707/// ```
27708pub struct ProjectInstanceInstancePartitionGetCall<'a, C>
27709where
27710 C: 'a,
27711{
27712 hub: &'a Spanner<C>,
27713 _name: String,
27714 _delegate: Option<&'a mut dyn common::Delegate>,
27715 _additional_params: HashMap<String, String>,
27716 _scopes: BTreeSet<String>,
27717}
27718
27719impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionGetCall<'a, C> {}
27720
27721impl<'a, C> ProjectInstanceInstancePartitionGetCall<'a, C>
27722where
27723 C: common::Connector,
27724{
27725 /// Perform the operation you have build so far.
27726 pub async fn doit(mut self) -> common::Result<(common::Response, InstancePartition)> {
27727 use std::borrow::Cow;
27728 use std::io::{Read, Seek};
27729
27730 use common::{url::Params, ToParts};
27731 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27732
27733 let mut dd = common::DefaultDelegate;
27734 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27735 dlg.begin(common::MethodInfo {
27736 id: "spanner.projects.instances.instancePartitions.get",
27737 http_method: hyper::Method::GET,
27738 });
27739
27740 for &field in ["alt", "name"].iter() {
27741 if self._additional_params.contains_key(field) {
27742 dlg.finished(false);
27743 return Err(common::Error::FieldClash(field));
27744 }
27745 }
27746
27747 let mut params = Params::with_capacity(3 + self._additional_params.len());
27748 params.push("name", self._name);
27749
27750 params.extend(self._additional_params.iter());
27751
27752 params.push("alt", "json");
27753 let mut url = self.hub._base_url.clone() + "v1/{+name}";
27754 if self._scopes.is_empty() {
27755 self._scopes
27756 .insert(Scope::CloudPlatform.as_ref().to_string());
27757 }
27758
27759 #[allow(clippy::single_element_loop)]
27760 for &(find_this, param_name) in [("{+name}", "name")].iter() {
27761 url = params.uri_replacement(url, param_name, find_this, true);
27762 }
27763 {
27764 let to_remove = ["name"];
27765 params.remove_params(&to_remove);
27766 }
27767
27768 let url = params.parse_with_url(&url);
27769
27770 loop {
27771 let token = match self
27772 .hub
27773 .auth
27774 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27775 .await
27776 {
27777 Ok(token) => token,
27778 Err(e) => match dlg.token(e) {
27779 Ok(token) => token,
27780 Err(e) => {
27781 dlg.finished(false);
27782 return Err(common::Error::MissingToken(e));
27783 }
27784 },
27785 };
27786 let mut req_result = {
27787 let client = &self.hub.client;
27788 dlg.pre_request();
27789 let mut req_builder = hyper::Request::builder()
27790 .method(hyper::Method::GET)
27791 .uri(url.as_str())
27792 .header(USER_AGENT, self.hub._user_agent.clone());
27793
27794 if let Some(token) = token.as_ref() {
27795 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27796 }
27797
27798 let request = req_builder
27799 .header(CONTENT_LENGTH, 0_u64)
27800 .body(common::to_body::<String>(None));
27801
27802 client.request(request.unwrap()).await
27803 };
27804
27805 match req_result {
27806 Err(err) => {
27807 if let common::Retry::After(d) = dlg.http_error(&err) {
27808 sleep(d).await;
27809 continue;
27810 }
27811 dlg.finished(false);
27812 return Err(common::Error::HttpError(err));
27813 }
27814 Ok(res) => {
27815 let (mut parts, body) = res.into_parts();
27816 let mut body = common::Body::new(body);
27817 if !parts.status.is_success() {
27818 let bytes = common::to_bytes(body).await.unwrap_or_default();
27819 let error = serde_json::from_str(&common::to_string(&bytes));
27820 let response = common::to_response(parts, bytes.into());
27821
27822 if let common::Retry::After(d) =
27823 dlg.http_failure(&response, error.as_ref().ok())
27824 {
27825 sleep(d).await;
27826 continue;
27827 }
27828
27829 dlg.finished(false);
27830
27831 return Err(match error {
27832 Ok(value) => common::Error::BadRequest(value),
27833 _ => common::Error::Failure(response),
27834 });
27835 }
27836 let response = {
27837 let bytes = common::to_bytes(body).await.unwrap_or_default();
27838 let encoded = common::to_string(&bytes);
27839 match serde_json::from_str(&encoded) {
27840 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27841 Err(error) => {
27842 dlg.response_json_decode_error(&encoded, &error);
27843 return Err(common::Error::JsonDecodeError(
27844 encoded.to_string(),
27845 error,
27846 ));
27847 }
27848 }
27849 };
27850
27851 dlg.finished(true);
27852 return Ok(response);
27853 }
27854 }
27855 }
27856 }
27857
27858 /// Required. The name of the requested instance partition. Values are of the form `projects/{project}/instances/{instance}/instancePartitions/{instance_partition}`.
27859 ///
27860 /// Sets the *name* path property to the given value.
27861 ///
27862 /// Even though the property as already been set when instantiating this call,
27863 /// we provide this method for API completeness.
27864 pub fn name(mut self, new_value: &str) -> ProjectInstanceInstancePartitionGetCall<'a, C> {
27865 self._name = new_value.to_string();
27866 self
27867 }
27868 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27869 /// while executing the actual API request.
27870 ///
27871 /// ````text
27872 /// It should be used to handle progress information, and to implement a certain level of resilience.
27873 /// ````
27874 ///
27875 /// Sets the *delegate* property to the given value.
27876 pub fn delegate(
27877 mut self,
27878 new_value: &'a mut dyn common::Delegate,
27879 ) -> ProjectInstanceInstancePartitionGetCall<'a, C> {
27880 self._delegate = Some(new_value);
27881 self
27882 }
27883
27884 /// Set any additional parameter of the query string used in the request.
27885 /// It should be used to set parameters which are not yet available through their own
27886 /// setters.
27887 ///
27888 /// Please note that this method must not be used to set any of the known parameters
27889 /// which have their own setter method. If done anyway, the request will fail.
27890 ///
27891 /// # Additional Parameters
27892 ///
27893 /// * *$.xgafv* (query-string) - V1 error format.
27894 /// * *access_token* (query-string) - OAuth access token.
27895 /// * *alt* (query-string) - Data format for response.
27896 /// * *callback* (query-string) - JSONP
27897 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27898 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
27899 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27900 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27901 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
27902 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27903 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27904 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceInstancePartitionGetCall<'a, C>
27905 where
27906 T: AsRef<str>,
27907 {
27908 self._additional_params
27909 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27910 self
27911 }
27912
27913 /// Identifies the authorization scope for the method you are building.
27914 ///
27915 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27916 /// [`Scope::CloudPlatform`].
27917 ///
27918 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27919 /// tokens for more than one scope.
27920 ///
27921 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27922 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27923 /// sufficient, a read-write scope will do as well.
27924 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionGetCall<'a, C>
27925 where
27926 St: AsRef<str>,
27927 {
27928 self._scopes.insert(String::from(scope.as_ref()));
27929 self
27930 }
27931 /// Identifies the authorization scope(s) for the method you are building.
27932 ///
27933 /// See [`Self::add_scope()`] for details.
27934 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceInstancePartitionGetCall<'a, C>
27935 where
27936 I: IntoIterator<Item = St>,
27937 St: AsRef<str>,
27938 {
27939 self._scopes
27940 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27941 self
27942 }
27943
27944 /// Removes all scopes, and no default scope will be used either.
27945 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27946 /// for details).
27947 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionGetCall<'a, C> {
27948 self._scopes.clear();
27949 self
27950 }
27951}
27952
27953/// Lists all instance partitions for the given instance.
27954///
27955/// A builder for the *instances.instancePartitions.list* method supported by a *project* resource.
27956/// It is not used directly, but through a [`ProjectMethods`] instance.
27957///
27958/// # Example
27959///
27960/// Instantiate a resource method builder
27961///
27962/// ```test_harness,no_run
27963/// # extern crate hyper;
27964/// # extern crate hyper_rustls;
27965/// # extern crate google_spanner1 as spanner1;
27966/// # async fn dox() {
27967/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27968///
27969/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27970/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27971/// # secret,
27972/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27973/// # ).build().await.unwrap();
27974///
27975/// # let client = hyper_util::client::legacy::Client::builder(
27976/// # hyper_util::rt::TokioExecutor::new()
27977/// # )
27978/// # .build(
27979/// # hyper_rustls::HttpsConnectorBuilder::new()
27980/// # .with_native_roots()
27981/// # .unwrap()
27982/// # .https_or_http()
27983/// # .enable_http1()
27984/// # .build()
27985/// # );
27986/// # let mut hub = Spanner::new(client, auth);
27987/// // You can configure optional parameters by calling the respective setters at will, and
27988/// // execute the final call using `doit()`.
27989/// // Values shown here are possibly random and not representative !
27990/// let result = hub.projects().instances_instance_partitions_list("parent")
27991/// .page_token("consetetur")
27992/// .page_size(-46)
27993/// .instance_partition_deadline(chrono::Utc::now())
27994/// .doit().await;
27995/// # }
27996/// ```
27997pub struct ProjectInstanceInstancePartitionListCall<'a, C>
27998where
27999 C: 'a,
28000{
28001 hub: &'a Spanner<C>,
28002 _parent: String,
28003 _page_token: Option<String>,
28004 _page_size: Option<i32>,
28005 _instance_partition_deadline: Option<chrono::DateTime<chrono::offset::Utc>>,
28006 _delegate: Option<&'a mut dyn common::Delegate>,
28007 _additional_params: HashMap<String, String>,
28008 _scopes: BTreeSet<String>,
28009}
28010
28011impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionListCall<'a, C> {}
28012
28013impl<'a, C> ProjectInstanceInstancePartitionListCall<'a, C>
28014where
28015 C: common::Connector,
28016{
28017 /// Perform the operation you have build so far.
28018 pub async fn doit(
28019 mut self,
28020 ) -> common::Result<(common::Response, ListInstancePartitionsResponse)> {
28021 use std::borrow::Cow;
28022 use std::io::{Read, Seek};
28023
28024 use common::{url::Params, ToParts};
28025 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28026
28027 let mut dd = common::DefaultDelegate;
28028 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28029 dlg.begin(common::MethodInfo {
28030 id: "spanner.projects.instances.instancePartitions.list",
28031 http_method: hyper::Method::GET,
28032 });
28033
28034 for &field in [
28035 "alt",
28036 "parent",
28037 "pageToken",
28038 "pageSize",
28039 "instancePartitionDeadline",
28040 ]
28041 .iter()
28042 {
28043 if self._additional_params.contains_key(field) {
28044 dlg.finished(false);
28045 return Err(common::Error::FieldClash(field));
28046 }
28047 }
28048
28049 let mut params = Params::with_capacity(6 + self._additional_params.len());
28050 params.push("parent", self._parent);
28051 if let Some(value) = self._page_token.as_ref() {
28052 params.push("pageToken", value);
28053 }
28054 if let Some(value) = self._page_size.as_ref() {
28055 params.push("pageSize", value.to_string());
28056 }
28057 if let Some(value) = self._instance_partition_deadline.as_ref() {
28058 params.push(
28059 "instancePartitionDeadline",
28060 common::serde::datetime_to_string(&value),
28061 );
28062 }
28063
28064 params.extend(self._additional_params.iter());
28065
28066 params.push("alt", "json");
28067 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instancePartitions";
28068 if self._scopes.is_empty() {
28069 self._scopes
28070 .insert(Scope::CloudPlatform.as_ref().to_string());
28071 }
28072
28073 #[allow(clippy::single_element_loop)]
28074 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
28075 url = params.uri_replacement(url, param_name, find_this, true);
28076 }
28077 {
28078 let to_remove = ["parent"];
28079 params.remove_params(&to_remove);
28080 }
28081
28082 let url = params.parse_with_url(&url);
28083
28084 loop {
28085 let token = match self
28086 .hub
28087 .auth
28088 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28089 .await
28090 {
28091 Ok(token) => token,
28092 Err(e) => match dlg.token(e) {
28093 Ok(token) => token,
28094 Err(e) => {
28095 dlg.finished(false);
28096 return Err(common::Error::MissingToken(e));
28097 }
28098 },
28099 };
28100 let mut req_result = {
28101 let client = &self.hub.client;
28102 dlg.pre_request();
28103 let mut req_builder = hyper::Request::builder()
28104 .method(hyper::Method::GET)
28105 .uri(url.as_str())
28106 .header(USER_AGENT, self.hub._user_agent.clone());
28107
28108 if let Some(token) = token.as_ref() {
28109 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28110 }
28111
28112 let request = req_builder
28113 .header(CONTENT_LENGTH, 0_u64)
28114 .body(common::to_body::<String>(None));
28115
28116 client.request(request.unwrap()).await
28117 };
28118
28119 match req_result {
28120 Err(err) => {
28121 if let common::Retry::After(d) = dlg.http_error(&err) {
28122 sleep(d).await;
28123 continue;
28124 }
28125 dlg.finished(false);
28126 return Err(common::Error::HttpError(err));
28127 }
28128 Ok(res) => {
28129 let (mut parts, body) = res.into_parts();
28130 let mut body = common::Body::new(body);
28131 if !parts.status.is_success() {
28132 let bytes = common::to_bytes(body).await.unwrap_or_default();
28133 let error = serde_json::from_str(&common::to_string(&bytes));
28134 let response = common::to_response(parts, bytes.into());
28135
28136 if let common::Retry::After(d) =
28137 dlg.http_failure(&response, error.as_ref().ok())
28138 {
28139 sleep(d).await;
28140 continue;
28141 }
28142
28143 dlg.finished(false);
28144
28145 return Err(match error {
28146 Ok(value) => common::Error::BadRequest(value),
28147 _ => common::Error::Failure(response),
28148 });
28149 }
28150 let response = {
28151 let bytes = common::to_bytes(body).await.unwrap_or_default();
28152 let encoded = common::to_string(&bytes);
28153 match serde_json::from_str(&encoded) {
28154 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28155 Err(error) => {
28156 dlg.response_json_decode_error(&encoded, &error);
28157 return Err(common::Error::JsonDecodeError(
28158 encoded.to_string(),
28159 error,
28160 ));
28161 }
28162 }
28163 };
28164
28165 dlg.finished(true);
28166 return Ok(response);
28167 }
28168 }
28169 }
28170 }
28171
28172 /// 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/-`.
28173 ///
28174 /// Sets the *parent* path property to the given value.
28175 ///
28176 /// Even though the property as already been set when instantiating this call,
28177 /// we provide this method for API completeness.
28178 pub fn parent(mut self, new_value: &str) -> ProjectInstanceInstancePartitionListCall<'a, C> {
28179 self._parent = new_value.to_string();
28180 self
28181 }
28182 /// If non-empty, `page_token` should contain a next_page_token from a previous ListInstancePartitionsResponse.
28183 ///
28184 /// Sets the *page token* query property to the given value.
28185 pub fn page_token(
28186 mut self,
28187 new_value: &str,
28188 ) -> ProjectInstanceInstancePartitionListCall<'a, C> {
28189 self._page_token = Some(new_value.to_string());
28190 self
28191 }
28192 /// Number of instance partitions to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
28193 ///
28194 /// Sets the *page size* query property to the given value.
28195 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceInstancePartitionListCall<'a, C> {
28196 self._page_size = Some(new_value);
28197 self
28198 }
28199 /// 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.
28200 ///
28201 /// Sets the *instance partition deadline* query property to the given value.
28202 pub fn instance_partition_deadline(
28203 mut self,
28204 new_value: chrono::DateTime<chrono::offset::Utc>,
28205 ) -> ProjectInstanceInstancePartitionListCall<'a, C> {
28206 self._instance_partition_deadline = Some(new_value);
28207 self
28208 }
28209 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28210 /// while executing the actual API request.
28211 ///
28212 /// ````text
28213 /// It should be used to handle progress information, and to implement a certain level of resilience.
28214 /// ````
28215 ///
28216 /// Sets the *delegate* property to the given value.
28217 pub fn delegate(
28218 mut self,
28219 new_value: &'a mut dyn common::Delegate,
28220 ) -> ProjectInstanceInstancePartitionListCall<'a, C> {
28221 self._delegate = Some(new_value);
28222 self
28223 }
28224
28225 /// Set any additional parameter of the query string used in the request.
28226 /// It should be used to set parameters which are not yet available through their own
28227 /// setters.
28228 ///
28229 /// Please note that this method must not be used to set any of the known parameters
28230 /// which have their own setter method. If done anyway, the request will fail.
28231 ///
28232 /// # Additional Parameters
28233 ///
28234 /// * *$.xgafv* (query-string) - V1 error format.
28235 /// * *access_token* (query-string) - OAuth access token.
28236 /// * *alt* (query-string) - Data format for response.
28237 /// * *callback* (query-string) - JSONP
28238 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28239 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
28240 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28241 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28242 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
28243 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28244 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28245 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceInstancePartitionListCall<'a, C>
28246 where
28247 T: AsRef<str>,
28248 {
28249 self._additional_params
28250 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28251 self
28252 }
28253
28254 /// Identifies the authorization scope for the method you are building.
28255 ///
28256 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28257 /// [`Scope::CloudPlatform`].
28258 ///
28259 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28260 /// tokens for more than one scope.
28261 ///
28262 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28263 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28264 /// sufficient, a read-write scope will do as well.
28265 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionListCall<'a, C>
28266 where
28267 St: AsRef<str>,
28268 {
28269 self._scopes.insert(String::from(scope.as_ref()));
28270 self
28271 }
28272 /// Identifies the authorization scope(s) for the method you are building.
28273 ///
28274 /// See [`Self::add_scope()`] for details.
28275 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceInstancePartitionListCall<'a, C>
28276 where
28277 I: IntoIterator<Item = St>,
28278 St: AsRef<str>,
28279 {
28280 self._scopes
28281 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28282 self
28283 }
28284
28285 /// Removes all scopes, and no default scope will be used either.
28286 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28287 /// for details).
28288 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionListCall<'a, C> {
28289 self._scopes.clear();
28290 self
28291 }
28292}
28293
28294/// 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.
28295///
28296/// A builder for the *instances.instancePartitions.patch* method supported by a *project* resource.
28297/// It is not used directly, but through a [`ProjectMethods`] instance.
28298///
28299/// # Example
28300///
28301/// Instantiate a resource method builder
28302///
28303/// ```test_harness,no_run
28304/// # extern crate hyper;
28305/// # extern crate hyper_rustls;
28306/// # extern crate google_spanner1 as spanner1;
28307/// use spanner1::api::UpdateInstancePartitionRequest;
28308/// # async fn dox() {
28309/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28310///
28311/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28312/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28313/// # secret,
28314/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28315/// # ).build().await.unwrap();
28316///
28317/// # let client = hyper_util::client::legacy::Client::builder(
28318/// # hyper_util::rt::TokioExecutor::new()
28319/// # )
28320/// # .build(
28321/// # hyper_rustls::HttpsConnectorBuilder::new()
28322/// # .with_native_roots()
28323/// # .unwrap()
28324/// # .https_or_http()
28325/// # .enable_http1()
28326/// # .build()
28327/// # );
28328/// # let mut hub = Spanner::new(client, auth);
28329/// // As the method needs a request, you would usually fill it with the desired information
28330/// // into the respective structure. Some of the parts shown here might not be applicable !
28331/// // Values shown here are possibly random and not representative !
28332/// let mut req = UpdateInstancePartitionRequest::default();
28333///
28334/// // You can configure optional parameters by calling the respective setters at will, and
28335/// // execute the final call using `doit()`.
28336/// // Values shown here are possibly random and not representative !
28337/// let result = hub.projects().instances_instance_partitions_patch(req, "name")
28338/// .doit().await;
28339/// # }
28340/// ```
28341pub struct ProjectInstanceInstancePartitionPatchCall<'a, C>
28342where
28343 C: 'a,
28344{
28345 hub: &'a Spanner<C>,
28346 _request: UpdateInstancePartitionRequest,
28347 _name: String,
28348 _delegate: Option<&'a mut dyn common::Delegate>,
28349 _additional_params: HashMap<String, String>,
28350 _scopes: BTreeSet<String>,
28351}
28352
28353impl<'a, C> common::CallBuilder for ProjectInstanceInstancePartitionPatchCall<'a, C> {}
28354
28355impl<'a, C> ProjectInstanceInstancePartitionPatchCall<'a, C>
28356where
28357 C: common::Connector,
28358{
28359 /// Perform the operation you have build so far.
28360 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
28361 use std::borrow::Cow;
28362 use std::io::{Read, Seek};
28363
28364 use common::{url::Params, ToParts};
28365 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28366
28367 let mut dd = common::DefaultDelegate;
28368 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28369 dlg.begin(common::MethodInfo {
28370 id: "spanner.projects.instances.instancePartitions.patch",
28371 http_method: hyper::Method::PATCH,
28372 });
28373
28374 for &field in ["alt", "name"].iter() {
28375 if self._additional_params.contains_key(field) {
28376 dlg.finished(false);
28377 return Err(common::Error::FieldClash(field));
28378 }
28379 }
28380
28381 let mut params = Params::with_capacity(4 + self._additional_params.len());
28382 params.push("name", self._name);
28383
28384 params.extend(self._additional_params.iter());
28385
28386 params.push("alt", "json");
28387 let mut url = self.hub._base_url.clone() + "v1/{+name}";
28388 if self._scopes.is_empty() {
28389 self._scopes
28390 .insert(Scope::CloudPlatform.as_ref().to_string());
28391 }
28392
28393 #[allow(clippy::single_element_loop)]
28394 for &(find_this, param_name) in [("{+name}", "name")].iter() {
28395 url = params.uri_replacement(url, param_name, find_this, true);
28396 }
28397 {
28398 let to_remove = ["name"];
28399 params.remove_params(&to_remove);
28400 }
28401
28402 let url = params.parse_with_url(&url);
28403
28404 let mut json_mime_type = mime::APPLICATION_JSON;
28405 let mut request_value_reader = {
28406 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28407 common::remove_json_null_values(&mut value);
28408 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28409 serde_json::to_writer(&mut dst, &value).unwrap();
28410 dst
28411 };
28412 let request_size = request_value_reader
28413 .seek(std::io::SeekFrom::End(0))
28414 .unwrap();
28415 request_value_reader
28416 .seek(std::io::SeekFrom::Start(0))
28417 .unwrap();
28418
28419 loop {
28420 let token = match self
28421 .hub
28422 .auth
28423 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28424 .await
28425 {
28426 Ok(token) => token,
28427 Err(e) => match dlg.token(e) {
28428 Ok(token) => token,
28429 Err(e) => {
28430 dlg.finished(false);
28431 return Err(common::Error::MissingToken(e));
28432 }
28433 },
28434 };
28435 request_value_reader
28436 .seek(std::io::SeekFrom::Start(0))
28437 .unwrap();
28438 let mut req_result = {
28439 let client = &self.hub.client;
28440 dlg.pre_request();
28441 let mut req_builder = hyper::Request::builder()
28442 .method(hyper::Method::PATCH)
28443 .uri(url.as_str())
28444 .header(USER_AGENT, self.hub._user_agent.clone());
28445
28446 if let Some(token) = token.as_ref() {
28447 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28448 }
28449
28450 let request = req_builder
28451 .header(CONTENT_TYPE, json_mime_type.to_string())
28452 .header(CONTENT_LENGTH, request_size as u64)
28453 .body(common::to_body(
28454 request_value_reader.get_ref().clone().into(),
28455 ));
28456
28457 client.request(request.unwrap()).await
28458 };
28459
28460 match req_result {
28461 Err(err) => {
28462 if let common::Retry::After(d) = dlg.http_error(&err) {
28463 sleep(d).await;
28464 continue;
28465 }
28466 dlg.finished(false);
28467 return Err(common::Error::HttpError(err));
28468 }
28469 Ok(res) => {
28470 let (mut parts, body) = res.into_parts();
28471 let mut body = common::Body::new(body);
28472 if !parts.status.is_success() {
28473 let bytes = common::to_bytes(body).await.unwrap_or_default();
28474 let error = serde_json::from_str(&common::to_string(&bytes));
28475 let response = common::to_response(parts, bytes.into());
28476
28477 if let common::Retry::After(d) =
28478 dlg.http_failure(&response, error.as_ref().ok())
28479 {
28480 sleep(d).await;
28481 continue;
28482 }
28483
28484 dlg.finished(false);
28485
28486 return Err(match error {
28487 Ok(value) => common::Error::BadRequest(value),
28488 _ => common::Error::Failure(response),
28489 });
28490 }
28491 let response = {
28492 let bytes = common::to_bytes(body).await.unwrap_or_default();
28493 let encoded = common::to_string(&bytes);
28494 match serde_json::from_str(&encoded) {
28495 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28496 Err(error) => {
28497 dlg.response_json_decode_error(&encoded, &error);
28498 return Err(common::Error::JsonDecodeError(
28499 encoded.to_string(),
28500 error,
28501 ));
28502 }
28503 }
28504 };
28505
28506 dlg.finished(true);
28507 return Ok(response);
28508 }
28509 }
28510 }
28511 }
28512
28513 ///
28514 /// Sets the *request* property to the given value.
28515 ///
28516 /// Even though the property as already been set when instantiating this call,
28517 /// we provide this method for API completeness.
28518 pub fn request(
28519 mut self,
28520 new_value: UpdateInstancePartitionRequest,
28521 ) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
28522 self._request = new_value;
28523 self
28524 }
28525 /// 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.
28526 ///
28527 /// Sets the *name* path property to the given value.
28528 ///
28529 /// Even though the property as already been set when instantiating this call,
28530 /// we provide this method for API completeness.
28531 pub fn name(mut self, new_value: &str) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
28532 self._name = new_value.to_string();
28533 self
28534 }
28535 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28536 /// while executing the actual API request.
28537 ///
28538 /// ````text
28539 /// It should be used to handle progress information, and to implement a certain level of resilience.
28540 /// ````
28541 ///
28542 /// Sets the *delegate* property to the given value.
28543 pub fn delegate(
28544 mut self,
28545 new_value: &'a mut dyn common::Delegate,
28546 ) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
28547 self._delegate = Some(new_value);
28548 self
28549 }
28550
28551 /// Set any additional parameter of the query string used in the request.
28552 /// It should be used to set parameters which are not yet available through their own
28553 /// setters.
28554 ///
28555 /// Please note that this method must not be used to set any of the known parameters
28556 /// which have their own setter method. If done anyway, the request will fail.
28557 ///
28558 /// # Additional Parameters
28559 ///
28560 /// * *$.xgafv* (query-string) - V1 error format.
28561 /// * *access_token* (query-string) - OAuth access token.
28562 /// * *alt* (query-string) - Data format for response.
28563 /// * *callback* (query-string) - JSONP
28564 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28565 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
28566 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28567 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28568 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
28569 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28570 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28571 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceInstancePartitionPatchCall<'a, C>
28572 where
28573 T: AsRef<str>,
28574 {
28575 self._additional_params
28576 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28577 self
28578 }
28579
28580 /// Identifies the authorization scope for the method you are building.
28581 ///
28582 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28583 /// [`Scope::CloudPlatform`].
28584 ///
28585 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28586 /// tokens for more than one scope.
28587 ///
28588 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28589 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28590 /// sufficient, a read-write scope will do as well.
28591 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceInstancePartitionPatchCall<'a, C>
28592 where
28593 St: AsRef<str>,
28594 {
28595 self._scopes.insert(String::from(scope.as_ref()));
28596 self
28597 }
28598 /// Identifies the authorization scope(s) for the method you are building.
28599 ///
28600 /// See [`Self::add_scope()`] for details.
28601 pub fn add_scopes<I, St>(
28602 mut self,
28603 scopes: I,
28604 ) -> ProjectInstanceInstancePartitionPatchCall<'a, C>
28605 where
28606 I: IntoIterator<Item = St>,
28607 St: AsRef<str>,
28608 {
28609 self._scopes
28610 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28611 self
28612 }
28613
28614 /// Removes all scopes, and no default scope will be used either.
28615 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28616 /// for details).
28617 pub fn clear_scopes(mut self) -> ProjectInstanceInstancePartitionPatchCall<'a, C> {
28618 self._scopes.clear();
28619 self
28620 }
28621}
28622
28623/// 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`.
28624///
28625/// A builder for the *instances.operations.cancel* method supported by a *project* resource.
28626/// It is not used directly, but through a [`ProjectMethods`] instance.
28627///
28628/// # Example
28629///
28630/// Instantiate a resource method builder
28631///
28632/// ```test_harness,no_run
28633/// # extern crate hyper;
28634/// # extern crate hyper_rustls;
28635/// # extern crate google_spanner1 as spanner1;
28636/// # async fn dox() {
28637/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28638///
28639/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28640/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28641/// # secret,
28642/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28643/// # ).build().await.unwrap();
28644///
28645/// # let client = hyper_util::client::legacy::Client::builder(
28646/// # hyper_util::rt::TokioExecutor::new()
28647/// # )
28648/// # .build(
28649/// # hyper_rustls::HttpsConnectorBuilder::new()
28650/// # .with_native_roots()
28651/// # .unwrap()
28652/// # .https_or_http()
28653/// # .enable_http1()
28654/// # .build()
28655/// # );
28656/// # let mut hub = Spanner::new(client, auth);
28657/// // You can configure optional parameters by calling the respective setters at will, and
28658/// // execute the final call using `doit()`.
28659/// // Values shown here are possibly random and not representative !
28660/// let result = hub.projects().instances_operations_cancel("name")
28661/// .doit().await;
28662/// # }
28663/// ```
28664pub struct ProjectInstanceOperationCancelCall<'a, C>
28665where
28666 C: 'a,
28667{
28668 hub: &'a Spanner<C>,
28669 _name: String,
28670 _delegate: Option<&'a mut dyn common::Delegate>,
28671 _additional_params: HashMap<String, String>,
28672 _scopes: BTreeSet<String>,
28673}
28674
28675impl<'a, C> common::CallBuilder for ProjectInstanceOperationCancelCall<'a, C> {}
28676
28677impl<'a, C> ProjectInstanceOperationCancelCall<'a, C>
28678where
28679 C: common::Connector,
28680{
28681 /// Perform the operation you have build so far.
28682 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
28683 use std::borrow::Cow;
28684 use std::io::{Read, Seek};
28685
28686 use common::{url::Params, ToParts};
28687 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28688
28689 let mut dd = common::DefaultDelegate;
28690 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28691 dlg.begin(common::MethodInfo {
28692 id: "spanner.projects.instances.operations.cancel",
28693 http_method: hyper::Method::POST,
28694 });
28695
28696 for &field in ["alt", "name"].iter() {
28697 if self._additional_params.contains_key(field) {
28698 dlg.finished(false);
28699 return Err(common::Error::FieldClash(field));
28700 }
28701 }
28702
28703 let mut params = Params::with_capacity(3 + self._additional_params.len());
28704 params.push("name", self._name);
28705
28706 params.extend(self._additional_params.iter());
28707
28708 params.push("alt", "json");
28709 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
28710 if self._scopes.is_empty() {
28711 self._scopes
28712 .insert(Scope::CloudPlatform.as_ref().to_string());
28713 }
28714
28715 #[allow(clippy::single_element_loop)]
28716 for &(find_this, param_name) in [("{+name}", "name")].iter() {
28717 url = params.uri_replacement(url, param_name, find_this, true);
28718 }
28719 {
28720 let to_remove = ["name"];
28721 params.remove_params(&to_remove);
28722 }
28723
28724 let url = params.parse_with_url(&url);
28725
28726 loop {
28727 let token = match self
28728 .hub
28729 .auth
28730 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28731 .await
28732 {
28733 Ok(token) => token,
28734 Err(e) => match dlg.token(e) {
28735 Ok(token) => token,
28736 Err(e) => {
28737 dlg.finished(false);
28738 return Err(common::Error::MissingToken(e));
28739 }
28740 },
28741 };
28742 let mut req_result = {
28743 let client = &self.hub.client;
28744 dlg.pre_request();
28745 let mut req_builder = hyper::Request::builder()
28746 .method(hyper::Method::POST)
28747 .uri(url.as_str())
28748 .header(USER_AGENT, self.hub._user_agent.clone());
28749
28750 if let Some(token) = token.as_ref() {
28751 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28752 }
28753
28754 let request = req_builder
28755 .header(CONTENT_LENGTH, 0_u64)
28756 .body(common::to_body::<String>(None));
28757
28758 client.request(request.unwrap()).await
28759 };
28760
28761 match req_result {
28762 Err(err) => {
28763 if let common::Retry::After(d) = dlg.http_error(&err) {
28764 sleep(d).await;
28765 continue;
28766 }
28767 dlg.finished(false);
28768 return Err(common::Error::HttpError(err));
28769 }
28770 Ok(res) => {
28771 let (mut parts, body) = res.into_parts();
28772 let mut body = common::Body::new(body);
28773 if !parts.status.is_success() {
28774 let bytes = common::to_bytes(body).await.unwrap_or_default();
28775 let error = serde_json::from_str(&common::to_string(&bytes));
28776 let response = common::to_response(parts, bytes.into());
28777
28778 if let common::Retry::After(d) =
28779 dlg.http_failure(&response, error.as_ref().ok())
28780 {
28781 sleep(d).await;
28782 continue;
28783 }
28784
28785 dlg.finished(false);
28786
28787 return Err(match error {
28788 Ok(value) => common::Error::BadRequest(value),
28789 _ => common::Error::Failure(response),
28790 });
28791 }
28792 let response = {
28793 let bytes = common::to_bytes(body).await.unwrap_or_default();
28794 let encoded = common::to_string(&bytes);
28795 match serde_json::from_str(&encoded) {
28796 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28797 Err(error) => {
28798 dlg.response_json_decode_error(&encoded, &error);
28799 return Err(common::Error::JsonDecodeError(
28800 encoded.to_string(),
28801 error,
28802 ));
28803 }
28804 }
28805 };
28806
28807 dlg.finished(true);
28808 return Ok(response);
28809 }
28810 }
28811 }
28812 }
28813
28814 /// The name of the operation resource to be cancelled.
28815 ///
28816 /// Sets the *name* path property to the given value.
28817 ///
28818 /// Even though the property as already been set when instantiating this call,
28819 /// we provide this method for API completeness.
28820 pub fn name(mut self, new_value: &str) -> ProjectInstanceOperationCancelCall<'a, C> {
28821 self._name = new_value.to_string();
28822 self
28823 }
28824 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28825 /// while executing the actual API request.
28826 ///
28827 /// ````text
28828 /// It should be used to handle progress information, and to implement a certain level of resilience.
28829 /// ````
28830 ///
28831 /// Sets the *delegate* property to the given value.
28832 pub fn delegate(
28833 mut self,
28834 new_value: &'a mut dyn common::Delegate,
28835 ) -> ProjectInstanceOperationCancelCall<'a, C> {
28836 self._delegate = Some(new_value);
28837 self
28838 }
28839
28840 /// Set any additional parameter of the query string used in the request.
28841 /// It should be used to set parameters which are not yet available through their own
28842 /// setters.
28843 ///
28844 /// Please note that this method must not be used to set any of the known parameters
28845 /// which have their own setter method. If done anyway, the request will fail.
28846 ///
28847 /// # Additional Parameters
28848 ///
28849 /// * *$.xgafv* (query-string) - V1 error format.
28850 /// * *access_token* (query-string) - OAuth access token.
28851 /// * *alt* (query-string) - Data format for response.
28852 /// * *callback* (query-string) - JSONP
28853 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28854 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
28855 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28856 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28857 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
28858 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28859 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28860 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceOperationCancelCall<'a, C>
28861 where
28862 T: AsRef<str>,
28863 {
28864 self._additional_params
28865 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28866 self
28867 }
28868
28869 /// Identifies the authorization scope for the method you are building.
28870 ///
28871 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28872 /// [`Scope::CloudPlatform`].
28873 ///
28874 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28875 /// tokens for more than one scope.
28876 ///
28877 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28878 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28879 /// sufficient, a read-write scope will do as well.
28880 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceOperationCancelCall<'a, C>
28881 where
28882 St: AsRef<str>,
28883 {
28884 self._scopes.insert(String::from(scope.as_ref()));
28885 self
28886 }
28887 /// Identifies the authorization scope(s) for the method you are building.
28888 ///
28889 /// See [`Self::add_scope()`] for details.
28890 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceOperationCancelCall<'a, C>
28891 where
28892 I: IntoIterator<Item = St>,
28893 St: AsRef<str>,
28894 {
28895 self._scopes
28896 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28897 self
28898 }
28899
28900 /// Removes all scopes, and no default scope will be used either.
28901 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28902 /// for details).
28903 pub fn clear_scopes(mut self) -> ProjectInstanceOperationCancelCall<'a, C> {
28904 self._scopes.clear();
28905 self
28906 }
28907}
28908
28909/// 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`.
28910///
28911/// A builder for the *instances.operations.delete* method supported by a *project* resource.
28912/// It is not used directly, but through a [`ProjectMethods`] instance.
28913///
28914/// # Example
28915///
28916/// Instantiate a resource method builder
28917///
28918/// ```test_harness,no_run
28919/// # extern crate hyper;
28920/// # extern crate hyper_rustls;
28921/// # extern crate google_spanner1 as spanner1;
28922/// # async fn dox() {
28923/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28924///
28925/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28926/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28927/// # secret,
28928/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28929/// # ).build().await.unwrap();
28930///
28931/// # let client = hyper_util::client::legacy::Client::builder(
28932/// # hyper_util::rt::TokioExecutor::new()
28933/// # )
28934/// # .build(
28935/// # hyper_rustls::HttpsConnectorBuilder::new()
28936/// # .with_native_roots()
28937/// # .unwrap()
28938/// # .https_or_http()
28939/// # .enable_http1()
28940/// # .build()
28941/// # );
28942/// # let mut hub = Spanner::new(client, auth);
28943/// // You can configure optional parameters by calling the respective setters at will, and
28944/// // execute the final call using `doit()`.
28945/// // Values shown here are possibly random and not representative !
28946/// let result = hub.projects().instances_operations_delete("name")
28947/// .doit().await;
28948/// # }
28949/// ```
28950pub struct ProjectInstanceOperationDeleteCall<'a, C>
28951where
28952 C: 'a,
28953{
28954 hub: &'a Spanner<C>,
28955 _name: String,
28956 _delegate: Option<&'a mut dyn common::Delegate>,
28957 _additional_params: HashMap<String, String>,
28958 _scopes: BTreeSet<String>,
28959}
28960
28961impl<'a, C> common::CallBuilder for ProjectInstanceOperationDeleteCall<'a, C> {}
28962
28963impl<'a, C> ProjectInstanceOperationDeleteCall<'a, C>
28964where
28965 C: common::Connector,
28966{
28967 /// Perform the operation you have build so far.
28968 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
28969 use std::borrow::Cow;
28970 use std::io::{Read, Seek};
28971
28972 use common::{url::Params, ToParts};
28973 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28974
28975 let mut dd = common::DefaultDelegate;
28976 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28977 dlg.begin(common::MethodInfo {
28978 id: "spanner.projects.instances.operations.delete",
28979 http_method: hyper::Method::DELETE,
28980 });
28981
28982 for &field in ["alt", "name"].iter() {
28983 if self._additional_params.contains_key(field) {
28984 dlg.finished(false);
28985 return Err(common::Error::FieldClash(field));
28986 }
28987 }
28988
28989 let mut params = Params::with_capacity(3 + self._additional_params.len());
28990 params.push("name", self._name);
28991
28992 params.extend(self._additional_params.iter());
28993
28994 params.push("alt", "json");
28995 let mut url = self.hub._base_url.clone() + "v1/{+name}";
28996 if self._scopes.is_empty() {
28997 self._scopes
28998 .insert(Scope::CloudPlatform.as_ref().to_string());
28999 }
29000
29001 #[allow(clippy::single_element_loop)]
29002 for &(find_this, param_name) in [("{+name}", "name")].iter() {
29003 url = params.uri_replacement(url, param_name, find_this, true);
29004 }
29005 {
29006 let to_remove = ["name"];
29007 params.remove_params(&to_remove);
29008 }
29009
29010 let url = params.parse_with_url(&url);
29011
29012 loop {
29013 let token = match self
29014 .hub
29015 .auth
29016 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29017 .await
29018 {
29019 Ok(token) => token,
29020 Err(e) => match dlg.token(e) {
29021 Ok(token) => token,
29022 Err(e) => {
29023 dlg.finished(false);
29024 return Err(common::Error::MissingToken(e));
29025 }
29026 },
29027 };
29028 let mut req_result = {
29029 let client = &self.hub.client;
29030 dlg.pre_request();
29031 let mut req_builder = hyper::Request::builder()
29032 .method(hyper::Method::DELETE)
29033 .uri(url.as_str())
29034 .header(USER_AGENT, self.hub._user_agent.clone());
29035
29036 if let Some(token) = token.as_ref() {
29037 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29038 }
29039
29040 let request = req_builder
29041 .header(CONTENT_LENGTH, 0_u64)
29042 .body(common::to_body::<String>(None));
29043
29044 client.request(request.unwrap()).await
29045 };
29046
29047 match req_result {
29048 Err(err) => {
29049 if let common::Retry::After(d) = dlg.http_error(&err) {
29050 sleep(d).await;
29051 continue;
29052 }
29053 dlg.finished(false);
29054 return Err(common::Error::HttpError(err));
29055 }
29056 Ok(res) => {
29057 let (mut parts, body) = res.into_parts();
29058 let mut body = common::Body::new(body);
29059 if !parts.status.is_success() {
29060 let bytes = common::to_bytes(body).await.unwrap_or_default();
29061 let error = serde_json::from_str(&common::to_string(&bytes));
29062 let response = common::to_response(parts, bytes.into());
29063
29064 if let common::Retry::After(d) =
29065 dlg.http_failure(&response, error.as_ref().ok())
29066 {
29067 sleep(d).await;
29068 continue;
29069 }
29070
29071 dlg.finished(false);
29072
29073 return Err(match error {
29074 Ok(value) => common::Error::BadRequest(value),
29075 _ => common::Error::Failure(response),
29076 });
29077 }
29078 let response = {
29079 let bytes = common::to_bytes(body).await.unwrap_or_default();
29080 let encoded = common::to_string(&bytes);
29081 match serde_json::from_str(&encoded) {
29082 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29083 Err(error) => {
29084 dlg.response_json_decode_error(&encoded, &error);
29085 return Err(common::Error::JsonDecodeError(
29086 encoded.to_string(),
29087 error,
29088 ));
29089 }
29090 }
29091 };
29092
29093 dlg.finished(true);
29094 return Ok(response);
29095 }
29096 }
29097 }
29098 }
29099
29100 /// The name of the operation resource to be deleted.
29101 ///
29102 /// Sets the *name* path property to the given value.
29103 ///
29104 /// Even though the property as already been set when instantiating this call,
29105 /// we provide this method for API completeness.
29106 pub fn name(mut self, new_value: &str) -> ProjectInstanceOperationDeleteCall<'a, C> {
29107 self._name = new_value.to_string();
29108 self
29109 }
29110 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29111 /// while executing the actual API request.
29112 ///
29113 /// ````text
29114 /// It should be used to handle progress information, and to implement a certain level of resilience.
29115 /// ````
29116 ///
29117 /// Sets the *delegate* property to the given value.
29118 pub fn delegate(
29119 mut self,
29120 new_value: &'a mut dyn common::Delegate,
29121 ) -> ProjectInstanceOperationDeleteCall<'a, C> {
29122 self._delegate = Some(new_value);
29123 self
29124 }
29125
29126 /// Set any additional parameter of the query string used in the request.
29127 /// It should be used to set parameters which are not yet available through their own
29128 /// setters.
29129 ///
29130 /// Please note that this method must not be used to set any of the known parameters
29131 /// which have their own setter method. If done anyway, the request will fail.
29132 ///
29133 /// # Additional Parameters
29134 ///
29135 /// * *$.xgafv* (query-string) - V1 error format.
29136 /// * *access_token* (query-string) - OAuth access token.
29137 /// * *alt* (query-string) - Data format for response.
29138 /// * *callback* (query-string) - JSONP
29139 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29140 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29141 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29142 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29143 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
29144 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29145 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29146 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceOperationDeleteCall<'a, C>
29147 where
29148 T: AsRef<str>,
29149 {
29150 self._additional_params
29151 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29152 self
29153 }
29154
29155 /// Identifies the authorization scope for the method you are building.
29156 ///
29157 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29158 /// [`Scope::CloudPlatform`].
29159 ///
29160 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29161 /// tokens for more than one scope.
29162 ///
29163 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29164 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29165 /// sufficient, a read-write scope will do as well.
29166 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceOperationDeleteCall<'a, C>
29167 where
29168 St: AsRef<str>,
29169 {
29170 self._scopes.insert(String::from(scope.as_ref()));
29171 self
29172 }
29173 /// Identifies the authorization scope(s) for the method you are building.
29174 ///
29175 /// See [`Self::add_scope()`] for details.
29176 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceOperationDeleteCall<'a, C>
29177 where
29178 I: IntoIterator<Item = St>,
29179 St: AsRef<str>,
29180 {
29181 self._scopes
29182 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29183 self
29184 }
29185
29186 /// Removes all scopes, and no default scope will be used either.
29187 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29188 /// for details).
29189 pub fn clear_scopes(mut self) -> ProjectInstanceOperationDeleteCall<'a, C> {
29190 self._scopes.clear();
29191 self
29192 }
29193}
29194
29195/// 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.
29196///
29197/// A builder for the *instances.operations.get* method supported by a *project* resource.
29198/// It is not used directly, but through a [`ProjectMethods`] instance.
29199///
29200/// # Example
29201///
29202/// Instantiate a resource method builder
29203///
29204/// ```test_harness,no_run
29205/// # extern crate hyper;
29206/// # extern crate hyper_rustls;
29207/// # extern crate google_spanner1 as spanner1;
29208/// # async fn dox() {
29209/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29210///
29211/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29212/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29213/// # secret,
29214/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29215/// # ).build().await.unwrap();
29216///
29217/// # let client = hyper_util::client::legacy::Client::builder(
29218/// # hyper_util::rt::TokioExecutor::new()
29219/// # )
29220/// # .build(
29221/// # hyper_rustls::HttpsConnectorBuilder::new()
29222/// # .with_native_roots()
29223/// # .unwrap()
29224/// # .https_or_http()
29225/// # .enable_http1()
29226/// # .build()
29227/// # );
29228/// # let mut hub = Spanner::new(client, auth);
29229/// // You can configure optional parameters by calling the respective setters at will, and
29230/// // execute the final call using `doit()`.
29231/// // Values shown here are possibly random and not representative !
29232/// let result = hub.projects().instances_operations_get("name")
29233/// .doit().await;
29234/// # }
29235/// ```
29236pub struct ProjectInstanceOperationGetCall<'a, C>
29237where
29238 C: 'a,
29239{
29240 hub: &'a Spanner<C>,
29241 _name: String,
29242 _delegate: Option<&'a mut dyn common::Delegate>,
29243 _additional_params: HashMap<String, String>,
29244 _scopes: BTreeSet<String>,
29245}
29246
29247impl<'a, C> common::CallBuilder for ProjectInstanceOperationGetCall<'a, C> {}
29248
29249impl<'a, C> ProjectInstanceOperationGetCall<'a, C>
29250where
29251 C: common::Connector,
29252{
29253 /// Perform the operation you have build so far.
29254 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
29255 use std::borrow::Cow;
29256 use std::io::{Read, Seek};
29257
29258 use common::{url::Params, ToParts};
29259 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29260
29261 let mut dd = common::DefaultDelegate;
29262 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29263 dlg.begin(common::MethodInfo {
29264 id: "spanner.projects.instances.operations.get",
29265 http_method: hyper::Method::GET,
29266 });
29267
29268 for &field in ["alt", "name"].iter() {
29269 if self._additional_params.contains_key(field) {
29270 dlg.finished(false);
29271 return Err(common::Error::FieldClash(field));
29272 }
29273 }
29274
29275 let mut params = Params::with_capacity(3 + self._additional_params.len());
29276 params.push("name", self._name);
29277
29278 params.extend(self._additional_params.iter());
29279
29280 params.push("alt", "json");
29281 let mut url = self.hub._base_url.clone() + "v1/{+name}";
29282 if self._scopes.is_empty() {
29283 self._scopes
29284 .insert(Scope::CloudPlatform.as_ref().to_string());
29285 }
29286
29287 #[allow(clippy::single_element_loop)]
29288 for &(find_this, param_name) in [("{+name}", "name")].iter() {
29289 url = params.uri_replacement(url, param_name, find_this, true);
29290 }
29291 {
29292 let to_remove = ["name"];
29293 params.remove_params(&to_remove);
29294 }
29295
29296 let url = params.parse_with_url(&url);
29297
29298 loop {
29299 let token = match self
29300 .hub
29301 .auth
29302 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29303 .await
29304 {
29305 Ok(token) => token,
29306 Err(e) => match dlg.token(e) {
29307 Ok(token) => token,
29308 Err(e) => {
29309 dlg.finished(false);
29310 return Err(common::Error::MissingToken(e));
29311 }
29312 },
29313 };
29314 let mut req_result = {
29315 let client = &self.hub.client;
29316 dlg.pre_request();
29317 let mut req_builder = hyper::Request::builder()
29318 .method(hyper::Method::GET)
29319 .uri(url.as_str())
29320 .header(USER_AGENT, self.hub._user_agent.clone());
29321
29322 if let Some(token) = token.as_ref() {
29323 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29324 }
29325
29326 let request = req_builder
29327 .header(CONTENT_LENGTH, 0_u64)
29328 .body(common::to_body::<String>(None));
29329
29330 client.request(request.unwrap()).await
29331 };
29332
29333 match req_result {
29334 Err(err) => {
29335 if let common::Retry::After(d) = dlg.http_error(&err) {
29336 sleep(d).await;
29337 continue;
29338 }
29339 dlg.finished(false);
29340 return Err(common::Error::HttpError(err));
29341 }
29342 Ok(res) => {
29343 let (mut parts, body) = res.into_parts();
29344 let mut body = common::Body::new(body);
29345 if !parts.status.is_success() {
29346 let bytes = common::to_bytes(body).await.unwrap_or_default();
29347 let error = serde_json::from_str(&common::to_string(&bytes));
29348 let response = common::to_response(parts, bytes.into());
29349
29350 if let common::Retry::After(d) =
29351 dlg.http_failure(&response, error.as_ref().ok())
29352 {
29353 sleep(d).await;
29354 continue;
29355 }
29356
29357 dlg.finished(false);
29358
29359 return Err(match error {
29360 Ok(value) => common::Error::BadRequest(value),
29361 _ => common::Error::Failure(response),
29362 });
29363 }
29364 let response = {
29365 let bytes = common::to_bytes(body).await.unwrap_or_default();
29366 let encoded = common::to_string(&bytes);
29367 match serde_json::from_str(&encoded) {
29368 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29369 Err(error) => {
29370 dlg.response_json_decode_error(&encoded, &error);
29371 return Err(common::Error::JsonDecodeError(
29372 encoded.to_string(),
29373 error,
29374 ));
29375 }
29376 }
29377 };
29378
29379 dlg.finished(true);
29380 return Ok(response);
29381 }
29382 }
29383 }
29384 }
29385
29386 /// The name of the operation resource.
29387 ///
29388 /// Sets the *name* path property to the given value.
29389 ///
29390 /// Even though the property as already been set when instantiating this call,
29391 /// we provide this method for API completeness.
29392 pub fn name(mut self, new_value: &str) -> ProjectInstanceOperationGetCall<'a, C> {
29393 self._name = new_value.to_string();
29394 self
29395 }
29396 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29397 /// while executing the actual API request.
29398 ///
29399 /// ````text
29400 /// It should be used to handle progress information, and to implement a certain level of resilience.
29401 /// ````
29402 ///
29403 /// Sets the *delegate* property to the given value.
29404 pub fn delegate(
29405 mut self,
29406 new_value: &'a mut dyn common::Delegate,
29407 ) -> ProjectInstanceOperationGetCall<'a, C> {
29408 self._delegate = Some(new_value);
29409 self
29410 }
29411
29412 /// Set any additional parameter of the query string used in the request.
29413 /// It should be used to set parameters which are not yet available through their own
29414 /// setters.
29415 ///
29416 /// Please note that this method must not be used to set any of the known parameters
29417 /// which have their own setter method. If done anyway, the request will fail.
29418 ///
29419 /// # Additional Parameters
29420 ///
29421 /// * *$.xgafv* (query-string) - V1 error format.
29422 /// * *access_token* (query-string) - OAuth access token.
29423 /// * *alt* (query-string) - Data format for response.
29424 /// * *callback* (query-string) - JSONP
29425 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29426 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29427 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29428 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29429 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
29430 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29431 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29432 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceOperationGetCall<'a, C>
29433 where
29434 T: AsRef<str>,
29435 {
29436 self._additional_params
29437 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29438 self
29439 }
29440
29441 /// Identifies the authorization scope for the method you are building.
29442 ///
29443 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29444 /// [`Scope::CloudPlatform`].
29445 ///
29446 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29447 /// tokens for more than one scope.
29448 ///
29449 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29450 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29451 /// sufficient, a read-write scope will do as well.
29452 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceOperationGetCall<'a, C>
29453 where
29454 St: AsRef<str>,
29455 {
29456 self._scopes.insert(String::from(scope.as_ref()));
29457 self
29458 }
29459 /// Identifies the authorization scope(s) for the method you are building.
29460 ///
29461 /// See [`Self::add_scope()`] for details.
29462 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceOperationGetCall<'a, C>
29463 where
29464 I: IntoIterator<Item = St>,
29465 St: AsRef<str>,
29466 {
29467 self._scopes
29468 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29469 self
29470 }
29471
29472 /// Removes all scopes, and no default scope will be used either.
29473 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29474 /// for details).
29475 pub fn clear_scopes(mut self) -> ProjectInstanceOperationGetCall<'a, C> {
29476 self._scopes.clear();
29477 self
29478 }
29479}
29480
29481/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
29482///
29483/// A builder for the *instances.operations.list* method supported by a *project* resource.
29484/// It is not used directly, but through a [`ProjectMethods`] instance.
29485///
29486/// # Example
29487///
29488/// Instantiate a resource method builder
29489///
29490/// ```test_harness,no_run
29491/// # extern crate hyper;
29492/// # extern crate hyper_rustls;
29493/// # extern crate google_spanner1 as spanner1;
29494/// # async fn dox() {
29495/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29496///
29497/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29498/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29499/// # secret,
29500/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29501/// # ).build().await.unwrap();
29502///
29503/// # let client = hyper_util::client::legacy::Client::builder(
29504/// # hyper_util::rt::TokioExecutor::new()
29505/// # )
29506/// # .build(
29507/// # hyper_rustls::HttpsConnectorBuilder::new()
29508/// # .with_native_roots()
29509/// # .unwrap()
29510/// # .https_or_http()
29511/// # .enable_http1()
29512/// # .build()
29513/// # );
29514/// # let mut hub = Spanner::new(client, auth);
29515/// // You can configure optional parameters by calling the respective setters at will, and
29516/// // execute the final call using `doit()`.
29517/// // Values shown here are possibly random and not representative !
29518/// let result = hub.projects().instances_operations_list("name")
29519/// .page_token("diam")
29520/// .page_size(-57)
29521/// .filter("sit")
29522/// .doit().await;
29523/// # }
29524/// ```
29525pub struct ProjectInstanceOperationListCall<'a, C>
29526where
29527 C: 'a,
29528{
29529 hub: &'a Spanner<C>,
29530 _name: String,
29531 _page_token: Option<String>,
29532 _page_size: Option<i32>,
29533 _filter: Option<String>,
29534 _delegate: Option<&'a mut dyn common::Delegate>,
29535 _additional_params: HashMap<String, String>,
29536 _scopes: BTreeSet<String>,
29537}
29538
29539impl<'a, C> common::CallBuilder for ProjectInstanceOperationListCall<'a, C> {}
29540
29541impl<'a, C> ProjectInstanceOperationListCall<'a, C>
29542where
29543 C: common::Connector,
29544{
29545 /// Perform the operation you have build so far.
29546 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
29547 use std::borrow::Cow;
29548 use std::io::{Read, Seek};
29549
29550 use common::{url::Params, ToParts};
29551 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29552
29553 let mut dd = common::DefaultDelegate;
29554 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29555 dlg.begin(common::MethodInfo {
29556 id: "spanner.projects.instances.operations.list",
29557 http_method: hyper::Method::GET,
29558 });
29559
29560 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
29561 if self._additional_params.contains_key(field) {
29562 dlg.finished(false);
29563 return Err(common::Error::FieldClash(field));
29564 }
29565 }
29566
29567 let mut params = Params::with_capacity(6 + self._additional_params.len());
29568 params.push("name", self._name);
29569 if let Some(value) = self._page_token.as_ref() {
29570 params.push("pageToken", value);
29571 }
29572 if let Some(value) = self._page_size.as_ref() {
29573 params.push("pageSize", value.to_string());
29574 }
29575 if let Some(value) = self._filter.as_ref() {
29576 params.push("filter", value);
29577 }
29578
29579 params.extend(self._additional_params.iter());
29580
29581 params.push("alt", "json");
29582 let mut url = self.hub._base_url.clone() + "v1/{+name}";
29583 if self._scopes.is_empty() {
29584 self._scopes
29585 .insert(Scope::CloudPlatform.as_ref().to_string());
29586 }
29587
29588 #[allow(clippy::single_element_loop)]
29589 for &(find_this, param_name) in [("{+name}", "name")].iter() {
29590 url = params.uri_replacement(url, param_name, find_this, true);
29591 }
29592 {
29593 let to_remove = ["name"];
29594 params.remove_params(&to_remove);
29595 }
29596
29597 let url = params.parse_with_url(&url);
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 let mut req_result = {
29616 let client = &self.hub.client;
29617 dlg.pre_request();
29618 let mut req_builder = hyper::Request::builder()
29619 .method(hyper::Method::GET)
29620 .uri(url.as_str())
29621 .header(USER_AGENT, self.hub._user_agent.clone());
29622
29623 if let Some(token) = token.as_ref() {
29624 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29625 }
29626
29627 let request = req_builder
29628 .header(CONTENT_LENGTH, 0_u64)
29629 .body(common::to_body::<String>(None));
29630
29631 client.request(request.unwrap()).await
29632 };
29633
29634 match req_result {
29635 Err(err) => {
29636 if let common::Retry::After(d) = dlg.http_error(&err) {
29637 sleep(d).await;
29638 continue;
29639 }
29640 dlg.finished(false);
29641 return Err(common::Error::HttpError(err));
29642 }
29643 Ok(res) => {
29644 let (mut parts, body) = res.into_parts();
29645 let mut body = common::Body::new(body);
29646 if !parts.status.is_success() {
29647 let bytes = common::to_bytes(body).await.unwrap_or_default();
29648 let error = serde_json::from_str(&common::to_string(&bytes));
29649 let response = common::to_response(parts, bytes.into());
29650
29651 if let common::Retry::After(d) =
29652 dlg.http_failure(&response, error.as_ref().ok())
29653 {
29654 sleep(d).await;
29655 continue;
29656 }
29657
29658 dlg.finished(false);
29659
29660 return Err(match error {
29661 Ok(value) => common::Error::BadRequest(value),
29662 _ => common::Error::Failure(response),
29663 });
29664 }
29665 let response = {
29666 let bytes = common::to_bytes(body).await.unwrap_or_default();
29667 let encoded = common::to_string(&bytes);
29668 match serde_json::from_str(&encoded) {
29669 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29670 Err(error) => {
29671 dlg.response_json_decode_error(&encoded, &error);
29672 return Err(common::Error::JsonDecodeError(
29673 encoded.to_string(),
29674 error,
29675 ));
29676 }
29677 }
29678 };
29679
29680 dlg.finished(true);
29681 return Ok(response);
29682 }
29683 }
29684 }
29685 }
29686
29687 /// The name of the operation's parent resource.
29688 ///
29689 /// Sets the *name* path property to the given value.
29690 ///
29691 /// Even though the property as already been set when instantiating this call,
29692 /// we provide this method for API completeness.
29693 pub fn name(mut self, new_value: &str) -> ProjectInstanceOperationListCall<'a, C> {
29694 self._name = new_value.to_string();
29695 self
29696 }
29697 /// The standard list page token.
29698 ///
29699 /// Sets the *page token* query property to the given value.
29700 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceOperationListCall<'a, C> {
29701 self._page_token = Some(new_value.to_string());
29702 self
29703 }
29704 /// The standard list page size.
29705 ///
29706 /// Sets the *page size* query property to the given value.
29707 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceOperationListCall<'a, C> {
29708 self._page_size = Some(new_value);
29709 self
29710 }
29711 /// The standard list filter.
29712 ///
29713 /// Sets the *filter* query property to the given value.
29714 pub fn filter(mut self, new_value: &str) -> ProjectInstanceOperationListCall<'a, C> {
29715 self._filter = Some(new_value.to_string());
29716 self
29717 }
29718 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29719 /// while executing the actual API request.
29720 ///
29721 /// ````text
29722 /// It should be used to handle progress information, and to implement a certain level of resilience.
29723 /// ````
29724 ///
29725 /// Sets the *delegate* property to the given value.
29726 pub fn delegate(
29727 mut self,
29728 new_value: &'a mut dyn common::Delegate,
29729 ) -> ProjectInstanceOperationListCall<'a, C> {
29730 self._delegate = Some(new_value);
29731 self
29732 }
29733
29734 /// Set any additional parameter of the query string used in the request.
29735 /// It should be used to set parameters which are not yet available through their own
29736 /// setters.
29737 ///
29738 /// Please note that this method must not be used to set any of the known parameters
29739 /// which have their own setter method. If done anyway, the request will fail.
29740 ///
29741 /// # Additional Parameters
29742 ///
29743 /// * *$.xgafv* (query-string) - V1 error format.
29744 /// * *access_token* (query-string) - OAuth access token.
29745 /// * *alt* (query-string) - Data format for response.
29746 /// * *callback* (query-string) - JSONP
29747 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29748 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29749 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29750 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29751 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
29752 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29753 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29754 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceOperationListCall<'a, C>
29755 where
29756 T: AsRef<str>,
29757 {
29758 self._additional_params
29759 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29760 self
29761 }
29762
29763 /// Identifies the authorization scope for the method you are building.
29764 ///
29765 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29766 /// [`Scope::CloudPlatform`].
29767 ///
29768 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29769 /// tokens for more than one scope.
29770 ///
29771 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29772 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29773 /// sufficient, a read-write scope will do as well.
29774 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceOperationListCall<'a, C>
29775 where
29776 St: AsRef<str>,
29777 {
29778 self._scopes.insert(String::from(scope.as_ref()));
29779 self
29780 }
29781 /// Identifies the authorization scope(s) for the method you are building.
29782 ///
29783 /// See [`Self::add_scope()`] for details.
29784 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceOperationListCall<'a, C>
29785 where
29786 I: IntoIterator<Item = St>,
29787 St: AsRef<str>,
29788 {
29789 self._scopes
29790 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29791 self
29792 }
29793
29794 /// Removes all scopes, and no default scope will be used either.
29795 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29796 /// for details).
29797 pub fn clear_scopes(mut self) -> ProjectInstanceOperationListCall<'a, C> {
29798 self._scopes.clear();
29799 self
29800 }
29801}
29802
29803/// 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.
29804///
29805/// A builder for the *instances.create* method supported by a *project* resource.
29806/// It is not used directly, but through a [`ProjectMethods`] instance.
29807///
29808/// # Example
29809///
29810/// Instantiate a resource method builder
29811///
29812/// ```test_harness,no_run
29813/// # extern crate hyper;
29814/// # extern crate hyper_rustls;
29815/// # extern crate google_spanner1 as spanner1;
29816/// use spanner1::api::CreateInstanceRequest;
29817/// # async fn dox() {
29818/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29819///
29820/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29821/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29822/// # secret,
29823/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29824/// # ).build().await.unwrap();
29825///
29826/// # let client = hyper_util::client::legacy::Client::builder(
29827/// # hyper_util::rt::TokioExecutor::new()
29828/// # )
29829/// # .build(
29830/// # hyper_rustls::HttpsConnectorBuilder::new()
29831/// # .with_native_roots()
29832/// # .unwrap()
29833/// # .https_or_http()
29834/// # .enable_http1()
29835/// # .build()
29836/// # );
29837/// # let mut hub = Spanner::new(client, auth);
29838/// // As the method needs a request, you would usually fill it with the desired information
29839/// // into the respective structure. Some of the parts shown here might not be applicable !
29840/// // Values shown here are possibly random and not representative !
29841/// let mut req = CreateInstanceRequest::default();
29842///
29843/// // You can configure optional parameters by calling the respective setters at will, and
29844/// // execute the final call using `doit()`.
29845/// // Values shown here are possibly random and not representative !
29846/// let result = hub.projects().instances_create(req, "parent")
29847/// .doit().await;
29848/// # }
29849/// ```
29850pub struct ProjectInstanceCreateCall<'a, C>
29851where
29852 C: 'a,
29853{
29854 hub: &'a Spanner<C>,
29855 _request: CreateInstanceRequest,
29856 _parent: String,
29857 _delegate: Option<&'a mut dyn common::Delegate>,
29858 _additional_params: HashMap<String, String>,
29859 _scopes: BTreeSet<String>,
29860}
29861
29862impl<'a, C> common::CallBuilder for ProjectInstanceCreateCall<'a, C> {}
29863
29864impl<'a, C> ProjectInstanceCreateCall<'a, C>
29865where
29866 C: common::Connector,
29867{
29868 /// Perform the operation you have build so far.
29869 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
29870 use std::borrow::Cow;
29871 use std::io::{Read, Seek};
29872
29873 use common::{url::Params, ToParts};
29874 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29875
29876 let mut dd = common::DefaultDelegate;
29877 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29878 dlg.begin(common::MethodInfo {
29879 id: "spanner.projects.instances.create",
29880 http_method: hyper::Method::POST,
29881 });
29882
29883 for &field in ["alt", "parent"].iter() {
29884 if self._additional_params.contains_key(field) {
29885 dlg.finished(false);
29886 return Err(common::Error::FieldClash(field));
29887 }
29888 }
29889
29890 let mut params = Params::with_capacity(4 + self._additional_params.len());
29891 params.push("parent", self._parent);
29892
29893 params.extend(self._additional_params.iter());
29894
29895 params.push("alt", "json");
29896 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
29897 if self._scopes.is_empty() {
29898 self._scopes
29899 .insert(Scope::CloudPlatform.as_ref().to_string());
29900 }
29901
29902 #[allow(clippy::single_element_loop)]
29903 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
29904 url = params.uri_replacement(url, param_name, find_this, true);
29905 }
29906 {
29907 let to_remove = ["parent"];
29908 params.remove_params(&to_remove);
29909 }
29910
29911 let url = params.parse_with_url(&url);
29912
29913 let mut json_mime_type = mime::APPLICATION_JSON;
29914 let mut request_value_reader = {
29915 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29916 common::remove_json_null_values(&mut value);
29917 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29918 serde_json::to_writer(&mut dst, &value).unwrap();
29919 dst
29920 };
29921 let request_size = request_value_reader
29922 .seek(std::io::SeekFrom::End(0))
29923 .unwrap();
29924 request_value_reader
29925 .seek(std::io::SeekFrom::Start(0))
29926 .unwrap();
29927
29928 loop {
29929 let token = match self
29930 .hub
29931 .auth
29932 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29933 .await
29934 {
29935 Ok(token) => token,
29936 Err(e) => match dlg.token(e) {
29937 Ok(token) => token,
29938 Err(e) => {
29939 dlg.finished(false);
29940 return Err(common::Error::MissingToken(e));
29941 }
29942 },
29943 };
29944 request_value_reader
29945 .seek(std::io::SeekFrom::Start(0))
29946 .unwrap();
29947 let mut req_result = {
29948 let client = &self.hub.client;
29949 dlg.pre_request();
29950 let mut req_builder = hyper::Request::builder()
29951 .method(hyper::Method::POST)
29952 .uri(url.as_str())
29953 .header(USER_AGENT, self.hub._user_agent.clone());
29954
29955 if let Some(token) = token.as_ref() {
29956 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29957 }
29958
29959 let request = req_builder
29960 .header(CONTENT_TYPE, json_mime_type.to_string())
29961 .header(CONTENT_LENGTH, request_size as u64)
29962 .body(common::to_body(
29963 request_value_reader.get_ref().clone().into(),
29964 ));
29965
29966 client.request(request.unwrap()).await
29967 };
29968
29969 match req_result {
29970 Err(err) => {
29971 if let common::Retry::After(d) = dlg.http_error(&err) {
29972 sleep(d).await;
29973 continue;
29974 }
29975 dlg.finished(false);
29976 return Err(common::Error::HttpError(err));
29977 }
29978 Ok(res) => {
29979 let (mut parts, body) = res.into_parts();
29980 let mut body = common::Body::new(body);
29981 if !parts.status.is_success() {
29982 let bytes = common::to_bytes(body).await.unwrap_or_default();
29983 let error = serde_json::from_str(&common::to_string(&bytes));
29984 let response = common::to_response(parts, bytes.into());
29985
29986 if let common::Retry::After(d) =
29987 dlg.http_failure(&response, error.as_ref().ok())
29988 {
29989 sleep(d).await;
29990 continue;
29991 }
29992
29993 dlg.finished(false);
29994
29995 return Err(match error {
29996 Ok(value) => common::Error::BadRequest(value),
29997 _ => common::Error::Failure(response),
29998 });
29999 }
30000 let response = {
30001 let bytes = common::to_bytes(body).await.unwrap_or_default();
30002 let encoded = common::to_string(&bytes);
30003 match serde_json::from_str(&encoded) {
30004 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30005 Err(error) => {
30006 dlg.response_json_decode_error(&encoded, &error);
30007 return Err(common::Error::JsonDecodeError(
30008 encoded.to_string(),
30009 error,
30010 ));
30011 }
30012 }
30013 };
30014
30015 dlg.finished(true);
30016 return Ok(response);
30017 }
30018 }
30019 }
30020 }
30021
30022 ///
30023 /// Sets the *request* property to the given value.
30024 ///
30025 /// Even though the property as already been set when instantiating this call,
30026 /// we provide this method for API completeness.
30027 pub fn request(mut self, new_value: CreateInstanceRequest) -> ProjectInstanceCreateCall<'a, C> {
30028 self._request = new_value;
30029 self
30030 }
30031 /// Required. The name of the project in which to create the instance. Values are of the form `projects/`.
30032 ///
30033 /// Sets the *parent* path property to the given value.
30034 ///
30035 /// Even though the property as already been set when instantiating this call,
30036 /// we provide this method for API completeness.
30037 pub fn parent(mut self, new_value: &str) -> ProjectInstanceCreateCall<'a, C> {
30038 self._parent = new_value.to_string();
30039 self
30040 }
30041 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30042 /// while executing the actual API request.
30043 ///
30044 /// ````text
30045 /// It should be used to handle progress information, and to implement a certain level of resilience.
30046 /// ````
30047 ///
30048 /// Sets the *delegate* property to the given value.
30049 pub fn delegate(
30050 mut self,
30051 new_value: &'a mut dyn common::Delegate,
30052 ) -> ProjectInstanceCreateCall<'a, C> {
30053 self._delegate = Some(new_value);
30054 self
30055 }
30056
30057 /// Set any additional parameter of the query string used in the request.
30058 /// It should be used to set parameters which are not yet available through their own
30059 /// setters.
30060 ///
30061 /// Please note that this method must not be used to set any of the known parameters
30062 /// which have their own setter method. If done anyway, the request will fail.
30063 ///
30064 /// # Additional Parameters
30065 ///
30066 /// * *$.xgafv* (query-string) - V1 error format.
30067 /// * *access_token* (query-string) - OAuth access token.
30068 /// * *alt* (query-string) - Data format for response.
30069 /// * *callback* (query-string) - JSONP
30070 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30071 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30072 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30073 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30074 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
30075 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30076 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30077 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceCreateCall<'a, C>
30078 where
30079 T: AsRef<str>,
30080 {
30081 self._additional_params
30082 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30083 self
30084 }
30085
30086 /// Identifies the authorization scope for the method you are building.
30087 ///
30088 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30089 /// [`Scope::CloudPlatform`].
30090 ///
30091 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30092 /// tokens for more than one scope.
30093 ///
30094 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30095 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30096 /// sufficient, a read-write scope will do as well.
30097 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceCreateCall<'a, C>
30098 where
30099 St: AsRef<str>,
30100 {
30101 self._scopes.insert(String::from(scope.as_ref()));
30102 self
30103 }
30104 /// Identifies the authorization scope(s) for the method you are building.
30105 ///
30106 /// See [`Self::add_scope()`] for details.
30107 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceCreateCall<'a, C>
30108 where
30109 I: IntoIterator<Item = St>,
30110 St: AsRef<str>,
30111 {
30112 self._scopes
30113 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30114 self
30115 }
30116
30117 /// Removes all scopes, and no default scope will be used either.
30118 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30119 /// for details).
30120 pub fn clear_scopes(mut self) -> ProjectInstanceCreateCall<'a, C> {
30121 self._scopes.clear();
30122 self
30123 }
30124}
30125
30126/// 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.
30127///
30128/// A builder for the *instances.delete* method supported by a *project* resource.
30129/// It is not used directly, but through a [`ProjectMethods`] instance.
30130///
30131/// # Example
30132///
30133/// Instantiate a resource method builder
30134///
30135/// ```test_harness,no_run
30136/// # extern crate hyper;
30137/// # extern crate hyper_rustls;
30138/// # extern crate google_spanner1 as spanner1;
30139/// # async fn dox() {
30140/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30141///
30142/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30143/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30144/// # secret,
30145/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30146/// # ).build().await.unwrap();
30147///
30148/// # let client = hyper_util::client::legacy::Client::builder(
30149/// # hyper_util::rt::TokioExecutor::new()
30150/// # )
30151/// # .build(
30152/// # hyper_rustls::HttpsConnectorBuilder::new()
30153/// # .with_native_roots()
30154/// # .unwrap()
30155/// # .https_or_http()
30156/// # .enable_http1()
30157/// # .build()
30158/// # );
30159/// # let mut hub = Spanner::new(client, auth);
30160/// // You can configure optional parameters by calling the respective setters at will, and
30161/// // execute the final call using `doit()`.
30162/// // Values shown here are possibly random and not representative !
30163/// let result = hub.projects().instances_delete("name")
30164/// .doit().await;
30165/// # }
30166/// ```
30167pub struct ProjectInstanceDeleteCall<'a, C>
30168where
30169 C: 'a,
30170{
30171 hub: &'a Spanner<C>,
30172 _name: String,
30173 _delegate: Option<&'a mut dyn common::Delegate>,
30174 _additional_params: HashMap<String, String>,
30175 _scopes: BTreeSet<String>,
30176}
30177
30178impl<'a, C> common::CallBuilder for ProjectInstanceDeleteCall<'a, C> {}
30179
30180impl<'a, C> ProjectInstanceDeleteCall<'a, C>
30181where
30182 C: common::Connector,
30183{
30184 /// Perform the operation you have build so far.
30185 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
30186 use std::borrow::Cow;
30187 use std::io::{Read, Seek};
30188
30189 use common::{url::Params, ToParts};
30190 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30191
30192 let mut dd = common::DefaultDelegate;
30193 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30194 dlg.begin(common::MethodInfo {
30195 id: "spanner.projects.instances.delete",
30196 http_method: hyper::Method::DELETE,
30197 });
30198
30199 for &field in ["alt", "name"].iter() {
30200 if self._additional_params.contains_key(field) {
30201 dlg.finished(false);
30202 return Err(common::Error::FieldClash(field));
30203 }
30204 }
30205
30206 let mut params = Params::with_capacity(3 + self._additional_params.len());
30207 params.push("name", self._name);
30208
30209 params.extend(self._additional_params.iter());
30210
30211 params.push("alt", "json");
30212 let mut url = self.hub._base_url.clone() + "v1/{+name}";
30213 if self._scopes.is_empty() {
30214 self._scopes
30215 .insert(Scope::CloudPlatform.as_ref().to_string());
30216 }
30217
30218 #[allow(clippy::single_element_loop)]
30219 for &(find_this, param_name) in [("{+name}", "name")].iter() {
30220 url = params.uri_replacement(url, param_name, find_this, true);
30221 }
30222 {
30223 let to_remove = ["name"];
30224 params.remove_params(&to_remove);
30225 }
30226
30227 let url = params.parse_with_url(&url);
30228
30229 loop {
30230 let token = match self
30231 .hub
30232 .auth
30233 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30234 .await
30235 {
30236 Ok(token) => token,
30237 Err(e) => match dlg.token(e) {
30238 Ok(token) => token,
30239 Err(e) => {
30240 dlg.finished(false);
30241 return Err(common::Error::MissingToken(e));
30242 }
30243 },
30244 };
30245 let mut req_result = {
30246 let client = &self.hub.client;
30247 dlg.pre_request();
30248 let mut req_builder = hyper::Request::builder()
30249 .method(hyper::Method::DELETE)
30250 .uri(url.as_str())
30251 .header(USER_AGENT, self.hub._user_agent.clone());
30252
30253 if let Some(token) = token.as_ref() {
30254 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30255 }
30256
30257 let request = req_builder
30258 .header(CONTENT_LENGTH, 0_u64)
30259 .body(common::to_body::<String>(None));
30260
30261 client.request(request.unwrap()).await
30262 };
30263
30264 match req_result {
30265 Err(err) => {
30266 if let common::Retry::After(d) = dlg.http_error(&err) {
30267 sleep(d).await;
30268 continue;
30269 }
30270 dlg.finished(false);
30271 return Err(common::Error::HttpError(err));
30272 }
30273 Ok(res) => {
30274 let (mut parts, body) = res.into_parts();
30275 let mut body = common::Body::new(body);
30276 if !parts.status.is_success() {
30277 let bytes = common::to_bytes(body).await.unwrap_or_default();
30278 let error = serde_json::from_str(&common::to_string(&bytes));
30279 let response = common::to_response(parts, bytes.into());
30280
30281 if let common::Retry::After(d) =
30282 dlg.http_failure(&response, error.as_ref().ok())
30283 {
30284 sleep(d).await;
30285 continue;
30286 }
30287
30288 dlg.finished(false);
30289
30290 return Err(match error {
30291 Ok(value) => common::Error::BadRequest(value),
30292 _ => common::Error::Failure(response),
30293 });
30294 }
30295 let response = {
30296 let bytes = common::to_bytes(body).await.unwrap_or_default();
30297 let encoded = common::to_string(&bytes);
30298 match serde_json::from_str(&encoded) {
30299 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30300 Err(error) => {
30301 dlg.response_json_decode_error(&encoded, &error);
30302 return Err(common::Error::JsonDecodeError(
30303 encoded.to_string(),
30304 error,
30305 ));
30306 }
30307 }
30308 };
30309
30310 dlg.finished(true);
30311 return Ok(response);
30312 }
30313 }
30314 }
30315 }
30316
30317 /// Required. The name of the instance to be deleted. Values are of the form `projects//instances/`
30318 ///
30319 /// Sets the *name* path property to the given value.
30320 ///
30321 /// Even though the property as already been set when instantiating this call,
30322 /// we provide this method for API completeness.
30323 pub fn name(mut self, new_value: &str) -> ProjectInstanceDeleteCall<'a, C> {
30324 self._name = new_value.to_string();
30325 self
30326 }
30327 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30328 /// while executing the actual API request.
30329 ///
30330 /// ````text
30331 /// It should be used to handle progress information, and to implement a certain level of resilience.
30332 /// ````
30333 ///
30334 /// Sets the *delegate* property to the given value.
30335 pub fn delegate(
30336 mut self,
30337 new_value: &'a mut dyn common::Delegate,
30338 ) -> ProjectInstanceDeleteCall<'a, C> {
30339 self._delegate = Some(new_value);
30340 self
30341 }
30342
30343 /// Set any additional parameter of the query string used in the request.
30344 /// It should be used to set parameters which are not yet available through their own
30345 /// setters.
30346 ///
30347 /// Please note that this method must not be used to set any of the known parameters
30348 /// which have their own setter method. If done anyway, the request will fail.
30349 ///
30350 /// # Additional Parameters
30351 ///
30352 /// * *$.xgafv* (query-string) - V1 error format.
30353 /// * *access_token* (query-string) - OAuth access token.
30354 /// * *alt* (query-string) - Data format for response.
30355 /// * *callback* (query-string) - JSONP
30356 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30357 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30358 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30359 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30360 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
30361 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30362 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30363 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceDeleteCall<'a, C>
30364 where
30365 T: AsRef<str>,
30366 {
30367 self._additional_params
30368 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30369 self
30370 }
30371
30372 /// Identifies the authorization scope for the method you are building.
30373 ///
30374 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30375 /// [`Scope::CloudPlatform`].
30376 ///
30377 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30378 /// tokens for more than one scope.
30379 ///
30380 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30381 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30382 /// sufficient, a read-write scope will do as well.
30383 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceDeleteCall<'a, C>
30384 where
30385 St: AsRef<str>,
30386 {
30387 self._scopes.insert(String::from(scope.as_ref()));
30388 self
30389 }
30390 /// Identifies the authorization scope(s) for the method you are building.
30391 ///
30392 /// See [`Self::add_scope()`] for details.
30393 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceDeleteCall<'a, C>
30394 where
30395 I: IntoIterator<Item = St>,
30396 St: AsRef<str>,
30397 {
30398 self._scopes
30399 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30400 self
30401 }
30402
30403 /// Removes all scopes, and no default scope will be used either.
30404 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30405 /// for details).
30406 pub fn clear_scopes(mut self) -> ProjectInstanceDeleteCall<'a, C> {
30407 self._scopes.clear();
30408 self
30409 }
30410}
30411
30412/// Gets information about a particular instance.
30413///
30414/// A builder for the *instances.get* method supported by a *project* resource.
30415/// It is not used directly, but through a [`ProjectMethods`] instance.
30416///
30417/// # Example
30418///
30419/// Instantiate a resource method builder
30420///
30421/// ```test_harness,no_run
30422/// # extern crate hyper;
30423/// # extern crate hyper_rustls;
30424/// # extern crate google_spanner1 as spanner1;
30425/// # async fn dox() {
30426/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30427///
30428/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30429/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30430/// # secret,
30431/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30432/// # ).build().await.unwrap();
30433///
30434/// # let client = hyper_util::client::legacy::Client::builder(
30435/// # hyper_util::rt::TokioExecutor::new()
30436/// # )
30437/// # .build(
30438/// # hyper_rustls::HttpsConnectorBuilder::new()
30439/// # .with_native_roots()
30440/// # .unwrap()
30441/// # .https_or_http()
30442/// # .enable_http1()
30443/// # .build()
30444/// # );
30445/// # let mut hub = Spanner::new(client, auth);
30446/// // You can configure optional parameters by calling the respective setters at will, and
30447/// // execute the final call using `doit()`.
30448/// // Values shown here are possibly random and not representative !
30449/// let result = hub.projects().instances_get("name")
30450/// .field_mask(FieldMask::new::<&str>(&[]))
30451/// .doit().await;
30452/// # }
30453/// ```
30454pub struct ProjectInstanceGetCall<'a, C>
30455where
30456 C: 'a,
30457{
30458 hub: &'a Spanner<C>,
30459 _name: String,
30460 _field_mask: Option<common::FieldMask>,
30461 _delegate: Option<&'a mut dyn common::Delegate>,
30462 _additional_params: HashMap<String, String>,
30463 _scopes: BTreeSet<String>,
30464}
30465
30466impl<'a, C> common::CallBuilder for ProjectInstanceGetCall<'a, C> {}
30467
30468impl<'a, C> ProjectInstanceGetCall<'a, C>
30469where
30470 C: common::Connector,
30471{
30472 /// Perform the operation you have build so far.
30473 pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
30474 use std::borrow::Cow;
30475 use std::io::{Read, Seek};
30476
30477 use common::{url::Params, ToParts};
30478 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30479
30480 let mut dd = common::DefaultDelegate;
30481 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30482 dlg.begin(common::MethodInfo {
30483 id: "spanner.projects.instances.get",
30484 http_method: hyper::Method::GET,
30485 });
30486
30487 for &field in ["alt", "name", "fieldMask"].iter() {
30488 if self._additional_params.contains_key(field) {
30489 dlg.finished(false);
30490 return Err(common::Error::FieldClash(field));
30491 }
30492 }
30493
30494 let mut params = Params::with_capacity(4 + self._additional_params.len());
30495 params.push("name", self._name);
30496 if let Some(value) = self._field_mask.as_ref() {
30497 params.push("fieldMask", value.to_string());
30498 }
30499
30500 params.extend(self._additional_params.iter());
30501
30502 params.push("alt", "json");
30503 let mut url = self.hub._base_url.clone() + "v1/{+name}";
30504 if self._scopes.is_empty() {
30505 self._scopes
30506 .insert(Scope::CloudPlatform.as_ref().to_string());
30507 }
30508
30509 #[allow(clippy::single_element_loop)]
30510 for &(find_this, param_name) in [("{+name}", "name")].iter() {
30511 url = params.uri_replacement(url, param_name, find_this, true);
30512 }
30513 {
30514 let to_remove = ["name"];
30515 params.remove_params(&to_remove);
30516 }
30517
30518 let url = params.parse_with_url(&url);
30519
30520 loop {
30521 let token = match self
30522 .hub
30523 .auth
30524 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30525 .await
30526 {
30527 Ok(token) => token,
30528 Err(e) => match dlg.token(e) {
30529 Ok(token) => token,
30530 Err(e) => {
30531 dlg.finished(false);
30532 return Err(common::Error::MissingToken(e));
30533 }
30534 },
30535 };
30536 let mut req_result = {
30537 let client = &self.hub.client;
30538 dlg.pre_request();
30539 let mut req_builder = hyper::Request::builder()
30540 .method(hyper::Method::GET)
30541 .uri(url.as_str())
30542 .header(USER_AGENT, self.hub._user_agent.clone());
30543
30544 if let Some(token) = token.as_ref() {
30545 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30546 }
30547
30548 let request = req_builder
30549 .header(CONTENT_LENGTH, 0_u64)
30550 .body(common::to_body::<String>(None));
30551
30552 client.request(request.unwrap()).await
30553 };
30554
30555 match req_result {
30556 Err(err) => {
30557 if let common::Retry::After(d) = dlg.http_error(&err) {
30558 sleep(d).await;
30559 continue;
30560 }
30561 dlg.finished(false);
30562 return Err(common::Error::HttpError(err));
30563 }
30564 Ok(res) => {
30565 let (mut parts, body) = res.into_parts();
30566 let mut body = common::Body::new(body);
30567 if !parts.status.is_success() {
30568 let bytes = common::to_bytes(body).await.unwrap_or_default();
30569 let error = serde_json::from_str(&common::to_string(&bytes));
30570 let response = common::to_response(parts, bytes.into());
30571
30572 if let common::Retry::After(d) =
30573 dlg.http_failure(&response, error.as_ref().ok())
30574 {
30575 sleep(d).await;
30576 continue;
30577 }
30578
30579 dlg.finished(false);
30580
30581 return Err(match error {
30582 Ok(value) => common::Error::BadRequest(value),
30583 _ => common::Error::Failure(response),
30584 });
30585 }
30586 let response = {
30587 let bytes = common::to_bytes(body).await.unwrap_or_default();
30588 let encoded = common::to_string(&bytes);
30589 match serde_json::from_str(&encoded) {
30590 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30591 Err(error) => {
30592 dlg.response_json_decode_error(&encoded, &error);
30593 return Err(common::Error::JsonDecodeError(
30594 encoded.to_string(),
30595 error,
30596 ));
30597 }
30598 }
30599 };
30600
30601 dlg.finished(true);
30602 return Ok(response);
30603 }
30604 }
30605 }
30606 }
30607
30608 /// Required. The name of the requested instance. Values are of the form `projects//instances/`.
30609 ///
30610 /// Sets the *name* path property to the given value.
30611 ///
30612 /// Even though the property as already been set when instantiating this call,
30613 /// we provide this method for API completeness.
30614 pub fn name(mut self, new_value: &str) -> ProjectInstanceGetCall<'a, C> {
30615 self._name = new_value.to_string();
30616 self
30617 }
30618 /// If field_mask is present, specifies the subset of Instance fields that should be returned. If absent, all Instance fields are returned.
30619 ///
30620 /// Sets the *field mask* query property to the given value.
30621 pub fn field_mask(mut self, new_value: common::FieldMask) -> ProjectInstanceGetCall<'a, C> {
30622 self._field_mask = Some(new_value);
30623 self
30624 }
30625 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30626 /// while executing the actual API request.
30627 ///
30628 /// ````text
30629 /// It should be used to handle progress information, and to implement a certain level of resilience.
30630 /// ````
30631 ///
30632 /// Sets the *delegate* property to the given value.
30633 pub fn delegate(
30634 mut self,
30635 new_value: &'a mut dyn common::Delegate,
30636 ) -> ProjectInstanceGetCall<'a, C> {
30637 self._delegate = Some(new_value);
30638 self
30639 }
30640
30641 /// Set any additional parameter of the query string used in the request.
30642 /// It should be used to set parameters which are not yet available through their own
30643 /// setters.
30644 ///
30645 /// Please note that this method must not be used to set any of the known parameters
30646 /// which have their own setter method. If done anyway, the request will fail.
30647 ///
30648 /// # Additional Parameters
30649 ///
30650 /// * *$.xgafv* (query-string) - V1 error format.
30651 /// * *access_token* (query-string) - OAuth access token.
30652 /// * *alt* (query-string) - Data format for response.
30653 /// * *callback* (query-string) - JSONP
30654 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30655 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30656 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30657 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30658 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
30659 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30660 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30661 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceGetCall<'a, C>
30662 where
30663 T: AsRef<str>,
30664 {
30665 self._additional_params
30666 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30667 self
30668 }
30669
30670 /// Identifies the authorization scope for the method you are building.
30671 ///
30672 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30673 /// [`Scope::CloudPlatform`].
30674 ///
30675 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30676 /// tokens for more than one scope.
30677 ///
30678 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30679 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30680 /// sufficient, a read-write scope will do as well.
30681 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceGetCall<'a, C>
30682 where
30683 St: AsRef<str>,
30684 {
30685 self._scopes.insert(String::from(scope.as_ref()));
30686 self
30687 }
30688 /// Identifies the authorization scope(s) for the method you are building.
30689 ///
30690 /// See [`Self::add_scope()`] for details.
30691 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceGetCall<'a, C>
30692 where
30693 I: IntoIterator<Item = St>,
30694 St: AsRef<str>,
30695 {
30696 self._scopes
30697 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30698 self
30699 }
30700
30701 /// Removes all scopes, and no default scope will be used either.
30702 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30703 /// for details).
30704 pub fn clear_scopes(mut self) -> ProjectInstanceGetCall<'a, C> {
30705 self._scopes.clear();
30706 self
30707 }
30708}
30709
30710/// 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.
30711///
30712/// A builder for the *instances.getIamPolicy* method supported by a *project* resource.
30713/// It is not used directly, but through a [`ProjectMethods`] instance.
30714///
30715/// # Example
30716///
30717/// Instantiate a resource method builder
30718///
30719/// ```test_harness,no_run
30720/// # extern crate hyper;
30721/// # extern crate hyper_rustls;
30722/// # extern crate google_spanner1 as spanner1;
30723/// use spanner1::api::GetIamPolicyRequest;
30724/// # async fn dox() {
30725/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30726///
30727/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30728/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30729/// # secret,
30730/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30731/// # ).build().await.unwrap();
30732///
30733/// # let client = hyper_util::client::legacy::Client::builder(
30734/// # hyper_util::rt::TokioExecutor::new()
30735/// # )
30736/// # .build(
30737/// # hyper_rustls::HttpsConnectorBuilder::new()
30738/// # .with_native_roots()
30739/// # .unwrap()
30740/// # .https_or_http()
30741/// # .enable_http1()
30742/// # .build()
30743/// # );
30744/// # let mut hub = Spanner::new(client, auth);
30745/// // As the method needs a request, you would usually fill it with the desired information
30746/// // into the respective structure. Some of the parts shown here might not be applicable !
30747/// // Values shown here are possibly random and not representative !
30748/// let mut req = GetIamPolicyRequest::default();
30749///
30750/// // You can configure optional parameters by calling the respective setters at will, and
30751/// // execute the final call using `doit()`.
30752/// // Values shown here are possibly random and not representative !
30753/// let result = hub.projects().instances_get_iam_policy(req, "resource")
30754/// .doit().await;
30755/// # }
30756/// ```
30757pub struct ProjectInstanceGetIamPolicyCall<'a, C>
30758where
30759 C: 'a,
30760{
30761 hub: &'a Spanner<C>,
30762 _request: GetIamPolicyRequest,
30763 _resource: String,
30764 _delegate: Option<&'a mut dyn common::Delegate>,
30765 _additional_params: HashMap<String, String>,
30766 _scopes: BTreeSet<String>,
30767}
30768
30769impl<'a, C> common::CallBuilder for ProjectInstanceGetIamPolicyCall<'a, C> {}
30770
30771impl<'a, C> ProjectInstanceGetIamPolicyCall<'a, C>
30772where
30773 C: common::Connector,
30774{
30775 /// Perform the operation you have build so far.
30776 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
30777 use std::borrow::Cow;
30778 use std::io::{Read, Seek};
30779
30780 use common::{url::Params, ToParts};
30781 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30782
30783 let mut dd = common::DefaultDelegate;
30784 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30785 dlg.begin(common::MethodInfo {
30786 id: "spanner.projects.instances.getIamPolicy",
30787 http_method: hyper::Method::POST,
30788 });
30789
30790 for &field in ["alt", "resource"].iter() {
30791 if self._additional_params.contains_key(field) {
30792 dlg.finished(false);
30793 return Err(common::Error::FieldClash(field));
30794 }
30795 }
30796
30797 let mut params = Params::with_capacity(4 + self._additional_params.len());
30798 params.push("resource", self._resource);
30799
30800 params.extend(self._additional_params.iter());
30801
30802 params.push("alt", "json");
30803 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
30804 if self._scopes.is_empty() {
30805 self._scopes
30806 .insert(Scope::CloudPlatform.as_ref().to_string());
30807 }
30808
30809 #[allow(clippy::single_element_loop)]
30810 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
30811 url = params.uri_replacement(url, param_name, find_this, true);
30812 }
30813 {
30814 let to_remove = ["resource"];
30815 params.remove_params(&to_remove);
30816 }
30817
30818 let url = params.parse_with_url(&url);
30819
30820 let mut json_mime_type = mime::APPLICATION_JSON;
30821 let mut request_value_reader = {
30822 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30823 common::remove_json_null_values(&mut value);
30824 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30825 serde_json::to_writer(&mut dst, &value).unwrap();
30826 dst
30827 };
30828 let request_size = request_value_reader
30829 .seek(std::io::SeekFrom::End(0))
30830 .unwrap();
30831 request_value_reader
30832 .seek(std::io::SeekFrom::Start(0))
30833 .unwrap();
30834
30835 loop {
30836 let token = match self
30837 .hub
30838 .auth
30839 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30840 .await
30841 {
30842 Ok(token) => token,
30843 Err(e) => match dlg.token(e) {
30844 Ok(token) => token,
30845 Err(e) => {
30846 dlg.finished(false);
30847 return Err(common::Error::MissingToken(e));
30848 }
30849 },
30850 };
30851 request_value_reader
30852 .seek(std::io::SeekFrom::Start(0))
30853 .unwrap();
30854 let mut req_result = {
30855 let client = &self.hub.client;
30856 dlg.pre_request();
30857 let mut req_builder = hyper::Request::builder()
30858 .method(hyper::Method::POST)
30859 .uri(url.as_str())
30860 .header(USER_AGENT, self.hub._user_agent.clone());
30861
30862 if let Some(token) = token.as_ref() {
30863 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30864 }
30865
30866 let request = req_builder
30867 .header(CONTENT_TYPE, json_mime_type.to_string())
30868 .header(CONTENT_LENGTH, request_size as u64)
30869 .body(common::to_body(
30870 request_value_reader.get_ref().clone().into(),
30871 ));
30872
30873 client.request(request.unwrap()).await
30874 };
30875
30876 match req_result {
30877 Err(err) => {
30878 if let common::Retry::After(d) = dlg.http_error(&err) {
30879 sleep(d).await;
30880 continue;
30881 }
30882 dlg.finished(false);
30883 return Err(common::Error::HttpError(err));
30884 }
30885 Ok(res) => {
30886 let (mut parts, body) = res.into_parts();
30887 let mut body = common::Body::new(body);
30888 if !parts.status.is_success() {
30889 let bytes = common::to_bytes(body).await.unwrap_or_default();
30890 let error = serde_json::from_str(&common::to_string(&bytes));
30891 let response = common::to_response(parts, bytes.into());
30892
30893 if let common::Retry::After(d) =
30894 dlg.http_failure(&response, error.as_ref().ok())
30895 {
30896 sleep(d).await;
30897 continue;
30898 }
30899
30900 dlg.finished(false);
30901
30902 return Err(match error {
30903 Ok(value) => common::Error::BadRequest(value),
30904 _ => common::Error::Failure(response),
30905 });
30906 }
30907 let response = {
30908 let bytes = common::to_bytes(body).await.unwrap_or_default();
30909 let encoded = common::to_string(&bytes);
30910 match serde_json::from_str(&encoded) {
30911 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30912 Err(error) => {
30913 dlg.response_json_decode_error(&encoded, &error);
30914 return Err(common::Error::JsonDecodeError(
30915 encoded.to_string(),
30916 error,
30917 ));
30918 }
30919 }
30920 };
30921
30922 dlg.finished(true);
30923 return Ok(response);
30924 }
30925 }
30926 }
30927 }
30928
30929 ///
30930 /// Sets the *request* property to the given value.
30931 ///
30932 /// Even though the property as already been set when instantiating this call,
30933 /// we provide this method for API completeness.
30934 pub fn request(
30935 mut self,
30936 new_value: GetIamPolicyRequest,
30937 ) -> ProjectInstanceGetIamPolicyCall<'a, C> {
30938 self._request = new_value;
30939 self
30940 }
30941 /// 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.
30942 ///
30943 /// Sets the *resource* path property to the given value.
30944 ///
30945 /// Even though the property as already been set when instantiating this call,
30946 /// we provide this method for API completeness.
30947 pub fn resource(mut self, new_value: &str) -> ProjectInstanceGetIamPolicyCall<'a, C> {
30948 self._resource = new_value.to_string();
30949 self
30950 }
30951 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30952 /// while executing the actual API request.
30953 ///
30954 /// ````text
30955 /// It should be used to handle progress information, and to implement a certain level of resilience.
30956 /// ````
30957 ///
30958 /// Sets the *delegate* property to the given value.
30959 pub fn delegate(
30960 mut self,
30961 new_value: &'a mut dyn common::Delegate,
30962 ) -> ProjectInstanceGetIamPolicyCall<'a, C> {
30963 self._delegate = Some(new_value);
30964 self
30965 }
30966
30967 /// Set any additional parameter of the query string used in the request.
30968 /// It should be used to set parameters which are not yet available through their own
30969 /// setters.
30970 ///
30971 /// Please note that this method must not be used to set any of the known parameters
30972 /// which have their own setter method. If done anyway, the request will fail.
30973 ///
30974 /// # Additional Parameters
30975 ///
30976 /// * *$.xgafv* (query-string) - V1 error format.
30977 /// * *access_token* (query-string) - OAuth access token.
30978 /// * *alt* (query-string) - Data format for response.
30979 /// * *callback* (query-string) - JSONP
30980 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30981 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30982 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30983 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30984 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
30985 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30986 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30987 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceGetIamPolicyCall<'a, C>
30988 where
30989 T: AsRef<str>,
30990 {
30991 self._additional_params
30992 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30993 self
30994 }
30995
30996 /// Identifies the authorization scope for the method you are building.
30997 ///
30998 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30999 /// [`Scope::CloudPlatform`].
31000 ///
31001 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31002 /// tokens for more than one scope.
31003 ///
31004 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31005 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31006 /// sufficient, a read-write scope will do as well.
31007 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceGetIamPolicyCall<'a, C>
31008 where
31009 St: AsRef<str>,
31010 {
31011 self._scopes.insert(String::from(scope.as_ref()));
31012 self
31013 }
31014 /// Identifies the authorization scope(s) for the method you are building.
31015 ///
31016 /// See [`Self::add_scope()`] for details.
31017 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceGetIamPolicyCall<'a, C>
31018 where
31019 I: IntoIterator<Item = St>,
31020 St: AsRef<str>,
31021 {
31022 self._scopes
31023 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31024 self
31025 }
31026
31027 /// Removes all scopes, and no default scope will be used either.
31028 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31029 /// for details).
31030 pub fn clear_scopes(mut self) -> ProjectInstanceGetIamPolicyCall<'a, C> {
31031 self._scopes.clear();
31032 self
31033 }
31034}
31035
31036/// Lists all instances in the given project.
31037///
31038/// A builder for the *instances.list* method supported by a *project* resource.
31039/// It is not used directly, but through a [`ProjectMethods`] instance.
31040///
31041/// # Example
31042///
31043/// Instantiate a resource method builder
31044///
31045/// ```test_harness,no_run
31046/// # extern crate hyper;
31047/// # extern crate hyper_rustls;
31048/// # extern crate google_spanner1 as spanner1;
31049/// # async fn dox() {
31050/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31051///
31052/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31054/// # secret,
31055/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31056/// # ).build().await.unwrap();
31057///
31058/// # let client = hyper_util::client::legacy::Client::builder(
31059/// # hyper_util::rt::TokioExecutor::new()
31060/// # )
31061/// # .build(
31062/// # hyper_rustls::HttpsConnectorBuilder::new()
31063/// # .with_native_roots()
31064/// # .unwrap()
31065/// # .https_or_http()
31066/// # .enable_http1()
31067/// # .build()
31068/// # );
31069/// # let mut hub = Spanner::new(client, auth);
31070/// // You can configure optional parameters by calling the respective setters at will, and
31071/// // execute the final call using `doit()`.
31072/// // Values shown here are possibly random and not representative !
31073/// let result = hub.projects().instances_list("parent")
31074/// .page_token("dolores")
31075/// .page_size(-25)
31076/// .instance_deadline(chrono::Utc::now())
31077/// .filter("et")
31078/// .doit().await;
31079/// # }
31080/// ```
31081pub struct ProjectInstanceListCall<'a, C>
31082where
31083 C: 'a,
31084{
31085 hub: &'a Spanner<C>,
31086 _parent: String,
31087 _page_token: Option<String>,
31088 _page_size: Option<i32>,
31089 _instance_deadline: Option<chrono::DateTime<chrono::offset::Utc>>,
31090 _filter: Option<String>,
31091 _delegate: Option<&'a mut dyn common::Delegate>,
31092 _additional_params: HashMap<String, String>,
31093 _scopes: BTreeSet<String>,
31094}
31095
31096impl<'a, C> common::CallBuilder for ProjectInstanceListCall<'a, C> {}
31097
31098impl<'a, C> ProjectInstanceListCall<'a, C>
31099where
31100 C: common::Connector,
31101{
31102 /// Perform the operation you have build so far.
31103 pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
31104 use std::borrow::Cow;
31105 use std::io::{Read, Seek};
31106
31107 use common::{url::Params, ToParts};
31108 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31109
31110 let mut dd = common::DefaultDelegate;
31111 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31112 dlg.begin(common::MethodInfo {
31113 id: "spanner.projects.instances.list",
31114 http_method: hyper::Method::GET,
31115 });
31116
31117 for &field in [
31118 "alt",
31119 "parent",
31120 "pageToken",
31121 "pageSize",
31122 "instanceDeadline",
31123 "filter",
31124 ]
31125 .iter()
31126 {
31127 if self._additional_params.contains_key(field) {
31128 dlg.finished(false);
31129 return Err(common::Error::FieldClash(field));
31130 }
31131 }
31132
31133 let mut params = Params::with_capacity(7 + self._additional_params.len());
31134 params.push("parent", self._parent);
31135 if let Some(value) = self._page_token.as_ref() {
31136 params.push("pageToken", value);
31137 }
31138 if let Some(value) = self._page_size.as_ref() {
31139 params.push("pageSize", value.to_string());
31140 }
31141 if let Some(value) = self._instance_deadline.as_ref() {
31142 params.push(
31143 "instanceDeadline",
31144 common::serde::datetime_to_string(&value),
31145 );
31146 }
31147 if let Some(value) = self._filter.as_ref() {
31148 params.push("filter", value);
31149 }
31150
31151 params.extend(self._additional_params.iter());
31152
31153 params.push("alt", "json");
31154 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
31155 if self._scopes.is_empty() {
31156 self._scopes
31157 .insert(Scope::CloudPlatform.as_ref().to_string());
31158 }
31159
31160 #[allow(clippy::single_element_loop)]
31161 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
31162 url = params.uri_replacement(url, param_name, find_this, true);
31163 }
31164 {
31165 let to_remove = ["parent"];
31166 params.remove_params(&to_remove);
31167 }
31168
31169 let url = params.parse_with_url(&url);
31170
31171 loop {
31172 let token = match self
31173 .hub
31174 .auth
31175 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31176 .await
31177 {
31178 Ok(token) => token,
31179 Err(e) => match dlg.token(e) {
31180 Ok(token) => token,
31181 Err(e) => {
31182 dlg.finished(false);
31183 return Err(common::Error::MissingToken(e));
31184 }
31185 },
31186 };
31187 let mut req_result = {
31188 let client = &self.hub.client;
31189 dlg.pre_request();
31190 let mut req_builder = hyper::Request::builder()
31191 .method(hyper::Method::GET)
31192 .uri(url.as_str())
31193 .header(USER_AGENT, self.hub._user_agent.clone());
31194
31195 if let Some(token) = token.as_ref() {
31196 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31197 }
31198
31199 let request = req_builder
31200 .header(CONTENT_LENGTH, 0_u64)
31201 .body(common::to_body::<String>(None));
31202
31203 client.request(request.unwrap()).await
31204 };
31205
31206 match req_result {
31207 Err(err) => {
31208 if let common::Retry::After(d) = dlg.http_error(&err) {
31209 sleep(d).await;
31210 continue;
31211 }
31212 dlg.finished(false);
31213 return Err(common::Error::HttpError(err));
31214 }
31215 Ok(res) => {
31216 let (mut parts, body) = res.into_parts();
31217 let mut body = common::Body::new(body);
31218 if !parts.status.is_success() {
31219 let bytes = common::to_bytes(body).await.unwrap_or_default();
31220 let error = serde_json::from_str(&common::to_string(&bytes));
31221 let response = common::to_response(parts, bytes.into());
31222
31223 if let common::Retry::After(d) =
31224 dlg.http_failure(&response, error.as_ref().ok())
31225 {
31226 sleep(d).await;
31227 continue;
31228 }
31229
31230 dlg.finished(false);
31231
31232 return Err(match error {
31233 Ok(value) => common::Error::BadRequest(value),
31234 _ => common::Error::Failure(response),
31235 });
31236 }
31237 let response = {
31238 let bytes = common::to_bytes(body).await.unwrap_or_default();
31239 let encoded = common::to_string(&bytes);
31240 match serde_json::from_str(&encoded) {
31241 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31242 Err(error) => {
31243 dlg.response_json_decode_error(&encoded, &error);
31244 return Err(common::Error::JsonDecodeError(
31245 encoded.to_string(),
31246 error,
31247 ));
31248 }
31249 }
31250 };
31251
31252 dlg.finished(true);
31253 return Ok(response);
31254 }
31255 }
31256 }
31257 }
31258
31259 /// Required. The name of the project for which a list of instances is requested. Values are of the form `projects/`.
31260 ///
31261 /// Sets the *parent* path property to the given value.
31262 ///
31263 /// Even though the property as already been set when instantiating this call,
31264 /// we provide this method for API completeness.
31265 pub fn parent(mut self, new_value: &str) -> ProjectInstanceListCall<'a, C> {
31266 self._parent = new_value.to_string();
31267 self
31268 }
31269 /// If non-empty, `page_token` should contain a next_page_token from a previous ListInstancesResponse.
31270 ///
31271 /// Sets the *page token* query property to the given value.
31272 pub fn page_token(mut self, new_value: &str) -> ProjectInstanceListCall<'a, C> {
31273 self._page_token = Some(new_value.to_string());
31274 self
31275 }
31276 /// Number of instances to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
31277 ///
31278 /// Sets the *page size* query property to the given value.
31279 pub fn page_size(mut self, new_value: i32) -> ProjectInstanceListCall<'a, C> {
31280 self._page_size = Some(new_value);
31281 self
31282 }
31283 /// Deadline used while retrieving metadata for instances. Instances whose metadata cannot be retrieved within this deadline will be added to unreachable in ListInstancesResponse.
31284 ///
31285 /// Sets the *instance deadline* query property to the given value.
31286 pub fn instance_deadline(
31287 mut self,
31288 new_value: chrono::DateTime<chrono::offset::Utc>,
31289 ) -> ProjectInstanceListCall<'a, C> {
31290 self._instance_deadline = Some(new_value);
31291 self
31292 }
31293 /// 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".
31294 ///
31295 /// Sets the *filter* query property to the given value.
31296 pub fn filter(mut self, new_value: &str) -> ProjectInstanceListCall<'a, C> {
31297 self._filter = Some(new_value.to_string());
31298 self
31299 }
31300 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31301 /// while executing the actual API request.
31302 ///
31303 /// ````text
31304 /// It should be used to handle progress information, and to implement a certain level of resilience.
31305 /// ````
31306 ///
31307 /// Sets the *delegate* property to the given value.
31308 pub fn delegate(
31309 mut self,
31310 new_value: &'a mut dyn common::Delegate,
31311 ) -> ProjectInstanceListCall<'a, C> {
31312 self._delegate = Some(new_value);
31313 self
31314 }
31315
31316 /// Set any additional parameter of the query string used in the request.
31317 /// It should be used to set parameters which are not yet available through their own
31318 /// setters.
31319 ///
31320 /// Please note that this method must not be used to set any of the known parameters
31321 /// which have their own setter method. If done anyway, the request will fail.
31322 ///
31323 /// # Additional Parameters
31324 ///
31325 /// * *$.xgafv* (query-string) - V1 error format.
31326 /// * *access_token* (query-string) - OAuth access token.
31327 /// * *alt* (query-string) - Data format for response.
31328 /// * *callback* (query-string) - JSONP
31329 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31330 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
31331 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31332 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31333 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
31334 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31335 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31336 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceListCall<'a, C>
31337 where
31338 T: AsRef<str>,
31339 {
31340 self._additional_params
31341 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31342 self
31343 }
31344
31345 /// Identifies the authorization scope for the method you are building.
31346 ///
31347 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31348 /// [`Scope::CloudPlatform`].
31349 ///
31350 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31351 /// tokens for more than one scope.
31352 ///
31353 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31354 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31355 /// sufficient, a read-write scope will do as well.
31356 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceListCall<'a, C>
31357 where
31358 St: AsRef<str>,
31359 {
31360 self._scopes.insert(String::from(scope.as_ref()));
31361 self
31362 }
31363 /// Identifies the authorization scope(s) for the method you are building.
31364 ///
31365 /// See [`Self::add_scope()`] for details.
31366 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceListCall<'a, C>
31367 where
31368 I: IntoIterator<Item = St>,
31369 St: AsRef<str>,
31370 {
31371 self._scopes
31372 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31373 self
31374 }
31375
31376 /// Removes all scopes, and no default scope will be used either.
31377 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31378 /// for details).
31379 pub fn clear_scopes(mut self) -> ProjectInstanceListCall<'a, C> {
31380 self._scopes.clear();
31381 self
31382 }
31383}
31384
31385/// Moves the instance to the target instance config. The returned long-running operation can be used to track the progress of moving the instance. `MoveInstance` returns `FAILED_PRECONDITION` if the instance meets any of the following criteria: * Has an ongoing move to a different instance config * Has backups * Has an ongoing update * Is under free trial * Contains any CMEK-enabled databases 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 configs are subject to hourly compute and storage charges. * The instance may experience higher read-write latencies and a higher transaction abort rate. However, moving an instance does not cause any downtime. The returned long-running operation will have 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 since it involves moving any data previously moved to target instance config back to the original instance config. The same operation can be used to track the progress of the cancellation. Upon successful completion of the cancellation, the operation terminates with CANCELLED status. Upon completion(if not cancelled) of the returned operation: * Instance would be successfully moved to the target instance config. * You are billed for compute and storage in target instance config. Authorization requires `spanner.instances.update` permission on the resource instance. For more details, please see [documentation](https://cloud.google.com/spanner/docs/move-instance).
31386///
31387/// A builder for the *instances.move* method supported by a *project* resource.
31388/// It is not used directly, but through a [`ProjectMethods`] instance.
31389///
31390/// # Example
31391///
31392/// Instantiate a resource method builder
31393///
31394/// ```test_harness,no_run
31395/// # extern crate hyper;
31396/// # extern crate hyper_rustls;
31397/// # extern crate google_spanner1 as spanner1;
31398/// use spanner1::api::MoveInstanceRequest;
31399/// # async fn dox() {
31400/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31401///
31402/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31403/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31404/// # secret,
31405/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31406/// # ).build().await.unwrap();
31407///
31408/// # let client = hyper_util::client::legacy::Client::builder(
31409/// # hyper_util::rt::TokioExecutor::new()
31410/// # )
31411/// # .build(
31412/// # hyper_rustls::HttpsConnectorBuilder::new()
31413/// # .with_native_roots()
31414/// # .unwrap()
31415/// # .https_or_http()
31416/// # .enable_http1()
31417/// # .build()
31418/// # );
31419/// # let mut hub = Spanner::new(client, auth);
31420/// // As the method needs a request, you would usually fill it with the desired information
31421/// // into the respective structure. Some of the parts shown here might not be applicable !
31422/// // Values shown here are possibly random and not representative !
31423/// let mut req = MoveInstanceRequest::default();
31424///
31425/// // You can configure optional parameters by calling the respective setters at will, and
31426/// // execute the final call using `doit()`.
31427/// // Values shown here are possibly random and not representative !
31428/// let result = hub.projects().instances_move(req, "name")
31429/// .doit().await;
31430/// # }
31431/// ```
31432pub struct ProjectInstanceMoveCall<'a, C>
31433where
31434 C: 'a,
31435{
31436 hub: &'a Spanner<C>,
31437 _request: MoveInstanceRequest,
31438 _name: String,
31439 _delegate: Option<&'a mut dyn common::Delegate>,
31440 _additional_params: HashMap<String, String>,
31441 _scopes: BTreeSet<String>,
31442}
31443
31444impl<'a, C> common::CallBuilder for ProjectInstanceMoveCall<'a, C> {}
31445
31446impl<'a, C> ProjectInstanceMoveCall<'a, C>
31447where
31448 C: common::Connector,
31449{
31450 /// Perform the operation you have build so far.
31451 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
31452 use std::borrow::Cow;
31453 use std::io::{Read, Seek};
31454
31455 use common::{url::Params, ToParts};
31456 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31457
31458 let mut dd = common::DefaultDelegate;
31459 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31460 dlg.begin(common::MethodInfo {
31461 id: "spanner.projects.instances.move",
31462 http_method: hyper::Method::POST,
31463 });
31464
31465 for &field in ["alt", "name"].iter() {
31466 if self._additional_params.contains_key(field) {
31467 dlg.finished(false);
31468 return Err(common::Error::FieldClash(field));
31469 }
31470 }
31471
31472 let mut params = Params::with_capacity(4 + self._additional_params.len());
31473 params.push("name", self._name);
31474
31475 params.extend(self._additional_params.iter());
31476
31477 params.push("alt", "json");
31478 let mut url = self.hub._base_url.clone() + "v1/{+name}:move";
31479 if self._scopes.is_empty() {
31480 self._scopes
31481 .insert(Scope::CloudPlatform.as_ref().to_string());
31482 }
31483
31484 #[allow(clippy::single_element_loop)]
31485 for &(find_this, param_name) in [("{+name}", "name")].iter() {
31486 url = params.uri_replacement(url, param_name, find_this, true);
31487 }
31488 {
31489 let to_remove = ["name"];
31490 params.remove_params(&to_remove);
31491 }
31492
31493 let url = params.parse_with_url(&url);
31494
31495 let mut json_mime_type = mime::APPLICATION_JSON;
31496 let mut request_value_reader = {
31497 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31498 common::remove_json_null_values(&mut value);
31499 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31500 serde_json::to_writer(&mut dst, &value).unwrap();
31501 dst
31502 };
31503 let request_size = request_value_reader
31504 .seek(std::io::SeekFrom::End(0))
31505 .unwrap();
31506 request_value_reader
31507 .seek(std::io::SeekFrom::Start(0))
31508 .unwrap();
31509
31510 loop {
31511 let token = match self
31512 .hub
31513 .auth
31514 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31515 .await
31516 {
31517 Ok(token) => token,
31518 Err(e) => match dlg.token(e) {
31519 Ok(token) => token,
31520 Err(e) => {
31521 dlg.finished(false);
31522 return Err(common::Error::MissingToken(e));
31523 }
31524 },
31525 };
31526 request_value_reader
31527 .seek(std::io::SeekFrom::Start(0))
31528 .unwrap();
31529 let mut req_result = {
31530 let client = &self.hub.client;
31531 dlg.pre_request();
31532 let mut req_builder = hyper::Request::builder()
31533 .method(hyper::Method::POST)
31534 .uri(url.as_str())
31535 .header(USER_AGENT, self.hub._user_agent.clone());
31536
31537 if let Some(token) = token.as_ref() {
31538 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31539 }
31540
31541 let request = req_builder
31542 .header(CONTENT_TYPE, json_mime_type.to_string())
31543 .header(CONTENT_LENGTH, request_size as u64)
31544 .body(common::to_body(
31545 request_value_reader.get_ref().clone().into(),
31546 ));
31547
31548 client.request(request.unwrap()).await
31549 };
31550
31551 match req_result {
31552 Err(err) => {
31553 if let common::Retry::After(d) = dlg.http_error(&err) {
31554 sleep(d).await;
31555 continue;
31556 }
31557 dlg.finished(false);
31558 return Err(common::Error::HttpError(err));
31559 }
31560 Ok(res) => {
31561 let (mut parts, body) = res.into_parts();
31562 let mut body = common::Body::new(body);
31563 if !parts.status.is_success() {
31564 let bytes = common::to_bytes(body).await.unwrap_or_default();
31565 let error = serde_json::from_str(&common::to_string(&bytes));
31566 let response = common::to_response(parts, bytes.into());
31567
31568 if let common::Retry::After(d) =
31569 dlg.http_failure(&response, error.as_ref().ok())
31570 {
31571 sleep(d).await;
31572 continue;
31573 }
31574
31575 dlg.finished(false);
31576
31577 return Err(match error {
31578 Ok(value) => common::Error::BadRequest(value),
31579 _ => common::Error::Failure(response),
31580 });
31581 }
31582 let response = {
31583 let bytes = common::to_bytes(body).await.unwrap_or_default();
31584 let encoded = common::to_string(&bytes);
31585 match serde_json::from_str(&encoded) {
31586 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31587 Err(error) => {
31588 dlg.response_json_decode_error(&encoded, &error);
31589 return Err(common::Error::JsonDecodeError(
31590 encoded.to_string(),
31591 error,
31592 ));
31593 }
31594 }
31595 };
31596
31597 dlg.finished(true);
31598 return Ok(response);
31599 }
31600 }
31601 }
31602 }
31603
31604 ///
31605 /// Sets the *request* property to the given value.
31606 ///
31607 /// Even though the property as already been set when instantiating this call,
31608 /// we provide this method for API completeness.
31609 pub fn request(mut self, new_value: MoveInstanceRequest) -> ProjectInstanceMoveCall<'a, C> {
31610 self._request = new_value;
31611 self
31612 }
31613 /// Required. The instance to move. Values are of the form `projects//instances/`.
31614 ///
31615 /// Sets the *name* path property to the given value.
31616 ///
31617 /// Even though the property as already been set when instantiating this call,
31618 /// we provide this method for API completeness.
31619 pub fn name(mut self, new_value: &str) -> ProjectInstanceMoveCall<'a, C> {
31620 self._name = new_value.to_string();
31621 self
31622 }
31623 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31624 /// while executing the actual API request.
31625 ///
31626 /// ````text
31627 /// It should be used to handle progress information, and to implement a certain level of resilience.
31628 /// ````
31629 ///
31630 /// Sets the *delegate* property to the given value.
31631 pub fn delegate(
31632 mut self,
31633 new_value: &'a mut dyn common::Delegate,
31634 ) -> ProjectInstanceMoveCall<'a, C> {
31635 self._delegate = Some(new_value);
31636 self
31637 }
31638
31639 /// Set any additional parameter of the query string used in the request.
31640 /// It should be used to set parameters which are not yet available through their own
31641 /// setters.
31642 ///
31643 /// Please note that this method must not be used to set any of the known parameters
31644 /// which have their own setter method. If done anyway, the request will fail.
31645 ///
31646 /// # Additional Parameters
31647 ///
31648 /// * *$.xgafv* (query-string) - V1 error format.
31649 /// * *access_token* (query-string) - OAuth access token.
31650 /// * *alt* (query-string) - Data format for response.
31651 /// * *callback* (query-string) - JSONP
31652 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31653 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
31654 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31655 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31656 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
31657 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31658 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31659 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceMoveCall<'a, C>
31660 where
31661 T: AsRef<str>,
31662 {
31663 self._additional_params
31664 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31665 self
31666 }
31667
31668 /// Identifies the authorization scope for the method you are building.
31669 ///
31670 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31671 /// [`Scope::CloudPlatform`].
31672 ///
31673 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31674 /// tokens for more than one scope.
31675 ///
31676 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31677 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31678 /// sufficient, a read-write scope will do as well.
31679 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceMoveCall<'a, C>
31680 where
31681 St: AsRef<str>,
31682 {
31683 self._scopes.insert(String::from(scope.as_ref()));
31684 self
31685 }
31686 /// Identifies the authorization scope(s) for the method you are building.
31687 ///
31688 /// See [`Self::add_scope()`] for details.
31689 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceMoveCall<'a, C>
31690 where
31691 I: IntoIterator<Item = St>,
31692 St: AsRef<str>,
31693 {
31694 self._scopes
31695 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31696 self
31697 }
31698
31699 /// Removes all scopes, and no default scope will be used either.
31700 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31701 /// for details).
31702 pub fn clear_scopes(mut self) -> ProjectInstanceMoveCall<'a, C> {
31703 self._scopes.clear();
31704 self
31705 }
31706}
31707
31708/// 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.
31709///
31710/// A builder for the *instances.patch* method supported by a *project* resource.
31711/// It is not used directly, but through a [`ProjectMethods`] instance.
31712///
31713/// # Example
31714///
31715/// Instantiate a resource method builder
31716///
31717/// ```test_harness,no_run
31718/// # extern crate hyper;
31719/// # extern crate hyper_rustls;
31720/// # extern crate google_spanner1 as spanner1;
31721/// use spanner1::api::UpdateInstanceRequest;
31722/// # async fn dox() {
31723/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31724///
31725/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31726/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31727/// # secret,
31728/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31729/// # ).build().await.unwrap();
31730///
31731/// # let client = hyper_util::client::legacy::Client::builder(
31732/// # hyper_util::rt::TokioExecutor::new()
31733/// # )
31734/// # .build(
31735/// # hyper_rustls::HttpsConnectorBuilder::new()
31736/// # .with_native_roots()
31737/// # .unwrap()
31738/// # .https_or_http()
31739/// # .enable_http1()
31740/// # .build()
31741/// # );
31742/// # let mut hub = Spanner::new(client, auth);
31743/// // As the method needs a request, you would usually fill it with the desired information
31744/// // into the respective structure. Some of the parts shown here might not be applicable !
31745/// // Values shown here are possibly random and not representative !
31746/// let mut req = UpdateInstanceRequest::default();
31747///
31748/// // You can configure optional parameters by calling the respective setters at will, and
31749/// // execute the final call using `doit()`.
31750/// // Values shown here are possibly random and not representative !
31751/// let result = hub.projects().instances_patch(req, "name")
31752/// .doit().await;
31753/// # }
31754/// ```
31755pub struct ProjectInstancePatchCall<'a, C>
31756where
31757 C: 'a,
31758{
31759 hub: &'a Spanner<C>,
31760 _request: UpdateInstanceRequest,
31761 _name: String,
31762 _delegate: Option<&'a mut dyn common::Delegate>,
31763 _additional_params: HashMap<String, String>,
31764 _scopes: BTreeSet<String>,
31765}
31766
31767impl<'a, C> common::CallBuilder for ProjectInstancePatchCall<'a, C> {}
31768
31769impl<'a, C> ProjectInstancePatchCall<'a, C>
31770where
31771 C: common::Connector,
31772{
31773 /// Perform the operation you have build so far.
31774 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
31775 use std::borrow::Cow;
31776 use std::io::{Read, Seek};
31777
31778 use common::{url::Params, ToParts};
31779 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31780
31781 let mut dd = common::DefaultDelegate;
31782 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31783 dlg.begin(common::MethodInfo {
31784 id: "spanner.projects.instances.patch",
31785 http_method: hyper::Method::PATCH,
31786 });
31787
31788 for &field in ["alt", "name"].iter() {
31789 if self._additional_params.contains_key(field) {
31790 dlg.finished(false);
31791 return Err(common::Error::FieldClash(field));
31792 }
31793 }
31794
31795 let mut params = Params::with_capacity(4 + self._additional_params.len());
31796 params.push("name", self._name);
31797
31798 params.extend(self._additional_params.iter());
31799
31800 params.push("alt", "json");
31801 let mut url = self.hub._base_url.clone() + "v1/{+name}";
31802 if self._scopes.is_empty() {
31803 self._scopes
31804 .insert(Scope::CloudPlatform.as_ref().to_string());
31805 }
31806
31807 #[allow(clippy::single_element_loop)]
31808 for &(find_this, param_name) in [("{+name}", "name")].iter() {
31809 url = params.uri_replacement(url, param_name, find_this, true);
31810 }
31811 {
31812 let to_remove = ["name"];
31813 params.remove_params(&to_remove);
31814 }
31815
31816 let url = params.parse_with_url(&url);
31817
31818 let mut json_mime_type = mime::APPLICATION_JSON;
31819 let mut request_value_reader = {
31820 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31821 common::remove_json_null_values(&mut value);
31822 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31823 serde_json::to_writer(&mut dst, &value).unwrap();
31824 dst
31825 };
31826 let request_size = request_value_reader
31827 .seek(std::io::SeekFrom::End(0))
31828 .unwrap();
31829 request_value_reader
31830 .seek(std::io::SeekFrom::Start(0))
31831 .unwrap();
31832
31833 loop {
31834 let token = match self
31835 .hub
31836 .auth
31837 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31838 .await
31839 {
31840 Ok(token) => token,
31841 Err(e) => match dlg.token(e) {
31842 Ok(token) => token,
31843 Err(e) => {
31844 dlg.finished(false);
31845 return Err(common::Error::MissingToken(e));
31846 }
31847 },
31848 };
31849 request_value_reader
31850 .seek(std::io::SeekFrom::Start(0))
31851 .unwrap();
31852 let mut req_result = {
31853 let client = &self.hub.client;
31854 dlg.pre_request();
31855 let mut req_builder = hyper::Request::builder()
31856 .method(hyper::Method::PATCH)
31857 .uri(url.as_str())
31858 .header(USER_AGENT, self.hub._user_agent.clone());
31859
31860 if let Some(token) = token.as_ref() {
31861 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31862 }
31863
31864 let request = req_builder
31865 .header(CONTENT_TYPE, json_mime_type.to_string())
31866 .header(CONTENT_LENGTH, request_size as u64)
31867 .body(common::to_body(
31868 request_value_reader.get_ref().clone().into(),
31869 ));
31870
31871 client.request(request.unwrap()).await
31872 };
31873
31874 match req_result {
31875 Err(err) => {
31876 if let common::Retry::After(d) = dlg.http_error(&err) {
31877 sleep(d).await;
31878 continue;
31879 }
31880 dlg.finished(false);
31881 return Err(common::Error::HttpError(err));
31882 }
31883 Ok(res) => {
31884 let (mut parts, body) = res.into_parts();
31885 let mut body = common::Body::new(body);
31886 if !parts.status.is_success() {
31887 let bytes = common::to_bytes(body).await.unwrap_or_default();
31888 let error = serde_json::from_str(&common::to_string(&bytes));
31889 let response = common::to_response(parts, bytes.into());
31890
31891 if let common::Retry::After(d) =
31892 dlg.http_failure(&response, error.as_ref().ok())
31893 {
31894 sleep(d).await;
31895 continue;
31896 }
31897
31898 dlg.finished(false);
31899
31900 return Err(match error {
31901 Ok(value) => common::Error::BadRequest(value),
31902 _ => common::Error::Failure(response),
31903 });
31904 }
31905 let response = {
31906 let bytes = common::to_bytes(body).await.unwrap_or_default();
31907 let encoded = common::to_string(&bytes);
31908 match serde_json::from_str(&encoded) {
31909 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31910 Err(error) => {
31911 dlg.response_json_decode_error(&encoded, &error);
31912 return Err(common::Error::JsonDecodeError(
31913 encoded.to_string(),
31914 error,
31915 ));
31916 }
31917 }
31918 };
31919
31920 dlg.finished(true);
31921 return Ok(response);
31922 }
31923 }
31924 }
31925 }
31926
31927 ///
31928 /// Sets the *request* property to the given value.
31929 ///
31930 /// Even though the property as already been set when instantiating this call,
31931 /// we provide this method for API completeness.
31932 pub fn request(mut self, new_value: UpdateInstanceRequest) -> ProjectInstancePatchCall<'a, C> {
31933 self._request = new_value;
31934 self
31935 }
31936 /// 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.
31937 ///
31938 /// Sets the *name* path property to the given value.
31939 ///
31940 /// Even though the property as already been set when instantiating this call,
31941 /// we provide this method for API completeness.
31942 pub fn name(mut self, new_value: &str) -> ProjectInstancePatchCall<'a, C> {
31943 self._name = new_value.to_string();
31944 self
31945 }
31946 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31947 /// while executing the actual API request.
31948 ///
31949 /// ````text
31950 /// It should be used to handle progress information, and to implement a certain level of resilience.
31951 /// ````
31952 ///
31953 /// Sets the *delegate* property to the given value.
31954 pub fn delegate(
31955 mut self,
31956 new_value: &'a mut dyn common::Delegate,
31957 ) -> ProjectInstancePatchCall<'a, C> {
31958 self._delegate = Some(new_value);
31959 self
31960 }
31961
31962 /// Set any additional parameter of the query string used in the request.
31963 /// It should be used to set parameters which are not yet available through their own
31964 /// setters.
31965 ///
31966 /// Please note that this method must not be used to set any of the known parameters
31967 /// which have their own setter method. If done anyway, the request will fail.
31968 ///
31969 /// # Additional Parameters
31970 ///
31971 /// * *$.xgafv* (query-string) - V1 error format.
31972 /// * *access_token* (query-string) - OAuth access token.
31973 /// * *alt* (query-string) - Data format for response.
31974 /// * *callback* (query-string) - JSONP
31975 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31976 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
31977 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31978 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31979 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
31980 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31981 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31982 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstancePatchCall<'a, C>
31983 where
31984 T: AsRef<str>,
31985 {
31986 self._additional_params
31987 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31988 self
31989 }
31990
31991 /// Identifies the authorization scope for the method you are building.
31992 ///
31993 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31994 /// [`Scope::CloudPlatform`].
31995 ///
31996 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31997 /// tokens for more than one scope.
31998 ///
31999 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32000 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32001 /// sufficient, a read-write scope will do as well.
32002 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstancePatchCall<'a, C>
32003 where
32004 St: AsRef<str>,
32005 {
32006 self._scopes.insert(String::from(scope.as_ref()));
32007 self
32008 }
32009 /// Identifies the authorization scope(s) for the method you are building.
32010 ///
32011 /// See [`Self::add_scope()`] for details.
32012 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstancePatchCall<'a, C>
32013 where
32014 I: IntoIterator<Item = St>,
32015 St: AsRef<str>,
32016 {
32017 self._scopes
32018 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32019 self
32020 }
32021
32022 /// Removes all scopes, and no default scope will be used either.
32023 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32024 /// for details).
32025 pub fn clear_scopes(mut self) -> ProjectInstancePatchCall<'a, C> {
32026 self._scopes.clear();
32027 self
32028 }
32029}
32030
32031/// Sets the access control policy on an instance resource. Replaces any existing policy. Authorization requires `spanner.instances.setIamPolicy` on resource.
32032///
32033/// A builder for the *instances.setIamPolicy* method supported by a *project* resource.
32034/// It is not used directly, but through a [`ProjectMethods`] instance.
32035///
32036/// # Example
32037///
32038/// Instantiate a resource method builder
32039///
32040/// ```test_harness,no_run
32041/// # extern crate hyper;
32042/// # extern crate hyper_rustls;
32043/// # extern crate google_spanner1 as spanner1;
32044/// use spanner1::api::SetIamPolicyRequest;
32045/// # async fn dox() {
32046/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32047///
32048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32049/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32050/// # secret,
32051/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32052/// # ).build().await.unwrap();
32053///
32054/// # let client = hyper_util::client::legacy::Client::builder(
32055/// # hyper_util::rt::TokioExecutor::new()
32056/// # )
32057/// # .build(
32058/// # hyper_rustls::HttpsConnectorBuilder::new()
32059/// # .with_native_roots()
32060/// # .unwrap()
32061/// # .https_or_http()
32062/// # .enable_http1()
32063/// # .build()
32064/// # );
32065/// # let mut hub = Spanner::new(client, auth);
32066/// // As the method needs a request, you would usually fill it with the desired information
32067/// // into the respective structure. Some of the parts shown here might not be applicable !
32068/// // Values shown here are possibly random and not representative !
32069/// let mut req = SetIamPolicyRequest::default();
32070///
32071/// // You can configure optional parameters by calling the respective setters at will, and
32072/// // execute the final call using `doit()`.
32073/// // Values shown here are possibly random and not representative !
32074/// let result = hub.projects().instances_set_iam_policy(req, "resource")
32075/// .doit().await;
32076/// # }
32077/// ```
32078pub struct ProjectInstanceSetIamPolicyCall<'a, C>
32079where
32080 C: 'a,
32081{
32082 hub: &'a Spanner<C>,
32083 _request: SetIamPolicyRequest,
32084 _resource: String,
32085 _delegate: Option<&'a mut dyn common::Delegate>,
32086 _additional_params: HashMap<String, String>,
32087 _scopes: BTreeSet<String>,
32088}
32089
32090impl<'a, C> common::CallBuilder for ProjectInstanceSetIamPolicyCall<'a, C> {}
32091
32092impl<'a, C> ProjectInstanceSetIamPolicyCall<'a, C>
32093where
32094 C: common::Connector,
32095{
32096 /// Perform the operation you have build so far.
32097 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
32098 use std::borrow::Cow;
32099 use std::io::{Read, Seek};
32100
32101 use common::{url::Params, ToParts};
32102 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32103
32104 let mut dd = common::DefaultDelegate;
32105 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32106 dlg.begin(common::MethodInfo {
32107 id: "spanner.projects.instances.setIamPolicy",
32108 http_method: hyper::Method::POST,
32109 });
32110
32111 for &field in ["alt", "resource"].iter() {
32112 if self._additional_params.contains_key(field) {
32113 dlg.finished(false);
32114 return Err(common::Error::FieldClash(field));
32115 }
32116 }
32117
32118 let mut params = Params::with_capacity(4 + self._additional_params.len());
32119 params.push("resource", self._resource);
32120
32121 params.extend(self._additional_params.iter());
32122
32123 params.push("alt", "json");
32124 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
32125 if self._scopes.is_empty() {
32126 self._scopes
32127 .insert(Scope::CloudPlatform.as_ref().to_string());
32128 }
32129
32130 #[allow(clippy::single_element_loop)]
32131 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
32132 url = params.uri_replacement(url, param_name, find_this, true);
32133 }
32134 {
32135 let to_remove = ["resource"];
32136 params.remove_params(&to_remove);
32137 }
32138
32139 let url = params.parse_with_url(&url);
32140
32141 let mut json_mime_type = mime::APPLICATION_JSON;
32142 let mut request_value_reader = {
32143 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32144 common::remove_json_null_values(&mut value);
32145 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32146 serde_json::to_writer(&mut dst, &value).unwrap();
32147 dst
32148 };
32149 let request_size = request_value_reader
32150 .seek(std::io::SeekFrom::End(0))
32151 .unwrap();
32152 request_value_reader
32153 .seek(std::io::SeekFrom::Start(0))
32154 .unwrap();
32155
32156 loop {
32157 let token = match self
32158 .hub
32159 .auth
32160 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32161 .await
32162 {
32163 Ok(token) => token,
32164 Err(e) => match dlg.token(e) {
32165 Ok(token) => token,
32166 Err(e) => {
32167 dlg.finished(false);
32168 return Err(common::Error::MissingToken(e));
32169 }
32170 },
32171 };
32172 request_value_reader
32173 .seek(std::io::SeekFrom::Start(0))
32174 .unwrap();
32175 let mut req_result = {
32176 let client = &self.hub.client;
32177 dlg.pre_request();
32178 let mut req_builder = hyper::Request::builder()
32179 .method(hyper::Method::POST)
32180 .uri(url.as_str())
32181 .header(USER_AGENT, self.hub._user_agent.clone());
32182
32183 if let Some(token) = token.as_ref() {
32184 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32185 }
32186
32187 let request = req_builder
32188 .header(CONTENT_TYPE, json_mime_type.to_string())
32189 .header(CONTENT_LENGTH, request_size as u64)
32190 .body(common::to_body(
32191 request_value_reader.get_ref().clone().into(),
32192 ));
32193
32194 client.request(request.unwrap()).await
32195 };
32196
32197 match req_result {
32198 Err(err) => {
32199 if let common::Retry::After(d) = dlg.http_error(&err) {
32200 sleep(d).await;
32201 continue;
32202 }
32203 dlg.finished(false);
32204 return Err(common::Error::HttpError(err));
32205 }
32206 Ok(res) => {
32207 let (mut parts, body) = res.into_parts();
32208 let mut body = common::Body::new(body);
32209 if !parts.status.is_success() {
32210 let bytes = common::to_bytes(body).await.unwrap_or_default();
32211 let error = serde_json::from_str(&common::to_string(&bytes));
32212 let response = common::to_response(parts, bytes.into());
32213
32214 if let common::Retry::After(d) =
32215 dlg.http_failure(&response, error.as_ref().ok())
32216 {
32217 sleep(d).await;
32218 continue;
32219 }
32220
32221 dlg.finished(false);
32222
32223 return Err(match error {
32224 Ok(value) => common::Error::BadRequest(value),
32225 _ => common::Error::Failure(response),
32226 });
32227 }
32228 let response = {
32229 let bytes = common::to_bytes(body).await.unwrap_or_default();
32230 let encoded = common::to_string(&bytes);
32231 match serde_json::from_str(&encoded) {
32232 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32233 Err(error) => {
32234 dlg.response_json_decode_error(&encoded, &error);
32235 return Err(common::Error::JsonDecodeError(
32236 encoded.to_string(),
32237 error,
32238 ));
32239 }
32240 }
32241 };
32242
32243 dlg.finished(true);
32244 return Ok(response);
32245 }
32246 }
32247 }
32248 }
32249
32250 ///
32251 /// Sets the *request* property to the given value.
32252 ///
32253 /// Even though the property as already been set when instantiating this call,
32254 /// we provide this method for API completeness.
32255 pub fn request(
32256 mut self,
32257 new_value: SetIamPolicyRequest,
32258 ) -> ProjectInstanceSetIamPolicyCall<'a, C> {
32259 self._request = new_value;
32260 self
32261 }
32262 /// 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.
32263 ///
32264 /// Sets the *resource* path property to the given value.
32265 ///
32266 /// Even though the property as already been set when instantiating this call,
32267 /// we provide this method for API completeness.
32268 pub fn resource(mut self, new_value: &str) -> ProjectInstanceSetIamPolicyCall<'a, C> {
32269 self._resource = new_value.to_string();
32270 self
32271 }
32272 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32273 /// while executing the actual API request.
32274 ///
32275 /// ````text
32276 /// It should be used to handle progress information, and to implement a certain level of resilience.
32277 /// ````
32278 ///
32279 /// Sets the *delegate* property to the given value.
32280 pub fn delegate(
32281 mut self,
32282 new_value: &'a mut dyn common::Delegate,
32283 ) -> ProjectInstanceSetIamPolicyCall<'a, C> {
32284 self._delegate = Some(new_value);
32285 self
32286 }
32287
32288 /// Set any additional parameter of the query string used in the request.
32289 /// It should be used to set parameters which are not yet available through their own
32290 /// setters.
32291 ///
32292 /// Please note that this method must not be used to set any of the known parameters
32293 /// which have their own setter method. If done anyway, the request will fail.
32294 ///
32295 /// # Additional Parameters
32296 ///
32297 /// * *$.xgafv* (query-string) - V1 error format.
32298 /// * *access_token* (query-string) - OAuth access token.
32299 /// * *alt* (query-string) - Data format for response.
32300 /// * *callback* (query-string) - JSONP
32301 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32302 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
32303 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32304 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32305 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
32306 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32307 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32308 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceSetIamPolicyCall<'a, C>
32309 where
32310 T: AsRef<str>,
32311 {
32312 self._additional_params
32313 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32314 self
32315 }
32316
32317 /// Identifies the authorization scope for the method you are building.
32318 ///
32319 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32320 /// [`Scope::CloudPlatform`].
32321 ///
32322 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32323 /// tokens for more than one scope.
32324 ///
32325 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32326 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32327 /// sufficient, a read-write scope will do as well.
32328 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceSetIamPolicyCall<'a, C>
32329 where
32330 St: AsRef<str>,
32331 {
32332 self._scopes.insert(String::from(scope.as_ref()));
32333 self
32334 }
32335 /// Identifies the authorization scope(s) for the method you are building.
32336 ///
32337 /// See [`Self::add_scope()`] for details.
32338 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceSetIamPolicyCall<'a, C>
32339 where
32340 I: IntoIterator<Item = St>,
32341 St: AsRef<str>,
32342 {
32343 self._scopes
32344 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32345 self
32346 }
32347
32348 /// Removes all scopes, and no default scope will be used either.
32349 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32350 /// for details).
32351 pub fn clear_scopes(mut self) -> ProjectInstanceSetIamPolicyCall<'a, C> {
32352 self._scopes.clear();
32353 self
32354 }
32355}
32356
32357/// 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.
32358///
32359/// A builder for the *instances.testIamPermissions* method supported by a *project* resource.
32360/// It is not used directly, but through a [`ProjectMethods`] instance.
32361///
32362/// # Example
32363///
32364/// Instantiate a resource method builder
32365///
32366/// ```test_harness,no_run
32367/// # extern crate hyper;
32368/// # extern crate hyper_rustls;
32369/// # extern crate google_spanner1 as spanner1;
32370/// use spanner1::api::TestIamPermissionsRequest;
32371/// # async fn dox() {
32372/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32373///
32374/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32375/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32376/// # secret,
32377/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32378/// # ).build().await.unwrap();
32379///
32380/// # let client = hyper_util::client::legacy::Client::builder(
32381/// # hyper_util::rt::TokioExecutor::new()
32382/// # )
32383/// # .build(
32384/// # hyper_rustls::HttpsConnectorBuilder::new()
32385/// # .with_native_roots()
32386/// # .unwrap()
32387/// # .https_or_http()
32388/// # .enable_http1()
32389/// # .build()
32390/// # );
32391/// # let mut hub = Spanner::new(client, auth);
32392/// // As the method needs a request, you would usually fill it with the desired information
32393/// // into the respective structure. Some of the parts shown here might not be applicable !
32394/// // Values shown here are possibly random and not representative !
32395/// let mut req = TestIamPermissionsRequest::default();
32396///
32397/// // You can configure optional parameters by calling the respective setters at will, and
32398/// // execute the final call using `doit()`.
32399/// // Values shown here are possibly random and not representative !
32400/// let result = hub.projects().instances_test_iam_permissions(req, "resource")
32401/// .doit().await;
32402/// # }
32403/// ```
32404pub struct ProjectInstanceTestIamPermissionCall<'a, C>
32405where
32406 C: 'a,
32407{
32408 hub: &'a Spanner<C>,
32409 _request: TestIamPermissionsRequest,
32410 _resource: String,
32411 _delegate: Option<&'a mut dyn common::Delegate>,
32412 _additional_params: HashMap<String, String>,
32413 _scopes: BTreeSet<String>,
32414}
32415
32416impl<'a, C> common::CallBuilder for ProjectInstanceTestIamPermissionCall<'a, C> {}
32417
32418impl<'a, C> ProjectInstanceTestIamPermissionCall<'a, C>
32419where
32420 C: common::Connector,
32421{
32422 /// Perform the operation you have build so far.
32423 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
32424 use std::borrow::Cow;
32425 use std::io::{Read, Seek};
32426
32427 use common::{url::Params, ToParts};
32428 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32429
32430 let mut dd = common::DefaultDelegate;
32431 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32432 dlg.begin(common::MethodInfo {
32433 id: "spanner.projects.instances.testIamPermissions",
32434 http_method: hyper::Method::POST,
32435 });
32436
32437 for &field in ["alt", "resource"].iter() {
32438 if self._additional_params.contains_key(field) {
32439 dlg.finished(false);
32440 return Err(common::Error::FieldClash(field));
32441 }
32442 }
32443
32444 let mut params = Params::with_capacity(4 + self._additional_params.len());
32445 params.push("resource", self._resource);
32446
32447 params.extend(self._additional_params.iter());
32448
32449 params.push("alt", "json");
32450 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
32451 if self._scopes.is_empty() {
32452 self._scopes
32453 .insert(Scope::CloudPlatform.as_ref().to_string());
32454 }
32455
32456 #[allow(clippy::single_element_loop)]
32457 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
32458 url = params.uri_replacement(url, param_name, find_this, true);
32459 }
32460 {
32461 let to_remove = ["resource"];
32462 params.remove_params(&to_remove);
32463 }
32464
32465 let url = params.parse_with_url(&url);
32466
32467 let mut json_mime_type = mime::APPLICATION_JSON;
32468 let mut request_value_reader = {
32469 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32470 common::remove_json_null_values(&mut value);
32471 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32472 serde_json::to_writer(&mut dst, &value).unwrap();
32473 dst
32474 };
32475 let request_size = request_value_reader
32476 .seek(std::io::SeekFrom::End(0))
32477 .unwrap();
32478 request_value_reader
32479 .seek(std::io::SeekFrom::Start(0))
32480 .unwrap();
32481
32482 loop {
32483 let token = match self
32484 .hub
32485 .auth
32486 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32487 .await
32488 {
32489 Ok(token) => token,
32490 Err(e) => match dlg.token(e) {
32491 Ok(token) => token,
32492 Err(e) => {
32493 dlg.finished(false);
32494 return Err(common::Error::MissingToken(e));
32495 }
32496 },
32497 };
32498 request_value_reader
32499 .seek(std::io::SeekFrom::Start(0))
32500 .unwrap();
32501 let mut req_result = {
32502 let client = &self.hub.client;
32503 dlg.pre_request();
32504 let mut req_builder = hyper::Request::builder()
32505 .method(hyper::Method::POST)
32506 .uri(url.as_str())
32507 .header(USER_AGENT, self.hub._user_agent.clone());
32508
32509 if let Some(token) = token.as_ref() {
32510 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32511 }
32512
32513 let request = req_builder
32514 .header(CONTENT_TYPE, json_mime_type.to_string())
32515 .header(CONTENT_LENGTH, request_size as u64)
32516 .body(common::to_body(
32517 request_value_reader.get_ref().clone().into(),
32518 ));
32519
32520 client.request(request.unwrap()).await
32521 };
32522
32523 match req_result {
32524 Err(err) => {
32525 if let common::Retry::After(d) = dlg.http_error(&err) {
32526 sleep(d).await;
32527 continue;
32528 }
32529 dlg.finished(false);
32530 return Err(common::Error::HttpError(err));
32531 }
32532 Ok(res) => {
32533 let (mut parts, body) = res.into_parts();
32534 let mut body = common::Body::new(body);
32535 if !parts.status.is_success() {
32536 let bytes = common::to_bytes(body).await.unwrap_or_default();
32537 let error = serde_json::from_str(&common::to_string(&bytes));
32538 let response = common::to_response(parts, bytes.into());
32539
32540 if let common::Retry::After(d) =
32541 dlg.http_failure(&response, error.as_ref().ok())
32542 {
32543 sleep(d).await;
32544 continue;
32545 }
32546
32547 dlg.finished(false);
32548
32549 return Err(match error {
32550 Ok(value) => common::Error::BadRequest(value),
32551 _ => common::Error::Failure(response),
32552 });
32553 }
32554 let response = {
32555 let bytes = common::to_bytes(body).await.unwrap_or_default();
32556 let encoded = common::to_string(&bytes);
32557 match serde_json::from_str(&encoded) {
32558 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32559 Err(error) => {
32560 dlg.response_json_decode_error(&encoded, &error);
32561 return Err(common::Error::JsonDecodeError(
32562 encoded.to_string(),
32563 error,
32564 ));
32565 }
32566 }
32567 };
32568
32569 dlg.finished(true);
32570 return Ok(response);
32571 }
32572 }
32573 }
32574 }
32575
32576 ///
32577 /// Sets the *request* property to the given value.
32578 ///
32579 /// Even though the property as already been set when instantiating this call,
32580 /// we provide this method for API completeness.
32581 pub fn request(
32582 mut self,
32583 new_value: TestIamPermissionsRequest,
32584 ) -> ProjectInstanceTestIamPermissionCall<'a, C> {
32585 self._request = new_value;
32586 self
32587 }
32588 /// 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.
32589 ///
32590 /// Sets the *resource* path property to the given value.
32591 ///
32592 /// Even though the property as already been set when instantiating this call,
32593 /// we provide this method for API completeness.
32594 pub fn resource(mut self, new_value: &str) -> ProjectInstanceTestIamPermissionCall<'a, C> {
32595 self._resource = new_value.to_string();
32596 self
32597 }
32598 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32599 /// while executing the actual API request.
32600 ///
32601 /// ````text
32602 /// It should be used to handle progress information, and to implement a certain level of resilience.
32603 /// ````
32604 ///
32605 /// Sets the *delegate* property to the given value.
32606 pub fn delegate(
32607 mut self,
32608 new_value: &'a mut dyn common::Delegate,
32609 ) -> ProjectInstanceTestIamPermissionCall<'a, C> {
32610 self._delegate = Some(new_value);
32611 self
32612 }
32613
32614 /// Set any additional parameter of the query string used in the request.
32615 /// It should be used to set parameters which are not yet available through their own
32616 /// setters.
32617 ///
32618 /// Please note that this method must not be used to set any of the known parameters
32619 /// which have their own setter method. If done anyway, the request will fail.
32620 ///
32621 /// # Additional Parameters
32622 ///
32623 /// * *$.xgafv* (query-string) - V1 error format.
32624 /// * *access_token* (query-string) - OAuth access token.
32625 /// * *alt* (query-string) - Data format for response.
32626 /// * *callback* (query-string) - JSONP
32627 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32628 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
32629 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32630 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32631 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
32632 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32633 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32634 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceTestIamPermissionCall<'a, C>
32635 where
32636 T: AsRef<str>,
32637 {
32638 self._additional_params
32639 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32640 self
32641 }
32642
32643 /// Identifies the authorization scope for the method you are building.
32644 ///
32645 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32646 /// [`Scope::CloudPlatform`].
32647 ///
32648 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32649 /// tokens for more than one scope.
32650 ///
32651 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32652 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32653 /// sufficient, a read-write scope will do as well.
32654 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceTestIamPermissionCall<'a, C>
32655 where
32656 St: AsRef<str>,
32657 {
32658 self._scopes.insert(String::from(scope.as_ref()));
32659 self
32660 }
32661 /// Identifies the authorization scope(s) for the method you are building.
32662 ///
32663 /// See [`Self::add_scope()`] for details.
32664 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceTestIamPermissionCall<'a, C>
32665 where
32666 I: IntoIterator<Item = St>,
32667 St: AsRef<str>,
32668 {
32669 self._scopes
32670 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32671 self
32672 }
32673
32674 /// Removes all scopes, and no default scope will be used either.
32675 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32676 /// for details).
32677 pub fn clear_scopes(mut self) -> ProjectInstanceTestIamPermissionCall<'a, C> {
32678 self._scopes.clear();
32679 self
32680 }
32681}
32682
32683/// Return available scans given a Database-specific resource name.
32684///
32685/// A builder for the *list* method supported by a *scan* resource.
32686/// It is not used directly, but through a [`ScanMethods`] instance.
32687///
32688/// # Example
32689///
32690/// Instantiate a resource method builder
32691///
32692/// ```test_harness,no_run
32693/// # extern crate hyper;
32694/// # extern crate hyper_rustls;
32695/// # extern crate google_spanner1 as spanner1;
32696/// # async fn dox() {
32697/// # use spanner1::{Spanner, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32698///
32699/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32701/// # secret,
32702/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32703/// # ).build().await.unwrap();
32704///
32705/// # let client = hyper_util::client::legacy::Client::builder(
32706/// # hyper_util::rt::TokioExecutor::new()
32707/// # )
32708/// # .build(
32709/// # hyper_rustls::HttpsConnectorBuilder::new()
32710/// # .with_native_roots()
32711/// # .unwrap()
32712/// # .https_or_http()
32713/// # .enable_http1()
32714/// # .build()
32715/// # );
32716/// # let mut hub = Spanner::new(client, auth);
32717/// // You can configure optional parameters by calling the respective setters at will, and
32718/// // execute the final call using `doit()`.
32719/// // Values shown here are possibly random and not representative !
32720/// let result = hub.scans().list("parent")
32721/// .view("Lorem")
32722/// .page_token("accusam")
32723/// .page_size(-47)
32724/// .filter("erat")
32725/// .doit().await;
32726/// # }
32727/// ```
32728pub struct ScanListCall<'a, C>
32729where
32730 C: 'a,
32731{
32732 hub: &'a Spanner<C>,
32733 _parent: String,
32734 _view: Option<String>,
32735 _page_token: Option<String>,
32736 _page_size: Option<i32>,
32737 _filter: Option<String>,
32738 _delegate: Option<&'a mut dyn common::Delegate>,
32739 _additional_params: HashMap<String, String>,
32740 _scopes: BTreeSet<String>,
32741}
32742
32743impl<'a, C> common::CallBuilder for ScanListCall<'a, C> {}
32744
32745impl<'a, C> ScanListCall<'a, C>
32746where
32747 C: common::Connector,
32748{
32749 /// Perform the operation you have build so far.
32750 pub async fn doit(mut self) -> common::Result<(common::Response, ListScansResponse)> {
32751 use std::borrow::Cow;
32752 use std::io::{Read, Seek};
32753
32754 use common::{url::Params, ToParts};
32755 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32756
32757 let mut dd = common::DefaultDelegate;
32758 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32759 dlg.begin(common::MethodInfo {
32760 id: "spanner.scans.list",
32761 http_method: hyper::Method::GET,
32762 });
32763
32764 for &field in ["alt", "parent", "view", "pageToken", "pageSize", "filter"].iter() {
32765 if self._additional_params.contains_key(field) {
32766 dlg.finished(false);
32767 return Err(common::Error::FieldClash(field));
32768 }
32769 }
32770
32771 let mut params = Params::with_capacity(7 + self._additional_params.len());
32772 params.push("parent", self._parent);
32773 if let Some(value) = self._view.as_ref() {
32774 params.push("view", value);
32775 }
32776 if let Some(value) = self._page_token.as_ref() {
32777 params.push("pageToken", value);
32778 }
32779 if let Some(value) = self._page_size.as_ref() {
32780 params.push("pageSize", value.to_string());
32781 }
32782 if let Some(value) = self._filter.as_ref() {
32783 params.push("filter", value);
32784 }
32785
32786 params.extend(self._additional_params.iter());
32787
32788 params.push("alt", "json");
32789 let mut url = self.hub._base_url.clone() + "v1/{+parent}";
32790 if self._scopes.is_empty() {
32791 self._scopes
32792 .insert(Scope::CloudPlatform.as_ref().to_string());
32793 }
32794
32795 #[allow(clippy::single_element_loop)]
32796 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
32797 url = params.uri_replacement(url, param_name, find_this, true);
32798 }
32799 {
32800 let to_remove = ["parent"];
32801 params.remove_params(&to_remove);
32802 }
32803
32804 let url = params.parse_with_url(&url);
32805
32806 loop {
32807 let token = match self
32808 .hub
32809 .auth
32810 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32811 .await
32812 {
32813 Ok(token) => token,
32814 Err(e) => match dlg.token(e) {
32815 Ok(token) => token,
32816 Err(e) => {
32817 dlg.finished(false);
32818 return Err(common::Error::MissingToken(e));
32819 }
32820 },
32821 };
32822 let mut req_result = {
32823 let client = &self.hub.client;
32824 dlg.pre_request();
32825 let mut req_builder = hyper::Request::builder()
32826 .method(hyper::Method::GET)
32827 .uri(url.as_str())
32828 .header(USER_AGENT, self.hub._user_agent.clone());
32829
32830 if let Some(token) = token.as_ref() {
32831 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32832 }
32833
32834 let request = req_builder
32835 .header(CONTENT_LENGTH, 0_u64)
32836 .body(common::to_body::<String>(None));
32837
32838 client.request(request.unwrap()).await
32839 };
32840
32841 match req_result {
32842 Err(err) => {
32843 if let common::Retry::After(d) = dlg.http_error(&err) {
32844 sleep(d).await;
32845 continue;
32846 }
32847 dlg.finished(false);
32848 return Err(common::Error::HttpError(err));
32849 }
32850 Ok(res) => {
32851 let (mut parts, body) = res.into_parts();
32852 let mut body = common::Body::new(body);
32853 if !parts.status.is_success() {
32854 let bytes = common::to_bytes(body).await.unwrap_or_default();
32855 let error = serde_json::from_str(&common::to_string(&bytes));
32856 let response = common::to_response(parts, bytes.into());
32857
32858 if let common::Retry::After(d) =
32859 dlg.http_failure(&response, error.as_ref().ok())
32860 {
32861 sleep(d).await;
32862 continue;
32863 }
32864
32865 dlg.finished(false);
32866
32867 return Err(match error {
32868 Ok(value) => common::Error::BadRequest(value),
32869 _ => common::Error::Failure(response),
32870 });
32871 }
32872 let response = {
32873 let bytes = common::to_bytes(body).await.unwrap_or_default();
32874 let encoded = common::to_string(&bytes);
32875 match serde_json::from_str(&encoded) {
32876 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32877 Err(error) => {
32878 dlg.response_json_decode_error(&encoded, &error);
32879 return Err(common::Error::JsonDecodeError(
32880 encoded.to_string(),
32881 error,
32882 ));
32883 }
32884 }
32885 };
32886
32887 dlg.finished(true);
32888 return Ok(response);
32889 }
32890 }
32891 }
32892 }
32893
32894 /// Required. The unique name of the parent resource, specific to the Database service implementing this interface.
32895 ///
32896 /// Sets the *parent* path property to the given value.
32897 ///
32898 /// Even though the property as already been set when instantiating this call,
32899 /// we provide this method for API completeness.
32900 pub fn parent(mut self, new_value: &str) -> ScanListCall<'a, C> {
32901 self._parent = new_value.to_string();
32902 self
32903 }
32904 /// Specifies which parts of the Scan should be returned in the response. Note, only the SUMMARY view (the default) is currently supported for ListScans.
32905 ///
32906 /// Sets the *view* query property to the given value.
32907 pub fn view(mut self, new_value: &str) -> ScanListCall<'a, C> {
32908 self._view = Some(new_value.to_string());
32909 self
32910 }
32911 /// The next_page_token value returned from a previous List request, if any.
32912 ///
32913 /// Sets the *page token* query property to the given value.
32914 pub fn page_token(mut self, new_value: &str) -> ScanListCall<'a, C> {
32915 self._page_token = Some(new_value.to_string());
32916 self
32917 }
32918 /// The maximum number of items to return.
32919 ///
32920 /// Sets the *page size* query property to the given value.
32921 pub fn page_size(mut self, new_value: i32) -> ScanListCall<'a, C> {
32922 self._page_size = Some(new_value);
32923 self
32924 }
32925 /// 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`.
32926 ///
32927 /// Sets the *filter* query property to the given value.
32928 pub fn filter(mut self, new_value: &str) -> ScanListCall<'a, C> {
32929 self._filter = Some(new_value.to_string());
32930 self
32931 }
32932 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32933 /// while executing the actual API request.
32934 ///
32935 /// ````text
32936 /// It should be used to handle progress information, and to implement a certain level of resilience.
32937 /// ````
32938 ///
32939 /// Sets the *delegate* property to the given value.
32940 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ScanListCall<'a, C> {
32941 self._delegate = Some(new_value);
32942 self
32943 }
32944
32945 /// Set any additional parameter of the query string used in the request.
32946 /// It should be used to set parameters which are not yet available through their own
32947 /// setters.
32948 ///
32949 /// Please note that this method must not be used to set any of the known parameters
32950 /// which have their own setter method. If done anyway, the request will fail.
32951 ///
32952 /// # Additional Parameters
32953 ///
32954 /// * *$.xgafv* (query-string) - V1 error format.
32955 /// * *access_token* (query-string) - OAuth access token.
32956 /// * *alt* (query-string) - Data format for response.
32957 /// * *callback* (query-string) - JSONP
32958 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32959 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
32960 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32961 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32962 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
32963 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32964 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32965 pub fn param<T>(mut self, name: T, value: T) -> ScanListCall<'a, C>
32966 where
32967 T: AsRef<str>,
32968 {
32969 self._additional_params
32970 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32971 self
32972 }
32973
32974 /// Identifies the authorization scope for the method you are building.
32975 ///
32976 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32977 /// [`Scope::CloudPlatform`].
32978 ///
32979 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32980 /// tokens for more than one scope.
32981 ///
32982 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32983 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32984 /// sufficient, a read-write scope will do as well.
32985 pub fn add_scope<St>(mut self, scope: St) -> ScanListCall<'a, C>
32986 where
32987 St: AsRef<str>,
32988 {
32989 self._scopes.insert(String::from(scope.as_ref()));
32990 self
32991 }
32992 /// Identifies the authorization scope(s) for the method you are building.
32993 ///
32994 /// See [`Self::add_scope()`] for details.
32995 pub fn add_scopes<I, St>(mut self, scopes: I) -> ScanListCall<'a, C>
32996 where
32997 I: IntoIterator<Item = St>,
32998 St: AsRef<str>,
32999 {
33000 self._scopes
33001 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33002 self
33003 }
33004
33005 /// Removes all scopes, and no default scope will be used either.
33006 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33007 /// for details).
33008 pub fn clear_scopes(mut self) -> ScanListCall<'a, C> {
33009 self._scopes.clear();
33010 self
33011 }
33012}