google_sql1_beta4/
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    /// View and manage your data across Google Cloud Platform services
17    CloudPlatform,
18
19    /// Manage your Google SQL Service instances
20    ServiceAdmin,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27            Scope::ServiceAdmin => "https://www.googleapis.com/auth/sqlservice.admin",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::CloudPlatform
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all SQLAdmin related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_sql1_beta4 as sql1_beta4;
53/// use sql1_beta4::api::User;
54/// use sql1_beta4::{Result, Error};
55/// # async fn dox() {
56/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67///     .with_native_roots()
68///     .unwrap()
69///     .https_only()
70///     .enable_http2()
71///     .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75///     secret,
76///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77///     yup_oauth2::client::CustomHyperClientBuilder::from(
78///         hyper_util::client::legacy::Client::builder(executor).build(connector),
79///     ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83///     hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86///     hyper_rustls::HttpsConnectorBuilder::new()
87///         .with_native_roots()
88///         .unwrap()
89///         .https_or_http()
90///         .enable_http2()
91///         .build()
92/// );
93/// let mut hub = SQLAdmin::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = User::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.users().update(req, "project", "instance")
103///              .name("amet.")
104///              .host("duo")
105///              .doit().await;
106///
107/// match result {
108///     Err(e) => match e {
109///         // The Error enum provides details about what exactly happened.
110///         // You can also just use its `Debug`, `Display` or `Error` traits
111///          Error::HttpError(_)
112///         |Error::Io(_)
113///         |Error::MissingAPIKey
114///         |Error::MissingToken(_)
115///         |Error::Cancelled
116///         |Error::UploadSizeLimitExceeded(_, _)
117///         |Error::Failure(_)
118///         |Error::BadRequest(_)
119///         |Error::FieldClash(_)
120///         |Error::JsonDecodeError(_, _) => println!("{}", e),
121///     },
122///     Ok(res) => println!("Success: {:?}", res),
123/// }
124/// # }
125/// ```
126#[derive(Clone)]
127pub struct SQLAdmin<C> {
128    pub client: common::Client<C>,
129    pub auth: Box<dyn common::GetToken>,
130    _user_agent: String,
131    _base_url: String,
132    _root_url: String,
133}
134
135impl<C> common::Hub for SQLAdmin<C> {}
136
137impl<'a, C> SQLAdmin<C> {
138    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> SQLAdmin<C> {
139        SQLAdmin {
140            client,
141            auth: Box::new(auth),
142            _user_agent: "google-api-rust-client/7.0.0".to_string(),
143            _base_url: "https://sqladmin.googleapis.com/".to_string(),
144            _root_url: "https://sqladmin.googleapis.com/".to_string(),
145        }
146    }
147
148    pub fn backup_runs(&'a self) -> BackupRunMethods<'a, C> {
149        BackupRunMethods { hub: self }
150    }
151    pub fn databases(&'a self) -> DatabaseMethods<'a, C> {
152        DatabaseMethods { hub: self }
153    }
154    pub fn flags(&'a self) -> FlagMethods<'a, C> {
155        FlagMethods { hub: self }
156    }
157    pub fn instances(&'a self) -> InstanceMethods<'a, C> {
158        InstanceMethods { hub: self }
159    }
160    pub fn operations(&'a self) -> OperationMethods<'a, C> {
161        OperationMethods { hub: self }
162    }
163    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
164        ProjectMethods { hub: self }
165    }
166    pub fn ssl_certs(&'a self) -> SslCertMethods<'a, C> {
167        SslCertMethods { hub: self }
168    }
169    pub fn tiers(&'a self) -> TierMethods<'a, C> {
170        TierMethods { hub: self }
171    }
172    pub fn users(&'a self) -> UserMethods<'a, C> {
173        UserMethods { hub: self }
174    }
175
176    /// Set the user-agent header field to use in all requests to the server.
177    /// It defaults to `google-api-rust-client/7.0.0`.
178    ///
179    /// Returns the previously set user-agent.
180    pub fn user_agent(&mut self, agent_name: String) -> String {
181        std::mem::replace(&mut self._user_agent, agent_name)
182    }
183
184    /// Set the base url to use in all requests to the server.
185    /// It defaults to `https://sqladmin.googleapis.com/`.
186    ///
187    /// Returns the previously set base url.
188    pub fn base_url(&mut self, new_base_url: String) -> String {
189        std::mem::replace(&mut self._base_url, new_base_url)
190    }
191
192    /// Set the root url to use in all requests to the server.
193    /// It defaults to `https://sqladmin.googleapis.com/`.
194    ///
195    /// Returns the previously set root url.
196    pub fn root_url(&mut self, new_root_url: String) -> String {
197        std::mem::replace(&mut self._root_url, new_root_url)
198    }
199}
200
201// ############
202// SCHEMAS ###
203// ##########
204/// An entry for an Access Control list.
205///
206/// This type is not used in any activity, and only used as *part* of another schema.
207///
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209#[serde_with::serde_as]
210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
211pub struct AclEntry {
212    /// The time when this access control entry expires in <a
213    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
214    /// <code>2012-11-15T16:19:00.094Z</code>.
215    #[serde(rename = "expirationTime")]
216    pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
217    /// This is always <code>sql#aclEntry</code>.
218    pub kind: Option<String>,
219    /// Optional. A label to identify this entry.
220    pub name: Option<String>,
221    /// The whitelisted value for the access control list.
222    pub value: Option<String>,
223}
224
225impl common::Part for AclEntry {}
226
227/// An Admin API warning message.
228///
229/// This type is not used in any activity, and only used as *part* of another schema.
230///
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct ApiWarning {
235    /// Code to uniquely identify the warning type.
236    pub code: Option<String>,
237    /// The warning message.
238    pub message: Option<String>,
239}
240
241impl common::Part for ApiWarning {}
242
243/// Database instance backup configuration.
244///
245/// This type is not used in any activity, and only used as *part* of another schema.
246///
247#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
248#[serde_with::serde_as]
249#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
250pub struct BackupConfiguration {
251    /// (MySQL only) Whether binary log is enabled. If backup configuration is
252    /// disabled, binarylog must be disabled as well.
253    #[serde(rename = "binaryLogEnabled")]
254    pub binary_log_enabled: Option<bool>,
255    /// Whether this configuration is enabled.
256    pub enabled: Option<bool>,
257    /// This is always <code>sql#backupConfiguration</code>.
258    pub kind: Option<String>,
259    /// Location of the backup
260    pub location: Option<String>,
261    /// Reserved for future use.
262    #[serde(rename = "pointInTimeRecoveryEnabled")]
263    pub point_in_time_recovery_enabled: Option<bool>,
264    /// Reserved for future use.
265    #[serde(rename = "replicationLogArchivingEnabled")]
266    pub replication_log_archiving_enabled: Option<bool>,
267    /// Start time for the daily backup configuration in UTC timezone in the 24
268    /// hour format - <code>HH:MM</code>.
269    #[serde(rename = "startTime")]
270    pub start_time: Option<String>,
271}
272
273impl common::Part for BackupConfiguration {}
274
275/// A BackupRun resource.
276///
277/// # Activities
278///
279/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
280/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
281///
282/// * [delete backup runs](BackupRunDeleteCall) (none)
283/// * [get backup runs](BackupRunGetCall) (response)
284/// * [insert backup runs](BackupRunInsertCall) (request)
285/// * [list backup runs](BackupRunListCall) (none)
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct BackupRun {
290    /// The description of this run, only applicable to on-demand backups.
291    pub description: Option<String>,
292    /// Encryption configuration specific to a backup.
293    /// Applies only to Second Generation instances.
294    #[serde(rename = "diskEncryptionConfiguration")]
295    pub disk_encryption_configuration: Option<DiskEncryptionConfiguration>,
296    /// Encryption status specific to a backup.
297    /// Applies only to Second Generation instances.
298    #[serde(rename = "diskEncryptionStatus")]
299    pub disk_encryption_status: Option<DiskEncryptionStatus>,
300    /// The time the backup operation completed in UTC timezone in <a
301    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
302    /// <code>2012-11-15T16:19:00.094Z</code>.
303    #[serde(rename = "endTime")]
304    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
305    /// The time the run was enqueued in UTC timezone in <a
306    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
307    /// <code>2012-11-15T16:19:00.094Z</code>.
308    #[serde(rename = "enqueuedTime")]
309    pub enqueued_time: Option<chrono::DateTime<chrono::offset::Utc>>,
310    /// Information about why the backup operation failed. This is only present if
311    /// the run has the FAILED status.
312    pub error: Option<OperationError>,
313    /// The identifier for this backup run. Unique only for a specific Cloud SQL
314    /// instance.
315    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
316    pub id: Option<i64>,
317    /// Name of the database instance.
318    pub instance: Option<String>,
319    /// This is always <code>sql#backupRun</code>.
320    pub kind: Option<String>,
321    /// Location of the backups.
322    pub location: Option<String>,
323    /// The URI of this resource.
324    #[serde(rename = "selfLink")]
325    pub self_link: Option<String>,
326    /// The time the backup operation actually started in UTC timezone in <a
327    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
328    /// <code>2012-11-15T16:19:00.094Z</code>.
329    #[serde(rename = "startTime")]
330    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
331    /// The status of this run.
332    pub status: Option<String>,
333    /// The type of this run; can be either "AUTOMATED" or "ON_DEMAND".
334    #[serde(rename = "type")]
335    pub type_: Option<String>,
336    /// The start time of the backup window during which this the backup was
337    /// attempted in <a href="https://tools.ietf.org/html/rfc3339">RFC 3339</a>
338    /// format, for example <code>2012-11-15T16:19:00.094Z</code>.
339    #[serde(rename = "windowStartTime")]
340    pub window_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
341}
342
343impl common::RequestValue for BackupRun {}
344impl common::Resource for BackupRun {}
345impl common::ResponseResult for BackupRun {}
346
347/// Backup run list results.
348///
349/// # Activities
350///
351/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
352/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
353///
354/// * [list backup runs](BackupRunListCall) (response)
355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
356#[serde_with::serde_as]
357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
358pub struct BackupRunsListResponse {
359    /// A list of backup runs in reverse chronological order of the enqueued time.
360    pub items: Option<Vec<BackupRun>>,
361    /// This is always <code>sql#backupRunsList</code>.
362    pub kind: Option<String>,
363    /// The continuation token, used to page through large result sets. Provide
364    /// this value in a subsequent request to return the next page of results.
365    #[serde(rename = "nextPageToken")]
366    pub next_page_token: Option<String>,
367}
368
369impl common::ResponseResult for BackupRunsListResponse {}
370
371/// Binary log coordinates.
372///
373/// This type is not used in any activity, and only used as *part* of another schema.
374///
375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
376#[serde_with::serde_as]
377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
378pub struct BinLogCoordinates {
379    /// Name of the binary log file for a Cloud SQL instance.
380    #[serde(rename = "binLogFileName")]
381    pub bin_log_file_name: Option<String>,
382    /// Position (offset) within the binary log file.
383    #[serde(rename = "binLogPosition")]
384    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
385    pub bin_log_position: Option<i64>,
386    /// This is always <code>sql#binLogCoordinates</code>.
387    pub kind: Option<String>,
388}
389
390impl common::Part for BinLogCoordinates {}
391
392/// Database instance clone context.
393///
394/// This type is not used in any activity, and only used as *part* of another schema.
395///
396#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
397#[serde_with::serde_as]
398#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
399pub struct CloneContext {
400    /// Binary log coordinates, if specified, identify the position up to which the
401    /// source instance should be cloned. If not specified, the source instance is
402    /// cloned up to the most recent binary log coordinates.
403    #[serde(rename = "binLogCoordinates")]
404    pub bin_log_coordinates: Option<BinLogCoordinates>,
405    /// Name of the Cloud SQL instance to be created as a clone.
406    #[serde(rename = "destinationInstanceName")]
407    pub destination_instance_name: Option<String>,
408    /// This is always <code>sql#cloneContext</code>.
409    pub kind: Option<String>,
410    /// Reserved for future use.
411    #[serde(rename = "pitrTimestampMs")]
412    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
413    pub pitr_timestamp_ms: Option<i64>,
414    /// Reserved for future use.
415    #[serde(rename = "pointInTime")]
416    pub point_in_time: Option<chrono::DateTime<chrono::offset::Utc>>,
417}
418
419impl common::Part for CloneContext {}
420
421/// Represents a SQL database on the Cloud SQL instance.
422///
423/// # Activities
424///
425/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
426/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
427///
428/// * [delete databases](DatabaseDeleteCall) (none)
429/// * [get databases](DatabaseGetCall) (response)
430/// * [insert databases](DatabaseInsertCall) (request)
431/// * [list databases](DatabaseListCall) (none)
432/// * [patch databases](DatabasePatchCall) (request)
433/// * [update databases](DatabaseUpdateCall) (request)
434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
435#[serde_with::serde_as]
436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
437pub struct Database {
438    /// The MySQL charset value.
439    pub charset: Option<String>,
440    /// The MySQL collation value.
441    pub collation: Option<String>,
442    /// This field is deprecated and will be removed from a future version of the
443    /// API.
444    pub etag: Option<String>,
445    /// The name of the Cloud SQL instance. This does not include the project ID.
446    pub instance: Option<String>,
447    /// This is always <code>sql#database</code>.
448    pub kind: Option<String>,
449    /// The name of the database in the Cloud SQL instance. This does not include
450    /// the project ID or instance name.
451    pub name: Option<String>,
452    /// The project ID of the project containing the Cloud SQL database. The Google
453    /// apps domain is prefixed if applicable.
454    pub project: Option<String>,
455    /// The URI of this resource.
456    #[serde(rename = "selfLink")]
457    pub self_link: Option<String>,
458    /// no description provided
459    #[serde(rename = "sqlserverDatabaseDetails")]
460    pub sqlserver_database_details: Option<SqlServerDatabaseDetails>,
461}
462
463impl common::RequestValue for Database {}
464impl common::Resource for Database {}
465impl common::ResponseResult for Database {}
466
467/// Database flags for Cloud SQL instances.
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 DatabaseFlags {
475    /// The name of the flag. These flags are passed at instance startup, so
476    /// include both server options and system variables for MySQL. Flags should be
477    /// specified with underscores, not hyphens. For more information, see <a
478    /// href="/sql/docs/mysql/flags">Configuring Database Flags</a> in the Cloud
479    /// SQL documentation.
480    pub name: Option<String>,
481    /// The value of the flag. Booleans should be set to <code>on</code> for true
482    /// and <code>off</code> for false. This field must be omitted if the flag
483    /// doesn't take a value.
484    pub value: Option<String>,
485}
486
487impl common::Part for DatabaseFlags {}
488
489/// A Cloud SQL instance resource.
490///
491/// # Activities
492///
493/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
494/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
495///
496/// * [get instances](InstanceGetCall) (response)
497/// * [insert instances](InstanceInsertCall) (request)
498/// * [patch instances](InstancePatchCall) (request)
499/// * [update instances](InstanceUpdateCall) (request)
500#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
501#[serde_with::serde_as]
502#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
503pub struct DatabaseInstance {
504    /// <code>FIRST_GEN</code>: First Generation instance. MySQL only. <br
505    /// /><code>SECOND_GEN</code>: Second Generation instance or PostgreSQL
506    /// instance. <br /><code>EXTERNAL</code>: A database server that is not
507    /// managed by Google. <br>This property is read-only; use the
508    /// <code>tier</code> property in the <code>settings</code> object to determine
509    /// the database type and Second or First Generation.
510    #[serde(rename = "backendType")]
511    pub backend_type: Option<String>,
512    /// Connection name of the Cloud SQL instance used in connection strings.
513    #[serde(rename = "connectionName")]
514    pub connection_name: Option<String>,
515    /// The current disk usage of the instance in bytes. This property has been
516    /// deprecated. Users should use the
517    /// "cloudsql.googleapis.com/database/disk/bytes_used" metric in Cloud
518    /// Monitoring API instead. Please see <a
519    /// href="https://groups.google.com/d/msg/google-cloud-sql-announce/I_7-F9EBhT0/BtvFtdFeAgAJ">this
520    /// announcement</a> for details.
521    #[serde(rename = "currentDiskSize")]
522    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
523    pub current_disk_size: Option<i64>,
524    /// The database engine type and version. The <code>databaseVersion</code>
525    /// field can not be changed after instance creation.  MySQL Second Generation
526    /// instances: <code>MYSQL_5_7</code> (default) or <code>MYSQL_5_6</code>.
527    /// PostgreSQL instances: <code>POSTGRES_9_6</code> (default) or
528    /// <code>POSTGRES_11 Beta</code> MySQL First Generation
529    /// instances: <code>MYSQL_5_6</code> (default) or <code>MYSQL_5_5</code>
530    #[serde(rename = "databaseVersion")]
531    pub database_version: Option<String>,
532    /// Disk encryption configuration specific to an instance.
533    /// Applies only to Second Generation instances.
534    #[serde(rename = "diskEncryptionConfiguration")]
535    pub disk_encryption_configuration: Option<DiskEncryptionConfiguration>,
536    /// Disk encryption status specific to an instance.
537    /// Applies only to Second Generation instances.
538    #[serde(rename = "diskEncryptionStatus")]
539    pub disk_encryption_status: Option<DiskEncryptionStatus>,
540    /// This field is deprecated and will be removed from a future version of the
541    /// API. Use the <code>settings.settingsVersion</code> field instead.
542    pub etag: Option<String>,
543    /// The name and status of the failover replica. This property is applicable
544    /// only to Second Generation instances.
545    #[serde(rename = "failoverReplica")]
546    pub failover_replica: Option<DatabaseInstanceFailoverReplica>,
547    /// The Compute Engine zone that the instance is currently serving from. This
548    /// value could be different from the zone that was specified when the instance
549    /// was created if the instance has failed over to its secondary zone.
550    #[serde(rename = "gceZone")]
551    pub gce_zone: Option<String>,
552    /// The instance type. This can be one of the following.
553    /// <br><code>CLOUD_SQL_INSTANCE</code>: A Cloud SQL instance that is not
554    /// replicating from a master. <br><code>ON_PREMISES_INSTANCE</code>: An
555    /// instance running on the
556    /// customer's premises. <br><code>READ_REPLICA_INSTANCE</code>: A Cloud SQL
557    /// instance configured as a read-replica.
558    #[serde(rename = "instanceType")]
559    pub instance_type: Option<String>,
560    /// The assigned IP addresses for the instance.
561    #[serde(rename = "ipAddresses")]
562    pub ip_addresses: Option<Vec<IpMapping>>,
563    /// The IPv6 address assigned to the instance. This property is applicable only
564    /// to First Generation instances.
565    #[serde(rename = "ipv6Address")]
566    pub ipv6_address: Option<String>,
567    /// This is always <code>sql#instance</code>.
568    pub kind: Option<String>,
569    /// The name of the instance which will act as master in the replication setup.
570    #[serde(rename = "masterInstanceName")]
571    pub master_instance_name: Option<String>,
572    /// The maximum disk size of the instance in bytes.
573    #[serde(rename = "maxDiskSize")]
574    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
575    pub max_disk_size: Option<i64>,
576    /// Name of the Cloud SQL instance. This does not include the project ID.
577    pub name: Option<String>,
578    /// Configuration specific to on-premises instances.
579    #[serde(rename = "onPremisesConfiguration")]
580    pub on_premises_configuration: Option<OnPremisesConfiguration>,
581    /// The project ID of the project containing the Cloud SQL instance. The Google
582    /// apps domain is prefixed if applicable.
583    pub project: Option<String>,
584    /// The geographical region. Can be <code>us-central</code>
585    /// (<code>FIRST_GEN</code> instances only), <code>us-central1</code>
586    /// (<code>SECOND_GEN</code> instances only), <code>asia-east1</code> or
587    /// <code>europe-west1</code>. Defaults to <code>us-central</code> or
588    /// <code>us-central1</code> depending on the instance type (First Generation
589    /// or Second Generation). The region can not be changed after instance
590    /// creation.
591    pub region: Option<String>,
592    /// Configuration specific to failover replicas and read replicas.
593    #[serde(rename = "replicaConfiguration")]
594    pub replica_configuration: Option<ReplicaConfiguration>,
595    /// The replicas of the instance.
596    #[serde(rename = "replicaNames")]
597    pub replica_names: Option<Vec<String>>,
598    /// Initial root password. Use only on creation.
599    #[serde(rename = "rootPassword")]
600    pub root_password: Option<String>,
601    /// The start time of any upcoming scheduled maintenance for this instance.
602    #[serde(rename = "scheduledMaintenance")]
603    pub scheduled_maintenance: Option<SqlScheduledMaintenance>,
604    /// The URI of this resource.
605    #[serde(rename = "selfLink")]
606    pub self_link: Option<String>,
607    /// SSL configuration.
608    #[serde(rename = "serverCaCert")]
609    pub server_ca_cert: Option<SslCert>,
610    /// The service account email address assigned to the instance. This property
611    /// is applicable only to Second Generation instances.
612    #[serde(rename = "serviceAccountEmailAddress")]
613    pub service_account_email_address: Option<String>,
614    /// The user settings.
615    pub settings: Option<Settings>,
616    /// The current serving state of the Cloud SQL instance. This can be one of the
617    /// following. <br><code>RUNNABLE</code>: The instance is running, or is ready
618    /// to run when accessed. <br><code>SUSPENDED</code>: The instance is not
619    /// available, for example due to problems with billing.
620    /// <br><code>PENDING_CREATE</code>: The instance is being created.
621    /// <br><code>MAINTENANCE</code>: The instance is down for maintenance.
622    /// <br><code>FAILED</code>: The instance creation failed.
623    /// <br><code>UNKNOWN_STATE</code>: The state of the instance is unknown.
624    pub state: Option<String>,
625    /// If the instance state is SUSPENDED, the reason for the suspension.
626    #[serde(rename = "suspensionReason")]
627    pub suspension_reason: Option<Vec<String>>,
628}
629
630impl common::RequestValue for DatabaseInstance {}
631impl common::ResponseResult for DatabaseInstance {}
632
633/// Database list response.
634///
635/// # Activities
636///
637/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
638/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
639///
640/// * [list databases](DatabaseListCall) (response)
641#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
642#[serde_with::serde_as]
643#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
644pub struct DatabasesListResponse {
645    /// List of database resources in the instance.
646    pub items: Option<Vec<Database>>,
647    /// This is always <code>sql#databasesList</code>.
648    pub kind: Option<String>,
649}
650
651impl common::ResponseResult for DatabasesListResponse {}
652
653/// Read-replica configuration for connecting to the on-premises master.
654///
655/// This type is not used in any activity, and only used as *part* of another schema.
656///
657#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
658#[serde_with::serde_as]
659#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
660pub struct DemoteMasterConfiguration {
661    /// This is always <code>sql#demoteMasterConfiguration</code>.
662    pub kind: Option<String>,
663    /// MySQL specific configuration when replicating from a MySQL on-premises
664    /// master. Replication configuration information such as the username,
665    /// password, certificates, and keys are not stored in the instance metadata.
666    /// The configuration information is used only to set up the replication
667    /// connection and is stored by MySQL in a file named <code>master.info</code>
668    /// in the data directory.
669    #[serde(rename = "mysqlReplicaConfiguration")]
670    pub mysql_replica_configuration: Option<DemoteMasterMySqlReplicaConfiguration>,
671}
672
673impl common::Part for DemoteMasterConfiguration {}
674
675/// Database instance demote master context.
676///
677/// This type is not used in any activity, and only used as *part* of another schema.
678///
679#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
680#[serde_with::serde_as]
681#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
682pub struct DemoteMasterContext {
683    /// This is always <code>sql#demoteMasterContext</code>.
684    pub kind: Option<String>,
685    /// The name of the instance which will act as on-premises master in the
686    /// replication setup.
687    #[serde(rename = "masterInstanceName")]
688    pub master_instance_name: Option<String>,
689    /// Configuration specific to read-replicas replicating from the on-premises
690    /// master.
691    #[serde(rename = "replicaConfiguration")]
692    pub replica_configuration: Option<DemoteMasterConfiguration>,
693    /// Verify GTID consistency for demote operation. Default value:
694    /// <code>True</code>. Second Generation instances only.  Setting this flag to
695    /// false enables you to bypass GTID consistency check between on-premises
696    /// master and Cloud SQL instance during the demotion operation but also
697    /// exposes you to the risk of future replication failures. Change the value
698    /// only if you know the reason for the GTID divergence and are confident that
699    /// doing so will not cause any replication issues.
700    #[serde(rename = "verifyGtidConsistency")]
701    pub verify_gtid_consistency: Option<bool>,
702}
703
704impl common::Part for DemoteMasterContext {}
705
706/// Read-replica configuration specific to MySQL databases.
707///
708/// This type is not used in any activity, and only used as *part* of another schema.
709///
710#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
711#[serde_with::serde_as]
712#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
713pub struct DemoteMasterMySqlReplicaConfiguration {
714    /// PEM representation of the trusted CA's x509 certificate.
715    #[serde(rename = "caCertificate")]
716    pub ca_certificate: Option<String>,
717    /// PEM representation of the slave's x509 certificate.
718    #[serde(rename = "clientCertificate")]
719    pub client_certificate: Option<String>,
720    /// PEM representation of the slave's private key. The corresponsing public key
721    /// is encoded in the client's certificate. The format of the slave's private
722    /// key can be either PKCS #1 or PKCS #8.
723    #[serde(rename = "clientKey")]
724    pub client_key: Option<String>,
725    /// This is always <code>sql#demoteMasterMysqlReplicaConfiguration</code>.
726    pub kind: Option<String>,
727    /// The password for the replication connection.
728    pub password: Option<String>,
729    /// The username for the replication connection.
730    pub username: Option<String>,
731}
732
733impl common::Part for DemoteMasterMySqlReplicaConfiguration {}
734
735/// Disk encryption configuration for an instance.
736///
737/// This type is not used in any activity, and only used as *part* of another schema.
738///
739#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
740#[serde_with::serde_as]
741#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
742pub struct DiskEncryptionConfiguration {
743    /// This is always <code>sql#diskEncryptionConfiguration</code>.
744    pub kind: Option<String>,
745    /// Resource name of KMS key for disk encryption
746    #[serde(rename = "kmsKeyName")]
747    pub kms_key_name: Option<String>,
748}
749
750impl common::Part for DiskEncryptionConfiguration {}
751
752/// Disk encryption status for an instance.
753///
754/// This type is not used in any activity, and only used as *part* of another schema.
755///
756#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
757#[serde_with::serde_as]
758#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
759pub struct DiskEncryptionStatus {
760    /// This is always <code>sql#diskEncryptionStatus</code>.
761    pub kind: Option<String>,
762    /// KMS key version used to encrypt the Cloud SQL instance resource
763    #[serde(rename = "kmsKeyVersionName")]
764    pub kms_key_version_name: Option<String>,
765}
766
767impl common::Part for DiskEncryptionStatus {}
768
769/// Database instance export context.
770///
771/// This type is not used in any activity, and only used as *part* of another schema.
772///
773#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
774#[serde_with::serde_as]
775#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
776pub struct ExportContext {
777    /// Options for exporting data as CSV.
778    #[serde(rename = "csvExportOptions")]
779    pub csv_export_options: Option<ExportContextCsvExportOptions>,
780    /// Databases to be exported. <br /> <b>MySQL instances:</b> If
781    /// <code>fileType</code> is <code>SQL</code> and no database is specified, all
782    /// databases are exported, except for the <code>mysql</code> system database.
783    /// If <code>fileType</code> is <code>CSV</code>, you can specify one database,
784    /// either by using this property or by using the
785    /// <code>csvExportOptions.selectQuery</code> property, which takes precedence
786    /// over this property. <br /> <b>PostgreSQL instances:</b> You must specify
787    /// one database to be exported. If <code>fileType</code> is <code>CSV</code>,
788    /// this database must match the one specified in the
789    /// <code>csvExportOptions.selectQuery</code> property.
790    pub databases: Option<Vec<String>>,
791    /// The file type for the specified uri. <br><code>SQL</code>: The file
792    /// contains SQL statements. <br><code>CSV</code>: The file contains CSV data.
793    #[serde(rename = "fileType")]
794    pub file_type: Option<String>,
795    /// This is always <code>sql#exportContext</code>.
796    pub kind: Option<String>,
797    /// Options for exporting data as SQL statements.
798    #[serde(rename = "sqlExportOptions")]
799    pub sql_export_options: Option<ExportContextSqlExportOptions>,
800    /// The path to the file in Google Cloud Storage where the export will be
801    /// stored. The URI is in the form <code>gs:
802    /// //bucketName/fileName</code>. If the file already exists, the requests
803    /// // succeeds, but the operation fails. If <code>fileType</code> is
804    /// // <code>SQL</code> and the filename ends with .gz, the contents are
805    /// // compressed.
806    pub uri: Option<String>,
807}
808
809impl common::Part for ExportContext {}
810
811/// Database instance failover context.
812///
813/// This type is not used in any activity, and only used as *part* of another schema.
814///
815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
816#[serde_with::serde_as]
817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
818pub struct FailoverContext {
819    /// This is always <code>sql#failoverContext</code>.
820    pub kind: Option<String>,
821    /// The current settings version of this instance. Request will be rejected if
822    /// this version doesn't match the current settings version.
823    #[serde(rename = "settingsVersion")]
824    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
825    pub settings_version: Option<i64>,
826}
827
828impl common::Part for FailoverContext {}
829
830/// A flag resource.
831///
832/// # Activities
833///
834/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
835/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
836///
837/// * [list flags](FlagListCall) (none)
838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
839#[serde_with::serde_as]
840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
841pub struct Flag {
842    /// Use this field if only certain integers are accepted. Can be combined
843    /// with min_value and max_value to add additional values.
844    #[serde(rename = "allowedIntValues")]
845    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
846    pub allowed_int_values: Option<Vec<i64>>,
847    /// For <code>STRING</code> flags, a list of strings that the value can be set
848    /// to.
849    #[serde(rename = "allowedStringValues")]
850    pub allowed_string_values: Option<Vec<String>>,
851    /// The database version this flag applies to. Can be <code>MYSQL_5_5</code>,
852    /// <code>MYSQL_5_6</code>, or <code>MYSQL_5_7</code>. <code>MYSQL_5_7</code>
853    /// is applicable only to Second Generation instances.
854    #[serde(rename = "appliesTo")]
855    pub applies_to: Option<Vec<String>>,
856    /// Whether or not the flag is considered in beta.
857    #[serde(rename = "inBeta")]
858    pub in_beta: Option<bool>,
859    /// This is always <code>sql#flag</code>.
860    pub kind: Option<String>,
861    /// For <code>INTEGER</code> flags, the maximum allowed value.
862    #[serde(rename = "maxValue")]
863    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
864    pub max_value: Option<i64>,
865    /// For <code>INTEGER</code> flags, the minimum allowed value.
866    #[serde(rename = "minValue")]
867    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
868    pub min_value: Option<i64>,
869    /// This is the name of the flag. Flag names always use underscores, not
870    /// hyphens, e.g. <code>max_allowed_packet</code>
871    pub name: Option<String>,
872    /// Indicates whether changing this flag will trigger a database restart. Only
873    /// applicable to Second Generation instances.
874    #[serde(rename = "requiresRestart")]
875    pub requires_restart: Option<bool>,
876    /// The type of the flag. Flags are typed to being <code>BOOLEAN</code>,
877    /// <code>STRING</code>, <code>INTEGER</code> or <code>NONE</code>.
878    /// <code>NONE</code> is used for flags which do not take a value, such as
879    /// <code>skip_grant_tables</code>.
880    #[serde(rename = "type")]
881    pub type_: Option<String>,
882}
883
884impl common::Resource for Flag {}
885
886/// Flags list response.
887///
888/// # Activities
889///
890/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
891/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
892///
893/// * [list flags](FlagListCall) (response)
894#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
895#[serde_with::serde_as]
896#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
897pub struct FlagsListResponse {
898    /// List of flags.
899    pub items: Option<Vec<Flag>>,
900    /// This is always <code>sql#flagsList</code>.
901    pub kind: Option<String>,
902}
903
904impl common::ResponseResult for FlagsListResponse {}
905
906/// Database instance import context.
907///
908/// This type is not used in any activity, and only used as *part* of another schema.
909///
910#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
911#[serde_with::serde_as]
912#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
913pub struct ImportContext {
914    /// Import parameters specific to SQL Server .BAK files
915    #[serde(rename = "bakImportOptions")]
916    pub bak_import_options: Option<ImportContextBakImportOptions>,
917    /// Options for importing data as CSV.
918    #[serde(rename = "csvImportOptions")]
919    pub csv_import_options: Option<ImportContextCsvImportOptions>,
920    /// The target database for the import. If <code>fileType</code> is
921    /// <code>SQL</code>, this field is required only if the import file does not
922    /// specify a database, and is overridden by any database specification in the
923    /// import file. If <code>fileType</code> is <code>CSV</code>, one database
924    /// must be specified.
925    pub database: Option<String>,
926    /// The file type for the specified uri. <br><code>SQL</code>: The file
927    /// contains SQL statements. <br><code>CSV</code>: The file contains CSV data.
928    #[serde(rename = "fileType")]
929    pub file_type: Option<String>,
930    /// The PostgreSQL user for this import operation. PostgreSQL instances only.
931    #[serde(rename = "importUser")]
932    pub import_user: Option<String>,
933    /// This is always <code>sql#importContext</code>.
934    pub kind: Option<String>,
935    /// Path to the import file in Cloud Storage, in the form
936    /// <code>gs:
937    /// //bucketName/fileName</code>. Compressed gzip files (.gz) are supported
938    /// // when <code>fileType</code> is <code>SQL</code>. The instance must have
939    /// // write permissions to the bucket and read access to the file.
940    pub uri: Option<String>,
941}
942
943impl common::Part for ImportContext {}
944
945/// Database instance clone request.
946///
947/// # Activities
948///
949/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
950/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
951///
952/// * [clone instances](InstanceCloneCall) (request)
953#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
954#[serde_with::serde_as]
955#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
956pub struct InstancesCloneRequest {
957    /// Contains details about the clone operation.
958    #[serde(rename = "cloneContext")]
959    pub clone_context: Option<CloneContext>,
960}
961
962impl common::RequestValue for InstancesCloneRequest {}
963
964/// Database demote master request.
965///
966/// # Activities
967///
968/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
969/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
970///
971/// * [demote master instances](InstanceDemoteMasterCall) (request)
972#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
973#[serde_with::serde_as]
974#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
975pub struct InstancesDemoteMasterRequest {
976    /// Contains details about the demoteMaster operation.
977    #[serde(rename = "demoteMasterContext")]
978    pub demote_master_context: Option<DemoteMasterContext>,
979}
980
981impl common::RequestValue for InstancesDemoteMasterRequest {}
982
983/// Database instance export request.
984///
985/// # Activities
986///
987/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
988/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
989///
990/// * [export instances](InstanceExportCall) (request)
991#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
992#[serde_with::serde_as]
993#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
994pub struct InstancesExportRequest {
995    /// Contains details about the export operation.
996    #[serde(rename = "exportContext")]
997    pub export_context: Option<ExportContext>,
998}
999
1000impl common::RequestValue for InstancesExportRequest {}
1001
1002/// Instance failover request.
1003///
1004/// # Activities
1005///
1006/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1007/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1008///
1009/// * [failover instances](InstanceFailoverCall) (request)
1010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1011#[serde_with::serde_as]
1012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1013pub struct InstancesFailoverRequest {
1014    /// Failover Context.
1015    #[serde(rename = "failoverContext")]
1016    pub failover_context: Option<FailoverContext>,
1017}
1018
1019impl common::RequestValue for InstancesFailoverRequest {}
1020
1021/// Database instance import request.
1022///
1023/// # Activities
1024///
1025/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1026/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1027///
1028/// * [import instances](InstanceImportCall) (request)
1029#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1030#[serde_with::serde_as]
1031#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1032pub struct InstancesImportRequest {
1033    /// Contains details about the import operation.
1034    #[serde(rename = "importContext")]
1035    pub import_context: Option<ImportContext>,
1036}
1037
1038impl common::RequestValue for InstancesImportRequest {}
1039
1040/// Database instances list response.
1041///
1042/// # Activities
1043///
1044/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1045/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1046///
1047/// * [list instances](InstanceListCall) (response)
1048#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1049#[serde_with::serde_as]
1050#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1051pub struct InstancesListResponse {
1052    /// List of database instance resources.
1053    pub items: Option<Vec<DatabaseInstance>>,
1054    /// This is always <code>sql#instancesList</code>.
1055    pub kind: Option<String>,
1056    /// The continuation token, used to page through large result sets. Provide
1057    /// this value in a subsequent request to return the next page of results.
1058    #[serde(rename = "nextPageToken")]
1059    pub next_page_token: Option<String>,
1060    /// List of warnings that occurred while handling the request.
1061    pub warnings: Option<Vec<ApiWarning>>,
1062}
1063
1064impl common::ResponseResult for InstancesListResponse {}
1065
1066/// Instances ListServerCas response.
1067///
1068/// # Activities
1069///
1070/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1071/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1072///
1073/// * [list server cas instances](InstanceListServerCaCall) (response)
1074#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1075#[serde_with::serde_as]
1076#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1077pub struct InstancesListServerCasResponse {
1078    /// no description provided
1079    #[serde(rename = "activeVersion")]
1080    pub active_version: Option<String>,
1081    /// List of server CA certificates for the instance.
1082    pub certs: Option<Vec<SslCert>>,
1083    /// This is always <code>sql#instancesListServerCas</code>.
1084    pub kind: Option<String>,
1085}
1086
1087impl common::ResponseResult for InstancesListServerCasResponse {}
1088
1089/// Database instance restore backup request.
1090///
1091/// # Activities
1092///
1093/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1094/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1095///
1096/// * [restore backup instances](InstanceRestoreBackupCall) (request)
1097#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1098#[serde_with::serde_as]
1099#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1100pub struct InstancesRestoreBackupRequest {
1101    /// Parameters required to perform the restore backup operation.
1102    #[serde(rename = "restoreBackupContext")]
1103    pub restore_backup_context: Option<RestoreBackupContext>,
1104}
1105
1106impl common::RequestValue for InstancesRestoreBackupRequest {}
1107
1108/// Rotate Server CA request.
1109///
1110/// # Activities
1111///
1112/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1113/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1114///
1115/// * [rotate server ca instances](InstanceRotateServerCaCall) (request)
1116#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1117#[serde_with::serde_as]
1118#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1119pub struct InstancesRotateServerCaRequest {
1120    /// Contains details about the rotate server CA operation.
1121    #[serde(rename = "rotateServerCaContext")]
1122    pub rotate_server_ca_context: Option<RotateServerCaContext>,
1123}
1124
1125impl common::RequestValue for InstancesRotateServerCaRequest {}
1126
1127/// Instance truncate log request.
1128///
1129/// # Activities
1130///
1131/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1132/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1133///
1134/// * [truncate log instances](InstanceTruncateLogCall) (request)
1135#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1136#[serde_with::serde_as]
1137#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1138pub struct InstancesTruncateLogRequest {
1139    /// Contains details about the truncate log operation.
1140    #[serde(rename = "truncateLogContext")]
1141    pub truncate_log_context: Option<TruncateLogContext>,
1142}
1143
1144impl common::RequestValue for InstancesTruncateLogRequest {}
1145
1146/// IP Management configuration.
1147///
1148/// This type is not used in any activity, and only used as *part* of another schema.
1149///
1150#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1151#[serde_with::serde_as]
1152#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1153pub struct IpConfiguration {
1154    /// The list of external networks that are allowed to connect to the instance
1155    /// using the IP. In <a
1156    /// href="http://en.wikipedia.org/wiki/CIDR_notation#CIDR_notation">CIDR
1157    /// notation</a>, also known as 'slash' notation (e.g.
1158    /// <code>192.168.100.0/24</code>).
1159    #[serde(rename = "authorizedNetworks")]
1160    pub authorized_networks: Option<Vec<AclEntry>>,
1161    /// Whether the instance should be assigned an IP address or not.
1162    #[serde(rename = "ipv4Enabled")]
1163    pub ipv4_enabled: Option<bool>,
1164    /// The resource link for the VPC network from which the Cloud SQL instance is
1165    /// accessible for private IP. For example,
1166    /// <code>/projects/myProject/global/networks/default</code>. This setting can
1167    /// be updated, but it cannot be removed after it is set.
1168    #[serde(rename = "privateNetwork")]
1169    pub private_network: Option<String>,
1170    /// Whether SSL connections over IP should be enforced or not.
1171    #[serde(rename = "requireSsl")]
1172    pub require_ssl: Option<bool>,
1173}
1174
1175impl common::Part for IpConfiguration {}
1176
1177/// Database instance IP Mapping.
1178///
1179/// This type is not used in any activity, and only used as *part* of another schema.
1180///
1181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1182#[serde_with::serde_as]
1183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1184pub struct IpMapping {
1185    /// The IP address assigned.
1186    #[serde(rename = "ipAddress")]
1187    pub ip_address: Option<String>,
1188    /// The due time for this IP to be retired in <a
1189    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1190    /// <code>2012-11-15T16:19:00.094Z</code>. This field is only available when
1191    /// the IP is scheduled to be retired.
1192    #[serde(rename = "timeToRetire")]
1193    pub time_to_retire: Option<chrono::DateTime<chrono::offset::Utc>>,
1194    /// The type of this IP address. A <code>PRIMARY</code> address is a public
1195    /// address that can accept incoming connections. A <code>PRIVATE</code>
1196    /// address is a private address that can accept incoming connections. An
1197    /// <code>OUTGOING</code> address is the source address of connections
1198    /// originating from the instance, if supported.
1199    #[serde(rename = "type")]
1200    pub type_: Option<String>,
1201}
1202
1203impl common::Part for IpMapping {}
1204
1205/// Preferred location. This specifies where a Cloud SQL instance should
1206/// preferably be located, either in a specific Compute Engine zone, or
1207/// co-located with an App Engine application. Note that if the preferred
1208/// location is not available, the instance will be located as close as possible
1209/// within the region. Only one location may be specified.
1210///
1211/// This type is not used in any activity, and only used as *part* of another schema.
1212///
1213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1214#[serde_with::serde_as]
1215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1216pub struct LocationPreference {
1217    /// The AppEngine application to follow, it must be in the same region as the
1218    /// Cloud SQL instance.
1219    #[serde(rename = "followGaeApplication")]
1220    pub follow_gae_application: Option<String>,
1221    /// This is always <code>sql#locationPreference</code>.
1222    pub kind: Option<String>,
1223    /// The preferred Compute Engine zone (e.g. us-central1-a, us-central1-b,
1224    /// etc.).
1225    pub zone: Option<String>,
1226}
1227
1228impl common::Part for LocationPreference {}
1229
1230/// Maintenance window. This specifies when a v2 Cloud SQL instance should
1231/// preferably be restarted for system maintenance purposes.
1232///
1233/// This type is not used in any activity, and only used as *part* of another schema.
1234///
1235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1236#[serde_with::serde_as]
1237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1238pub struct MaintenanceWindow {
1239    /// day of week (1-7), starting on Monday.
1240    pub day: Option<i32>,
1241    /// hour of day - 0 to 23.
1242    pub hour: Option<i32>,
1243    /// This is always <code>sql#maintenanceWindow</code>.
1244    pub kind: Option<String>,
1245    /// Maintenance timing setting: <code>canary</code> (Earlier) or
1246    /// <code>stable</code> (Later). <br /><a
1247    /// href="/sql/docs/db_path/instance-settings#maintenance-timing-2ndgen">
1248    /// Learn more</a>.
1249    #[serde(rename = "updateTrack")]
1250    pub update_track: Option<String>,
1251}
1252
1253impl common::Part for MaintenanceWindow {}
1254
1255/// Read-replica configuration specific to MySQL databases.
1256///
1257/// This type is not used in any activity, and only used as *part* of another schema.
1258///
1259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1260#[serde_with::serde_as]
1261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1262pub struct MySqlReplicaConfiguration {
1263    /// PEM representation of the trusted CA's x509 certificate.
1264    #[serde(rename = "caCertificate")]
1265    pub ca_certificate: Option<String>,
1266    /// PEM representation of the slave's x509 certificate.
1267    #[serde(rename = "clientCertificate")]
1268    pub client_certificate: Option<String>,
1269    /// PEM representation of the slave's private key. The corresponsing public key
1270    /// is encoded in the client's certificate.
1271    #[serde(rename = "clientKey")]
1272    pub client_key: Option<String>,
1273    /// Seconds to wait between connect retries. MySQL's default is 60 seconds.
1274    #[serde(rename = "connectRetryInterval")]
1275    pub connect_retry_interval: Option<i32>,
1276    /// Path to a SQL dump file in Google Cloud Storage from which the slave
1277    /// instance is to be created. The URI is in the form gs:
1278    /// //bucketName/fileName. Compressed gzip files (.gz) are also supported.
1279    /// // Dumps should have the binlog co-ordinates from which replication should
1280    /// // begin. This can be accomplished by setting --master-data to 1 when using
1281    /// // mysqldump.
1282    #[serde(rename = "dumpFilePath")]
1283    pub dump_file_path: Option<String>,
1284    /// This is always <code>sql#mysqlReplicaConfiguration</code>.
1285    pub kind: Option<String>,
1286    /// Interval in milliseconds between replication heartbeats.
1287    #[serde(rename = "masterHeartbeatPeriod")]
1288    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1289    pub master_heartbeat_period: Option<i64>,
1290    /// The password for the replication connection.
1291    pub password: Option<String>,
1292    /// A list of permissible ciphers to use for SSL encryption.
1293    #[serde(rename = "sslCipher")]
1294    pub ssl_cipher: Option<String>,
1295    /// The username for the replication connection.
1296    pub username: Option<String>,
1297    /// Whether or not to check the master's Common Name value in the certificate
1298    /// that it sends during the SSL handshake.
1299    #[serde(rename = "verifyServerCertificate")]
1300    pub verify_server_certificate: Option<bool>,
1301}
1302
1303impl common::Part for MySqlReplicaConfiguration {}
1304
1305/// On-premises instance configuration.
1306///
1307/// This type is not used in any activity, and only used as *part* of another schema.
1308///
1309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1310#[serde_with::serde_as]
1311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1312pub struct OnPremisesConfiguration {
1313    /// PEM representation of the trusted CA's x509 certificate.
1314    #[serde(rename = "caCertificate")]
1315    pub ca_certificate: Option<String>,
1316    /// PEM representation of the slave's x509 certificate.
1317    #[serde(rename = "clientCertificate")]
1318    pub client_certificate: Option<String>,
1319    /// PEM representation of the slave's private key. The corresponsing public key
1320    /// is encoded in the client's certificate.
1321    #[serde(rename = "clientKey")]
1322    pub client_key: Option<String>,
1323    /// The dump file to create the Cloud SQL replica.
1324    #[serde(rename = "dumpFilePath")]
1325    pub dump_file_path: Option<String>,
1326    /// The host and port of the on-premises instance in host:port format
1327    #[serde(rename = "hostPort")]
1328    pub host_port: Option<String>,
1329    /// This is always <code>sql#onPremisesConfiguration</code>.
1330    pub kind: Option<String>,
1331    /// The password for connecting to on-premises instance.
1332    pub password: Option<String>,
1333    /// The username for connecting to on-premises instance.
1334    pub username: Option<String>,
1335}
1336
1337impl common::Part for OnPremisesConfiguration {}
1338
1339/// An Operation resource. For successful operations that return an
1340/// Operation resource, only the fields relevant to the operation are populated
1341/// in the resource.
1342///
1343/// # Activities
1344///
1345/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1346/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1347///
1348/// * [delete backup runs](BackupRunDeleteCall) (response)
1349/// * [insert backup runs](BackupRunInsertCall) (response)
1350/// * [delete databases](DatabaseDeleteCall) (response)
1351/// * [insert databases](DatabaseInsertCall) (response)
1352/// * [patch databases](DatabasePatchCall) (response)
1353/// * [update databases](DatabaseUpdateCall) (response)
1354/// * [add server ca instances](InstanceAddServerCaCall) (response)
1355/// * [clone instances](InstanceCloneCall) (response)
1356/// * [delete instances](InstanceDeleteCall) (response)
1357/// * [demote master instances](InstanceDemoteMasterCall) (response)
1358/// * [export instances](InstanceExportCall) (response)
1359/// * [failover instances](InstanceFailoverCall) (response)
1360/// * [import instances](InstanceImportCall) (response)
1361/// * [insert instances](InstanceInsertCall) (response)
1362/// * [patch instances](InstancePatchCall) (response)
1363/// * [promote replica instances](InstancePromoteReplicaCall) (response)
1364/// * [reset ssl config instances](InstanceResetSslConfigCall) (response)
1365/// * [restart instances](InstanceRestartCall) (response)
1366/// * [restore backup instances](InstanceRestoreBackupCall) (response)
1367/// * [rotate server ca instances](InstanceRotateServerCaCall) (response)
1368/// * [start replica instances](InstanceStartReplicaCall) (response)
1369/// * [stop replica instances](InstanceStopReplicaCall) (response)
1370/// * [truncate log instances](InstanceTruncateLogCall) (response)
1371/// * [update instances](InstanceUpdateCall) (response)
1372/// * [get operations](OperationGetCall) (response)
1373/// * [list operations](OperationListCall) (none)
1374/// * [instances reschedule maintenance projects](ProjectInstanceRescheduleMaintenanceCall) (response)
1375/// * [instances start external sync projects](ProjectInstanceStartExternalSyncCall) (response)
1376/// * [delete ssl certs](SslCertDeleteCall) (response)
1377/// * [delete users](UserDeleteCall) (response)
1378/// * [insert users](UserInsertCall) (response)
1379/// * [update users](UserUpdateCall) (response)
1380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1381#[serde_with::serde_as]
1382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1383pub struct Operation {
1384    /// The time this operation finished in UTC timezone in <a
1385    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1386    /// <code>2012-11-15T16:19:00.094Z</code>.
1387    #[serde(rename = "endTime")]
1388    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1389    /// If errors occurred during processing of this operation, this field will be
1390    /// populated.
1391    pub error: Option<OperationErrors>,
1392    /// The context for export operation, if applicable.
1393    #[serde(rename = "exportContext")]
1394    pub export_context: Option<ExportContext>,
1395    /// The context for import operation, if applicable.
1396    #[serde(rename = "importContext")]
1397    pub import_context: Option<ImportContext>,
1398    /// The time this operation was enqueued in UTC timezone in <a
1399    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1400    /// <code>2012-11-15T16:19:00.094Z</code>.
1401    #[serde(rename = "insertTime")]
1402    pub insert_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1403    /// This is always <code>sql#operation</code>.
1404    pub kind: Option<String>,
1405    /// An identifier that uniquely identifies the operation. You can use this
1406    /// identifier to retrieve the Operations resource that has information about
1407    /// the operation.
1408    pub name: Option<String>,
1409    /// The type of the operation. Valid values are <code>CREATE</code>,
1410    /// <code>DELETE</code>, <code>UPDATE</code>, <code>RESTART</code>,
1411    /// <code>IMPORT</code>, <code>EXPORT</code>, <code>BACKUP_VOLUME</code>,
1412    /// <code>RESTORE_VOLUME</code>, <code>CREATE_USER</code>,
1413    /// <code>DELETE_USER</code>, <code>CREATE_DATABASE</code>,
1414    /// <code>DELETE_DATABASE</code> .
1415    #[serde(rename = "operationType")]
1416    pub operation_type: Option<String>,
1417    /// The URI of this resource.
1418    #[serde(rename = "selfLink")]
1419    pub self_link: Option<String>,
1420    /// The time this operation actually started in UTC timezone in <a
1421    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1422    /// <code>2012-11-15T16:19:00.094Z</code>.
1423    #[serde(rename = "startTime")]
1424    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1425    /// The status of an operation. Valid values are <code>PENDING</code>,
1426    /// <code>RUNNING</code>, <code>DONE</code>,
1427    /// <code>SQL_OPERATION_STATUS_UNSPECIFIED</code>.
1428    pub status: Option<String>,
1429    /// Name of the database instance related to this operation.
1430    #[serde(rename = "targetId")]
1431    pub target_id: Option<String>,
1432    /// no description provided
1433    #[serde(rename = "targetLink")]
1434    pub target_link: Option<String>,
1435    /// The project ID of the target instance related to this operation.
1436    #[serde(rename = "targetProject")]
1437    pub target_project: Option<String>,
1438    /// The email address of the user who initiated this operation.
1439    pub user: Option<String>,
1440}
1441
1442impl common::Resource for Operation {}
1443impl common::ResponseResult for Operation {}
1444
1445/// Database instance operation error.
1446///
1447/// This type is not used in any activity, and only used as *part* of another schema.
1448///
1449#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1450#[serde_with::serde_as]
1451#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1452pub struct OperationError {
1453    /// Identifies the specific error that occurred.
1454    pub code: Option<String>,
1455    /// This is always <code>sql#operationError</code>.
1456    pub kind: Option<String>,
1457    /// Additional information about the error encountered.
1458    pub message: Option<String>,
1459}
1460
1461impl common::Part for OperationError {}
1462
1463/// Database instance operation errors list wrapper.
1464///
1465/// This type is not used in any activity, and only used as *part* of another schema.
1466///
1467#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1468#[serde_with::serde_as]
1469#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1470pub struct OperationErrors {
1471    /// The list of errors encountered while processing this operation.
1472    pub errors: Option<Vec<OperationError>>,
1473    /// This is always <code>sql#operationErrors</code>.
1474    pub kind: Option<String>,
1475}
1476
1477impl common::Part for OperationErrors {}
1478
1479/// Database instance list operations response.
1480///
1481/// # Activities
1482///
1483/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1484/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1485///
1486/// * [list operations](OperationListCall) (response)
1487#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1488#[serde_with::serde_as]
1489#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1490pub struct OperationsListResponse {
1491    /// List of operation resources.
1492    pub items: Option<Vec<Operation>>,
1493    /// This is always <code>sql#operationsList</code>.
1494    pub kind: Option<String>,
1495    /// The continuation token, used to page through large result sets. Provide
1496    /// this value in a subsequent request to return the next page of results.
1497    #[serde(rename = "nextPageToken")]
1498    pub next_page_token: Option<String>,
1499}
1500
1501impl common::ResponseResult for OperationsListResponse {}
1502
1503/// Read-replica configuration for connecting to the master.
1504///
1505/// This type is not used in any activity, and only used as *part* of another schema.
1506///
1507#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1508#[serde_with::serde_as]
1509#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1510pub struct ReplicaConfiguration {
1511    /// Specifies if the replica is the failover target. If the field is set to
1512    /// <code>true</code> the replica will be designated as a failover replica. In
1513    /// case the master instance fails, the replica instance will be promoted as
1514    /// the new master instance.  <p>Only one replica can be specified as failover
1515    /// target, and the replica has to be in different zone with the master
1516    /// instance.
1517    #[serde(rename = "failoverTarget")]
1518    pub failover_target: Option<bool>,
1519    /// This is always <code>sql#replicaConfiguration</code>.
1520    pub kind: Option<String>,
1521    /// MySQL specific configuration when replicating from a MySQL on-premises
1522    /// master. Replication configuration information such as the username,
1523    /// password, certificates, and keys are not stored in the instance metadata.
1524    /// The configuration information is used only to set up the replication
1525    /// connection and is stored by MySQL in a file named <code>master.info</code>
1526    /// in the data directory.
1527    #[serde(rename = "mysqlReplicaConfiguration")]
1528    pub mysql_replica_configuration: Option<MySqlReplicaConfiguration>,
1529}
1530
1531impl common::Part for ReplicaConfiguration {}
1532
1533/// There is no detailed description.
1534///
1535/// This type is not used in any activity, and only used as *part* of another schema.
1536///
1537#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1538#[serde_with::serde_as]
1539#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1540pub struct Reschedule {
1541    /// Required. The type of the reschedule.
1542    #[serde(rename = "rescheduleType")]
1543    pub reschedule_type: Option<String>,
1544    /// Optional. Timestamp when the maintenance shall be rescheduled to if
1545    /// reschedule_type=SPECIFIC_TIME, in <a
1546    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for
1547    /// example <code>2012-11-15T16:19:00.094Z</code>.
1548    #[serde(rename = "scheduleTime")]
1549    pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1550}
1551
1552impl common::Part for Reschedule {}
1553
1554/// Database instance restore from backup context.
1555/// Backup context contains source instance id and project id.
1556///
1557/// This type is not used in any activity, and only used as *part* of another schema.
1558///
1559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1560#[serde_with::serde_as]
1561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1562pub struct RestoreBackupContext {
1563    /// The ID of the backup run to restore from.
1564    #[serde(rename = "backupRunId")]
1565    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1566    pub backup_run_id: Option<i64>,
1567    /// The ID of the instance that the backup was taken from.
1568    #[serde(rename = "instanceId")]
1569    pub instance_id: Option<String>,
1570    /// This is always <code>sql#restoreBackupContext</code>.
1571    pub kind: Option<String>,
1572    /// The full project ID of the source instance.
1573    pub project: Option<String>,
1574}
1575
1576impl common::Part for RestoreBackupContext {}
1577
1578/// Instance rotate server CA context.
1579///
1580/// This type is not used in any activity, and only used as *part* of another schema.
1581///
1582#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1583#[serde_with::serde_as]
1584#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1585pub struct RotateServerCaContext {
1586    /// This is always <code>sql#rotateServerCaContext</code>.
1587    pub kind: Option<String>,
1588    /// The fingerprint of the next version to be rotated to. If left unspecified,
1589    /// will be rotated to the most recently added server CA version.
1590    #[serde(rename = "nextVersion")]
1591    pub next_version: Option<String>,
1592}
1593
1594impl common::Part for RotateServerCaContext {}
1595
1596/// Database instance settings.
1597///
1598/// This type is not used in any activity, and only used as *part* of another schema.
1599///
1600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1601#[serde_with::serde_as]
1602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1603pub struct Settings {
1604    /// The activation policy specifies when the instance is activated; it is
1605    /// applicable only when the instance state is <code>RUNNABLE</code>. Valid
1606    /// values: <br><code>ALWAYS</code>: The instance is on, and remains so even in
1607    /// the absence of connection requests. <br><code>NEVER</code>: The instance is
1608    /// off; it is not activated, even if a connection request arrives.
1609    /// <br><code>ON_DEMAND</code>: First Generation instances only. The instance
1610    /// responds to incoming requests, and turns itself off when not in use.
1611    /// Instances with <code>PER_USE</code> pricing turn off after 15 minutes of
1612    /// inactivity. Instances with <code>PER_PACKAGE</code> pricing turn off after
1613    /// 12 hours of inactivity.
1614    #[serde(rename = "activationPolicy")]
1615    pub activation_policy: Option<String>,
1616    /// The App Engine app IDs that can access this instance. First Generation
1617    /// instances only.
1618    #[serde(rename = "authorizedGaeApplications")]
1619    pub authorized_gae_applications: Option<Vec<String>>,
1620    /// Availability type (PostgreSQL and MySQL instances only). Potential values:
1621    /// <br><code>ZONAL</code>: The instance serves data from only one zone.
1622    /// Outages in that zone affect data accessibility. <br><code>REGIONAL</code>:
1623    /// The instance can serve data from more than one zone in a region (it is
1624    /// highly available). <br>For more information, see <a
1625    /// href="https://cloud.google.com/sql/docs/postgres/high-availability">Overview
1626    /// of the High Availability Configuration</a>.
1627    #[serde(rename = "availabilityType")]
1628    pub availability_type: Option<String>,
1629    /// The daily backup configuration for the instance.
1630    #[serde(rename = "backupConfiguration")]
1631    pub backup_configuration: Option<BackupConfiguration>,
1632    /// Configuration specific to read replica instances. Indicates whether
1633    /// database flags for crash-safe replication are enabled. This property is
1634    /// only applicable to First Generation instances.
1635    #[serde(rename = "crashSafeReplicationEnabled")]
1636    pub crash_safe_replication_enabled: Option<bool>,
1637    /// The size of data disk, in GB. The data disk size minimum is 10GB. Not used
1638    /// for First Generation instances.
1639    #[serde(rename = "dataDiskSizeGb")]
1640    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1641    pub data_disk_size_gb: Option<i64>,
1642    /// The type of data disk: <code>PD_SSD</code> (default) or
1643    /// <code>PD_HDD</code>. Not used for First Generation instances.
1644    #[serde(rename = "dataDiskType")]
1645    pub data_disk_type: Option<String>,
1646    /// The database flags passed to the instance at startup.
1647    #[serde(rename = "databaseFlags")]
1648    pub database_flags: Option<Vec<DatabaseFlags>>,
1649    /// Configuration specific to read replica instances. Indicates whether
1650    /// replication is enabled or not.
1651    #[serde(rename = "databaseReplicationEnabled")]
1652    pub database_replication_enabled: Option<bool>,
1653    /// The settings for IP Management. This allows to enable or disable the
1654    /// instance IP and manage which external networks can connect to the instance.
1655    /// The IPv4 address cannot be disabled for Second Generation instances.
1656    #[serde(rename = "ipConfiguration")]
1657    pub ip_configuration: Option<IpConfiguration>,
1658    /// This is always <code>sql#settings</code>.
1659    pub kind: Option<String>,
1660    /// The location preference settings. This allows the instance to be located as
1661    /// near as possible to either an App Engine app or Compute Engine zone for
1662    /// better performance. App Engine co-location is only applicable to First
1663    /// Generation instances.
1664    #[serde(rename = "locationPreference")]
1665    pub location_preference: Option<LocationPreference>,
1666    /// The maintenance window for this instance. This specifies when the instance
1667    /// can be restarted for maintenance purposes. Not used for First Generation
1668    /// instances.
1669    #[serde(rename = "maintenanceWindow")]
1670    pub maintenance_window: Option<MaintenanceWindow>,
1671    /// The pricing plan for this instance. This can be either <code>PER_USE</code>
1672    /// or <code>PACKAGE</code>. Only <code>PER_USE</code> is supported for Second
1673    /// Generation instances.
1674    #[serde(rename = "pricingPlan")]
1675    pub pricing_plan: Option<String>,
1676    /// The type of replication this instance uses. This can be either
1677    /// <code>ASYNCHRONOUS</code> or <code>SYNCHRONOUS</code>. This property is
1678    /// only applicable to First Generation instances.
1679    #[serde(rename = "replicationType")]
1680    pub replication_type: Option<String>,
1681    /// The version of instance settings. This is a required field for update
1682    /// method to make sure concurrent updates are handled properly. During update,
1683    /// use the most recent settingsVersion value for this instance and do not try
1684    /// to update this value.
1685    #[serde(rename = "settingsVersion")]
1686    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1687    pub settings_version: Option<i64>,
1688    /// Configuration to increase storage size automatically. The default value is
1689    /// true. Not used for First Generation instances.
1690    #[serde(rename = "storageAutoResize")]
1691    pub storage_auto_resize: Option<bool>,
1692    /// The maximum size to which storage capacity can be automatically increased.
1693    /// The default value is 0, which specifies that there is no limit. Not used
1694    /// for First Generation instances.
1695    #[serde(rename = "storageAutoResizeLimit")]
1696    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1697    pub storage_auto_resize_limit: Option<i64>,
1698    /// The tier (or machine type) for this instance, for example
1699    /// <code>db-n1-standard-1</code> (MySQL instances) or
1700    /// <code>db-custom-1-3840</code> (PostgreSQL instances). For MySQL instances,
1701    /// this property determines whether the instance is First or Second
1702    /// Generation. For more information, see <a
1703    /// href="/sql/docs/db_path/instance-settings">Instance Settings</a>.
1704    pub tier: Option<String>,
1705    /// User-provided labels, represented as a dictionary where each label is a
1706    /// single key value pair.
1707    #[serde(rename = "userLabels")]
1708    pub user_labels: Option<HashMap<String, String>>,
1709}
1710
1711impl common::Part for Settings {}
1712
1713/// External master migration setting error.
1714///
1715/// This type is not used in any activity, and only used as *part* of another schema.
1716///
1717#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1718#[serde_with::serde_as]
1719#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1720pub struct SqlExternalSyncSettingError {
1721    /// Additional information about the error encountered.
1722    pub detail: Option<String>,
1723    /// This is always <code>sql#migrationSettingError</code>.
1724    pub kind: Option<String>,
1725    /// Identifies the specific error that occurred.
1726    #[serde(rename = "type")]
1727    pub type_: Option<String>,
1728}
1729
1730impl common::Part for SqlExternalSyncSettingError {}
1731
1732/// Reschedule options for maintenance windows.
1733///
1734/// # Activities
1735///
1736/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1737/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1738///
1739/// * [instances reschedule maintenance projects](ProjectInstanceRescheduleMaintenanceCall) (request)
1740#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1741#[serde_with::serde_as]
1742#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1743pub struct SqlInstancesRescheduleMaintenanceRequestBody {
1744    /// Required. The type of the reschedule the user wants.
1745    pub reschedule: Option<Reschedule>,
1746}
1747
1748impl common::RequestValue for SqlInstancesRescheduleMaintenanceRequestBody {}
1749
1750/// Instance verify external sync settings response.
1751///
1752/// # Activities
1753///
1754/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1755/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1756///
1757/// * [instances verify external sync settings projects](ProjectInstanceVerifyExternalSyncSettingCall) (response)
1758#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1759#[serde_with::serde_as]
1760#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1761pub struct SqlInstancesVerifyExternalSyncSettingsResponse {
1762    /// List of migration violations.
1763    pub errors: Option<Vec<SqlExternalSyncSettingError>>,
1764    /// This is always <code>sql#migrationSettingErrorList</code>.
1765    pub kind: Option<String>,
1766}
1767
1768impl common::ResponseResult for SqlInstancesVerifyExternalSyncSettingsResponse {}
1769
1770/// Any scheduled maintenancce for this instance.
1771///
1772/// This type is not used in any activity, and only used as *part* of another schema.
1773///
1774#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1775#[serde_with::serde_as]
1776#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1777pub struct SqlScheduledMaintenance {
1778    /// no description provided
1779    #[serde(rename = "canDefer")]
1780    pub can_defer: Option<bool>,
1781    /// If the scheduled maintenance can be rescheduled.
1782    #[serde(rename = "canReschedule")]
1783    pub can_reschedule: Option<bool>,
1784    /// The start time of any upcoming scheduled maintenance for this instance.
1785    #[serde(rename = "startTime")]
1786    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1787}
1788
1789impl common::Part for SqlScheduledMaintenance {}
1790
1791/// Represents a Sql Server database on the Cloud SQL instance.
1792///
1793/// This type is not used in any activity, and only used as *part* of another schema.
1794///
1795#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1796#[serde_with::serde_as]
1797#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1798pub struct SqlServerDatabaseDetails {
1799    /// The version of SQL Server with which the database is to be made compatible
1800    #[serde(rename = "compatibilityLevel")]
1801    pub compatibility_level: Option<i32>,
1802    /// The recovery model of a SQL Server database
1803    #[serde(rename = "recoveryModel")]
1804    pub recovery_model: Option<String>,
1805}
1806
1807impl common::Part for SqlServerDatabaseDetails {}
1808
1809/// Represents a Sql Server user on the Cloud SQL instance.
1810///
1811/// This type is not used in any activity, and only used as *part* of another schema.
1812///
1813#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1814#[serde_with::serde_as]
1815#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1816pub struct SqlServerUserDetails {
1817    /// If the user has been disabled
1818    pub disabled: Option<bool>,
1819    /// The server roles for this user
1820    #[serde(rename = "serverRoles")]
1821    pub server_roles: Option<Vec<String>>,
1822}
1823
1824impl common::Part for SqlServerUserDetails {}
1825
1826/// SslCerts Resource
1827///
1828/// # Activities
1829///
1830/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1831/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1832///
1833/// * [create ephemeral ssl certs](SslCertCreateEphemeralCall) (response)
1834/// * [delete ssl certs](SslCertDeleteCall) (none)
1835/// * [get ssl certs](SslCertGetCall) (response)
1836/// * [insert ssl certs](SslCertInsertCall) (none)
1837/// * [list ssl certs](SslCertListCall) (none)
1838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1839#[serde_with::serde_as]
1840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1841pub struct SslCert {
1842    /// PEM representation.
1843    pub cert: Option<String>,
1844    /// Serial number, as extracted from the certificate.
1845    #[serde(rename = "certSerialNumber")]
1846    pub cert_serial_number: Option<String>,
1847    /// User supplied name.  Constrained to [a-zA-Z.-_ ]+.
1848    #[serde(rename = "commonName")]
1849    pub common_name: Option<String>,
1850    /// The time when the certificate was created in <a
1851    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1852    /// <code>2012-11-15T16:19:00.094Z</code>
1853    #[serde(rename = "createTime")]
1854    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1855    /// The time when the certificate expires in <a
1856    /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1857    /// <code>2012-11-15T16:19:00.094Z</code>.
1858    #[serde(rename = "expirationTime")]
1859    pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1860    /// Name of the database instance.
1861    pub instance: Option<String>,
1862    /// This is always <code>sql#sslCert</code>.
1863    pub kind: Option<String>,
1864    /// The URI of this resource.
1865    #[serde(rename = "selfLink")]
1866    pub self_link: Option<String>,
1867    /// Sha1 Fingerprint.
1868    #[serde(rename = "sha1Fingerprint")]
1869    pub sha1_fingerprint: Option<String>,
1870}
1871
1872impl common::Resource for SslCert {}
1873impl common::ResponseResult for SslCert {}
1874
1875/// SslCertDetail.
1876///
1877/// This type is not used in any activity, and only used as *part* of another schema.
1878///
1879#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1880#[serde_with::serde_as]
1881#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1882pub struct SslCertDetail {
1883    /// The public information about the cert.
1884    #[serde(rename = "certInfo")]
1885    pub cert_info: Option<SslCert>,
1886    /// The private key for the client cert, in pem format.  Keep private in order
1887    /// to protect your security.
1888    #[serde(rename = "certPrivateKey")]
1889    pub cert_private_key: Option<String>,
1890}
1891
1892impl common::Part for SslCertDetail {}
1893
1894/// SslCerts create ephemeral certificate request.
1895///
1896/// # Activities
1897///
1898/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1899/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1900///
1901/// * [create ephemeral ssl certs](SslCertCreateEphemeralCall) (request)
1902#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1903#[serde_with::serde_as]
1904#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1905pub struct SslCertsCreateEphemeralRequest {
1906    /// PEM encoded public key to include in the signed certificate.
1907    pub public_key: Option<String>,
1908}
1909
1910impl common::RequestValue for SslCertsCreateEphemeralRequest {}
1911
1912/// SslCerts insert request.
1913///
1914/// # Activities
1915///
1916/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1917/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1918///
1919/// * [insert ssl certs](SslCertInsertCall) (request)
1920#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1921#[serde_with::serde_as]
1922#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1923pub struct SslCertsInsertRequest {
1924    /// User supplied name.  Must be a distinct name from the other certificates
1925    /// for this instance.
1926    #[serde(rename = "commonName")]
1927    pub common_name: Option<String>,
1928}
1929
1930impl common::RequestValue for SslCertsInsertRequest {}
1931
1932/// SslCert insert response.
1933///
1934/// # Activities
1935///
1936/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1937/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1938///
1939/// * [insert ssl certs](SslCertInsertCall) (response)
1940#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1941#[serde_with::serde_as]
1942#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1943pub struct SslCertsInsertResponse {
1944    /// The new client certificate and private key.  For First Generation
1945    /// instances, the new certificate does not take effect until the instance is
1946    /// restarted.
1947    #[serde(rename = "clientCert")]
1948    pub client_cert: Option<SslCertDetail>,
1949    /// This is always <code>sql#sslCertsInsert</code>.
1950    pub kind: Option<String>,
1951    /// The operation to track the ssl certs insert request.
1952    pub operation: Option<Operation>,
1953    /// The server Certificate Authority's certificate.  If this is missing you can
1954    /// force a new one to be generated by calling resetSslConfig method on
1955    /// instances resource.
1956    #[serde(rename = "serverCaCert")]
1957    pub server_ca_cert: Option<SslCert>,
1958}
1959
1960impl common::ResponseResult for SslCertsInsertResponse {}
1961
1962/// SslCerts list response.
1963///
1964/// # Activities
1965///
1966/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1967/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1968///
1969/// * [list ssl certs](SslCertListCall) (response)
1970#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1971#[serde_with::serde_as]
1972#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1973pub struct SslCertsListResponse {
1974    /// List of client certificates for the instance.
1975    pub items: Option<Vec<SslCert>>,
1976    /// This is always <code>sql#sslCertsList</code>.
1977    pub kind: Option<String>,
1978}
1979
1980impl common::ResponseResult for SslCertsListResponse {}
1981
1982/// A Google Cloud SQL service tier resource.
1983///
1984/// # Activities
1985///
1986/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1987/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1988///
1989/// * [list tiers](TierListCall) (none)
1990#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1991#[serde_with::serde_as]
1992#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1993pub struct Tier {
1994    /// The maximum disk size of this tier in bytes.
1995    #[serde(rename = "DiskQuota")]
1996    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1997    pub disk_quota: Option<i64>,
1998    /// The maximum RAM usage of this tier in bytes.
1999    #[serde(rename = "RAM")]
2000    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2001    pub ram: Option<i64>,
2002    /// This is always <code>sql#tier</code>.
2003    pub kind: Option<String>,
2004    /// The applicable regions for this tier.
2005    pub region: Option<Vec<String>>,
2006    /// An identifier for the machine type, for example, db-n1-standard-1. For
2007    /// related information, see <a href="/sql/pricing">Pricing</a>.
2008    pub tier: Option<String>,
2009}
2010
2011impl common::Resource for Tier {}
2012
2013/// Tiers list response.
2014///
2015/// # Activities
2016///
2017/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2018/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2019///
2020/// * [list tiers](TierListCall) (response)
2021#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2022#[serde_with::serde_as]
2023#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2024pub struct TiersListResponse {
2025    /// List of tiers.
2026    pub items: Option<Vec<Tier>>,
2027    /// This is always <code>sql#tiersList</code>.
2028    pub kind: Option<String>,
2029}
2030
2031impl common::ResponseResult for TiersListResponse {}
2032
2033/// Database Instance truncate log context.
2034///
2035/// This type is not used in any activity, and only used as *part* of another schema.
2036///
2037#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2038#[serde_with::serde_as]
2039#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2040pub struct TruncateLogContext {
2041    /// This is always <code>sql#truncateLogContext</code>.
2042    pub kind: Option<String>,
2043    /// The type of log to truncate. Valid values are
2044    /// <code>MYSQL_GENERAL_TABLE</code> and <code>MYSQL_SLOW_TABLE</code>.
2045    #[serde(rename = "logType")]
2046    pub log_type: Option<String>,
2047}
2048
2049impl common::Part for TruncateLogContext {}
2050
2051/// A Cloud SQL user resource.
2052///
2053/// # Activities
2054///
2055/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2056/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2057///
2058/// * [delete users](UserDeleteCall) (none)
2059/// * [insert users](UserInsertCall) (request)
2060/// * [list users](UserListCall) (none)
2061/// * [update users](UserUpdateCall) (request)
2062#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2063#[serde_with::serde_as]
2064#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2065pub struct User {
2066    /// This field is deprecated and will be removed from a future version of the
2067    /// API.
2068    pub etag: Option<String>,
2069    /// The host name from which the user can connect. For <code>insert</code>
2070    /// operations, host defaults to an empty string. For <code>update</code>
2071    /// operations, host is specified as part of the request URL. The host name
2072    /// cannot be updated after insertion.
2073    pub host: Option<String>,
2074    /// The name of the Cloud SQL instance. This does not include the project ID.
2075    /// Can be omitted for <code>update</code> since it is already specified on the
2076    /// URL.
2077    pub instance: Option<String>,
2078    /// This is always <code>sql#user</code>.
2079    pub kind: Option<String>,
2080    /// The name of the user in the Cloud SQL instance. Can be omitted for
2081    /// <code>update</code> since it is already specified in the URL.
2082    pub name: Option<String>,
2083    /// The password for the user.
2084    pub password: Option<String>,
2085    /// The project ID of the project containing the Cloud SQL database. The Google
2086    /// apps domain is prefixed if applicable. Can be omitted for
2087    /// <code>update</code> since it is already specified on the URL.
2088    pub project: Option<String>,
2089    /// no description provided
2090    #[serde(rename = "sqlserverUserDetails")]
2091    pub sqlserver_user_details: Option<SqlServerUserDetails>,
2092}
2093
2094impl common::RequestValue for User {}
2095impl common::Resource for User {}
2096
2097/// User list response.
2098///
2099/// # Activities
2100///
2101/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2102/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2103///
2104/// * [list users](UserListCall) (response)
2105#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2106#[serde_with::serde_as]
2107#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2108pub struct UsersListResponse {
2109    /// List of user resources in the instance.
2110    pub items: Option<Vec<User>>,
2111    /// This is always <code>sql#usersList</code>.
2112    pub kind: Option<String>,
2113    /// An identifier that uniquely identifies the operation. You can use this
2114    /// identifier to retrieve the Operations resource that has information about
2115    /// the operation.
2116    #[serde(rename = "nextPageToken")]
2117    pub next_page_token: Option<String>,
2118}
2119
2120impl common::ResponseResult for UsersListResponse {}
2121
2122/// The name and status of the failover replica. This property is applicable
2123/// only to Second Generation instances.
2124///
2125/// This type is not used in any activity, and only used as *part* of another schema.
2126///
2127#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2128#[serde_with::serde_as]
2129#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2130pub struct DatabaseInstanceFailoverReplica {
2131    /// The availability status of the failover replica. A false status indicates
2132    /// that the failover replica is out of sync. The master can only failover to
2133    /// the failover replica when the status is true.
2134    pub available: Option<bool>,
2135    /// The name of the failover replica. If specified at instance creation, a
2136    /// failover replica is created for the instance. The name
2137    /// doesn't include the project ID. This property is applicable only to
2138    /// Second Generation instances.
2139    pub name: Option<String>,
2140}
2141
2142impl common::NestedType for DatabaseInstanceFailoverReplica {}
2143impl common::Part for DatabaseInstanceFailoverReplica {}
2144
2145/// Options for exporting data as CSV.
2146///
2147/// This type is not used in any activity, and only used as *part* of another schema.
2148///
2149#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2150#[serde_with::serde_as]
2151#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2152pub struct ExportContextCsvExportOptions {
2153    /// The select query used to extract the data.
2154    #[serde(rename = "selectQuery")]
2155    pub select_query: Option<String>,
2156}
2157
2158impl common::NestedType for ExportContextCsvExportOptions {}
2159impl common::Part for ExportContextCsvExportOptions {}
2160
2161/// Options for exporting data as SQL statements.
2162///
2163/// This type is not used in any activity, and only used as *part* of another schema.
2164///
2165#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2166#[serde_with::serde_as]
2167#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2168pub struct ExportContextSqlExportOptions {
2169    /// Options for exporting from MySQL.
2170    #[serde(rename = "mysqlExportOptions")]
2171    pub mysql_export_options: Option<ExportContextSqlExportOptionsMysqlExportOptions>,
2172    /// Export only schemas.
2173    #[serde(rename = "schemaOnly")]
2174    pub schema_only: Option<bool>,
2175    /// Tables to export, or that were exported, from the specified database. If
2176    /// you specify tables, specify one and only one database. For PostgreSQL
2177    /// instances, you can specify only one table.
2178    pub tables: Option<Vec<String>>,
2179}
2180
2181impl common::NestedType for ExportContextSqlExportOptions {}
2182impl common::Part for ExportContextSqlExportOptions {}
2183
2184/// Options for exporting from MySQL.
2185///
2186/// This type is not used in any activity, and only used as *part* of another schema.
2187///
2188#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2189#[serde_with::serde_as]
2190#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2191pub struct ExportContextSqlExportOptionsMysqlExportOptions {
2192    /// Option to include SQL statement required to set up replication.
2193    /// If set to <code>1</code>, the dump file includes
2194    ///  a CHANGE MASTER TO statement with the binary log coordinates.
2195    /// If set to <code>2</code>, the CHANGE MASTER TO statement is written as
2196    ///  a SQL comment, and has no effect.
2197    /// All other values are ignored.
2198    #[serde(rename = "masterData")]
2199    pub master_data: Option<i32>,
2200}
2201
2202impl common::NestedType for ExportContextSqlExportOptionsMysqlExportOptions {}
2203impl common::Part for ExportContextSqlExportOptionsMysqlExportOptions {}
2204
2205/// Import parameters specific to SQL Server .BAK files
2206///
2207/// This type is not used in any activity, and only used as *part* of another schema.
2208///
2209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2210#[serde_with::serde_as]
2211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2212pub struct ImportContextBakImportOptions {
2213    /// no description provided
2214    #[serde(rename = "encryptionOptions")]
2215    pub encryption_options: Option<ImportContextBakImportOptionsEncryptionOptions>,
2216}
2217
2218impl common::NestedType for ImportContextBakImportOptions {}
2219impl common::Part for ImportContextBakImportOptions {}
2220
2221/// There is no detailed description.
2222///
2223/// This type is not used in any activity, and only used as *part* of another schema.
2224///
2225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2226#[serde_with::serde_as]
2227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2228pub struct ImportContextBakImportOptionsEncryptionOptions {
2229    /// Path to the Certificate (.cer) in Cloud Storage, in the form
2230    /// <code>gs://bucketName/fileName</code>. The instance must have
2231    /// write permissions to the bucket and read access to the file.
2232    #[serde(rename = "certPath")]
2233    pub cert_path: Option<String>,
2234    /// Password that encrypts the private key
2235    #[serde(rename = "pvkPassword")]
2236    pub pvk_password: Option<String>,
2237    /// Path to the Certificate Private Key (.pvk)  in Cloud Storage, in the
2238    /// form <code>gs://bucketName/fileName</code>. The instance must have
2239    /// write permissions to the bucket and read access to the file.
2240    #[serde(rename = "pvkPath")]
2241    pub pvk_path: Option<String>,
2242}
2243
2244impl common::NestedType for ImportContextBakImportOptionsEncryptionOptions {}
2245impl common::Part for ImportContextBakImportOptionsEncryptionOptions {}
2246
2247/// Options for importing data as CSV.
2248///
2249/// This type is not used in any activity, and only used as *part* of another schema.
2250///
2251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2252#[serde_with::serde_as]
2253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2254pub struct ImportContextCsvImportOptions {
2255    /// The columns to which CSV data is imported. If not specified, all columns
2256    /// of the database table are loaded with CSV data.
2257    pub columns: Option<Vec<String>>,
2258    /// The table to which CSV data is imported.
2259    pub table: Option<String>,
2260}
2261
2262impl common::NestedType for ImportContextCsvImportOptions {}
2263impl common::Part for ImportContextCsvImportOptions {}
2264
2265// ###################
2266// MethodBuilders ###
2267// #################
2268
2269/// A builder providing access to all methods supported on *backupRun* resources.
2270/// It is not used directly, but through the [`SQLAdmin`] hub.
2271///
2272/// # Example
2273///
2274/// Instantiate a resource builder
2275///
2276/// ```test_harness,no_run
2277/// extern crate hyper;
2278/// extern crate hyper_rustls;
2279/// extern crate google_sql1_beta4 as sql1_beta4;
2280///
2281/// # async fn dox() {
2282/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2283///
2284/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2285/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2286///     .with_native_roots()
2287///     .unwrap()
2288///     .https_only()
2289///     .enable_http2()
2290///     .build();
2291///
2292/// let executor = hyper_util::rt::TokioExecutor::new();
2293/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2294///     secret,
2295///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2296///     yup_oauth2::client::CustomHyperClientBuilder::from(
2297///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2298///     ),
2299/// ).build().await.unwrap();
2300///
2301/// let client = hyper_util::client::legacy::Client::builder(
2302///     hyper_util::rt::TokioExecutor::new()
2303/// )
2304/// .build(
2305///     hyper_rustls::HttpsConnectorBuilder::new()
2306///         .with_native_roots()
2307///         .unwrap()
2308///         .https_or_http()
2309///         .enable_http2()
2310///         .build()
2311/// );
2312/// let mut hub = SQLAdmin::new(client, auth);
2313/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2314/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
2315/// // to build up your call.
2316/// let rb = hub.backup_runs();
2317/// # }
2318/// ```
2319pub struct BackupRunMethods<'a, C>
2320where
2321    C: 'a,
2322{
2323    hub: &'a SQLAdmin<C>,
2324}
2325
2326impl<'a, C> common::MethodsBuilder for BackupRunMethods<'a, C> {}
2327
2328impl<'a, C> BackupRunMethods<'a, C> {
2329    /// Create a builder to help you perform the following task:
2330    ///
2331    /// Deletes the backup taken by a backup run.
2332    ///
2333    /// # Arguments
2334    ///
2335    /// * `project` - Project ID of the project that contains the instance.
2336    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2337    /// * `id` - The ID of the Backup Run to delete. To find a Backup Run ID, use the <a
2338    ///          href="/sql/docs/db_path/admin-api/rest/v1beta4/backupRuns/list">list</a>
2339    ///          method.
2340    pub fn delete(&self, project: &str, instance: &str, id: i64) -> BackupRunDeleteCall<'a, C> {
2341        BackupRunDeleteCall {
2342            hub: self.hub,
2343            _project: project.to_string(),
2344            _instance: instance.to_string(),
2345            _id: id,
2346            _delegate: Default::default(),
2347            _additional_params: Default::default(),
2348            _scopes: Default::default(),
2349        }
2350    }
2351
2352    /// Create a builder to help you perform the following task:
2353    ///
2354    /// Retrieves a resource containing information about a backup run.
2355    ///
2356    /// # Arguments
2357    ///
2358    /// * `project` - Project ID of the project that contains the instance.
2359    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2360    /// * `id` - The ID of this Backup Run.
2361    pub fn get(&self, project: &str, instance: &str, id: i64) -> BackupRunGetCall<'a, C> {
2362        BackupRunGetCall {
2363            hub: self.hub,
2364            _project: project.to_string(),
2365            _instance: instance.to_string(),
2366            _id: id,
2367            _delegate: Default::default(),
2368            _additional_params: Default::default(),
2369            _scopes: Default::default(),
2370        }
2371    }
2372
2373    /// Create a builder to help you perform the following task:
2374    ///
2375    /// Creates a new backup run on demand. This method is applicable only to
2376    /// Second Generation instances.
2377    ///
2378    /// # Arguments
2379    ///
2380    /// * `request` - No description provided.
2381    /// * `project` - Project ID of the project that contains the instance.
2382    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2383    pub fn insert(
2384        &self,
2385        request: BackupRun,
2386        project: &str,
2387        instance: &str,
2388    ) -> BackupRunInsertCall<'a, C> {
2389        BackupRunInsertCall {
2390            hub: self.hub,
2391            _request: request,
2392            _project: project.to_string(),
2393            _instance: instance.to_string(),
2394            _delegate: Default::default(),
2395            _additional_params: Default::default(),
2396            _scopes: Default::default(),
2397        }
2398    }
2399
2400    /// Create a builder to help you perform the following task:
2401    ///
2402    /// Lists all backup runs associated with a given instance and configuration in
2403    /// the reverse chronological order of the backup initiation time.
2404    ///
2405    /// # Arguments
2406    ///
2407    /// * `project` - Project ID of the project that contains the instance.
2408    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2409    pub fn list(&self, project: &str, instance: &str) -> BackupRunListCall<'a, C> {
2410        BackupRunListCall {
2411            hub: self.hub,
2412            _project: project.to_string(),
2413            _instance: instance.to_string(),
2414            _page_token: Default::default(),
2415            _max_results: Default::default(),
2416            _delegate: Default::default(),
2417            _additional_params: Default::default(),
2418            _scopes: Default::default(),
2419        }
2420    }
2421}
2422
2423/// A builder providing access to all methods supported on *database* resources.
2424/// It is not used directly, but through the [`SQLAdmin`] hub.
2425///
2426/// # Example
2427///
2428/// Instantiate a resource builder
2429///
2430/// ```test_harness,no_run
2431/// extern crate hyper;
2432/// extern crate hyper_rustls;
2433/// extern crate google_sql1_beta4 as sql1_beta4;
2434///
2435/// # async fn dox() {
2436/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2437///
2438/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2439/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2440///     .with_native_roots()
2441///     .unwrap()
2442///     .https_only()
2443///     .enable_http2()
2444///     .build();
2445///
2446/// let executor = hyper_util::rt::TokioExecutor::new();
2447/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2448///     secret,
2449///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2450///     yup_oauth2::client::CustomHyperClientBuilder::from(
2451///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2452///     ),
2453/// ).build().await.unwrap();
2454///
2455/// let client = hyper_util::client::legacy::Client::builder(
2456///     hyper_util::rt::TokioExecutor::new()
2457/// )
2458/// .build(
2459///     hyper_rustls::HttpsConnectorBuilder::new()
2460///         .with_native_roots()
2461///         .unwrap()
2462///         .https_or_http()
2463///         .enable_http2()
2464///         .build()
2465/// );
2466/// let mut hub = SQLAdmin::new(client, auth);
2467/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2468/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
2469/// // to build up your call.
2470/// let rb = hub.databases();
2471/// # }
2472/// ```
2473pub struct DatabaseMethods<'a, C>
2474where
2475    C: 'a,
2476{
2477    hub: &'a SQLAdmin<C>,
2478}
2479
2480impl<'a, C> common::MethodsBuilder for DatabaseMethods<'a, C> {}
2481
2482impl<'a, C> DatabaseMethods<'a, C> {
2483    /// Create a builder to help you perform the following task:
2484    ///
2485    /// Deletes a database from a Cloud SQL instance.
2486    ///
2487    /// # Arguments
2488    ///
2489    /// * `project` - Project ID of the project that contains the instance.
2490    /// * `instance` - Database instance ID. This does not include the project ID.
2491    /// * `database` - Name of the database to be deleted in the instance.
2492    pub fn delete(
2493        &self,
2494        project: &str,
2495        instance: &str,
2496        database: &str,
2497    ) -> DatabaseDeleteCall<'a, C> {
2498        DatabaseDeleteCall {
2499            hub: self.hub,
2500            _project: project.to_string(),
2501            _instance: instance.to_string(),
2502            _database: database.to_string(),
2503            _delegate: Default::default(),
2504            _additional_params: Default::default(),
2505            _scopes: Default::default(),
2506        }
2507    }
2508
2509    /// Create a builder to help you perform the following task:
2510    ///
2511    /// Retrieves a resource containing information about a database inside a Cloud
2512    /// SQL instance.
2513    ///
2514    /// # Arguments
2515    ///
2516    /// * `project` - Project ID of the project that contains the instance.
2517    /// * `instance` - Database instance ID. This does not include the project ID.
2518    /// * `database` - Name of the database in the instance.
2519    pub fn get(&self, project: &str, instance: &str, database: &str) -> DatabaseGetCall<'a, C> {
2520        DatabaseGetCall {
2521            hub: self.hub,
2522            _project: project.to_string(),
2523            _instance: instance.to_string(),
2524            _database: database.to_string(),
2525            _delegate: Default::default(),
2526            _additional_params: Default::default(),
2527            _scopes: Default::default(),
2528        }
2529    }
2530
2531    /// Create a builder to help you perform the following task:
2532    ///
2533    /// Inserts a resource containing information about a database inside a Cloud
2534    /// SQL instance.
2535    ///
2536    /// # Arguments
2537    ///
2538    /// * `request` - No description provided.
2539    /// * `project` - Project ID of the project that contains the instance.
2540    /// * `instance` - Database instance ID. This does not include the project ID.
2541    pub fn insert(
2542        &self,
2543        request: Database,
2544        project: &str,
2545        instance: &str,
2546    ) -> DatabaseInsertCall<'a, C> {
2547        DatabaseInsertCall {
2548            hub: self.hub,
2549            _request: request,
2550            _project: project.to_string(),
2551            _instance: instance.to_string(),
2552            _delegate: Default::default(),
2553            _additional_params: Default::default(),
2554            _scopes: Default::default(),
2555        }
2556    }
2557
2558    /// Create a builder to help you perform the following task:
2559    ///
2560    /// Lists databases in the specified Cloud SQL instance.
2561    ///
2562    /// # Arguments
2563    ///
2564    /// * `project` - Project ID of the project that contains the instance.
2565    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2566    pub fn list(&self, project: &str, instance: &str) -> DatabaseListCall<'a, C> {
2567        DatabaseListCall {
2568            hub: self.hub,
2569            _project: project.to_string(),
2570            _instance: instance.to_string(),
2571            _delegate: Default::default(),
2572            _additional_params: Default::default(),
2573            _scopes: Default::default(),
2574        }
2575    }
2576
2577    /// Create a builder to help you perform the following task:
2578    ///
2579    /// Partially updates a resource containing information about a database inside
2580    /// a Cloud SQL instance. This method supports patch semantics.
2581    ///
2582    /// # Arguments
2583    ///
2584    /// * `request` - No description provided.
2585    /// * `project` - Project ID of the project that contains the instance.
2586    /// * `instance` - Database instance ID. This does not include the project ID.
2587    /// * `database` - Name of the database to be updated in the instance.
2588    pub fn patch(
2589        &self,
2590        request: Database,
2591        project: &str,
2592        instance: &str,
2593        database: &str,
2594    ) -> DatabasePatchCall<'a, C> {
2595        DatabasePatchCall {
2596            hub: self.hub,
2597            _request: request,
2598            _project: project.to_string(),
2599            _instance: instance.to_string(),
2600            _database: database.to_string(),
2601            _delegate: Default::default(),
2602            _additional_params: Default::default(),
2603            _scopes: Default::default(),
2604        }
2605    }
2606
2607    /// Create a builder to help you perform the following task:
2608    ///
2609    /// Updates a resource containing information about a database inside a Cloud
2610    /// SQL instance.
2611    ///
2612    /// # Arguments
2613    ///
2614    /// * `request` - No description provided.
2615    /// * `project` - Project ID of the project that contains the instance.
2616    /// * `instance` - Database instance ID. This does not include the project ID.
2617    /// * `database` - Name of the database to be updated in the instance.
2618    pub fn update(
2619        &self,
2620        request: Database,
2621        project: &str,
2622        instance: &str,
2623        database: &str,
2624    ) -> DatabaseUpdateCall<'a, C> {
2625        DatabaseUpdateCall {
2626            hub: self.hub,
2627            _request: request,
2628            _project: project.to_string(),
2629            _instance: instance.to_string(),
2630            _database: database.to_string(),
2631            _delegate: Default::default(),
2632            _additional_params: Default::default(),
2633            _scopes: Default::default(),
2634        }
2635    }
2636}
2637
2638/// A builder providing access to all methods supported on *flag* resources.
2639/// It is not used directly, but through the [`SQLAdmin`] hub.
2640///
2641/// # Example
2642///
2643/// Instantiate a resource builder
2644///
2645/// ```test_harness,no_run
2646/// extern crate hyper;
2647/// extern crate hyper_rustls;
2648/// extern crate google_sql1_beta4 as sql1_beta4;
2649///
2650/// # async fn dox() {
2651/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2652///
2653/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2654/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2655///     .with_native_roots()
2656///     .unwrap()
2657///     .https_only()
2658///     .enable_http2()
2659///     .build();
2660///
2661/// let executor = hyper_util::rt::TokioExecutor::new();
2662/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2663///     secret,
2664///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2665///     yup_oauth2::client::CustomHyperClientBuilder::from(
2666///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2667///     ),
2668/// ).build().await.unwrap();
2669///
2670/// let client = hyper_util::client::legacy::Client::builder(
2671///     hyper_util::rt::TokioExecutor::new()
2672/// )
2673/// .build(
2674///     hyper_rustls::HttpsConnectorBuilder::new()
2675///         .with_native_roots()
2676///         .unwrap()
2677///         .https_or_http()
2678///         .enable_http2()
2679///         .build()
2680/// );
2681/// let mut hub = SQLAdmin::new(client, auth);
2682/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2683/// // like `list(...)`
2684/// // to build up your call.
2685/// let rb = hub.flags();
2686/// # }
2687/// ```
2688pub struct FlagMethods<'a, C>
2689where
2690    C: 'a,
2691{
2692    hub: &'a SQLAdmin<C>,
2693}
2694
2695impl<'a, C> common::MethodsBuilder for FlagMethods<'a, C> {}
2696
2697impl<'a, C> FlagMethods<'a, C> {
2698    /// Create a builder to help you perform the following task:
2699    ///
2700    /// List all available database flags for Cloud SQL instances.
2701    pub fn list(&self) -> FlagListCall<'a, C> {
2702        FlagListCall {
2703            hub: self.hub,
2704            _database_version: Default::default(),
2705            _delegate: Default::default(),
2706            _additional_params: Default::default(),
2707            _scopes: Default::default(),
2708        }
2709    }
2710}
2711
2712/// A builder providing access to all methods supported on *instance* resources.
2713/// It is not used directly, but through the [`SQLAdmin`] hub.
2714///
2715/// # Example
2716///
2717/// Instantiate a resource builder
2718///
2719/// ```test_harness,no_run
2720/// extern crate hyper;
2721/// extern crate hyper_rustls;
2722/// extern crate google_sql1_beta4 as sql1_beta4;
2723///
2724/// # async fn dox() {
2725/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2726///
2727/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2728/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2729///     .with_native_roots()
2730///     .unwrap()
2731///     .https_only()
2732///     .enable_http2()
2733///     .build();
2734///
2735/// let executor = hyper_util::rt::TokioExecutor::new();
2736/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2737///     secret,
2738///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2739///     yup_oauth2::client::CustomHyperClientBuilder::from(
2740///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2741///     ),
2742/// ).build().await.unwrap();
2743///
2744/// let client = hyper_util::client::legacy::Client::builder(
2745///     hyper_util::rt::TokioExecutor::new()
2746/// )
2747/// .build(
2748///     hyper_rustls::HttpsConnectorBuilder::new()
2749///         .with_native_roots()
2750///         .unwrap()
2751///         .https_or_http()
2752///         .enable_http2()
2753///         .build()
2754/// );
2755/// let mut hub = SQLAdmin::new(client, auth);
2756/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2757/// // like `add_server_ca(...)`, `clone(...)`, `delete(...)`, `demote_master(...)`, `export(...)`, `failover(...)`, `get(...)`, `import(...)`, `insert(...)`, `list(...)`, `list_server_cas(...)`, `patch(...)`, `promote_replica(...)`, `reset_ssl_config(...)`, `restart(...)`, `restore_backup(...)`, `rotate_server_ca(...)`, `start_replica(...)`, `stop_replica(...)`, `truncate_log(...)` and `update(...)`
2758/// // to build up your call.
2759/// let rb = hub.instances();
2760/// # }
2761/// ```
2762pub struct InstanceMethods<'a, C>
2763where
2764    C: 'a,
2765{
2766    hub: &'a SQLAdmin<C>,
2767}
2768
2769impl<'a, C> common::MethodsBuilder for InstanceMethods<'a, C> {}
2770
2771impl<'a, C> InstanceMethods<'a, C> {
2772    /// Create a builder to help you perform the following task:
2773    ///
2774    /// Add a new trusted Certificate Authority (CA) version for the specified
2775    /// instance. Required to prepare for a certificate rotation. If a CA version
2776    /// was previously added but never used in a certificate rotation, this
2777    /// operation replaces that version. There cannot be more than one CA version
2778    /// waiting to be rotated in.
2779    ///
2780    /// # Arguments
2781    ///
2782    /// * `project` - Project ID of the project that contains the instance.
2783    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2784    pub fn add_server_ca(&self, project: &str, instance: &str) -> InstanceAddServerCaCall<'a, C> {
2785        InstanceAddServerCaCall {
2786            hub: self.hub,
2787            _project: project.to_string(),
2788            _instance: instance.to_string(),
2789            _delegate: Default::default(),
2790            _additional_params: Default::default(),
2791            _scopes: Default::default(),
2792        }
2793    }
2794
2795    /// Create a builder to help you perform the following task:
2796    ///
2797    /// Creates a Cloud SQL instance as a clone of the source instance. Using this
2798    /// operation might cause your instance to restart.
2799    ///
2800    /// # Arguments
2801    ///
2802    /// * `request` - No description provided.
2803    /// * `project` - Project ID of the source as well as the clone Cloud SQL instance.
2804    /// * `instance` - The ID of the Cloud SQL instance to be cloned (source). This does not
2805    ///                include the project ID.
2806    pub fn clone(
2807        &self,
2808        request: InstancesCloneRequest,
2809        project: &str,
2810        instance: &str,
2811    ) -> InstanceCloneCall<'a, C> {
2812        InstanceCloneCall {
2813            hub: self.hub,
2814            _request: request,
2815            _project: project.to_string(),
2816            _instance: instance.to_string(),
2817            _delegate: Default::default(),
2818            _additional_params: Default::default(),
2819            _scopes: Default::default(),
2820        }
2821    }
2822
2823    /// Create a builder to help you perform the following task:
2824    ///
2825    /// Deletes a Cloud SQL instance.
2826    ///
2827    /// # Arguments
2828    ///
2829    /// * `project` - Project ID of the project that contains the instance to be deleted.
2830    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2831    pub fn delete(&self, project: &str, instance: &str) -> InstanceDeleteCall<'a, C> {
2832        InstanceDeleteCall {
2833            hub: self.hub,
2834            _project: project.to_string(),
2835            _instance: instance.to_string(),
2836            _delegate: Default::default(),
2837            _additional_params: Default::default(),
2838            _scopes: Default::default(),
2839        }
2840    }
2841
2842    /// Create a builder to help you perform the following task:
2843    ///
2844    /// Demotes the stand-alone instance to be a Cloud SQL read replica for an
2845    /// external database server.
2846    ///
2847    /// # Arguments
2848    ///
2849    /// * `request` - No description provided.
2850    /// * `project` - ID of the project that contains the instance.
2851    /// * `instance` - Cloud SQL instance name.
2852    pub fn demote_master(
2853        &self,
2854        request: InstancesDemoteMasterRequest,
2855        project: &str,
2856        instance: &str,
2857    ) -> InstanceDemoteMasterCall<'a, C> {
2858        InstanceDemoteMasterCall {
2859            hub: self.hub,
2860            _request: request,
2861            _project: project.to_string(),
2862            _instance: instance.to_string(),
2863            _delegate: Default::default(),
2864            _additional_params: Default::default(),
2865            _scopes: Default::default(),
2866        }
2867    }
2868
2869    /// Create a builder to help you perform the following task:
2870    ///
2871    /// Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL
2872    /// dump or CSV file.
2873    ///
2874    /// # Arguments
2875    ///
2876    /// * `request` - No description provided.
2877    /// * `project` - Project ID of the project that contains the instance to be exported.
2878    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2879    pub fn export(
2880        &self,
2881        request: InstancesExportRequest,
2882        project: &str,
2883        instance: &str,
2884    ) -> InstanceExportCall<'a, C> {
2885        InstanceExportCall {
2886            hub: self.hub,
2887            _request: request,
2888            _project: project.to_string(),
2889            _instance: instance.to_string(),
2890            _delegate: Default::default(),
2891            _additional_params: Default::default(),
2892            _scopes: Default::default(),
2893        }
2894    }
2895
2896    /// Create a builder to help you perform the following task:
2897    ///
2898    /// Failover the instance to its failover replica instance. Using this
2899    /// operation might cause your instance to restart.
2900    ///
2901    /// # Arguments
2902    ///
2903    /// * `request` - No description provided.
2904    /// * `project` - ID of the project that contains the read replica.
2905    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2906    pub fn failover(
2907        &self,
2908        request: InstancesFailoverRequest,
2909        project: &str,
2910        instance: &str,
2911    ) -> InstanceFailoverCall<'a, C> {
2912        InstanceFailoverCall {
2913            hub: self.hub,
2914            _request: request,
2915            _project: project.to_string(),
2916            _instance: instance.to_string(),
2917            _delegate: Default::default(),
2918            _additional_params: Default::default(),
2919            _scopes: Default::default(),
2920        }
2921    }
2922
2923    /// Create a builder to help you perform the following task:
2924    ///
2925    /// Retrieves a resource containing information about a Cloud SQL instance.
2926    ///
2927    /// # Arguments
2928    ///
2929    /// * `project` - Project ID of the project that contains the instance.
2930    /// * `instance` - Database instance ID. This does not include the project ID.
2931    pub fn get(&self, project: &str, instance: &str) -> InstanceGetCall<'a, C> {
2932        InstanceGetCall {
2933            hub: self.hub,
2934            _project: project.to_string(),
2935            _instance: instance.to_string(),
2936            _delegate: Default::default(),
2937            _additional_params: Default::default(),
2938            _scopes: Default::default(),
2939        }
2940    }
2941
2942    /// Create a builder to help you perform the following task:
2943    ///
2944    /// Imports data into a Cloud SQL instance from a SQL dump  or CSV file in
2945    /// Cloud Storage.
2946    ///
2947    /// # Arguments
2948    ///
2949    /// * `request` - No description provided.
2950    /// * `project` - Project ID of the project that contains the instance.
2951    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2952    pub fn import(
2953        &self,
2954        request: InstancesImportRequest,
2955        project: &str,
2956        instance: &str,
2957    ) -> InstanceImportCall<'a, C> {
2958        InstanceImportCall {
2959            hub: self.hub,
2960            _request: request,
2961            _project: project.to_string(),
2962            _instance: instance.to_string(),
2963            _delegate: Default::default(),
2964            _additional_params: Default::default(),
2965            _scopes: Default::default(),
2966        }
2967    }
2968
2969    /// Create a builder to help you perform the following task:
2970    ///
2971    /// Creates a new Cloud SQL instance.
2972    ///
2973    /// # Arguments
2974    ///
2975    /// * `request` - No description provided.
2976    /// * `project` - Project ID of the project to which the newly created Cloud SQL instances
2977    ///               should belong.
2978    pub fn insert(&self, request: DatabaseInstance, project: &str) -> InstanceInsertCall<'a, C> {
2979        InstanceInsertCall {
2980            hub: self.hub,
2981            _request: request,
2982            _project: project.to_string(),
2983            _delegate: Default::default(),
2984            _additional_params: Default::default(),
2985            _scopes: Default::default(),
2986        }
2987    }
2988
2989    /// Create a builder to help you perform the following task:
2990    ///
2991    /// Lists instances under a given project.
2992    ///
2993    /// # Arguments
2994    ///
2995    /// * `project` - Project ID of the project for which to list Cloud SQL instances.
2996    pub fn list(&self, project: &str) -> InstanceListCall<'a, C> {
2997        InstanceListCall {
2998            hub: self.hub,
2999            _project: project.to_string(),
3000            _page_token: Default::default(),
3001            _max_results: Default::default(),
3002            _filter: Default::default(),
3003            _delegate: Default::default(),
3004            _additional_params: Default::default(),
3005            _scopes: Default::default(),
3006        }
3007    }
3008
3009    /// Create a builder to help you perform the following task:
3010    ///
3011    /// Lists all of the trusted Certificate Authorities (CAs) for the specified
3012    /// instance. There can be up to three CAs listed: the CA that was used to sign
3013    /// the certificate that is currently in use, a CA that has been added but not
3014    /// yet used to sign a certificate, and a CA used to sign a certificate that
3015    /// has previously rotated out.
3016    ///
3017    /// # Arguments
3018    ///
3019    /// * `project` - Project ID of the project that contains the instance.
3020    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3021    pub fn list_server_cas(
3022        &self,
3023        project: &str,
3024        instance: &str,
3025    ) -> InstanceListServerCaCall<'a, C> {
3026        InstanceListServerCaCall {
3027            hub: self.hub,
3028            _project: project.to_string(),
3029            _instance: instance.to_string(),
3030            _delegate: Default::default(),
3031            _additional_params: Default::default(),
3032            _scopes: Default::default(),
3033        }
3034    }
3035
3036    /// Create a builder to help you perform the following task:
3037    ///
3038    /// Updates settings of a Cloud SQL instance.
3039    /// This method supports patch semantics.
3040    ///
3041    /// # Arguments
3042    ///
3043    /// * `request` - No description provided.
3044    /// * `project` - Project ID of the project that contains the instance.
3045    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3046    pub fn patch(
3047        &self,
3048        request: DatabaseInstance,
3049        project: &str,
3050        instance: &str,
3051    ) -> InstancePatchCall<'a, C> {
3052        InstancePatchCall {
3053            hub: self.hub,
3054            _request: request,
3055            _project: project.to_string(),
3056            _instance: instance.to_string(),
3057            _delegate: Default::default(),
3058            _additional_params: Default::default(),
3059            _scopes: Default::default(),
3060        }
3061    }
3062
3063    /// Create a builder to help you perform the following task:
3064    ///
3065    /// Promotes the read replica instance to be a stand-alone Cloud SQL instance.
3066    /// Using this operation might cause your instance to restart.
3067    ///
3068    /// # Arguments
3069    ///
3070    /// * `project` - ID of the project that contains the read replica.
3071    /// * `instance` - Cloud SQL read replica instance name.
3072    pub fn promote_replica(
3073        &self,
3074        project: &str,
3075        instance: &str,
3076    ) -> InstancePromoteReplicaCall<'a, C> {
3077        InstancePromoteReplicaCall {
3078            hub: self.hub,
3079            _project: project.to_string(),
3080            _instance: instance.to_string(),
3081            _delegate: Default::default(),
3082            _additional_params: Default::default(),
3083            _scopes: Default::default(),
3084        }
3085    }
3086
3087    /// Create a builder to help you perform the following task:
3088    ///
3089    /// Deletes all client certificates and generates a new server SSL certificate
3090    /// for the instance.
3091    ///
3092    /// # Arguments
3093    ///
3094    /// * `project` - Project ID of the project that contains the instance.
3095    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3096    pub fn reset_ssl_config(
3097        &self,
3098        project: &str,
3099        instance: &str,
3100    ) -> InstanceResetSslConfigCall<'a, C> {
3101        InstanceResetSslConfigCall {
3102            hub: self.hub,
3103            _project: project.to_string(),
3104            _instance: instance.to_string(),
3105            _delegate: Default::default(),
3106            _additional_params: Default::default(),
3107            _scopes: Default::default(),
3108        }
3109    }
3110
3111    /// Create a builder to help you perform the following task:
3112    ///
3113    /// Restarts a Cloud SQL instance.
3114    ///
3115    /// # Arguments
3116    ///
3117    /// * `project` - Project ID of the project that contains the instance to be restarted.
3118    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3119    pub fn restart(&self, project: &str, instance: &str) -> InstanceRestartCall<'a, C> {
3120        InstanceRestartCall {
3121            hub: self.hub,
3122            _project: project.to_string(),
3123            _instance: instance.to_string(),
3124            _delegate: Default::default(),
3125            _additional_params: Default::default(),
3126            _scopes: Default::default(),
3127        }
3128    }
3129
3130    /// Create a builder to help you perform the following task:
3131    ///
3132    /// Restores a backup of a Cloud SQL instance. Using this operation might cause
3133    /// your instance to restart.
3134    ///
3135    /// # Arguments
3136    ///
3137    /// * `request` - No description provided.
3138    /// * `project` - Project ID of the project that contains the instance.
3139    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3140    pub fn restore_backup(
3141        &self,
3142        request: InstancesRestoreBackupRequest,
3143        project: &str,
3144        instance: &str,
3145    ) -> InstanceRestoreBackupCall<'a, C> {
3146        InstanceRestoreBackupCall {
3147            hub: self.hub,
3148            _request: request,
3149            _project: project.to_string(),
3150            _instance: instance.to_string(),
3151            _delegate: Default::default(),
3152            _additional_params: Default::default(),
3153            _scopes: Default::default(),
3154        }
3155    }
3156
3157    /// Create a builder to help you perform the following task:
3158    ///
3159    /// Rotates the server certificate to one signed by the Certificate Authority
3160    /// (CA) version previously added with the addServerCA method.
3161    ///
3162    /// # Arguments
3163    ///
3164    /// * `request` - No description provided.
3165    /// * `project` - Project ID of the project that contains the instance.
3166    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3167    pub fn rotate_server_ca(
3168        &self,
3169        request: InstancesRotateServerCaRequest,
3170        project: &str,
3171        instance: &str,
3172    ) -> InstanceRotateServerCaCall<'a, C> {
3173        InstanceRotateServerCaCall {
3174            hub: self.hub,
3175            _request: request,
3176            _project: project.to_string(),
3177            _instance: instance.to_string(),
3178            _delegate: Default::default(),
3179            _additional_params: Default::default(),
3180            _scopes: Default::default(),
3181        }
3182    }
3183
3184    /// Create a builder to help you perform the following task:
3185    ///
3186    /// Starts the replication in the read replica instance.
3187    ///
3188    /// # Arguments
3189    ///
3190    /// * `project` - ID of the project that contains the read replica.
3191    /// * `instance` - Cloud SQL read replica instance name.
3192    pub fn start_replica(&self, project: &str, instance: &str) -> InstanceStartReplicaCall<'a, C> {
3193        InstanceStartReplicaCall {
3194            hub: self.hub,
3195            _project: project.to_string(),
3196            _instance: instance.to_string(),
3197            _delegate: Default::default(),
3198            _additional_params: Default::default(),
3199            _scopes: Default::default(),
3200        }
3201    }
3202
3203    /// Create a builder to help you perform the following task:
3204    ///
3205    /// Stops the replication in the read replica instance.
3206    ///
3207    /// # Arguments
3208    ///
3209    /// * `project` - ID of the project that contains the read replica.
3210    /// * `instance` - Cloud SQL read replica instance name.
3211    pub fn stop_replica(&self, project: &str, instance: &str) -> InstanceStopReplicaCall<'a, C> {
3212        InstanceStopReplicaCall {
3213            hub: self.hub,
3214            _project: project.to_string(),
3215            _instance: instance.to_string(),
3216            _delegate: Default::default(),
3217            _additional_params: Default::default(),
3218            _scopes: Default::default(),
3219        }
3220    }
3221
3222    /// Create a builder to help you perform the following task:
3223    ///
3224    /// Truncate MySQL general and slow query log tables
3225    ///
3226    /// # Arguments
3227    ///
3228    /// * `request` - No description provided.
3229    /// * `project` - Project ID of the Cloud SQL project.
3230    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3231    pub fn truncate_log(
3232        &self,
3233        request: InstancesTruncateLogRequest,
3234        project: &str,
3235        instance: &str,
3236    ) -> InstanceTruncateLogCall<'a, C> {
3237        InstanceTruncateLogCall {
3238            hub: self.hub,
3239            _request: request,
3240            _project: project.to_string(),
3241            _instance: instance.to_string(),
3242            _delegate: Default::default(),
3243            _additional_params: Default::default(),
3244            _scopes: Default::default(),
3245        }
3246    }
3247
3248    /// Create a builder to help you perform the following task:
3249    ///
3250    /// Updates settings of a Cloud SQL instance. Using this operation might cause
3251    /// your instance to restart.
3252    ///
3253    /// # Arguments
3254    ///
3255    /// * `request` - No description provided.
3256    /// * `project` - Project ID of the project that contains the instance.
3257    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3258    pub fn update(
3259        &self,
3260        request: DatabaseInstance,
3261        project: &str,
3262        instance: &str,
3263    ) -> InstanceUpdateCall<'a, C> {
3264        InstanceUpdateCall {
3265            hub: self.hub,
3266            _request: request,
3267            _project: project.to_string(),
3268            _instance: instance.to_string(),
3269            _delegate: Default::default(),
3270            _additional_params: Default::default(),
3271            _scopes: Default::default(),
3272        }
3273    }
3274}
3275
3276/// A builder providing access to all methods supported on *operation* resources.
3277/// It is not used directly, but through the [`SQLAdmin`] hub.
3278///
3279/// # Example
3280///
3281/// Instantiate a resource builder
3282///
3283/// ```test_harness,no_run
3284/// extern crate hyper;
3285/// extern crate hyper_rustls;
3286/// extern crate google_sql1_beta4 as sql1_beta4;
3287///
3288/// # async fn dox() {
3289/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3290///
3291/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3292/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3293///     .with_native_roots()
3294///     .unwrap()
3295///     .https_only()
3296///     .enable_http2()
3297///     .build();
3298///
3299/// let executor = hyper_util::rt::TokioExecutor::new();
3300/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3301///     secret,
3302///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3303///     yup_oauth2::client::CustomHyperClientBuilder::from(
3304///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3305///     ),
3306/// ).build().await.unwrap();
3307///
3308/// let client = hyper_util::client::legacy::Client::builder(
3309///     hyper_util::rt::TokioExecutor::new()
3310/// )
3311/// .build(
3312///     hyper_rustls::HttpsConnectorBuilder::new()
3313///         .with_native_roots()
3314///         .unwrap()
3315///         .https_or_http()
3316///         .enable_http2()
3317///         .build()
3318/// );
3319/// let mut hub = SQLAdmin::new(client, auth);
3320/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3321/// // like `get(...)` and `list(...)`
3322/// // to build up your call.
3323/// let rb = hub.operations();
3324/// # }
3325/// ```
3326pub struct OperationMethods<'a, C>
3327where
3328    C: 'a,
3329{
3330    hub: &'a SQLAdmin<C>,
3331}
3332
3333impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
3334
3335impl<'a, C> OperationMethods<'a, C> {
3336    /// Create a builder to help you perform the following task:
3337    ///
3338    /// Retrieves an instance operation that has been performed on an instance.
3339    ///
3340    /// # Arguments
3341    ///
3342    /// * `project` - Project ID of the project that contains the instance.
3343    /// * `operation` - Instance operation ID.
3344    pub fn get(&self, project: &str, operation: &str) -> OperationGetCall<'a, C> {
3345        OperationGetCall {
3346            hub: self.hub,
3347            _project: project.to_string(),
3348            _operation: operation.to_string(),
3349            _delegate: Default::default(),
3350            _additional_params: Default::default(),
3351            _scopes: Default::default(),
3352        }
3353    }
3354
3355    /// Create a builder to help you perform the following task:
3356    ///
3357    /// Lists all instance operations that have been performed on the given Cloud
3358    /// SQL instance in the reverse chronological order of the start time.
3359    ///
3360    /// # Arguments
3361    ///
3362    /// * `project` - Project ID of the project that contains the instance.
3363    pub fn list(&self, project: &str) -> OperationListCall<'a, C> {
3364        OperationListCall {
3365            hub: self.hub,
3366            _project: project.to_string(),
3367            _page_token: Default::default(),
3368            _max_results: Default::default(),
3369            _instance: Default::default(),
3370            _delegate: Default::default(),
3371            _additional_params: Default::default(),
3372            _scopes: Default::default(),
3373        }
3374    }
3375}
3376
3377/// A builder providing access to all methods supported on *project* resources.
3378/// It is not used directly, but through the [`SQLAdmin`] hub.
3379///
3380/// # Example
3381///
3382/// Instantiate a resource builder
3383///
3384/// ```test_harness,no_run
3385/// extern crate hyper;
3386/// extern crate hyper_rustls;
3387/// extern crate google_sql1_beta4 as sql1_beta4;
3388///
3389/// # async fn dox() {
3390/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3391///
3392/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3393/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3394///     .with_native_roots()
3395///     .unwrap()
3396///     .https_only()
3397///     .enable_http2()
3398///     .build();
3399///
3400/// let executor = hyper_util::rt::TokioExecutor::new();
3401/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3402///     secret,
3403///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3404///     yup_oauth2::client::CustomHyperClientBuilder::from(
3405///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3406///     ),
3407/// ).build().await.unwrap();
3408///
3409/// let client = hyper_util::client::legacy::Client::builder(
3410///     hyper_util::rt::TokioExecutor::new()
3411/// )
3412/// .build(
3413///     hyper_rustls::HttpsConnectorBuilder::new()
3414///         .with_native_roots()
3415///         .unwrap()
3416///         .https_or_http()
3417///         .enable_http2()
3418///         .build()
3419/// );
3420/// let mut hub = SQLAdmin::new(client, auth);
3421/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3422/// // like `instances_reschedule_maintenance(...)`, `instances_start_external_sync(...)` and `instances_verify_external_sync_settings(...)`
3423/// // to build up your call.
3424/// let rb = hub.projects();
3425/// # }
3426/// ```
3427pub struct ProjectMethods<'a, C>
3428where
3429    C: 'a,
3430{
3431    hub: &'a SQLAdmin<C>,
3432}
3433
3434impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3435
3436impl<'a, C> ProjectMethods<'a, C> {
3437    /// Create a builder to help you perform the following task:
3438    ///
3439    /// Reschedules the maintenance on the given instance.
3440    ///
3441    /// # Arguments
3442    ///
3443    /// * `request` - No description provided.
3444    /// * `project` - ID of the project that contains the instance.
3445    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3446    pub fn instances_reschedule_maintenance(
3447        &self,
3448        request: SqlInstancesRescheduleMaintenanceRequestBody,
3449        project: &str,
3450        instance: &str,
3451    ) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
3452        ProjectInstanceRescheduleMaintenanceCall {
3453            hub: self.hub,
3454            _request: request,
3455            _project: project.to_string(),
3456            _instance: instance.to_string(),
3457            _delegate: Default::default(),
3458            _additional_params: Default::default(),
3459            _scopes: Default::default(),
3460        }
3461    }
3462
3463    /// Create a builder to help you perform the following task:
3464    ///
3465    /// Start External master migration.
3466    ///
3467    /// # Arguments
3468    ///
3469    /// * `project` - ID of the project that contains the first generation instance.
3470    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3471    pub fn instances_start_external_sync(
3472        &self,
3473        project: &str,
3474        instance: &str,
3475    ) -> ProjectInstanceStartExternalSyncCall<'a, C> {
3476        ProjectInstanceStartExternalSyncCall {
3477            hub: self.hub,
3478            _project: project.to_string(),
3479            _instance: instance.to_string(),
3480            _sync_mode: Default::default(),
3481            _delegate: Default::default(),
3482            _additional_params: Default::default(),
3483            _scopes: Default::default(),
3484        }
3485    }
3486
3487    /// Create a builder to help you perform the following task:
3488    ///
3489    /// Verify External master external sync settings.
3490    ///
3491    /// # Arguments
3492    ///
3493    /// * `project` - Project ID of the project that contains the instance.
3494    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3495    pub fn instances_verify_external_sync_settings(
3496        &self,
3497        project: &str,
3498        instance: &str,
3499    ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
3500        ProjectInstanceVerifyExternalSyncSettingCall {
3501            hub: self.hub,
3502            _project: project.to_string(),
3503            _instance: instance.to_string(),
3504            _verify_connection_only: Default::default(),
3505            _sync_mode: Default::default(),
3506            _delegate: Default::default(),
3507            _additional_params: Default::default(),
3508            _scopes: Default::default(),
3509        }
3510    }
3511}
3512
3513/// A builder providing access to all methods supported on *sslCert* resources.
3514/// It is not used directly, but through the [`SQLAdmin`] hub.
3515///
3516/// # Example
3517///
3518/// Instantiate a resource builder
3519///
3520/// ```test_harness,no_run
3521/// extern crate hyper;
3522/// extern crate hyper_rustls;
3523/// extern crate google_sql1_beta4 as sql1_beta4;
3524///
3525/// # async fn dox() {
3526/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3527///
3528/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3529/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3530///     .with_native_roots()
3531///     .unwrap()
3532///     .https_only()
3533///     .enable_http2()
3534///     .build();
3535///
3536/// let executor = hyper_util::rt::TokioExecutor::new();
3537/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3538///     secret,
3539///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3540///     yup_oauth2::client::CustomHyperClientBuilder::from(
3541///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3542///     ),
3543/// ).build().await.unwrap();
3544///
3545/// let client = hyper_util::client::legacy::Client::builder(
3546///     hyper_util::rt::TokioExecutor::new()
3547/// )
3548/// .build(
3549///     hyper_rustls::HttpsConnectorBuilder::new()
3550///         .with_native_roots()
3551///         .unwrap()
3552///         .https_or_http()
3553///         .enable_http2()
3554///         .build()
3555/// );
3556/// let mut hub = SQLAdmin::new(client, auth);
3557/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3558/// // like `create_ephemeral(...)`, `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
3559/// // to build up your call.
3560/// let rb = hub.ssl_certs();
3561/// # }
3562/// ```
3563pub struct SslCertMethods<'a, C>
3564where
3565    C: 'a,
3566{
3567    hub: &'a SQLAdmin<C>,
3568}
3569
3570impl<'a, C> common::MethodsBuilder for SslCertMethods<'a, C> {}
3571
3572impl<'a, C> SslCertMethods<'a, C> {
3573    /// Create a builder to help you perform the following task:
3574    ///
3575    /// Generates a short-lived X509 certificate containing the provided public key
3576    /// and signed by a private key specific to the target instance. Users may use
3577    /// the certificate to authenticate as themselves when connecting to the
3578    /// database.
3579    ///
3580    /// # Arguments
3581    ///
3582    /// * `request` - No description provided.
3583    /// * `project` - Project ID of the Cloud SQL project.
3584    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3585    pub fn create_ephemeral(
3586        &self,
3587        request: SslCertsCreateEphemeralRequest,
3588        project: &str,
3589        instance: &str,
3590    ) -> SslCertCreateEphemeralCall<'a, C> {
3591        SslCertCreateEphemeralCall {
3592            hub: self.hub,
3593            _request: request,
3594            _project: project.to_string(),
3595            _instance: instance.to_string(),
3596            _delegate: Default::default(),
3597            _additional_params: Default::default(),
3598            _scopes: Default::default(),
3599        }
3600    }
3601
3602    /// Create a builder to help you perform the following task:
3603    ///
3604    /// Deletes the SSL certificate. For First Generation instances, the
3605    /// certificate remains valid until the instance is restarted.
3606    ///
3607    /// # Arguments
3608    ///
3609    /// * `project` - Project ID of the project that contains the instance.
3610    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3611    /// * `sha1Fingerprint` - Sha1 FingerPrint.
3612    pub fn delete(
3613        &self,
3614        project: &str,
3615        instance: &str,
3616        sha1_fingerprint: &str,
3617    ) -> SslCertDeleteCall<'a, C> {
3618        SslCertDeleteCall {
3619            hub: self.hub,
3620            _project: project.to_string(),
3621            _instance: instance.to_string(),
3622            _sha1_fingerprint: sha1_fingerprint.to_string(),
3623            _delegate: Default::default(),
3624            _additional_params: Default::default(),
3625            _scopes: Default::default(),
3626        }
3627    }
3628
3629    /// Create a builder to help you perform the following task:
3630    ///
3631    /// Retrieves a particular SSL certificate.  Does not include the private key
3632    /// (required for usage).  The private key must be saved from the response to
3633    /// initial creation.
3634    ///
3635    /// # Arguments
3636    ///
3637    /// * `project` - Project ID of the project that contains the instance.
3638    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3639    /// * `sha1Fingerprint` - Sha1 FingerPrint.
3640    pub fn get(
3641        &self,
3642        project: &str,
3643        instance: &str,
3644        sha1_fingerprint: &str,
3645    ) -> SslCertGetCall<'a, C> {
3646        SslCertGetCall {
3647            hub: self.hub,
3648            _project: project.to_string(),
3649            _instance: instance.to_string(),
3650            _sha1_fingerprint: sha1_fingerprint.to_string(),
3651            _delegate: Default::default(),
3652            _additional_params: Default::default(),
3653            _scopes: Default::default(),
3654        }
3655    }
3656
3657    /// Create a builder to help you perform the following task:
3658    ///
3659    /// Creates an SSL certificate and returns it along with the private key and
3660    /// server certificate authority.  The new certificate will not be usable until
3661    /// the instance is restarted.
3662    ///
3663    /// # Arguments
3664    ///
3665    /// * `request` - No description provided.
3666    /// * `project` - Project ID of the project that contains the instance.
3667    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3668    pub fn insert(
3669        &self,
3670        request: SslCertsInsertRequest,
3671        project: &str,
3672        instance: &str,
3673    ) -> SslCertInsertCall<'a, C> {
3674        SslCertInsertCall {
3675            hub: self.hub,
3676            _request: request,
3677            _project: project.to_string(),
3678            _instance: instance.to_string(),
3679            _delegate: Default::default(),
3680            _additional_params: Default::default(),
3681            _scopes: Default::default(),
3682        }
3683    }
3684
3685    /// Create a builder to help you perform the following task:
3686    ///
3687    /// Lists all of the current SSL certificates for the instance.
3688    ///
3689    /// # Arguments
3690    ///
3691    /// * `project` - Project ID of the project that contains the instance.
3692    /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3693    pub fn list(&self, project: &str, instance: &str) -> SslCertListCall<'a, C> {
3694        SslCertListCall {
3695            hub: self.hub,
3696            _project: project.to_string(),
3697            _instance: instance.to_string(),
3698            _delegate: Default::default(),
3699            _additional_params: Default::default(),
3700            _scopes: Default::default(),
3701        }
3702    }
3703}
3704
3705/// A builder providing access to all methods supported on *tier* resources.
3706/// It is not used directly, but through the [`SQLAdmin`] hub.
3707///
3708/// # Example
3709///
3710/// Instantiate a resource builder
3711///
3712/// ```test_harness,no_run
3713/// extern crate hyper;
3714/// extern crate hyper_rustls;
3715/// extern crate google_sql1_beta4 as sql1_beta4;
3716///
3717/// # async fn dox() {
3718/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3719///
3720/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3721/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3722///     .with_native_roots()
3723///     .unwrap()
3724///     .https_only()
3725///     .enable_http2()
3726///     .build();
3727///
3728/// let executor = hyper_util::rt::TokioExecutor::new();
3729/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3730///     secret,
3731///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3732///     yup_oauth2::client::CustomHyperClientBuilder::from(
3733///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3734///     ),
3735/// ).build().await.unwrap();
3736///
3737/// let client = hyper_util::client::legacy::Client::builder(
3738///     hyper_util::rt::TokioExecutor::new()
3739/// )
3740/// .build(
3741///     hyper_rustls::HttpsConnectorBuilder::new()
3742///         .with_native_roots()
3743///         .unwrap()
3744///         .https_or_http()
3745///         .enable_http2()
3746///         .build()
3747/// );
3748/// let mut hub = SQLAdmin::new(client, auth);
3749/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3750/// // like `list(...)`
3751/// // to build up your call.
3752/// let rb = hub.tiers();
3753/// # }
3754/// ```
3755pub struct TierMethods<'a, C>
3756where
3757    C: 'a,
3758{
3759    hub: &'a SQLAdmin<C>,
3760}
3761
3762impl<'a, C> common::MethodsBuilder for TierMethods<'a, C> {}
3763
3764impl<'a, C> TierMethods<'a, C> {
3765    /// Create a builder to help you perform the following task:
3766    ///
3767    /// Lists all available machine types (tiers) for Cloud SQL, for example,
3768    /// db-n1-standard-1. For related information, see <a
3769    /// href="/sql/pricing">Pricing</a>.
3770    ///
3771    /// # Arguments
3772    ///
3773    /// * `project` - Project ID of the project for which to list tiers.
3774    pub fn list(&self, project: &str) -> TierListCall<'a, C> {
3775        TierListCall {
3776            hub: self.hub,
3777            _project: project.to_string(),
3778            _delegate: Default::default(),
3779            _additional_params: Default::default(),
3780            _scopes: Default::default(),
3781        }
3782    }
3783}
3784
3785/// A builder providing access to all methods supported on *user* resources.
3786/// It is not used directly, but through the [`SQLAdmin`] hub.
3787///
3788/// # Example
3789///
3790/// Instantiate a resource builder
3791///
3792/// ```test_harness,no_run
3793/// extern crate hyper;
3794/// extern crate hyper_rustls;
3795/// extern crate google_sql1_beta4 as sql1_beta4;
3796///
3797/// # async fn dox() {
3798/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3799///
3800/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3801/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3802///     .with_native_roots()
3803///     .unwrap()
3804///     .https_only()
3805///     .enable_http2()
3806///     .build();
3807///
3808/// let executor = hyper_util::rt::TokioExecutor::new();
3809/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3810///     secret,
3811///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3812///     yup_oauth2::client::CustomHyperClientBuilder::from(
3813///         hyper_util::client::legacy::Client::builder(executor).build(connector),
3814///     ),
3815/// ).build().await.unwrap();
3816///
3817/// let client = hyper_util::client::legacy::Client::builder(
3818///     hyper_util::rt::TokioExecutor::new()
3819/// )
3820/// .build(
3821///     hyper_rustls::HttpsConnectorBuilder::new()
3822///         .with_native_roots()
3823///         .unwrap()
3824///         .https_or_http()
3825///         .enable_http2()
3826///         .build()
3827/// );
3828/// let mut hub = SQLAdmin::new(client, auth);
3829/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3830/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)`
3831/// // to build up your call.
3832/// let rb = hub.users();
3833/// # }
3834/// ```
3835pub struct UserMethods<'a, C>
3836where
3837    C: 'a,
3838{
3839    hub: &'a SQLAdmin<C>,
3840}
3841
3842impl<'a, C> common::MethodsBuilder for UserMethods<'a, C> {}
3843
3844impl<'a, C> UserMethods<'a, C> {
3845    /// Create a builder to help you perform the following task:
3846    ///
3847    /// Deletes a user from a Cloud SQL instance.
3848    ///
3849    /// # Arguments
3850    ///
3851    /// * `project` - Project ID of the project that contains the instance.
3852    /// * `instance` - Database instance ID. This does not include the project ID.
3853    pub fn delete(&self, project: &str, instance: &str) -> UserDeleteCall<'a, C> {
3854        UserDeleteCall {
3855            hub: self.hub,
3856            _project: project.to_string(),
3857            _instance: instance.to_string(),
3858            _name: Default::default(),
3859            _host: Default::default(),
3860            _delegate: Default::default(),
3861            _additional_params: Default::default(),
3862            _scopes: Default::default(),
3863        }
3864    }
3865
3866    /// Create a builder to help you perform the following task:
3867    ///
3868    /// Creates a new user in a Cloud SQL instance.
3869    ///
3870    /// # Arguments
3871    ///
3872    /// * `request` - No description provided.
3873    /// * `project` - Project ID of the project that contains the instance.
3874    /// * `instance` - Database instance ID. This does not include the project ID.
3875    pub fn insert(&self, request: User, project: &str, instance: &str) -> UserInsertCall<'a, C> {
3876        UserInsertCall {
3877            hub: self.hub,
3878            _request: request,
3879            _project: project.to_string(),
3880            _instance: instance.to_string(),
3881            _delegate: Default::default(),
3882            _additional_params: Default::default(),
3883            _scopes: Default::default(),
3884        }
3885    }
3886
3887    /// Create a builder to help you perform the following task:
3888    ///
3889    /// Lists users in the specified Cloud SQL instance.
3890    ///
3891    /// # Arguments
3892    ///
3893    /// * `project` - Project ID of the project that contains the instance.
3894    /// * `instance` - Database instance ID. This does not include the project ID.
3895    pub fn list(&self, project: &str, instance: &str) -> UserListCall<'a, C> {
3896        UserListCall {
3897            hub: self.hub,
3898            _project: project.to_string(),
3899            _instance: instance.to_string(),
3900            _delegate: Default::default(),
3901            _additional_params: Default::default(),
3902            _scopes: Default::default(),
3903        }
3904    }
3905
3906    /// Create a builder to help you perform the following task:
3907    ///
3908    /// Updates an existing user in a Cloud SQL instance.
3909    ///
3910    /// # Arguments
3911    ///
3912    /// * `request` - No description provided.
3913    /// * `project` - Project ID of the project that contains the instance.
3914    /// * `instance` - Database instance ID. This does not include the project ID.
3915    pub fn update(&self, request: User, project: &str, instance: &str) -> UserUpdateCall<'a, C> {
3916        UserUpdateCall {
3917            hub: self.hub,
3918            _request: request,
3919            _project: project.to_string(),
3920            _instance: instance.to_string(),
3921            _name: Default::default(),
3922            _host: Default::default(),
3923            _delegate: Default::default(),
3924            _additional_params: Default::default(),
3925            _scopes: Default::default(),
3926        }
3927    }
3928}
3929
3930// ###################
3931// CallBuilders   ###
3932// #################
3933
3934/// Deletes the backup taken by a backup run.
3935///
3936/// A builder for the *delete* method supported by a *backupRun* resource.
3937/// It is not used directly, but through a [`BackupRunMethods`] instance.
3938///
3939/// # Example
3940///
3941/// Instantiate a resource method builder
3942///
3943/// ```test_harness,no_run
3944/// # extern crate hyper;
3945/// # extern crate hyper_rustls;
3946/// # extern crate google_sql1_beta4 as sql1_beta4;
3947/// # async fn dox() {
3948/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3949///
3950/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3951/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3952/// #     .with_native_roots()
3953/// #     .unwrap()
3954/// #     .https_only()
3955/// #     .enable_http2()
3956/// #     .build();
3957///
3958/// # let executor = hyper_util::rt::TokioExecutor::new();
3959/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3960/// #     secret,
3961/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3962/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3963/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3964/// #     ),
3965/// # ).build().await.unwrap();
3966///
3967/// # let client = hyper_util::client::legacy::Client::builder(
3968/// #     hyper_util::rt::TokioExecutor::new()
3969/// # )
3970/// # .build(
3971/// #     hyper_rustls::HttpsConnectorBuilder::new()
3972/// #         .with_native_roots()
3973/// #         .unwrap()
3974/// #         .https_or_http()
3975/// #         .enable_http2()
3976/// #         .build()
3977/// # );
3978/// # let mut hub = SQLAdmin::new(client, auth);
3979/// // You can configure optional parameters by calling the respective setters at will, and
3980/// // execute the final call using `doit()`.
3981/// // Values shown here are possibly random and not representative !
3982/// let result = hub.backup_runs().delete("project", "instance", -51)
3983///              .doit().await;
3984/// # }
3985/// ```
3986pub struct BackupRunDeleteCall<'a, C>
3987where
3988    C: 'a,
3989{
3990    hub: &'a SQLAdmin<C>,
3991    _project: String,
3992    _instance: String,
3993    _id: i64,
3994    _delegate: Option<&'a mut dyn common::Delegate>,
3995    _additional_params: HashMap<String, String>,
3996    _scopes: BTreeSet<String>,
3997}
3998
3999impl<'a, C> common::CallBuilder for BackupRunDeleteCall<'a, C> {}
4000
4001impl<'a, C> BackupRunDeleteCall<'a, C>
4002where
4003    C: common::Connector,
4004{
4005    /// Perform the operation you have build so far.
4006    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4007        use std::borrow::Cow;
4008        use std::io::{Read, Seek};
4009
4010        use common::{url::Params, ToParts};
4011        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4012
4013        let mut dd = common::DefaultDelegate;
4014        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4015        dlg.begin(common::MethodInfo {
4016            id: "sql.backupRuns.delete",
4017            http_method: hyper::Method::DELETE,
4018        });
4019
4020        for &field in ["alt", "project", "instance", "id"].iter() {
4021            if self._additional_params.contains_key(field) {
4022                dlg.finished(false);
4023                return Err(common::Error::FieldClash(field));
4024            }
4025        }
4026
4027        let mut params = Params::with_capacity(5 + self._additional_params.len());
4028        params.push("project", self._project);
4029        params.push("instance", self._instance);
4030        params.push("id", self._id.to_string());
4031
4032        params.extend(self._additional_params.iter());
4033
4034        params.push("alt", "json");
4035        let mut url = self.hub._base_url.clone()
4036            + "sql/v1beta4/projects/{project}/instances/{instance}/backupRuns/{id}";
4037        if self._scopes.is_empty() {
4038            self._scopes
4039                .insert(Scope::CloudPlatform.as_ref().to_string());
4040        }
4041
4042        #[allow(clippy::single_element_loop)]
4043        for &(find_this, param_name) in [
4044            ("{project}", "project"),
4045            ("{instance}", "instance"),
4046            ("{id}", "id"),
4047        ]
4048        .iter()
4049        {
4050            url = params.uri_replacement(url, param_name, find_this, false);
4051        }
4052        {
4053            let to_remove = ["id", "instance", "project"];
4054            params.remove_params(&to_remove);
4055        }
4056
4057        let url = params.parse_with_url(&url);
4058
4059        loop {
4060            let token = match self
4061                .hub
4062                .auth
4063                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4064                .await
4065            {
4066                Ok(token) => token,
4067                Err(e) => match dlg.token(e) {
4068                    Ok(token) => token,
4069                    Err(e) => {
4070                        dlg.finished(false);
4071                        return Err(common::Error::MissingToken(e));
4072                    }
4073                },
4074            };
4075            let mut req_result = {
4076                let client = &self.hub.client;
4077                dlg.pre_request();
4078                let mut req_builder = hyper::Request::builder()
4079                    .method(hyper::Method::DELETE)
4080                    .uri(url.as_str())
4081                    .header(USER_AGENT, self.hub._user_agent.clone());
4082
4083                if let Some(token) = token.as_ref() {
4084                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4085                }
4086
4087                let request = req_builder
4088                    .header(CONTENT_LENGTH, 0_u64)
4089                    .body(common::to_body::<String>(None));
4090
4091                client.request(request.unwrap()).await
4092            };
4093
4094            match req_result {
4095                Err(err) => {
4096                    if let common::Retry::After(d) = dlg.http_error(&err) {
4097                        sleep(d).await;
4098                        continue;
4099                    }
4100                    dlg.finished(false);
4101                    return Err(common::Error::HttpError(err));
4102                }
4103                Ok(res) => {
4104                    let (mut parts, body) = res.into_parts();
4105                    let mut body = common::Body::new(body);
4106                    if !parts.status.is_success() {
4107                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4108                        let error = serde_json::from_str(&common::to_string(&bytes));
4109                        let response = common::to_response(parts, bytes.into());
4110
4111                        if let common::Retry::After(d) =
4112                            dlg.http_failure(&response, error.as_ref().ok())
4113                        {
4114                            sleep(d).await;
4115                            continue;
4116                        }
4117
4118                        dlg.finished(false);
4119
4120                        return Err(match error {
4121                            Ok(value) => common::Error::BadRequest(value),
4122                            _ => common::Error::Failure(response),
4123                        });
4124                    }
4125                    let response = {
4126                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4127                        let encoded = common::to_string(&bytes);
4128                        match serde_json::from_str(&encoded) {
4129                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4130                            Err(error) => {
4131                                dlg.response_json_decode_error(&encoded, &error);
4132                                return Err(common::Error::JsonDecodeError(
4133                                    encoded.to_string(),
4134                                    error,
4135                                ));
4136                            }
4137                        }
4138                    };
4139
4140                    dlg.finished(true);
4141                    return Ok(response);
4142                }
4143            }
4144        }
4145    }
4146
4147    /// Project ID of the project that contains the instance.
4148    ///
4149    /// Sets the *project* path property to the given value.
4150    ///
4151    /// Even though the property as already been set when instantiating this call,
4152    /// we provide this method for API completeness.
4153    pub fn project(mut self, new_value: &str) -> BackupRunDeleteCall<'a, C> {
4154        self._project = new_value.to_string();
4155        self
4156    }
4157    /// Cloud SQL instance ID. This does not include the project ID.
4158    ///
4159    /// Sets the *instance* path property to the given value.
4160    ///
4161    /// Even though the property as already been set when instantiating this call,
4162    /// we provide this method for API completeness.
4163    pub fn instance(mut self, new_value: &str) -> BackupRunDeleteCall<'a, C> {
4164        self._instance = new_value.to_string();
4165        self
4166    }
4167    /// The ID of the Backup Run to delete. To find a Backup Run ID, use the <a
4168    /// href="/sql/docs/db_path/admin-api/rest/v1beta4/backupRuns/list">list</a>
4169    /// method.
4170    ///
4171    /// Sets the *id* path property to the given value.
4172    ///
4173    /// Even though the property as already been set when instantiating this call,
4174    /// we provide this method for API completeness.
4175    pub fn id(mut self, new_value: i64) -> BackupRunDeleteCall<'a, C> {
4176        self._id = new_value;
4177        self
4178    }
4179    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4180    /// while executing the actual API request.
4181    ///
4182    /// ````text
4183    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4184    /// ````
4185    ///
4186    /// Sets the *delegate* property to the given value.
4187    pub fn delegate(
4188        mut self,
4189        new_value: &'a mut dyn common::Delegate,
4190    ) -> BackupRunDeleteCall<'a, C> {
4191        self._delegate = Some(new_value);
4192        self
4193    }
4194
4195    /// Set any additional parameter of the query string used in the request.
4196    /// It should be used to set parameters which are not yet available through their own
4197    /// setters.
4198    ///
4199    /// Please note that this method must not be used to set any of the known parameters
4200    /// which have their own setter method. If done anyway, the request will fail.
4201    ///
4202    /// # Additional Parameters
4203    ///
4204    /// * *$.xgafv* (query-string) - V1 error format.
4205    /// * *access_token* (query-string) - OAuth access token.
4206    /// * *alt* (query-string) - Data format for response.
4207    /// * *callback* (query-string) - JSONP
4208    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4209    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4210    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4211    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4212    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4213    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4214    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4215    pub fn param<T>(mut self, name: T, value: T) -> BackupRunDeleteCall<'a, C>
4216    where
4217        T: AsRef<str>,
4218    {
4219        self._additional_params
4220            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4221        self
4222    }
4223
4224    /// Identifies the authorization scope for the method you are building.
4225    ///
4226    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4227    /// [`Scope::CloudPlatform`].
4228    ///
4229    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4230    /// tokens for more than one scope.
4231    ///
4232    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4233    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4234    /// sufficient, a read-write scope will do as well.
4235    pub fn add_scope<St>(mut self, scope: St) -> BackupRunDeleteCall<'a, C>
4236    where
4237        St: AsRef<str>,
4238    {
4239        self._scopes.insert(String::from(scope.as_ref()));
4240        self
4241    }
4242    /// Identifies the authorization scope(s) for the method you are building.
4243    ///
4244    /// See [`Self::add_scope()`] for details.
4245    pub fn add_scopes<I, St>(mut self, scopes: I) -> BackupRunDeleteCall<'a, C>
4246    where
4247        I: IntoIterator<Item = St>,
4248        St: AsRef<str>,
4249    {
4250        self._scopes
4251            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4252        self
4253    }
4254
4255    /// Removes all scopes, and no default scope will be used either.
4256    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4257    /// for details).
4258    pub fn clear_scopes(mut self) -> BackupRunDeleteCall<'a, C> {
4259        self._scopes.clear();
4260        self
4261    }
4262}
4263
4264/// Retrieves a resource containing information about a backup run.
4265///
4266/// A builder for the *get* method supported by a *backupRun* resource.
4267/// It is not used directly, but through a [`BackupRunMethods`] instance.
4268///
4269/// # Example
4270///
4271/// Instantiate a resource method builder
4272///
4273/// ```test_harness,no_run
4274/// # extern crate hyper;
4275/// # extern crate hyper_rustls;
4276/// # extern crate google_sql1_beta4 as sql1_beta4;
4277/// # async fn dox() {
4278/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4279///
4280/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4281/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4282/// #     .with_native_roots()
4283/// #     .unwrap()
4284/// #     .https_only()
4285/// #     .enable_http2()
4286/// #     .build();
4287///
4288/// # let executor = hyper_util::rt::TokioExecutor::new();
4289/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4290/// #     secret,
4291/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4292/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4293/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4294/// #     ),
4295/// # ).build().await.unwrap();
4296///
4297/// # let client = hyper_util::client::legacy::Client::builder(
4298/// #     hyper_util::rt::TokioExecutor::new()
4299/// # )
4300/// # .build(
4301/// #     hyper_rustls::HttpsConnectorBuilder::new()
4302/// #         .with_native_roots()
4303/// #         .unwrap()
4304/// #         .https_or_http()
4305/// #         .enable_http2()
4306/// #         .build()
4307/// # );
4308/// # let mut hub = SQLAdmin::new(client, auth);
4309/// // You can configure optional parameters by calling the respective setters at will, and
4310/// // execute the final call using `doit()`.
4311/// // Values shown here are possibly random and not representative !
4312/// let result = hub.backup_runs().get("project", "instance", -4)
4313///              .doit().await;
4314/// # }
4315/// ```
4316pub struct BackupRunGetCall<'a, C>
4317where
4318    C: 'a,
4319{
4320    hub: &'a SQLAdmin<C>,
4321    _project: String,
4322    _instance: String,
4323    _id: i64,
4324    _delegate: Option<&'a mut dyn common::Delegate>,
4325    _additional_params: HashMap<String, String>,
4326    _scopes: BTreeSet<String>,
4327}
4328
4329impl<'a, C> common::CallBuilder for BackupRunGetCall<'a, C> {}
4330
4331impl<'a, C> BackupRunGetCall<'a, C>
4332where
4333    C: common::Connector,
4334{
4335    /// Perform the operation you have build so far.
4336    pub async fn doit(mut self) -> common::Result<(common::Response, BackupRun)> {
4337        use std::borrow::Cow;
4338        use std::io::{Read, Seek};
4339
4340        use common::{url::Params, ToParts};
4341        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4342
4343        let mut dd = common::DefaultDelegate;
4344        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4345        dlg.begin(common::MethodInfo {
4346            id: "sql.backupRuns.get",
4347            http_method: hyper::Method::GET,
4348        });
4349
4350        for &field in ["alt", "project", "instance", "id"].iter() {
4351            if self._additional_params.contains_key(field) {
4352                dlg.finished(false);
4353                return Err(common::Error::FieldClash(field));
4354            }
4355        }
4356
4357        let mut params = Params::with_capacity(5 + self._additional_params.len());
4358        params.push("project", self._project);
4359        params.push("instance", self._instance);
4360        params.push("id", self._id.to_string());
4361
4362        params.extend(self._additional_params.iter());
4363
4364        params.push("alt", "json");
4365        let mut url = self.hub._base_url.clone()
4366            + "sql/v1beta4/projects/{project}/instances/{instance}/backupRuns/{id}";
4367        if self._scopes.is_empty() {
4368            self._scopes
4369                .insert(Scope::CloudPlatform.as_ref().to_string());
4370        }
4371
4372        #[allow(clippy::single_element_loop)]
4373        for &(find_this, param_name) in [
4374            ("{project}", "project"),
4375            ("{instance}", "instance"),
4376            ("{id}", "id"),
4377        ]
4378        .iter()
4379        {
4380            url = params.uri_replacement(url, param_name, find_this, false);
4381        }
4382        {
4383            let to_remove = ["id", "instance", "project"];
4384            params.remove_params(&to_remove);
4385        }
4386
4387        let url = params.parse_with_url(&url);
4388
4389        loop {
4390            let token = match self
4391                .hub
4392                .auth
4393                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4394                .await
4395            {
4396                Ok(token) => token,
4397                Err(e) => match dlg.token(e) {
4398                    Ok(token) => token,
4399                    Err(e) => {
4400                        dlg.finished(false);
4401                        return Err(common::Error::MissingToken(e));
4402                    }
4403                },
4404            };
4405            let mut req_result = {
4406                let client = &self.hub.client;
4407                dlg.pre_request();
4408                let mut req_builder = hyper::Request::builder()
4409                    .method(hyper::Method::GET)
4410                    .uri(url.as_str())
4411                    .header(USER_AGENT, self.hub._user_agent.clone());
4412
4413                if let Some(token) = token.as_ref() {
4414                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4415                }
4416
4417                let request = req_builder
4418                    .header(CONTENT_LENGTH, 0_u64)
4419                    .body(common::to_body::<String>(None));
4420
4421                client.request(request.unwrap()).await
4422            };
4423
4424            match req_result {
4425                Err(err) => {
4426                    if let common::Retry::After(d) = dlg.http_error(&err) {
4427                        sleep(d).await;
4428                        continue;
4429                    }
4430                    dlg.finished(false);
4431                    return Err(common::Error::HttpError(err));
4432                }
4433                Ok(res) => {
4434                    let (mut parts, body) = res.into_parts();
4435                    let mut body = common::Body::new(body);
4436                    if !parts.status.is_success() {
4437                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4438                        let error = serde_json::from_str(&common::to_string(&bytes));
4439                        let response = common::to_response(parts, bytes.into());
4440
4441                        if let common::Retry::After(d) =
4442                            dlg.http_failure(&response, error.as_ref().ok())
4443                        {
4444                            sleep(d).await;
4445                            continue;
4446                        }
4447
4448                        dlg.finished(false);
4449
4450                        return Err(match error {
4451                            Ok(value) => common::Error::BadRequest(value),
4452                            _ => common::Error::Failure(response),
4453                        });
4454                    }
4455                    let response = {
4456                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4457                        let encoded = common::to_string(&bytes);
4458                        match serde_json::from_str(&encoded) {
4459                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4460                            Err(error) => {
4461                                dlg.response_json_decode_error(&encoded, &error);
4462                                return Err(common::Error::JsonDecodeError(
4463                                    encoded.to_string(),
4464                                    error,
4465                                ));
4466                            }
4467                        }
4468                    };
4469
4470                    dlg.finished(true);
4471                    return Ok(response);
4472                }
4473            }
4474        }
4475    }
4476
4477    /// Project ID of the project that contains the instance.
4478    ///
4479    /// Sets the *project* path property to the given value.
4480    ///
4481    /// Even though the property as already been set when instantiating this call,
4482    /// we provide this method for API completeness.
4483    pub fn project(mut self, new_value: &str) -> BackupRunGetCall<'a, C> {
4484        self._project = new_value.to_string();
4485        self
4486    }
4487    /// Cloud SQL instance ID. This does not include the project ID.
4488    ///
4489    /// Sets the *instance* path property to the given value.
4490    ///
4491    /// Even though the property as already been set when instantiating this call,
4492    /// we provide this method for API completeness.
4493    pub fn instance(mut self, new_value: &str) -> BackupRunGetCall<'a, C> {
4494        self._instance = new_value.to_string();
4495        self
4496    }
4497    /// The ID of this Backup Run.
4498    ///
4499    /// Sets the *id* path property to the given value.
4500    ///
4501    /// Even though the property as already been set when instantiating this call,
4502    /// we provide this method for API completeness.
4503    pub fn id(mut self, new_value: i64) -> BackupRunGetCall<'a, C> {
4504        self._id = new_value;
4505        self
4506    }
4507    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4508    /// while executing the actual API request.
4509    ///
4510    /// ````text
4511    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4512    /// ````
4513    ///
4514    /// Sets the *delegate* property to the given value.
4515    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BackupRunGetCall<'a, C> {
4516        self._delegate = Some(new_value);
4517        self
4518    }
4519
4520    /// Set any additional parameter of the query string used in the request.
4521    /// It should be used to set parameters which are not yet available through their own
4522    /// setters.
4523    ///
4524    /// Please note that this method must not be used to set any of the known parameters
4525    /// which have their own setter method. If done anyway, the request will fail.
4526    ///
4527    /// # Additional Parameters
4528    ///
4529    /// * *$.xgafv* (query-string) - V1 error format.
4530    /// * *access_token* (query-string) - OAuth access token.
4531    /// * *alt* (query-string) - Data format for response.
4532    /// * *callback* (query-string) - JSONP
4533    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4534    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4535    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4536    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4537    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4538    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4539    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4540    pub fn param<T>(mut self, name: T, value: T) -> BackupRunGetCall<'a, C>
4541    where
4542        T: AsRef<str>,
4543    {
4544        self._additional_params
4545            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4546        self
4547    }
4548
4549    /// Identifies the authorization scope for the method you are building.
4550    ///
4551    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4552    /// [`Scope::CloudPlatform`].
4553    ///
4554    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4555    /// tokens for more than one scope.
4556    ///
4557    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4558    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4559    /// sufficient, a read-write scope will do as well.
4560    pub fn add_scope<St>(mut self, scope: St) -> BackupRunGetCall<'a, C>
4561    where
4562        St: AsRef<str>,
4563    {
4564        self._scopes.insert(String::from(scope.as_ref()));
4565        self
4566    }
4567    /// Identifies the authorization scope(s) for the method you are building.
4568    ///
4569    /// See [`Self::add_scope()`] for details.
4570    pub fn add_scopes<I, St>(mut self, scopes: I) -> BackupRunGetCall<'a, C>
4571    where
4572        I: IntoIterator<Item = St>,
4573        St: AsRef<str>,
4574    {
4575        self._scopes
4576            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4577        self
4578    }
4579
4580    /// Removes all scopes, and no default scope will be used either.
4581    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4582    /// for details).
4583    pub fn clear_scopes(mut self) -> BackupRunGetCall<'a, C> {
4584        self._scopes.clear();
4585        self
4586    }
4587}
4588
4589/// Creates a new backup run on demand. This method is applicable only to
4590/// Second Generation instances.
4591///
4592/// A builder for the *insert* method supported by a *backupRun* resource.
4593/// It is not used directly, but through a [`BackupRunMethods`] instance.
4594///
4595/// # Example
4596///
4597/// Instantiate a resource method builder
4598///
4599/// ```test_harness,no_run
4600/// # extern crate hyper;
4601/// # extern crate hyper_rustls;
4602/// # extern crate google_sql1_beta4 as sql1_beta4;
4603/// use sql1_beta4::api::BackupRun;
4604/// # async fn dox() {
4605/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4606///
4607/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4608/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4609/// #     .with_native_roots()
4610/// #     .unwrap()
4611/// #     .https_only()
4612/// #     .enable_http2()
4613/// #     .build();
4614///
4615/// # let executor = hyper_util::rt::TokioExecutor::new();
4616/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4617/// #     secret,
4618/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4619/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4620/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4621/// #     ),
4622/// # ).build().await.unwrap();
4623///
4624/// # let client = hyper_util::client::legacy::Client::builder(
4625/// #     hyper_util::rt::TokioExecutor::new()
4626/// # )
4627/// # .build(
4628/// #     hyper_rustls::HttpsConnectorBuilder::new()
4629/// #         .with_native_roots()
4630/// #         .unwrap()
4631/// #         .https_or_http()
4632/// #         .enable_http2()
4633/// #         .build()
4634/// # );
4635/// # let mut hub = SQLAdmin::new(client, auth);
4636/// // As the method needs a request, you would usually fill it with the desired information
4637/// // into the respective structure. Some of the parts shown here might not be applicable !
4638/// // Values shown here are possibly random and not representative !
4639/// let mut req = BackupRun::default();
4640///
4641/// // You can configure optional parameters by calling the respective setters at will, and
4642/// // execute the final call using `doit()`.
4643/// // Values shown here are possibly random and not representative !
4644/// let result = hub.backup_runs().insert(req, "project", "instance")
4645///              .doit().await;
4646/// # }
4647/// ```
4648pub struct BackupRunInsertCall<'a, C>
4649where
4650    C: 'a,
4651{
4652    hub: &'a SQLAdmin<C>,
4653    _request: BackupRun,
4654    _project: String,
4655    _instance: String,
4656    _delegate: Option<&'a mut dyn common::Delegate>,
4657    _additional_params: HashMap<String, String>,
4658    _scopes: BTreeSet<String>,
4659}
4660
4661impl<'a, C> common::CallBuilder for BackupRunInsertCall<'a, C> {}
4662
4663impl<'a, C> BackupRunInsertCall<'a, C>
4664where
4665    C: common::Connector,
4666{
4667    /// Perform the operation you have build so far.
4668    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4669        use std::borrow::Cow;
4670        use std::io::{Read, Seek};
4671
4672        use common::{url::Params, ToParts};
4673        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4674
4675        let mut dd = common::DefaultDelegate;
4676        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4677        dlg.begin(common::MethodInfo {
4678            id: "sql.backupRuns.insert",
4679            http_method: hyper::Method::POST,
4680        });
4681
4682        for &field in ["alt", "project", "instance"].iter() {
4683            if self._additional_params.contains_key(field) {
4684                dlg.finished(false);
4685                return Err(common::Error::FieldClash(field));
4686            }
4687        }
4688
4689        let mut params = Params::with_capacity(5 + self._additional_params.len());
4690        params.push("project", self._project);
4691        params.push("instance", self._instance);
4692
4693        params.extend(self._additional_params.iter());
4694
4695        params.push("alt", "json");
4696        let mut url = self.hub._base_url.clone()
4697            + "sql/v1beta4/projects/{project}/instances/{instance}/backupRuns";
4698        if self._scopes.is_empty() {
4699            self._scopes
4700                .insert(Scope::CloudPlatform.as_ref().to_string());
4701        }
4702
4703        #[allow(clippy::single_element_loop)]
4704        for &(find_this, param_name) in
4705            [("{project}", "project"), ("{instance}", "instance")].iter()
4706        {
4707            url = params.uri_replacement(url, param_name, find_this, false);
4708        }
4709        {
4710            let to_remove = ["instance", "project"];
4711            params.remove_params(&to_remove);
4712        }
4713
4714        let url = params.parse_with_url(&url);
4715
4716        let mut json_mime_type = mime::APPLICATION_JSON;
4717        let mut request_value_reader = {
4718            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4719            common::remove_json_null_values(&mut value);
4720            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4721            serde_json::to_writer(&mut dst, &value).unwrap();
4722            dst
4723        };
4724        let request_size = request_value_reader
4725            .seek(std::io::SeekFrom::End(0))
4726            .unwrap();
4727        request_value_reader
4728            .seek(std::io::SeekFrom::Start(0))
4729            .unwrap();
4730
4731        loop {
4732            let token = match self
4733                .hub
4734                .auth
4735                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4736                .await
4737            {
4738                Ok(token) => token,
4739                Err(e) => match dlg.token(e) {
4740                    Ok(token) => token,
4741                    Err(e) => {
4742                        dlg.finished(false);
4743                        return Err(common::Error::MissingToken(e));
4744                    }
4745                },
4746            };
4747            request_value_reader
4748                .seek(std::io::SeekFrom::Start(0))
4749                .unwrap();
4750            let mut req_result = {
4751                let client = &self.hub.client;
4752                dlg.pre_request();
4753                let mut req_builder = hyper::Request::builder()
4754                    .method(hyper::Method::POST)
4755                    .uri(url.as_str())
4756                    .header(USER_AGENT, self.hub._user_agent.clone());
4757
4758                if let Some(token) = token.as_ref() {
4759                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4760                }
4761
4762                let request = req_builder
4763                    .header(CONTENT_TYPE, json_mime_type.to_string())
4764                    .header(CONTENT_LENGTH, request_size as u64)
4765                    .body(common::to_body(
4766                        request_value_reader.get_ref().clone().into(),
4767                    ));
4768
4769                client.request(request.unwrap()).await
4770            };
4771
4772            match req_result {
4773                Err(err) => {
4774                    if let common::Retry::After(d) = dlg.http_error(&err) {
4775                        sleep(d).await;
4776                        continue;
4777                    }
4778                    dlg.finished(false);
4779                    return Err(common::Error::HttpError(err));
4780                }
4781                Ok(res) => {
4782                    let (mut parts, body) = res.into_parts();
4783                    let mut body = common::Body::new(body);
4784                    if !parts.status.is_success() {
4785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4786                        let error = serde_json::from_str(&common::to_string(&bytes));
4787                        let response = common::to_response(parts, bytes.into());
4788
4789                        if let common::Retry::After(d) =
4790                            dlg.http_failure(&response, error.as_ref().ok())
4791                        {
4792                            sleep(d).await;
4793                            continue;
4794                        }
4795
4796                        dlg.finished(false);
4797
4798                        return Err(match error {
4799                            Ok(value) => common::Error::BadRequest(value),
4800                            _ => common::Error::Failure(response),
4801                        });
4802                    }
4803                    let response = {
4804                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4805                        let encoded = common::to_string(&bytes);
4806                        match serde_json::from_str(&encoded) {
4807                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4808                            Err(error) => {
4809                                dlg.response_json_decode_error(&encoded, &error);
4810                                return Err(common::Error::JsonDecodeError(
4811                                    encoded.to_string(),
4812                                    error,
4813                                ));
4814                            }
4815                        }
4816                    };
4817
4818                    dlg.finished(true);
4819                    return Ok(response);
4820                }
4821            }
4822        }
4823    }
4824
4825    ///
4826    /// Sets the *request* property to the given value.
4827    ///
4828    /// Even though the property as already been set when instantiating this call,
4829    /// we provide this method for API completeness.
4830    pub fn request(mut self, new_value: BackupRun) -> BackupRunInsertCall<'a, C> {
4831        self._request = new_value;
4832        self
4833    }
4834    /// Project ID of the project that contains the instance.
4835    ///
4836    /// Sets the *project* path property to the given value.
4837    ///
4838    /// Even though the property as already been set when instantiating this call,
4839    /// we provide this method for API completeness.
4840    pub fn project(mut self, new_value: &str) -> BackupRunInsertCall<'a, C> {
4841        self._project = new_value.to_string();
4842        self
4843    }
4844    /// Cloud SQL instance ID. This does not include the project ID.
4845    ///
4846    /// Sets the *instance* path property to the given value.
4847    ///
4848    /// Even though the property as already been set when instantiating this call,
4849    /// we provide this method for API completeness.
4850    pub fn instance(mut self, new_value: &str) -> BackupRunInsertCall<'a, C> {
4851        self._instance = new_value.to_string();
4852        self
4853    }
4854    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4855    /// while executing the actual API request.
4856    ///
4857    /// ````text
4858    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4859    /// ````
4860    ///
4861    /// Sets the *delegate* property to the given value.
4862    pub fn delegate(
4863        mut self,
4864        new_value: &'a mut dyn common::Delegate,
4865    ) -> BackupRunInsertCall<'a, C> {
4866        self._delegate = Some(new_value);
4867        self
4868    }
4869
4870    /// Set any additional parameter of the query string used in the request.
4871    /// It should be used to set parameters which are not yet available through their own
4872    /// setters.
4873    ///
4874    /// Please note that this method must not be used to set any of the known parameters
4875    /// which have their own setter method. If done anyway, the request will fail.
4876    ///
4877    /// # Additional Parameters
4878    ///
4879    /// * *$.xgafv* (query-string) - V1 error format.
4880    /// * *access_token* (query-string) - OAuth access token.
4881    /// * *alt* (query-string) - Data format for response.
4882    /// * *callback* (query-string) - JSONP
4883    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4884    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4885    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4886    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4887    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4888    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4889    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4890    pub fn param<T>(mut self, name: T, value: T) -> BackupRunInsertCall<'a, C>
4891    where
4892        T: AsRef<str>,
4893    {
4894        self._additional_params
4895            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4896        self
4897    }
4898
4899    /// Identifies the authorization scope for the method you are building.
4900    ///
4901    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4902    /// [`Scope::CloudPlatform`].
4903    ///
4904    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4905    /// tokens for more than one scope.
4906    ///
4907    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4908    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4909    /// sufficient, a read-write scope will do as well.
4910    pub fn add_scope<St>(mut self, scope: St) -> BackupRunInsertCall<'a, C>
4911    where
4912        St: AsRef<str>,
4913    {
4914        self._scopes.insert(String::from(scope.as_ref()));
4915        self
4916    }
4917    /// Identifies the authorization scope(s) for the method you are building.
4918    ///
4919    /// See [`Self::add_scope()`] for details.
4920    pub fn add_scopes<I, St>(mut self, scopes: I) -> BackupRunInsertCall<'a, C>
4921    where
4922        I: IntoIterator<Item = St>,
4923        St: AsRef<str>,
4924    {
4925        self._scopes
4926            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4927        self
4928    }
4929
4930    /// Removes all scopes, and no default scope will be used either.
4931    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4932    /// for details).
4933    pub fn clear_scopes(mut self) -> BackupRunInsertCall<'a, C> {
4934        self._scopes.clear();
4935        self
4936    }
4937}
4938
4939/// Lists all backup runs associated with a given instance and configuration in
4940/// the reverse chronological order of the backup initiation time.
4941///
4942/// A builder for the *list* method supported by a *backupRun* resource.
4943/// It is not used directly, but through a [`BackupRunMethods`] instance.
4944///
4945/// # Example
4946///
4947/// Instantiate a resource method builder
4948///
4949/// ```test_harness,no_run
4950/// # extern crate hyper;
4951/// # extern crate hyper_rustls;
4952/// # extern crate google_sql1_beta4 as sql1_beta4;
4953/// # async fn dox() {
4954/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4955///
4956/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4957/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4958/// #     .with_native_roots()
4959/// #     .unwrap()
4960/// #     .https_only()
4961/// #     .enable_http2()
4962/// #     .build();
4963///
4964/// # let executor = hyper_util::rt::TokioExecutor::new();
4965/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4966/// #     secret,
4967/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4968/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4969/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4970/// #     ),
4971/// # ).build().await.unwrap();
4972///
4973/// # let client = hyper_util::client::legacy::Client::builder(
4974/// #     hyper_util::rt::TokioExecutor::new()
4975/// # )
4976/// # .build(
4977/// #     hyper_rustls::HttpsConnectorBuilder::new()
4978/// #         .with_native_roots()
4979/// #         .unwrap()
4980/// #         .https_or_http()
4981/// #         .enable_http2()
4982/// #         .build()
4983/// # );
4984/// # let mut hub = SQLAdmin::new(client, auth);
4985/// // You can configure optional parameters by calling the respective setters at will, and
4986/// // execute the final call using `doit()`.
4987/// // Values shown here are possibly random and not representative !
4988/// let result = hub.backup_runs().list("project", "instance")
4989///              .page_token("duo")
4990///              .max_results(-50)
4991///              .doit().await;
4992/// # }
4993/// ```
4994pub struct BackupRunListCall<'a, C>
4995where
4996    C: 'a,
4997{
4998    hub: &'a SQLAdmin<C>,
4999    _project: String,
5000    _instance: String,
5001    _page_token: Option<String>,
5002    _max_results: Option<i32>,
5003    _delegate: Option<&'a mut dyn common::Delegate>,
5004    _additional_params: HashMap<String, String>,
5005    _scopes: BTreeSet<String>,
5006}
5007
5008impl<'a, C> common::CallBuilder for BackupRunListCall<'a, C> {}
5009
5010impl<'a, C> BackupRunListCall<'a, C>
5011where
5012    C: common::Connector,
5013{
5014    /// Perform the operation you have build so far.
5015    pub async fn doit(mut self) -> common::Result<(common::Response, BackupRunsListResponse)> {
5016        use std::borrow::Cow;
5017        use std::io::{Read, Seek};
5018
5019        use common::{url::Params, ToParts};
5020        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5021
5022        let mut dd = common::DefaultDelegate;
5023        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5024        dlg.begin(common::MethodInfo {
5025            id: "sql.backupRuns.list",
5026            http_method: hyper::Method::GET,
5027        });
5028
5029        for &field in ["alt", "project", "instance", "pageToken", "maxResults"].iter() {
5030            if self._additional_params.contains_key(field) {
5031                dlg.finished(false);
5032                return Err(common::Error::FieldClash(field));
5033            }
5034        }
5035
5036        let mut params = Params::with_capacity(6 + self._additional_params.len());
5037        params.push("project", self._project);
5038        params.push("instance", self._instance);
5039        if let Some(value) = self._page_token.as_ref() {
5040            params.push("pageToken", value);
5041        }
5042        if let Some(value) = self._max_results.as_ref() {
5043            params.push("maxResults", value.to_string());
5044        }
5045
5046        params.extend(self._additional_params.iter());
5047
5048        params.push("alt", "json");
5049        let mut url = self.hub._base_url.clone()
5050            + "sql/v1beta4/projects/{project}/instances/{instance}/backupRuns";
5051        if self._scopes.is_empty() {
5052            self._scopes
5053                .insert(Scope::CloudPlatform.as_ref().to_string());
5054        }
5055
5056        #[allow(clippy::single_element_loop)]
5057        for &(find_this, param_name) in
5058            [("{project}", "project"), ("{instance}", "instance")].iter()
5059        {
5060            url = params.uri_replacement(url, param_name, find_this, false);
5061        }
5062        {
5063            let to_remove = ["instance", "project"];
5064            params.remove_params(&to_remove);
5065        }
5066
5067        let url = params.parse_with_url(&url);
5068
5069        loop {
5070            let token = match self
5071                .hub
5072                .auth
5073                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5074                .await
5075            {
5076                Ok(token) => token,
5077                Err(e) => match dlg.token(e) {
5078                    Ok(token) => token,
5079                    Err(e) => {
5080                        dlg.finished(false);
5081                        return Err(common::Error::MissingToken(e));
5082                    }
5083                },
5084            };
5085            let mut req_result = {
5086                let client = &self.hub.client;
5087                dlg.pre_request();
5088                let mut req_builder = hyper::Request::builder()
5089                    .method(hyper::Method::GET)
5090                    .uri(url.as_str())
5091                    .header(USER_AGENT, self.hub._user_agent.clone());
5092
5093                if let Some(token) = token.as_ref() {
5094                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5095                }
5096
5097                let request = req_builder
5098                    .header(CONTENT_LENGTH, 0_u64)
5099                    .body(common::to_body::<String>(None));
5100
5101                client.request(request.unwrap()).await
5102            };
5103
5104            match req_result {
5105                Err(err) => {
5106                    if let common::Retry::After(d) = dlg.http_error(&err) {
5107                        sleep(d).await;
5108                        continue;
5109                    }
5110                    dlg.finished(false);
5111                    return Err(common::Error::HttpError(err));
5112                }
5113                Ok(res) => {
5114                    let (mut parts, body) = res.into_parts();
5115                    let mut body = common::Body::new(body);
5116                    if !parts.status.is_success() {
5117                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5118                        let error = serde_json::from_str(&common::to_string(&bytes));
5119                        let response = common::to_response(parts, bytes.into());
5120
5121                        if let common::Retry::After(d) =
5122                            dlg.http_failure(&response, error.as_ref().ok())
5123                        {
5124                            sleep(d).await;
5125                            continue;
5126                        }
5127
5128                        dlg.finished(false);
5129
5130                        return Err(match error {
5131                            Ok(value) => common::Error::BadRequest(value),
5132                            _ => common::Error::Failure(response),
5133                        });
5134                    }
5135                    let response = {
5136                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5137                        let encoded = common::to_string(&bytes);
5138                        match serde_json::from_str(&encoded) {
5139                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5140                            Err(error) => {
5141                                dlg.response_json_decode_error(&encoded, &error);
5142                                return Err(common::Error::JsonDecodeError(
5143                                    encoded.to_string(),
5144                                    error,
5145                                ));
5146                            }
5147                        }
5148                    };
5149
5150                    dlg.finished(true);
5151                    return Ok(response);
5152                }
5153            }
5154        }
5155    }
5156
5157    /// Project ID of the project that contains the instance.
5158    ///
5159    /// Sets the *project* path property to the given value.
5160    ///
5161    /// Even though the property as already been set when instantiating this call,
5162    /// we provide this method for API completeness.
5163    pub fn project(mut self, new_value: &str) -> BackupRunListCall<'a, C> {
5164        self._project = new_value.to_string();
5165        self
5166    }
5167    /// Cloud SQL instance ID. This does not include the project ID.
5168    ///
5169    /// Sets the *instance* path property to the given value.
5170    ///
5171    /// Even though the property as already been set when instantiating this call,
5172    /// we provide this method for API completeness.
5173    pub fn instance(mut self, new_value: &str) -> BackupRunListCall<'a, C> {
5174        self._instance = new_value.to_string();
5175        self
5176    }
5177    /// A previously-returned page token representing part of the larger set of
5178    /// results to view.
5179    ///
5180    /// Sets the *page token* query property to the given value.
5181    pub fn page_token(mut self, new_value: &str) -> BackupRunListCall<'a, C> {
5182        self._page_token = Some(new_value.to_string());
5183        self
5184    }
5185    /// Maximum number of backup runs per response.
5186    ///
5187    /// Sets the *max results* query property to the given value.
5188    pub fn max_results(mut self, new_value: i32) -> BackupRunListCall<'a, C> {
5189        self._max_results = Some(new_value);
5190        self
5191    }
5192    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5193    /// while executing the actual API request.
5194    ///
5195    /// ````text
5196    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5197    /// ````
5198    ///
5199    /// Sets the *delegate* property to the given value.
5200    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BackupRunListCall<'a, C> {
5201        self._delegate = Some(new_value);
5202        self
5203    }
5204
5205    /// Set any additional parameter of the query string used in the request.
5206    /// It should be used to set parameters which are not yet available through their own
5207    /// setters.
5208    ///
5209    /// Please note that this method must not be used to set any of the known parameters
5210    /// which have their own setter method. If done anyway, the request will fail.
5211    ///
5212    /// # Additional Parameters
5213    ///
5214    /// * *$.xgafv* (query-string) - V1 error format.
5215    /// * *access_token* (query-string) - OAuth access token.
5216    /// * *alt* (query-string) - Data format for response.
5217    /// * *callback* (query-string) - JSONP
5218    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5219    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5220    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5221    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5222    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5223    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5224    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5225    pub fn param<T>(mut self, name: T, value: T) -> BackupRunListCall<'a, C>
5226    where
5227        T: AsRef<str>,
5228    {
5229        self._additional_params
5230            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5231        self
5232    }
5233
5234    /// Identifies the authorization scope for the method you are building.
5235    ///
5236    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5237    /// [`Scope::CloudPlatform`].
5238    ///
5239    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5240    /// tokens for more than one scope.
5241    ///
5242    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5243    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5244    /// sufficient, a read-write scope will do as well.
5245    pub fn add_scope<St>(mut self, scope: St) -> BackupRunListCall<'a, C>
5246    where
5247        St: AsRef<str>,
5248    {
5249        self._scopes.insert(String::from(scope.as_ref()));
5250        self
5251    }
5252    /// Identifies the authorization scope(s) for the method you are building.
5253    ///
5254    /// See [`Self::add_scope()`] for details.
5255    pub fn add_scopes<I, St>(mut self, scopes: I) -> BackupRunListCall<'a, C>
5256    where
5257        I: IntoIterator<Item = St>,
5258        St: AsRef<str>,
5259    {
5260        self._scopes
5261            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5262        self
5263    }
5264
5265    /// Removes all scopes, and no default scope will be used either.
5266    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5267    /// for details).
5268    pub fn clear_scopes(mut self) -> BackupRunListCall<'a, C> {
5269        self._scopes.clear();
5270        self
5271    }
5272}
5273
5274/// Deletes a database from a Cloud SQL instance.
5275///
5276/// A builder for the *delete* method supported by a *database* resource.
5277/// It is not used directly, but through a [`DatabaseMethods`] instance.
5278///
5279/// # Example
5280///
5281/// Instantiate a resource method builder
5282///
5283/// ```test_harness,no_run
5284/// # extern crate hyper;
5285/// # extern crate hyper_rustls;
5286/// # extern crate google_sql1_beta4 as sql1_beta4;
5287/// # async fn dox() {
5288/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5289///
5290/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5291/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5292/// #     .with_native_roots()
5293/// #     .unwrap()
5294/// #     .https_only()
5295/// #     .enable_http2()
5296/// #     .build();
5297///
5298/// # let executor = hyper_util::rt::TokioExecutor::new();
5299/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5300/// #     secret,
5301/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5302/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5303/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5304/// #     ),
5305/// # ).build().await.unwrap();
5306///
5307/// # let client = hyper_util::client::legacy::Client::builder(
5308/// #     hyper_util::rt::TokioExecutor::new()
5309/// # )
5310/// # .build(
5311/// #     hyper_rustls::HttpsConnectorBuilder::new()
5312/// #         .with_native_roots()
5313/// #         .unwrap()
5314/// #         .https_or_http()
5315/// #         .enable_http2()
5316/// #         .build()
5317/// # );
5318/// # let mut hub = SQLAdmin::new(client, auth);
5319/// // You can configure optional parameters by calling the respective setters at will, and
5320/// // execute the final call using `doit()`.
5321/// // Values shown here are possibly random and not representative !
5322/// let result = hub.databases().delete("project", "instance", "database")
5323///              .doit().await;
5324/// # }
5325/// ```
5326pub struct DatabaseDeleteCall<'a, C>
5327where
5328    C: 'a,
5329{
5330    hub: &'a SQLAdmin<C>,
5331    _project: String,
5332    _instance: String,
5333    _database: String,
5334    _delegate: Option<&'a mut dyn common::Delegate>,
5335    _additional_params: HashMap<String, String>,
5336    _scopes: BTreeSet<String>,
5337}
5338
5339impl<'a, C> common::CallBuilder for DatabaseDeleteCall<'a, C> {}
5340
5341impl<'a, C> DatabaseDeleteCall<'a, C>
5342where
5343    C: common::Connector,
5344{
5345    /// Perform the operation you have build so far.
5346    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5347        use std::borrow::Cow;
5348        use std::io::{Read, Seek};
5349
5350        use common::{url::Params, ToParts};
5351        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5352
5353        let mut dd = common::DefaultDelegate;
5354        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5355        dlg.begin(common::MethodInfo {
5356            id: "sql.databases.delete",
5357            http_method: hyper::Method::DELETE,
5358        });
5359
5360        for &field in ["alt", "project", "instance", "database"].iter() {
5361            if self._additional_params.contains_key(field) {
5362                dlg.finished(false);
5363                return Err(common::Error::FieldClash(field));
5364            }
5365        }
5366
5367        let mut params = Params::with_capacity(5 + self._additional_params.len());
5368        params.push("project", self._project);
5369        params.push("instance", self._instance);
5370        params.push("database", self._database);
5371
5372        params.extend(self._additional_params.iter());
5373
5374        params.push("alt", "json");
5375        let mut url = self.hub._base_url.clone()
5376            + "sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}";
5377        if self._scopes.is_empty() {
5378            self._scopes
5379                .insert(Scope::CloudPlatform.as_ref().to_string());
5380        }
5381
5382        #[allow(clippy::single_element_loop)]
5383        for &(find_this, param_name) in [
5384            ("{project}", "project"),
5385            ("{instance}", "instance"),
5386            ("{database}", "database"),
5387        ]
5388        .iter()
5389        {
5390            url = params.uri_replacement(url, param_name, find_this, false);
5391        }
5392        {
5393            let to_remove = ["database", "instance", "project"];
5394            params.remove_params(&to_remove);
5395        }
5396
5397        let url = params.parse_with_url(&url);
5398
5399        loop {
5400            let token = match self
5401                .hub
5402                .auth
5403                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5404                .await
5405            {
5406                Ok(token) => token,
5407                Err(e) => match dlg.token(e) {
5408                    Ok(token) => token,
5409                    Err(e) => {
5410                        dlg.finished(false);
5411                        return Err(common::Error::MissingToken(e));
5412                    }
5413                },
5414            };
5415            let mut req_result = {
5416                let client = &self.hub.client;
5417                dlg.pre_request();
5418                let mut req_builder = hyper::Request::builder()
5419                    .method(hyper::Method::DELETE)
5420                    .uri(url.as_str())
5421                    .header(USER_AGENT, self.hub._user_agent.clone());
5422
5423                if let Some(token) = token.as_ref() {
5424                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5425                }
5426
5427                let request = req_builder
5428                    .header(CONTENT_LENGTH, 0_u64)
5429                    .body(common::to_body::<String>(None));
5430
5431                client.request(request.unwrap()).await
5432            };
5433
5434            match req_result {
5435                Err(err) => {
5436                    if let common::Retry::After(d) = dlg.http_error(&err) {
5437                        sleep(d).await;
5438                        continue;
5439                    }
5440                    dlg.finished(false);
5441                    return Err(common::Error::HttpError(err));
5442                }
5443                Ok(res) => {
5444                    let (mut parts, body) = res.into_parts();
5445                    let mut body = common::Body::new(body);
5446                    if !parts.status.is_success() {
5447                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5448                        let error = serde_json::from_str(&common::to_string(&bytes));
5449                        let response = common::to_response(parts, bytes.into());
5450
5451                        if let common::Retry::After(d) =
5452                            dlg.http_failure(&response, error.as_ref().ok())
5453                        {
5454                            sleep(d).await;
5455                            continue;
5456                        }
5457
5458                        dlg.finished(false);
5459
5460                        return Err(match error {
5461                            Ok(value) => common::Error::BadRequest(value),
5462                            _ => common::Error::Failure(response),
5463                        });
5464                    }
5465                    let response = {
5466                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5467                        let encoded = common::to_string(&bytes);
5468                        match serde_json::from_str(&encoded) {
5469                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5470                            Err(error) => {
5471                                dlg.response_json_decode_error(&encoded, &error);
5472                                return Err(common::Error::JsonDecodeError(
5473                                    encoded.to_string(),
5474                                    error,
5475                                ));
5476                            }
5477                        }
5478                    };
5479
5480                    dlg.finished(true);
5481                    return Ok(response);
5482                }
5483            }
5484        }
5485    }
5486
5487    /// Project ID of the project that contains the instance.
5488    ///
5489    /// Sets the *project* path property to the given value.
5490    ///
5491    /// Even though the property as already been set when instantiating this call,
5492    /// we provide this method for API completeness.
5493    pub fn project(mut self, new_value: &str) -> DatabaseDeleteCall<'a, C> {
5494        self._project = new_value.to_string();
5495        self
5496    }
5497    /// Database instance ID. This does not include the project ID.
5498    ///
5499    /// Sets the *instance* path property to the given value.
5500    ///
5501    /// Even though the property as already been set when instantiating this call,
5502    /// we provide this method for API completeness.
5503    pub fn instance(mut self, new_value: &str) -> DatabaseDeleteCall<'a, C> {
5504        self._instance = new_value.to_string();
5505        self
5506    }
5507    /// Name of the database to be deleted in the instance.
5508    ///
5509    /// Sets the *database* path property to the given value.
5510    ///
5511    /// Even though the property as already been set when instantiating this call,
5512    /// we provide this method for API completeness.
5513    pub fn database(mut self, new_value: &str) -> DatabaseDeleteCall<'a, C> {
5514        self._database = new_value.to_string();
5515        self
5516    }
5517    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5518    /// while executing the actual API request.
5519    ///
5520    /// ````text
5521    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5522    /// ````
5523    ///
5524    /// Sets the *delegate* property to the given value.
5525    pub fn delegate(
5526        mut self,
5527        new_value: &'a mut dyn common::Delegate,
5528    ) -> DatabaseDeleteCall<'a, C> {
5529        self._delegate = Some(new_value);
5530        self
5531    }
5532
5533    /// Set any additional parameter of the query string used in the request.
5534    /// It should be used to set parameters which are not yet available through their own
5535    /// setters.
5536    ///
5537    /// Please note that this method must not be used to set any of the known parameters
5538    /// which have their own setter method. If done anyway, the request will fail.
5539    ///
5540    /// # Additional Parameters
5541    ///
5542    /// * *$.xgafv* (query-string) - V1 error format.
5543    /// * *access_token* (query-string) - OAuth access token.
5544    /// * *alt* (query-string) - Data format for response.
5545    /// * *callback* (query-string) - JSONP
5546    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5547    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5548    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5549    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5550    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5551    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5552    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5553    pub fn param<T>(mut self, name: T, value: T) -> DatabaseDeleteCall<'a, C>
5554    where
5555        T: AsRef<str>,
5556    {
5557        self._additional_params
5558            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5559        self
5560    }
5561
5562    /// Identifies the authorization scope for the method you are building.
5563    ///
5564    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5565    /// [`Scope::CloudPlatform`].
5566    ///
5567    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5568    /// tokens for more than one scope.
5569    ///
5570    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5571    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5572    /// sufficient, a read-write scope will do as well.
5573    pub fn add_scope<St>(mut self, scope: St) -> DatabaseDeleteCall<'a, C>
5574    where
5575        St: AsRef<str>,
5576    {
5577        self._scopes.insert(String::from(scope.as_ref()));
5578        self
5579    }
5580    /// Identifies the authorization scope(s) for the method you are building.
5581    ///
5582    /// See [`Self::add_scope()`] for details.
5583    pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseDeleteCall<'a, C>
5584    where
5585        I: IntoIterator<Item = St>,
5586        St: AsRef<str>,
5587    {
5588        self._scopes
5589            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5590        self
5591    }
5592
5593    /// Removes all scopes, and no default scope will be used either.
5594    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5595    /// for details).
5596    pub fn clear_scopes(mut self) -> DatabaseDeleteCall<'a, C> {
5597        self._scopes.clear();
5598        self
5599    }
5600}
5601
5602/// Retrieves a resource containing information about a database inside a Cloud
5603/// SQL instance.
5604///
5605/// A builder for the *get* method supported by a *database* resource.
5606/// It is not used directly, but through a [`DatabaseMethods`] instance.
5607///
5608/// # Example
5609///
5610/// Instantiate a resource method builder
5611///
5612/// ```test_harness,no_run
5613/// # extern crate hyper;
5614/// # extern crate hyper_rustls;
5615/// # extern crate google_sql1_beta4 as sql1_beta4;
5616/// # async fn dox() {
5617/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5618///
5619/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5620/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5621/// #     .with_native_roots()
5622/// #     .unwrap()
5623/// #     .https_only()
5624/// #     .enable_http2()
5625/// #     .build();
5626///
5627/// # let executor = hyper_util::rt::TokioExecutor::new();
5628/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5629/// #     secret,
5630/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5631/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5632/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5633/// #     ),
5634/// # ).build().await.unwrap();
5635///
5636/// # let client = hyper_util::client::legacy::Client::builder(
5637/// #     hyper_util::rt::TokioExecutor::new()
5638/// # )
5639/// # .build(
5640/// #     hyper_rustls::HttpsConnectorBuilder::new()
5641/// #         .with_native_roots()
5642/// #         .unwrap()
5643/// #         .https_or_http()
5644/// #         .enable_http2()
5645/// #         .build()
5646/// # );
5647/// # let mut hub = SQLAdmin::new(client, auth);
5648/// // You can configure optional parameters by calling the respective setters at will, and
5649/// // execute the final call using `doit()`.
5650/// // Values shown here are possibly random and not representative !
5651/// let result = hub.databases().get("project", "instance", "database")
5652///              .doit().await;
5653/// # }
5654/// ```
5655pub struct DatabaseGetCall<'a, C>
5656where
5657    C: 'a,
5658{
5659    hub: &'a SQLAdmin<C>,
5660    _project: String,
5661    _instance: String,
5662    _database: String,
5663    _delegate: Option<&'a mut dyn common::Delegate>,
5664    _additional_params: HashMap<String, String>,
5665    _scopes: BTreeSet<String>,
5666}
5667
5668impl<'a, C> common::CallBuilder for DatabaseGetCall<'a, C> {}
5669
5670impl<'a, C> DatabaseGetCall<'a, C>
5671where
5672    C: common::Connector,
5673{
5674    /// Perform the operation you have build so far.
5675    pub async fn doit(mut self) -> common::Result<(common::Response, Database)> {
5676        use std::borrow::Cow;
5677        use std::io::{Read, Seek};
5678
5679        use common::{url::Params, ToParts};
5680        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5681
5682        let mut dd = common::DefaultDelegate;
5683        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5684        dlg.begin(common::MethodInfo {
5685            id: "sql.databases.get",
5686            http_method: hyper::Method::GET,
5687        });
5688
5689        for &field in ["alt", "project", "instance", "database"].iter() {
5690            if self._additional_params.contains_key(field) {
5691                dlg.finished(false);
5692                return Err(common::Error::FieldClash(field));
5693            }
5694        }
5695
5696        let mut params = Params::with_capacity(5 + self._additional_params.len());
5697        params.push("project", self._project);
5698        params.push("instance", self._instance);
5699        params.push("database", self._database);
5700
5701        params.extend(self._additional_params.iter());
5702
5703        params.push("alt", "json");
5704        let mut url = self.hub._base_url.clone()
5705            + "sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}";
5706        if self._scopes.is_empty() {
5707            self._scopes
5708                .insert(Scope::CloudPlatform.as_ref().to_string());
5709        }
5710
5711        #[allow(clippy::single_element_loop)]
5712        for &(find_this, param_name) in [
5713            ("{project}", "project"),
5714            ("{instance}", "instance"),
5715            ("{database}", "database"),
5716        ]
5717        .iter()
5718        {
5719            url = params.uri_replacement(url, param_name, find_this, false);
5720        }
5721        {
5722            let to_remove = ["database", "instance", "project"];
5723            params.remove_params(&to_remove);
5724        }
5725
5726        let url = params.parse_with_url(&url);
5727
5728        loop {
5729            let token = match self
5730                .hub
5731                .auth
5732                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5733                .await
5734            {
5735                Ok(token) => token,
5736                Err(e) => match dlg.token(e) {
5737                    Ok(token) => token,
5738                    Err(e) => {
5739                        dlg.finished(false);
5740                        return Err(common::Error::MissingToken(e));
5741                    }
5742                },
5743            };
5744            let mut req_result = {
5745                let client = &self.hub.client;
5746                dlg.pre_request();
5747                let mut req_builder = hyper::Request::builder()
5748                    .method(hyper::Method::GET)
5749                    .uri(url.as_str())
5750                    .header(USER_AGENT, self.hub._user_agent.clone());
5751
5752                if let Some(token) = token.as_ref() {
5753                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5754                }
5755
5756                let request = req_builder
5757                    .header(CONTENT_LENGTH, 0_u64)
5758                    .body(common::to_body::<String>(None));
5759
5760                client.request(request.unwrap()).await
5761            };
5762
5763            match req_result {
5764                Err(err) => {
5765                    if let common::Retry::After(d) = dlg.http_error(&err) {
5766                        sleep(d).await;
5767                        continue;
5768                    }
5769                    dlg.finished(false);
5770                    return Err(common::Error::HttpError(err));
5771                }
5772                Ok(res) => {
5773                    let (mut parts, body) = res.into_parts();
5774                    let mut body = common::Body::new(body);
5775                    if !parts.status.is_success() {
5776                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5777                        let error = serde_json::from_str(&common::to_string(&bytes));
5778                        let response = common::to_response(parts, bytes.into());
5779
5780                        if let common::Retry::After(d) =
5781                            dlg.http_failure(&response, error.as_ref().ok())
5782                        {
5783                            sleep(d).await;
5784                            continue;
5785                        }
5786
5787                        dlg.finished(false);
5788
5789                        return Err(match error {
5790                            Ok(value) => common::Error::BadRequest(value),
5791                            _ => common::Error::Failure(response),
5792                        });
5793                    }
5794                    let response = {
5795                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5796                        let encoded = common::to_string(&bytes);
5797                        match serde_json::from_str(&encoded) {
5798                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5799                            Err(error) => {
5800                                dlg.response_json_decode_error(&encoded, &error);
5801                                return Err(common::Error::JsonDecodeError(
5802                                    encoded.to_string(),
5803                                    error,
5804                                ));
5805                            }
5806                        }
5807                    };
5808
5809                    dlg.finished(true);
5810                    return Ok(response);
5811                }
5812            }
5813        }
5814    }
5815
5816    /// Project ID of the project that contains the instance.
5817    ///
5818    /// Sets the *project* path property to the given value.
5819    ///
5820    /// Even though the property as already been set when instantiating this call,
5821    /// we provide this method for API completeness.
5822    pub fn project(mut self, new_value: &str) -> DatabaseGetCall<'a, C> {
5823        self._project = new_value.to_string();
5824        self
5825    }
5826    /// Database instance ID. This does not include the project ID.
5827    ///
5828    /// Sets the *instance* path property to the given value.
5829    ///
5830    /// Even though the property as already been set when instantiating this call,
5831    /// we provide this method for API completeness.
5832    pub fn instance(mut self, new_value: &str) -> DatabaseGetCall<'a, C> {
5833        self._instance = new_value.to_string();
5834        self
5835    }
5836    /// Name of the database in the instance.
5837    ///
5838    /// Sets the *database* path property to the given value.
5839    ///
5840    /// Even though the property as already been set when instantiating this call,
5841    /// we provide this method for API completeness.
5842    pub fn database(mut self, new_value: &str) -> DatabaseGetCall<'a, C> {
5843        self._database = new_value.to_string();
5844        self
5845    }
5846    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5847    /// while executing the actual API request.
5848    ///
5849    /// ````text
5850    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5851    /// ````
5852    ///
5853    /// Sets the *delegate* property to the given value.
5854    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DatabaseGetCall<'a, C> {
5855        self._delegate = Some(new_value);
5856        self
5857    }
5858
5859    /// Set any additional parameter of the query string used in the request.
5860    /// It should be used to set parameters which are not yet available through their own
5861    /// setters.
5862    ///
5863    /// Please note that this method must not be used to set any of the known parameters
5864    /// which have their own setter method. If done anyway, the request will fail.
5865    ///
5866    /// # Additional Parameters
5867    ///
5868    /// * *$.xgafv* (query-string) - V1 error format.
5869    /// * *access_token* (query-string) - OAuth access token.
5870    /// * *alt* (query-string) - Data format for response.
5871    /// * *callback* (query-string) - JSONP
5872    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5873    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5874    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5875    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5876    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5877    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5878    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5879    pub fn param<T>(mut self, name: T, value: T) -> DatabaseGetCall<'a, C>
5880    where
5881        T: AsRef<str>,
5882    {
5883        self._additional_params
5884            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5885        self
5886    }
5887
5888    /// Identifies the authorization scope for the method you are building.
5889    ///
5890    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5891    /// [`Scope::CloudPlatform`].
5892    ///
5893    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5894    /// tokens for more than one scope.
5895    ///
5896    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5897    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5898    /// sufficient, a read-write scope will do as well.
5899    pub fn add_scope<St>(mut self, scope: St) -> DatabaseGetCall<'a, C>
5900    where
5901        St: AsRef<str>,
5902    {
5903        self._scopes.insert(String::from(scope.as_ref()));
5904        self
5905    }
5906    /// Identifies the authorization scope(s) for the method you are building.
5907    ///
5908    /// See [`Self::add_scope()`] for details.
5909    pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseGetCall<'a, C>
5910    where
5911        I: IntoIterator<Item = St>,
5912        St: AsRef<str>,
5913    {
5914        self._scopes
5915            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5916        self
5917    }
5918
5919    /// Removes all scopes, and no default scope will be used either.
5920    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5921    /// for details).
5922    pub fn clear_scopes(mut self) -> DatabaseGetCall<'a, C> {
5923        self._scopes.clear();
5924        self
5925    }
5926}
5927
5928/// Inserts a resource containing information about a database inside a Cloud
5929/// SQL instance.
5930///
5931/// A builder for the *insert* method supported by a *database* resource.
5932/// It is not used directly, but through a [`DatabaseMethods`] instance.
5933///
5934/// # Example
5935///
5936/// Instantiate a resource method builder
5937///
5938/// ```test_harness,no_run
5939/// # extern crate hyper;
5940/// # extern crate hyper_rustls;
5941/// # extern crate google_sql1_beta4 as sql1_beta4;
5942/// use sql1_beta4::api::Database;
5943/// # async fn dox() {
5944/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5945///
5946/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5947/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5948/// #     .with_native_roots()
5949/// #     .unwrap()
5950/// #     .https_only()
5951/// #     .enable_http2()
5952/// #     .build();
5953///
5954/// # let executor = hyper_util::rt::TokioExecutor::new();
5955/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5956/// #     secret,
5957/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5958/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5959/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5960/// #     ),
5961/// # ).build().await.unwrap();
5962///
5963/// # let client = hyper_util::client::legacy::Client::builder(
5964/// #     hyper_util::rt::TokioExecutor::new()
5965/// # )
5966/// # .build(
5967/// #     hyper_rustls::HttpsConnectorBuilder::new()
5968/// #         .with_native_roots()
5969/// #         .unwrap()
5970/// #         .https_or_http()
5971/// #         .enable_http2()
5972/// #         .build()
5973/// # );
5974/// # let mut hub = SQLAdmin::new(client, auth);
5975/// // As the method needs a request, you would usually fill it with the desired information
5976/// // into the respective structure. Some of the parts shown here might not be applicable !
5977/// // Values shown here are possibly random and not representative !
5978/// let mut req = Database::default();
5979///
5980/// // You can configure optional parameters by calling the respective setters at will, and
5981/// // execute the final call using `doit()`.
5982/// // Values shown here are possibly random and not representative !
5983/// let result = hub.databases().insert(req, "project", "instance")
5984///              .doit().await;
5985/// # }
5986/// ```
5987pub struct DatabaseInsertCall<'a, C>
5988where
5989    C: 'a,
5990{
5991    hub: &'a SQLAdmin<C>,
5992    _request: Database,
5993    _project: String,
5994    _instance: String,
5995    _delegate: Option<&'a mut dyn common::Delegate>,
5996    _additional_params: HashMap<String, String>,
5997    _scopes: BTreeSet<String>,
5998}
5999
6000impl<'a, C> common::CallBuilder for DatabaseInsertCall<'a, C> {}
6001
6002impl<'a, C> DatabaseInsertCall<'a, C>
6003where
6004    C: common::Connector,
6005{
6006    /// Perform the operation you have build so far.
6007    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6008        use std::borrow::Cow;
6009        use std::io::{Read, Seek};
6010
6011        use common::{url::Params, ToParts};
6012        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6013
6014        let mut dd = common::DefaultDelegate;
6015        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6016        dlg.begin(common::MethodInfo {
6017            id: "sql.databases.insert",
6018            http_method: hyper::Method::POST,
6019        });
6020
6021        for &field in ["alt", "project", "instance"].iter() {
6022            if self._additional_params.contains_key(field) {
6023                dlg.finished(false);
6024                return Err(common::Error::FieldClash(field));
6025            }
6026        }
6027
6028        let mut params = Params::with_capacity(5 + self._additional_params.len());
6029        params.push("project", self._project);
6030        params.push("instance", self._instance);
6031
6032        params.extend(self._additional_params.iter());
6033
6034        params.push("alt", "json");
6035        let mut url = self.hub._base_url.clone()
6036            + "sql/v1beta4/projects/{project}/instances/{instance}/databases";
6037        if self._scopes.is_empty() {
6038            self._scopes
6039                .insert(Scope::CloudPlatform.as_ref().to_string());
6040        }
6041
6042        #[allow(clippy::single_element_loop)]
6043        for &(find_this, param_name) in
6044            [("{project}", "project"), ("{instance}", "instance")].iter()
6045        {
6046            url = params.uri_replacement(url, param_name, find_this, false);
6047        }
6048        {
6049            let to_remove = ["instance", "project"];
6050            params.remove_params(&to_remove);
6051        }
6052
6053        let url = params.parse_with_url(&url);
6054
6055        let mut json_mime_type = mime::APPLICATION_JSON;
6056        let mut request_value_reader = {
6057            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6058            common::remove_json_null_values(&mut value);
6059            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6060            serde_json::to_writer(&mut dst, &value).unwrap();
6061            dst
6062        };
6063        let request_size = request_value_reader
6064            .seek(std::io::SeekFrom::End(0))
6065            .unwrap();
6066        request_value_reader
6067            .seek(std::io::SeekFrom::Start(0))
6068            .unwrap();
6069
6070        loop {
6071            let token = match self
6072                .hub
6073                .auth
6074                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6075                .await
6076            {
6077                Ok(token) => token,
6078                Err(e) => match dlg.token(e) {
6079                    Ok(token) => token,
6080                    Err(e) => {
6081                        dlg.finished(false);
6082                        return Err(common::Error::MissingToken(e));
6083                    }
6084                },
6085            };
6086            request_value_reader
6087                .seek(std::io::SeekFrom::Start(0))
6088                .unwrap();
6089            let mut req_result = {
6090                let client = &self.hub.client;
6091                dlg.pre_request();
6092                let mut req_builder = hyper::Request::builder()
6093                    .method(hyper::Method::POST)
6094                    .uri(url.as_str())
6095                    .header(USER_AGENT, self.hub._user_agent.clone());
6096
6097                if let Some(token) = token.as_ref() {
6098                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6099                }
6100
6101                let request = req_builder
6102                    .header(CONTENT_TYPE, json_mime_type.to_string())
6103                    .header(CONTENT_LENGTH, request_size as u64)
6104                    .body(common::to_body(
6105                        request_value_reader.get_ref().clone().into(),
6106                    ));
6107
6108                client.request(request.unwrap()).await
6109            };
6110
6111            match req_result {
6112                Err(err) => {
6113                    if let common::Retry::After(d) = dlg.http_error(&err) {
6114                        sleep(d).await;
6115                        continue;
6116                    }
6117                    dlg.finished(false);
6118                    return Err(common::Error::HttpError(err));
6119                }
6120                Ok(res) => {
6121                    let (mut parts, body) = res.into_parts();
6122                    let mut body = common::Body::new(body);
6123                    if !parts.status.is_success() {
6124                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6125                        let error = serde_json::from_str(&common::to_string(&bytes));
6126                        let response = common::to_response(parts, bytes.into());
6127
6128                        if let common::Retry::After(d) =
6129                            dlg.http_failure(&response, error.as_ref().ok())
6130                        {
6131                            sleep(d).await;
6132                            continue;
6133                        }
6134
6135                        dlg.finished(false);
6136
6137                        return Err(match error {
6138                            Ok(value) => common::Error::BadRequest(value),
6139                            _ => common::Error::Failure(response),
6140                        });
6141                    }
6142                    let response = {
6143                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6144                        let encoded = common::to_string(&bytes);
6145                        match serde_json::from_str(&encoded) {
6146                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6147                            Err(error) => {
6148                                dlg.response_json_decode_error(&encoded, &error);
6149                                return Err(common::Error::JsonDecodeError(
6150                                    encoded.to_string(),
6151                                    error,
6152                                ));
6153                            }
6154                        }
6155                    };
6156
6157                    dlg.finished(true);
6158                    return Ok(response);
6159                }
6160            }
6161        }
6162    }
6163
6164    ///
6165    /// Sets the *request* property to the given value.
6166    ///
6167    /// Even though the property as already been set when instantiating this call,
6168    /// we provide this method for API completeness.
6169    pub fn request(mut self, new_value: Database) -> DatabaseInsertCall<'a, C> {
6170        self._request = new_value;
6171        self
6172    }
6173    /// Project ID of the project that contains the instance.
6174    ///
6175    /// Sets the *project* path property to the given value.
6176    ///
6177    /// Even though the property as already been set when instantiating this call,
6178    /// we provide this method for API completeness.
6179    pub fn project(mut self, new_value: &str) -> DatabaseInsertCall<'a, C> {
6180        self._project = new_value.to_string();
6181        self
6182    }
6183    /// Database instance ID. This does not include the project ID.
6184    ///
6185    /// Sets the *instance* path property to the given value.
6186    ///
6187    /// Even though the property as already been set when instantiating this call,
6188    /// we provide this method for API completeness.
6189    pub fn instance(mut self, new_value: &str) -> DatabaseInsertCall<'a, C> {
6190        self._instance = new_value.to_string();
6191        self
6192    }
6193    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6194    /// while executing the actual API request.
6195    ///
6196    /// ````text
6197    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6198    /// ````
6199    ///
6200    /// Sets the *delegate* property to the given value.
6201    pub fn delegate(
6202        mut self,
6203        new_value: &'a mut dyn common::Delegate,
6204    ) -> DatabaseInsertCall<'a, C> {
6205        self._delegate = Some(new_value);
6206        self
6207    }
6208
6209    /// Set any additional parameter of the query string used in the request.
6210    /// It should be used to set parameters which are not yet available through their own
6211    /// setters.
6212    ///
6213    /// Please note that this method must not be used to set any of the known parameters
6214    /// which have their own setter method. If done anyway, the request will fail.
6215    ///
6216    /// # Additional Parameters
6217    ///
6218    /// * *$.xgafv* (query-string) - V1 error format.
6219    /// * *access_token* (query-string) - OAuth access token.
6220    /// * *alt* (query-string) - Data format for response.
6221    /// * *callback* (query-string) - JSONP
6222    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6223    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6224    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6225    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6226    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6227    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6228    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6229    pub fn param<T>(mut self, name: T, value: T) -> DatabaseInsertCall<'a, C>
6230    where
6231        T: AsRef<str>,
6232    {
6233        self._additional_params
6234            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6235        self
6236    }
6237
6238    /// Identifies the authorization scope for the method you are building.
6239    ///
6240    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6241    /// [`Scope::CloudPlatform`].
6242    ///
6243    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6244    /// tokens for more than one scope.
6245    ///
6246    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6247    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6248    /// sufficient, a read-write scope will do as well.
6249    pub fn add_scope<St>(mut self, scope: St) -> DatabaseInsertCall<'a, C>
6250    where
6251        St: AsRef<str>,
6252    {
6253        self._scopes.insert(String::from(scope.as_ref()));
6254        self
6255    }
6256    /// Identifies the authorization scope(s) for the method you are building.
6257    ///
6258    /// See [`Self::add_scope()`] for details.
6259    pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseInsertCall<'a, C>
6260    where
6261        I: IntoIterator<Item = St>,
6262        St: AsRef<str>,
6263    {
6264        self._scopes
6265            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6266        self
6267    }
6268
6269    /// Removes all scopes, and no default scope will be used either.
6270    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6271    /// for details).
6272    pub fn clear_scopes(mut self) -> DatabaseInsertCall<'a, C> {
6273        self._scopes.clear();
6274        self
6275    }
6276}
6277
6278/// Lists databases in the specified Cloud SQL instance.
6279///
6280/// A builder for the *list* method supported by a *database* resource.
6281/// It is not used directly, but through a [`DatabaseMethods`] instance.
6282///
6283/// # Example
6284///
6285/// Instantiate a resource method builder
6286///
6287/// ```test_harness,no_run
6288/// # extern crate hyper;
6289/// # extern crate hyper_rustls;
6290/// # extern crate google_sql1_beta4 as sql1_beta4;
6291/// # async fn dox() {
6292/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6293///
6294/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6295/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6296/// #     .with_native_roots()
6297/// #     .unwrap()
6298/// #     .https_only()
6299/// #     .enable_http2()
6300/// #     .build();
6301///
6302/// # let executor = hyper_util::rt::TokioExecutor::new();
6303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6304/// #     secret,
6305/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6306/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6307/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6308/// #     ),
6309/// # ).build().await.unwrap();
6310///
6311/// # let client = hyper_util::client::legacy::Client::builder(
6312/// #     hyper_util::rt::TokioExecutor::new()
6313/// # )
6314/// # .build(
6315/// #     hyper_rustls::HttpsConnectorBuilder::new()
6316/// #         .with_native_roots()
6317/// #         .unwrap()
6318/// #         .https_or_http()
6319/// #         .enable_http2()
6320/// #         .build()
6321/// # );
6322/// # let mut hub = SQLAdmin::new(client, auth);
6323/// // You can configure optional parameters by calling the respective setters at will, and
6324/// // execute the final call using `doit()`.
6325/// // Values shown here are possibly random and not representative !
6326/// let result = hub.databases().list("project", "instance")
6327///              .doit().await;
6328/// # }
6329/// ```
6330pub struct DatabaseListCall<'a, C>
6331where
6332    C: 'a,
6333{
6334    hub: &'a SQLAdmin<C>,
6335    _project: String,
6336    _instance: String,
6337    _delegate: Option<&'a mut dyn common::Delegate>,
6338    _additional_params: HashMap<String, String>,
6339    _scopes: BTreeSet<String>,
6340}
6341
6342impl<'a, C> common::CallBuilder for DatabaseListCall<'a, C> {}
6343
6344impl<'a, C> DatabaseListCall<'a, C>
6345where
6346    C: common::Connector,
6347{
6348    /// Perform the operation you have build so far.
6349    pub async fn doit(mut self) -> common::Result<(common::Response, DatabasesListResponse)> {
6350        use std::borrow::Cow;
6351        use std::io::{Read, Seek};
6352
6353        use common::{url::Params, ToParts};
6354        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6355
6356        let mut dd = common::DefaultDelegate;
6357        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6358        dlg.begin(common::MethodInfo {
6359            id: "sql.databases.list",
6360            http_method: hyper::Method::GET,
6361        });
6362
6363        for &field in ["alt", "project", "instance"].iter() {
6364            if self._additional_params.contains_key(field) {
6365                dlg.finished(false);
6366                return Err(common::Error::FieldClash(field));
6367            }
6368        }
6369
6370        let mut params = Params::with_capacity(4 + self._additional_params.len());
6371        params.push("project", self._project);
6372        params.push("instance", self._instance);
6373
6374        params.extend(self._additional_params.iter());
6375
6376        params.push("alt", "json");
6377        let mut url = self.hub._base_url.clone()
6378            + "sql/v1beta4/projects/{project}/instances/{instance}/databases";
6379        if self._scopes.is_empty() {
6380            self._scopes
6381                .insert(Scope::CloudPlatform.as_ref().to_string());
6382        }
6383
6384        #[allow(clippy::single_element_loop)]
6385        for &(find_this, param_name) in
6386            [("{project}", "project"), ("{instance}", "instance")].iter()
6387        {
6388            url = params.uri_replacement(url, param_name, find_this, false);
6389        }
6390        {
6391            let to_remove = ["instance", "project"];
6392            params.remove_params(&to_remove);
6393        }
6394
6395        let url = params.parse_with_url(&url);
6396
6397        loop {
6398            let token = match self
6399                .hub
6400                .auth
6401                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6402                .await
6403            {
6404                Ok(token) => token,
6405                Err(e) => match dlg.token(e) {
6406                    Ok(token) => token,
6407                    Err(e) => {
6408                        dlg.finished(false);
6409                        return Err(common::Error::MissingToken(e));
6410                    }
6411                },
6412            };
6413            let mut req_result = {
6414                let client = &self.hub.client;
6415                dlg.pre_request();
6416                let mut req_builder = hyper::Request::builder()
6417                    .method(hyper::Method::GET)
6418                    .uri(url.as_str())
6419                    .header(USER_AGENT, self.hub._user_agent.clone());
6420
6421                if let Some(token) = token.as_ref() {
6422                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6423                }
6424
6425                let request = req_builder
6426                    .header(CONTENT_LENGTH, 0_u64)
6427                    .body(common::to_body::<String>(None));
6428
6429                client.request(request.unwrap()).await
6430            };
6431
6432            match req_result {
6433                Err(err) => {
6434                    if let common::Retry::After(d) = dlg.http_error(&err) {
6435                        sleep(d).await;
6436                        continue;
6437                    }
6438                    dlg.finished(false);
6439                    return Err(common::Error::HttpError(err));
6440                }
6441                Ok(res) => {
6442                    let (mut parts, body) = res.into_parts();
6443                    let mut body = common::Body::new(body);
6444                    if !parts.status.is_success() {
6445                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6446                        let error = serde_json::from_str(&common::to_string(&bytes));
6447                        let response = common::to_response(parts, bytes.into());
6448
6449                        if let common::Retry::After(d) =
6450                            dlg.http_failure(&response, error.as_ref().ok())
6451                        {
6452                            sleep(d).await;
6453                            continue;
6454                        }
6455
6456                        dlg.finished(false);
6457
6458                        return Err(match error {
6459                            Ok(value) => common::Error::BadRequest(value),
6460                            _ => common::Error::Failure(response),
6461                        });
6462                    }
6463                    let response = {
6464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6465                        let encoded = common::to_string(&bytes);
6466                        match serde_json::from_str(&encoded) {
6467                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6468                            Err(error) => {
6469                                dlg.response_json_decode_error(&encoded, &error);
6470                                return Err(common::Error::JsonDecodeError(
6471                                    encoded.to_string(),
6472                                    error,
6473                                ));
6474                            }
6475                        }
6476                    };
6477
6478                    dlg.finished(true);
6479                    return Ok(response);
6480                }
6481            }
6482        }
6483    }
6484
6485    /// Project ID of the project that contains the instance.
6486    ///
6487    /// Sets the *project* path property to the given value.
6488    ///
6489    /// Even though the property as already been set when instantiating this call,
6490    /// we provide this method for API completeness.
6491    pub fn project(mut self, new_value: &str) -> DatabaseListCall<'a, C> {
6492        self._project = new_value.to_string();
6493        self
6494    }
6495    /// Cloud SQL instance ID. This does not include the project ID.
6496    ///
6497    /// Sets the *instance* path property to the given value.
6498    ///
6499    /// Even though the property as already been set when instantiating this call,
6500    /// we provide this method for API completeness.
6501    pub fn instance(mut self, new_value: &str) -> DatabaseListCall<'a, C> {
6502        self._instance = new_value.to_string();
6503        self
6504    }
6505    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6506    /// while executing the actual API request.
6507    ///
6508    /// ````text
6509    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6510    /// ````
6511    ///
6512    /// Sets the *delegate* property to the given value.
6513    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DatabaseListCall<'a, C> {
6514        self._delegate = Some(new_value);
6515        self
6516    }
6517
6518    /// Set any additional parameter of the query string used in the request.
6519    /// It should be used to set parameters which are not yet available through their own
6520    /// setters.
6521    ///
6522    /// Please note that this method must not be used to set any of the known parameters
6523    /// which have their own setter method. If done anyway, the request will fail.
6524    ///
6525    /// # Additional Parameters
6526    ///
6527    /// * *$.xgafv* (query-string) - V1 error format.
6528    /// * *access_token* (query-string) - OAuth access token.
6529    /// * *alt* (query-string) - Data format for response.
6530    /// * *callback* (query-string) - JSONP
6531    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6532    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6533    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6534    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6535    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6536    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6537    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6538    pub fn param<T>(mut self, name: T, value: T) -> DatabaseListCall<'a, C>
6539    where
6540        T: AsRef<str>,
6541    {
6542        self._additional_params
6543            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6544        self
6545    }
6546
6547    /// Identifies the authorization scope for the method you are building.
6548    ///
6549    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6550    /// [`Scope::CloudPlatform`].
6551    ///
6552    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6553    /// tokens for more than one scope.
6554    ///
6555    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6556    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6557    /// sufficient, a read-write scope will do as well.
6558    pub fn add_scope<St>(mut self, scope: St) -> DatabaseListCall<'a, C>
6559    where
6560        St: AsRef<str>,
6561    {
6562        self._scopes.insert(String::from(scope.as_ref()));
6563        self
6564    }
6565    /// Identifies the authorization scope(s) for the method you are building.
6566    ///
6567    /// See [`Self::add_scope()`] for details.
6568    pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseListCall<'a, C>
6569    where
6570        I: IntoIterator<Item = St>,
6571        St: AsRef<str>,
6572    {
6573        self._scopes
6574            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6575        self
6576    }
6577
6578    /// Removes all scopes, and no default scope will be used either.
6579    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6580    /// for details).
6581    pub fn clear_scopes(mut self) -> DatabaseListCall<'a, C> {
6582        self._scopes.clear();
6583        self
6584    }
6585}
6586
6587/// Partially updates a resource containing information about a database inside
6588/// a Cloud SQL instance. This method supports patch semantics.
6589///
6590/// A builder for the *patch* method supported by a *database* resource.
6591/// It is not used directly, but through a [`DatabaseMethods`] instance.
6592///
6593/// # Example
6594///
6595/// Instantiate a resource method builder
6596///
6597/// ```test_harness,no_run
6598/// # extern crate hyper;
6599/// # extern crate hyper_rustls;
6600/// # extern crate google_sql1_beta4 as sql1_beta4;
6601/// use sql1_beta4::api::Database;
6602/// # async fn dox() {
6603/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6604///
6605/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6606/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6607/// #     .with_native_roots()
6608/// #     .unwrap()
6609/// #     .https_only()
6610/// #     .enable_http2()
6611/// #     .build();
6612///
6613/// # let executor = hyper_util::rt::TokioExecutor::new();
6614/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6615/// #     secret,
6616/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6617/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6618/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6619/// #     ),
6620/// # ).build().await.unwrap();
6621///
6622/// # let client = hyper_util::client::legacy::Client::builder(
6623/// #     hyper_util::rt::TokioExecutor::new()
6624/// # )
6625/// # .build(
6626/// #     hyper_rustls::HttpsConnectorBuilder::new()
6627/// #         .with_native_roots()
6628/// #         .unwrap()
6629/// #         .https_or_http()
6630/// #         .enable_http2()
6631/// #         .build()
6632/// # );
6633/// # let mut hub = SQLAdmin::new(client, auth);
6634/// // As the method needs a request, you would usually fill it with the desired information
6635/// // into the respective structure. Some of the parts shown here might not be applicable !
6636/// // Values shown here are possibly random and not representative !
6637/// let mut req = Database::default();
6638///
6639/// // You can configure optional parameters by calling the respective setters at will, and
6640/// // execute the final call using `doit()`.
6641/// // Values shown here are possibly random and not representative !
6642/// let result = hub.databases().patch(req, "project", "instance", "database")
6643///              .doit().await;
6644/// # }
6645/// ```
6646pub struct DatabasePatchCall<'a, C>
6647where
6648    C: 'a,
6649{
6650    hub: &'a SQLAdmin<C>,
6651    _request: Database,
6652    _project: String,
6653    _instance: String,
6654    _database: String,
6655    _delegate: Option<&'a mut dyn common::Delegate>,
6656    _additional_params: HashMap<String, String>,
6657    _scopes: BTreeSet<String>,
6658}
6659
6660impl<'a, C> common::CallBuilder for DatabasePatchCall<'a, C> {}
6661
6662impl<'a, C> DatabasePatchCall<'a, C>
6663where
6664    C: common::Connector,
6665{
6666    /// Perform the operation you have build so far.
6667    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6668        use std::borrow::Cow;
6669        use std::io::{Read, Seek};
6670
6671        use common::{url::Params, ToParts};
6672        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6673
6674        let mut dd = common::DefaultDelegate;
6675        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6676        dlg.begin(common::MethodInfo {
6677            id: "sql.databases.patch",
6678            http_method: hyper::Method::PATCH,
6679        });
6680
6681        for &field in ["alt", "project", "instance", "database"].iter() {
6682            if self._additional_params.contains_key(field) {
6683                dlg.finished(false);
6684                return Err(common::Error::FieldClash(field));
6685            }
6686        }
6687
6688        let mut params = Params::with_capacity(6 + self._additional_params.len());
6689        params.push("project", self._project);
6690        params.push("instance", self._instance);
6691        params.push("database", self._database);
6692
6693        params.extend(self._additional_params.iter());
6694
6695        params.push("alt", "json");
6696        let mut url = self.hub._base_url.clone()
6697            + "sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}";
6698        if self._scopes.is_empty() {
6699            self._scopes
6700                .insert(Scope::CloudPlatform.as_ref().to_string());
6701        }
6702
6703        #[allow(clippy::single_element_loop)]
6704        for &(find_this, param_name) in [
6705            ("{project}", "project"),
6706            ("{instance}", "instance"),
6707            ("{database}", "database"),
6708        ]
6709        .iter()
6710        {
6711            url = params.uri_replacement(url, param_name, find_this, false);
6712        }
6713        {
6714            let to_remove = ["database", "instance", "project"];
6715            params.remove_params(&to_remove);
6716        }
6717
6718        let url = params.parse_with_url(&url);
6719
6720        let mut json_mime_type = mime::APPLICATION_JSON;
6721        let mut request_value_reader = {
6722            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6723            common::remove_json_null_values(&mut value);
6724            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6725            serde_json::to_writer(&mut dst, &value).unwrap();
6726            dst
6727        };
6728        let request_size = request_value_reader
6729            .seek(std::io::SeekFrom::End(0))
6730            .unwrap();
6731        request_value_reader
6732            .seek(std::io::SeekFrom::Start(0))
6733            .unwrap();
6734
6735        loop {
6736            let token = match self
6737                .hub
6738                .auth
6739                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6740                .await
6741            {
6742                Ok(token) => token,
6743                Err(e) => match dlg.token(e) {
6744                    Ok(token) => token,
6745                    Err(e) => {
6746                        dlg.finished(false);
6747                        return Err(common::Error::MissingToken(e));
6748                    }
6749                },
6750            };
6751            request_value_reader
6752                .seek(std::io::SeekFrom::Start(0))
6753                .unwrap();
6754            let mut req_result = {
6755                let client = &self.hub.client;
6756                dlg.pre_request();
6757                let mut req_builder = hyper::Request::builder()
6758                    .method(hyper::Method::PATCH)
6759                    .uri(url.as_str())
6760                    .header(USER_AGENT, self.hub._user_agent.clone());
6761
6762                if let Some(token) = token.as_ref() {
6763                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6764                }
6765
6766                let request = req_builder
6767                    .header(CONTENT_TYPE, json_mime_type.to_string())
6768                    .header(CONTENT_LENGTH, request_size as u64)
6769                    .body(common::to_body(
6770                        request_value_reader.get_ref().clone().into(),
6771                    ));
6772
6773                client.request(request.unwrap()).await
6774            };
6775
6776            match req_result {
6777                Err(err) => {
6778                    if let common::Retry::After(d) = dlg.http_error(&err) {
6779                        sleep(d).await;
6780                        continue;
6781                    }
6782                    dlg.finished(false);
6783                    return Err(common::Error::HttpError(err));
6784                }
6785                Ok(res) => {
6786                    let (mut parts, body) = res.into_parts();
6787                    let mut body = common::Body::new(body);
6788                    if !parts.status.is_success() {
6789                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6790                        let error = serde_json::from_str(&common::to_string(&bytes));
6791                        let response = common::to_response(parts, bytes.into());
6792
6793                        if let common::Retry::After(d) =
6794                            dlg.http_failure(&response, error.as_ref().ok())
6795                        {
6796                            sleep(d).await;
6797                            continue;
6798                        }
6799
6800                        dlg.finished(false);
6801
6802                        return Err(match error {
6803                            Ok(value) => common::Error::BadRequest(value),
6804                            _ => common::Error::Failure(response),
6805                        });
6806                    }
6807                    let response = {
6808                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6809                        let encoded = common::to_string(&bytes);
6810                        match serde_json::from_str(&encoded) {
6811                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6812                            Err(error) => {
6813                                dlg.response_json_decode_error(&encoded, &error);
6814                                return Err(common::Error::JsonDecodeError(
6815                                    encoded.to_string(),
6816                                    error,
6817                                ));
6818                            }
6819                        }
6820                    };
6821
6822                    dlg.finished(true);
6823                    return Ok(response);
6824                }
6825            }
6826        }
6827    }
6828
6829    ///
6830    /// Sets the *request* property to the given value.
6831    ///
6832    /// Even though the property as already been set when instantiating this call,
6833    /// we provide this method for API completeness.
6834    pub fn request(mut self, new_value: Database) -> DatabasePatchCall<'a, C> {
6835        self._request = new_value;
6836        self
6837    }
6838    /// Project ID of the project that contains the instance.
6839    ///
6840    /// Sets the *project* path property to the given value.
6841    ///
6842    /// Even though the property as already been set when instantiating this call,
6843    /// we provide this method for API completeness.
6844    pub fn project(mut self, new_value: &str) -> DatabasePatchCall<'a, C> {
6845        self._project = new_value.to_string();
6846        self
6847    }
6848    /// Database instance ID. This does not include the project ID.
6849    ///
6850    /// Sets the *instance* path property to the given value.
6851    ///
6852    /// Even though the property as already been set when instantiating this call,
6853    /// we provide this method for API completeness.
6854    pub fn instance(mut self, new_value: &str) -> DatabasePatchCall<'a, C> {
6855        self._instance = new_value.to_string();
6856        self
6857    }
6858    /// Name of the database to be updated in the instance.
6859    ///
6860    /// Sets the *database* path property to the given value.
6861    ///
6862    /// Even though the property as already been set when instantiating this call,
6863    /// we provide this method for API completeness.
6864    pub fn database(mut self, new_value: &str) -> DatabasePatchCall<'a, C> {
6865        self._database = new_value.to_string();
6866        self
6867    }
6868    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6869    /// while executing the actual API request.
6870    ///
6871    /// ````text
6872    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6873    /// ````
6874    ///
6875    /// Sets the *delegate* property to the given value.
6876    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DatabasePatchCall<'a, C> {
6877        self._delegate = Some(new_value);
6878        self
6879    }
6880
6881    /// Set any additional parameter of the query string used in the request.
6882    /// It should be used to set parameters which are not yet available through their own
6883    /// setters.
6884    ///
6885    /// Please note that this method must not be used to set any of the known parameters
6886    /// which have their own setter method. If done anyway, the request will fail.
6887    ///
6888    /// # Additional Parameters
6889    ///
6890    /// * *$.xgafv* (query-string) - V1 error format.
6891    /// * *access_token* (query-string) - OAuth access token.
6892    /// * *alt* (query-string) - Data format for response.
6893    /// * *callback* (query-string) - JSONP
6894    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6895    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6896    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6897    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6898    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6899    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6900    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6901    pub fn param<T>(mut self, name: T, value: T) -> DatabasePatchCall<'a, C>
6902    where
6903        T: AsRef<str>,
6904    {
6905        self._additional_params
6906            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6907        self
6908    }
6909
6910    /// Identifies the authorization scope for the method you are building.
6911    ///
6912    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6913    /// [`Scope::CloudPlatform`].
6914    ///
6915    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6916    /// tokens for more than one scope.
6917    ///
6918    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6919    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6920    /// sufficient, a read-write scope will do as well.
6921    pub fn add_scope<St>(mut self, scope: St) -> DatabasePatchCall<'a, C>
6922    where
6923        St: AsRef<str>,
6924    {
6925        self._scopes.insert(String::from(scope.as_ref()));
6926        self
6927    }
6928    /// Identifies the authorization scope(s) for the method you are building.
6929    ///
6930    /// See [`Self::add_scope()`] for details.
6931    pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabasePatchCall<'a, C>
6932    where
6933        I: IntoIterator<Item = St>,
6934        St: AsRef<str>,
6935    {
6936        self._scopes
6937            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6938        self
6939    }
6940
6941    /// Removes all scopes, and no default scope will be used either.
6942    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6943    /// for details).
6944    pub fn clear_scopes(mut self) -> DatabasePatchCall<'a, C> {
6945        self._scopes.clear();
6946        self
6947    }
6948}
6949
6950/// Updates a resource containing information about a database inside a Cloud
6951/// SQL instance.
6952///
6953/// A builder for the *update* method supported by a *database* resource.
6954/// It is not used directly, but through a [`DatabaseMethods`] instance.
6955///
6956/// # Example
6957///
6958/// Instantiate a resource method builder
6959///
6960/// ```test_harness,no_run
6961/// # extern crate hyper;
6962/// # extern crate hyper_rustls;
6963/// # extern crate google_sql1_beta4 as sql1_beta4;
6964/// use sql1_beta4::api::Database;
6965/// # async fn dox() {
6966/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6967///
6968/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6969/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6970/// #     .with_native_roots()
6971/// #     .unwrap()
6972/// #     .https_only()
6973/// #     .enable_http2()
6974/// #     .build();
6975///
6976/// # let executor = hyper_util::rt::TokioExecutor::new();
6977/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6978/// #     secret,
6979/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6980/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6981/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6982/// #     ),
6983/// # ).build().await.unwrap();
6984///
6985/// # let client = hyper_util::client::legacy::Client::builder(
6986/// #     hyper_util::rt::TokioExecutor::new()
6987/// # )
6988/// # .build(
6989/// #     hyper_rustls::HttpsConnectorBuilder::new()
6990/// #         .with_native_roots()
6991/// #         .unwrap()
6992/// #         .https_or_http()
6993/// #         .enable_http2()
6994/// #         .build()
6995/// # );
6996/// # let mut hub = SQLAdmin::new(client, auth);
6997/// // As the method needs a request, you would usually fill it with the desired information
6998/// // into the respective structure. Some of the parts shown here might not be applicable !
6999/// // Values shown here are possibly random and not representative !
7000/// let mut req = Database::default();
7001///
7002/// // You can configure optional parameters by calling the respective setters at will, and
7003/// // execute the final call using `doit()`.
7004/// // Values shown here are possibly random and not representative !
7005/// let result = hub.databases().update(req, "project", "instance", "database")
7006///              .doit().await;
7007/// # }
7008/// ```
7009pub struct DatabaseUpdateCall<'a, C>
7010where
7011    C: 'a,
7012{
7013    hub: &'a SQLAdmin<C>,
7014    _request: Database,
7015    _project: String,
7016    _instance: String,
7017    _database: String,
7018    _delegate: Option<&'a mut dyn common::Delegate>,
7019    _additional_params: HashMap<String, String>,
7020    _scopes: BTreeSet<String>,
7021}
7022
7023impl<'a, C> common::CallBuilder for DatabaseUpdateCall<'a, C> {}
7024
7025impl<'a, C> DatabaseUpdateCall<'a, C>
7026where
7027    C: common::Connector,
7028{
7029    /// Perform the operation you have build so far.
7030    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7031        use std::borrow::Cow;
7032        use std::io::{Read, Seek};
7033
7034        use common::{url::Params, ToParts};
7035        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7036
7037        let mut dd = common::DefaultDelegate;
7038        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7039        dlg.begin(common::MethodInfo {
7040            id: "sql.databases.update",
7041            http_method: hyper::Method::PUT,
7042        });
7043
7044        for &field in ["alt", "project", "instance", "database"].iter() {
7045            if self._additional_params.contains_key(field) {
7046                dlg.finished(false);
7047                return Err(common::Error::FieldClash(field));
7048            }
7049        }
7050
7051        let mut params = Params::with_capacity(6 + self._additional_params.len());
7052        params.push("project", self._project);
7053        params.push("instance", self._instance);
7054        params.push("database", self._database);
7055
7056        params.extend(self._additional_params.iter());
7057
7058        params.push("alt", "json");
7059        let mut url = self.hub._base_url.clone()
7060            + "sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}";
7061        if self._scopes.is_empty() {
7062            self._scopes
7063                .insert(Scope::CloudPlatform.as_ref().to_string());
7064        }
7065
7066        #[allow(clippy::single_element_loop)]
7067        for &(find_this, param_name) in [
7068            ("{project}", "project"),
7069            ("{instance}", "instance"),
7070            ("{database}", "database"),
7071        ]
7072        .iter()
7073        {
7074            url = params.uri_replacement(url, param_name, find_this, false);
7075        }
7076        {
7077            let to_remove = ["database", "instance", "project"];
7078            params.remove_params(&to_remove);
7079        }
7080
7081        let url = params.parse_with_url(&url);
7082
7083        let mut json_mime_type = mime::APPLICATION_JSON;
7084        let mut request_value_reader = {
7085            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7086            common::remove_json_null_values(&mut value);
7087            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7088            serde_json::to_writer(&mut dst, &value).unwrap();
7089            dst
7090        };
7091        let request_size = request_value_reader
7092            .seek(std::io::SeekFrom::End(0))
7093            .unwrap();
7094        request_value_reader
7095            .seek(std::io::SeekFrom::Start(0))
7096            .unwrap();
7097
7098        loop {
7099            let token = match self
7100                .hub
7101                .auth
7102                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7103                .await
7104            {
7105                Ok(token) => token,
7106                Err(e) => match dlg.token(e) {
7107                    Ok(token) => token,
7108                    Err(e) => {
7109                        dlg.finished(false);
7110                        return Err(common::Error::MissingToken(e));
7111                    }
7112                },
7113            };
7114            request_value_reader
7115                .seek(std::io::SeekFrom::Start(0))
7116                .unwrap();
7117            let mut req_result = {
7118                let client = &self.hub.client;
7119                dlg.pre_request();
7120                let mut req_builder = hyper::Request::builder()
7121                    .method(hyper::Method::PUT)
7122                    .uri(url.as_str())
7123                    .header(USER_AGENT, self.hub._user_agent.clone());
7124
7125                if let Some(token) = token.as_ref() {
7126                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7127                }
7128
7129                let request = req_builder
7130                    .header(CONTENT_TYPE, json_mime_type.to_string())
7131                    .header(CONTENT_LENGTH, request_size as u64)
7132                    .body(common::to_body(
7133                        request_value_reader.get_ref().clone().into(),
7134                    ));
7135
7136                client.request(request.unwrap()).await
7137            };
7138
7139            match req_result {
7140                Err(err) => {
7141                    if let common::Retry::After(d) = dlg.http_error(&err) {
7142                        sleep(d).await;
7143                        continue;
7144                    }
7145                    dlg.finished(false);
7146                    return Err(common::Error::HttpError(err));
7147                }
7148                Ok(res) => {
7149                    let (mut parts, body) = res.into_parts();
7150                    let mut body = common::Body::new(body);
7151                    if !parts.status.is_success() {
7152                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7153                        let error = serde_json::from_str(&common::to_string(&bytes));
7154                        let response = common::to_response(parts, bytes.into());
7155
7156                        if let common::Retry::After(d) =
7157                            dlg.http_failure(&response, error.as_ref().ok())
7158                        {
7159                            sleep(d).await;
7160                            continue;
7161                        }
7162
7163                        dlg.finished(false);
7164
7165                        return Err(match error {
7166                            Ok(value) => common::Error::BadRequest(value),
7167                            _ => common::Error::Failure(response),
7168                        });
7169                    }
7170                    let response = {
7171                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7172                        let encoded = common::to_string(&bytes);
7173                        match serde_json::from_str(&encoded) {
7174                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7175                            Err(error) => {
7176                                dlg.response_json_decode_error(&encoded, &error);
7177                                return Err(common::Error::JsonDecodeError(
7178                                    encoded.to_string(),
7179                                    error,
7180                                ));
7181                            }
7182                        }
7183                    };
7184
7185                    dlg.finished(true);
7186                    return Ok(response);
7187                }
7188            }
7189        }
7190    }
7191
7192    ///
7193    /// Sets the *request* property to the given value.
7194    ///
7195    /// Even though the property as already been set when instantiating this call,
7196    /// we provide this method for API completeness.
7197    pub fn request(mut self, new_value: Database) -> DatabaseUpdateCall<'a, C> {
7198        self._request = new_value;
7199        self
7200    }
7201    /// Project ID of the project that contains the instance.
7202    ///
7203    /// Sets the *project* path property to the given value.
7204    ///
7205    /// Even though the property as already been set when instantiating this call,
7206    /// we provide this method for API completeness.
7207    pub fn project(mut self, new_value: &str) -> DatabaseUpdateCall<'a, C> {
7208        self._project = new_value.to_string();
7209        self
7210    }
7211    /// Database instance ID. This does not include the project ID.
7212    ///
7213    /// Sets the *instance* path property to the given value.
7214    ///
7215    /// Even though the property as already been set when instantiating this call,
7216    /// we provide this method for API completeness.
7217    pub fn instance(mut self, new_value: &str) -> DatabaseUpdateCall<'a, C> {
7218        self._instance = new_value.to_string();
7219        self
7220    }
7221    /// Name of the database to be updated in the instance.
7222    ///
7223    /// Sets the *database* path property to the given value.
7224    ///
7225    /// Even though the property as already been set when instantiating this call,
7226    /// we provide this method for API completeness.
7227    pub fn database(mut self, new_value: &str) -> DatabaseUpdateCall<'a, C> {
7228        self._database = new_value.to_string();
7229        self
7230    }
7231    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7232    /// while executing the actual API request.
7233    ///
7234    /// ````text
7235    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7236    /// ````
7237    ///
7238    /// Sets the *delegate* property to the given value.
7239    pub fn delegate(
7240        mut self,
7241        new_value: &'a mut dyn common::Delegate,
7242    ) -> DatabaseUpdateCall<'a, C> {
7243        self._delegate = Some(new_value);
7244        self
7245    }
7246
7247    /// Set any additional parameter of the query string used in the request.
7248    /// It should be used to set parameters which are not yet available through their own
7249    /// setters.
7250    ///
7251    /// Please note that this method must not be used to set any of the known parameters
7252    /// which have their own setter method. If done anyway, the request will fail.
7253    ///
7254    /// # Additional Parameters
7255    ///
7256    /// * *$.xgafv* (query-string) - V1 error format.
7257    /// * *access_token* (query-string) - OAuth access token.
7258    /// * *alt* (query-string) - Data format for response.
7259    /// * *callback* (query-string) - JSONP
7260    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7261    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7262    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7263    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7264    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7265    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7266    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7267    pub fn param<T>(mut self, name: T, value: T) -> DatabaseUpdateCall<'a, C>
7268    where
7269        T: AsRef<str>,
7270    {
7271        self._additional_params
7272            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7273        self
7274    }
7275
7276    /// Identifies the authorization scope for the method you are building.
7277    ///
7278    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7279    /// [`Scope::CloudPlatform`].
7280    ///
7281    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7282    /// tokens for more than one scope.
7283    ///
7284    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7285    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7286    /// sufficient, a read-write scope will do as well.
7287    pub fn add_scope<St>(mut self, scope: St) -> DatabaseUpdateCall<'a, C>
7288    where
7289        St: AsRef<str>,
7290    {
7291        self._scopes.insert(String::from(scope.as_ref()));
7292        self
7293    }
7294    /// Identifies the authorization scope(s) for the method you are building.
7295    ///
7296    /// See [`Self::add_scope()`] for details.
7297    pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseUpdateCall<'a, C>
7298    where
7299        I: IntoIterator<Item = St>,
7300        St: AsRef<str>,
7301    {
7302        self._scopes
7303            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7304        self
7305    }
7306
7307    /// Removes all scopes, and no default scope will be used either.
7308    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7309    /// for details).
7310    pub fn clear_scopes(mut self) -> DatabaseUpdateCall<'a, C> {
7311        self._scopes.clear();
7312        self
7313    }
7314}
7315
7316/// List all available database flags for Cloud SQL instances.
7317///
7318/// A builder for the *list* method supported by a *flag* resource.
7319/// It is not used directly, but through a [`FlagMethods`] instance.
7320///
7321/// # Example
7322///
7323/// Instantiate a resource method builder
7324///
7325/// ```test_harness,no_run
7326/// # extern crate hyper;
7327/// # extern crate hyper_rustls;
7328/// # extern crate google_sql1_beta4 as sql1_beta4;
7329/// # async fn dox() {
7330/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7331///
7332/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7333/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7334/// #     .with_native_roots()
7335/// #     .unwrap()
7336/// #     .https_only()
7337/// #     .enable_http2()
7338/// #     .build();
7339///
7340/// # let executor = hyper_util::rt::TokioExecutor::new();
7341/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7342/// #     secret,
7343/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7344/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7345/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7346/// #     ),
7347/// # ).build().await.unwrap();
7348///
7349/// # let client = hyper_util::client::legacy::Client::builder(
7350/// #     hyper_util::rt::TokioExecutor::new()
7351/// # )
7352/// # .build(
7353/// #     hyper_rustls::HttpsConnectorBuilder::new()
7354/// #         .with_native_roots()
7355/// #         .unwrap()
7356/// #         .https_or_http()
7357/// #         .enable_http2()
7358/// #         .build()
7359/// # );
7360/// # let mut hub = SQLAdmin::new(client, auth);
7361/// // You can configure optional parameters by calling the respective setters at will, and
7362/// // execute the final call using `doit()`.
7363/// // Values shown here are possibly random and not representative !
7364/// let result = hub.flags().list()
7365///              .database_version("sed")
7366///              .doit().await;
7367/// # }
7368/// ```
7369pub struct FlagListCall<'a, C>
7370where
7371    C: 'a,
7372{
7373    hub: &'a SQLAdmin<C>,
7374    _database_version: Option<String>,
7375    _delegate: Option<&'a mut dyn common::Delegate>,
7376    _additional_params: HashMap<String, String>,
7377    _scopes: BTreeSet<String>,
7378}
7379
7380impl<'a, C> common::CallBuilder for FlagListCall<'a, C> {}
7381
7382impl<'a, C> FlagListCall<'a, C>
7383where
7384    C: common::Connector,
7385{
7386    /// Perform the operation you have build so far.
7387    pub async fn doit(mut self) -> common::Result<(common::Response, FlagsListResponse)> {
7388        use std::borrow::Cow;
7389        use std::io::{Read, Seek};
7390
7391        use common::{url::Params, ToParts};
7392        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7393
7394        let mut dd = common::DefaultDelegate;
7395        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7396        dlg.begin(common::MethodInfo {
7397            id: "sql.flags.list",
7398            http_method: hyper::Method::GET,
7399        });
7400
7401        for &field in ["alt", "databaseVersion"].iter() {
7402            if self._additional_params.contains_key(field) {
7403                dlg.finished(false);
7404                return Err(common::Error::FieldClash(field));
7405            }
7406        }
7407
7408        let mut params = Params::with_capacity(3 + self._additional_params.len());
7409        if let Some(value) = self._database_version.as_ref() {
7410            params.push("databaseVersion", value);
7411        }
7412
7413        params.extend(self._additional_params.iter());
7414
7415        params.push("alt", "json");
7416        let mut url = self.hub._base_url.clone() + "sql/v1beta4/flags";
7417        if self._scopes.is_empty() {
7418            self._scopes
7419                .insert(Scope::CloudPlatform.as_ref().to_string());
7420        }
7421
7422        let url = params.parse_with_url(&url);
7423
7424        loop {
7425            let token = match self
7426                .hub
7427                .auth
7428                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7429                .await
7430            {
7431                Ok(token) => token,
7432                Err(e) => match dlg.token(e) {
7433                    Ok(token) => token,
7434                    Err(e) => {
7435                        dlg.finished(false);
7436                        return Err(common::Error::MissingToken(e));
7437                    }
7438                },
7439            };
7440            let mut req_result = {
7441                let client = &self.hub.client;
7442                dlg.pre_request();
7443                let mut req_builder = hyper::Request::builder()
7444                    .method(hyper::Method::GET)
7445                    .uri(url.as_str())
7446                    .header(USER_AGENT, self.hub._user_agent.clone());
7447
7448                if let Some(token) = token.as_ref() {
7449                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7450                }
7451
7452                let request = req_builder
7453                    .header(CONTENT_LENGTH, 0_u64)
7454                    .body(common::to_body::<String>(None));
7455
7456                client.request(request.unwrap()).await
7457            };
7458
7459            match req_result {
7460                Err(err) => {
7461                    if let common::Retry::After(d) = dlg.http_error(&err) {
7462                        sleep(d).await;
7463                        continue;
7464                    }
7465                    dlg.finished(false);
7466                    return Err(common::Error::HttpError(err));
7467                }
7468                Ok(res) => {
7469                    let (mut parts, body) = res.into_parts();
7470                    let mut body = common::Body::new(body);
7471                    if !parts.status.is_success() {
7472                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7473                        let error = serde_json::from_str(&common::to_string(&bytes));
7474                        let response = common::to_response(parts, bytes.into());
7475
7476                        if let common::Retry::After(d) =
7477                            dlg.http_failure(&response, error.as_ref().ok())
7478                        {
7479                            sleep(d).await;
7480                            continue;
7481                        }
7482
7483                        dlg.finished(false);
7484
7485                        return Err(match error {
7486                            Ok(value) => common::Error::BadRequest(value),
7487                            _ => common::Error::Failure(response),
7488                        });
7489                    }
7490                    let response = {
7491                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7492                        let encoded = common::to_string(&bytes);
7493                        match serde_json::from_str(&encoded) {
7494                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7495                            Err(error) => {
7496                                dlg.response_json_decode_error(&encoded, &error);
7497                                return Err(common::Error::JsonDecodeError(
7498                                    encoded.to_string(),
7499                                    error,
7500                                ));
7501                            }
7502                        }
7503                    };
7504
7505                    dlg.finished(true);
7506                    return Ok(response);
7507                }
7508            }
7509        }
7510    }
7511
7512    /// Database type and version you want to retrieve flags for. By default, this
7513    /// method returns flags for all database types and versions.
7514    ///
7515    /// Sets the *database version* query property to the given value.
7516    pub fn database_version(mut self, new_value: &str) -> FlagListCall<'a, C> {
7517        self._database_version = Some(new_value.to_string());
7518        self
7519    }
7520    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7521    /// while executing the actual API request.
7522    ///
7523    /// ````text
7524    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7525    /// ````
7526    ///
7527    /// Sets the *delegate* property to the given value.
7528    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FlagListCall<'a, C> {
7529        self._delegate = Some(new_value);
7530        self
7531    }
7532
7533    /// Set any additional parameter of the query string used in the request.
7534    /// It should be used to set parameters which are not yet available through their own
7535    /// setters.
7536    ///
7537    /// Please note that this method must not be used to set any of the known parameters
7538    /// which have their own setter method. If done anyway, the request will fail.
7539    ///
7540    /// # Additional Parameters
7541    ///
7542    /// * *$.xgafv* (query-string) - V1 error format.
7543    /// * *access_token* (query-string) - OAuth access token.
7544    /// * *alt* (query-string) - Data format for response.
7545    /// * *callback* (query-string) - JSONP
7546    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7547    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7548    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7549    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7550    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7551    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7552    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7553    pub fn param<T>(mut self, name: T, value: T) -> FlagListCall<'a, C>
7554    where
7555        T: AsRef<str>,
7556    {
7557        self._additional_params
7558            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7559        self
7560    }
7561
7562    /// Identifies the authorization scope for the method you are building.
7563    ///
7564    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7565    /// [`Scope::CloudPlatform`].
7566    ///
7567    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7568    /// tokens for more than one scope.
7569    ///
7570    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7571    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7572    /// sufficient, a read-write scope will do as well.
7573    pub fn add_scope<St>(mut self, scope: St) -> FlagListCall<'a, C>
7574    where
7575        St: AsRef<str>,
7576    {
7577        self._scopes.insert(String::from(scope.as_ref()));
7578        self
7579    }
7580    /// Identifies the authorization scope(s) for the method you are building.
7581    ///
7582    /// See [`Self::add_scope()`] for details.
7583    pub fn add_scopes<I, St>(mut self, scopes: I) -> FlagListCall<'a, C>
7584    where
7585        I: IntoIterator<Item = St>,
7586        St: AsRef<str>,
7587    {
7588        self._scopes
7589            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7590        self
7591    }
7592
7593    /// Removes all scopes, and no default scope will be used either.
7594    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7595    /// for details).
7596    pub fn clear_scopes(mut self) -> FlagListCall<'a, C> {
7597        self._scopes.clear();
7598        self
7599    }
7600}
7601
7602/// Add a new trusted Certificate Authority (CA) version for the specified
7603/// instance. Required to prepare for a certificate rotation. If a CA version
7604/// was previously added but never used in a certificate rotation, this
7605/// operation replaces that version. There cannot be more than one CA version
7606/// waiting to be rotated in.
7607///
7608/// A builder for the *addServerCa* method supported by a *instance* resource.
7609/// It is not used directly, but through a [`InstanceMethods`] instance.
7610///
7611/// # Example
7612///
7613/// Instantiate a resource method builder
7614///
7615/// ```test_harness,no_run
7616/// # extern crate hyper;
7617/// # extern crate hyper_rustls;
7618/// # extern crate google_sql1_beta4 as sql1_beta4;
7619/// # async fn dox() {
7620/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7621///
7622/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7623/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7624/// #     .with_native_roots()
7625/// #     .unwrap()
7626/// #     .https_only()
7627/// #     .enable_http2()
7628/// #     .build();
7629///
7630/// # let executor = hyper_util::rt::TokioExecutor::new();
7631/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7632/// #     secret,
7633/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7634/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7635/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7636/// #     ),
7637/// # ).build().await.unwrap();
7638///
7639/// # let client = hyper_util::client::legacy::Client::builder(
7640/// #     hyper_util::rt::TokioExecutor::new()
7641/// # )
7642/// # .build(
7643/// #     hyper_rustls::HttpsConnectorBuilder::new()
7644/// #         .with_native_roots()
7645/// #         .unwrap()
7646/// #         .https_or_http()
7647/// #         .enable_http2()
7648/// #         .build()
7649/// # );
7650/// # let mut hub = SQLAdmin::new(client, auth);
7651/// // You can configure optional parameters by calling the respective setters at will, and
7652/// // execute the final call using `doit()`.
7653/// // Values shown here are possibly random and not representative !
7654/// let result = hub.instances().add_server_ca("project", "instance")
7655///              .doit().await;
7656/// # }
7657/// ```
7658pub struct InstanceAddServerCaCall<'a, C>
7659where
7660    C: 'a,
7661{
7662    hub: &'a SQLAdmin<C>,
7663    _project: String,
7664    _instance: String,
7665    _delegate: Option<&'a mut dyn common::Delegate>,
7666    _additional_params: HashMap<String, String>,
7667    _scopes: BTreeSet<String>,
7668}
7669
7670impl<'a, C> common::CallBuilder for InstanceAddServerCaCall<'a, C> {}
7671
7672impl<'a, C> InstanceAddServerCaCall<'a, C>
7673where
7674    C: common::Connector,
7675{
7676    /// Perform the operation you have build so far.
7677    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7678        use std::borrow::Cow;
7679        use std::io::{Read, Seek};
7680
7681        use common::{url::Params, ToParts};
7682        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7683
7684        let mut dd = common::DefaultDelegate;
7685        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7686        dlg.begin(common::MethodInfo {
7687            id: "sql.instances.addServerCa",
7688            http_method: hyper::Method::POST,
7689        });
7690
7691        for &field in ["alt", "project", "instance"].iter() {
7692            if self._additional_params.contains_key(field) {
7693                dlg.finished(false);
7694                return Err(common::Error::FieldClash(field));
7695            }
7696        }
7697
7698        let mut params = Params::with_capacity(4 + self._additional_params.len());
7699        params.push("project", self._project);
7700        params.push("instance", self._instance);
7701
7702        params.extend(self._additional_params.iter());
7703
7704        params.push("alt", "json");
7705        let mut url = self.hub._base_url.clone()
7706            + "sql/v1beta4/projects/{project}/instances/{instance}/addServerCa";
7707        if self._scopes.is_empty() {
7708            self._scopes
7709                .insert(Scope::CloudPlatform.as_ref().to_string());
7710        }
7711
7712        #[allow(clippy::single_element_loop)]
7713        for &(find_this, param_name) in
7714            [("{project}", "project"), ("{instance}", "instance")].iter()
7715        {
7716            url = params.uri_replacement(url, param_name, find_this, false);
7717        }
7718        {
7719            let to_remove = ["instance", "project"];
7720            params.remove_params(&to_remove);
7721        }
7722
7723        let url = params.parse_with_url(&url);
7724
7725        loop {
7726            let token = match self
7727                .hub
7728                .auth
7729                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7730                .await
7731            {
7732                Ok(token) => token,
7733                Err(e) => match dlg.token(e) {
7734                    Ok(token) => token,
7735                    Err(e) => {
7736                        dlg.finished(false);
7737                        return Err(common::Error::MissingToken(e));
7738                    }
7739                },
7740            };
7741            let mut req_result = {
7742                let client = &self.hub.client;
7743                dlg.pre_request();
7744                let mut req_builder = hyper::Request::builder()
7745                    .method(hyper::Method::POST)
7746                    .uri(url.as_str())
7747                    .header(USER_AGENT, self.hub._user_agent.clone());
7748
7749                if let Some(token) = token.as_ref() {
7750                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7751                }
7752
7753                let request = req_builder
7754                    .header(CONTENT_LENGTH, 0_u64)
7755                    .body(common::to_body::<String>(None));
7756
7757                client.request(request.unwrap()).await
7758            };
7759
7760            match req_result {
7761                Err(err) => {
7762                    if let common::Retry::After(d) = dlg.http_error(&err) {
7763                        sleep(d).await;
7764                        continue;
7765                    }
7766                    dlg.finished(false);
7767                    return Err(common::Error::HttpError(err));
7768                }
7769                Ok(res) => {
7770                    let (mut parts, body) = res.into_parts();
7771                    let mut body = common::Body::new(body);
7772                    if !parts.status.is_success() {
7773                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7774                        let error = serde_json::from_str(&common::to_string(&bytes));
7775                        let response = common::to_response(parts, bytes.into());
7776
7777                        if let common::Retry::After(d) =
7778                            dlg.http_failure(&response, error.as_ref().ok())
7779                        {
7780                            sleep(d).await;
7781                            continue;
7782                        }
7783
7784                        dlg.finished(false);
7785
7786                        return Err(match error {
7787                            Ok(value) => common::Error::BadRequest(value),
7788                            _ => common::Error::Failure(response),
7789                        });
7790                    }
7791                    let response = {
7792                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7793                        let encoded = common::to_string(&bytes);
7794                        match serde_json::from_str(&encoded) {
7795                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7796                            Err(error) => {
7797                                dlg.response_json_decode_error(&encoded, &error);
7798                                return Err(common::Error::JsonDecodeError(
7799                                    encoded.to_string(),
7800                                    error,
7801                                ));
7802                            }
7803                        }
7804                    };
7805
7806                    dlg.finished(true);
7807                    return Ok(response);
7808                }
7809            }
7810        }
7811    }
7812
7813    /// Project ID of the project that contains the instance.
7814    ///
7815    /// Sets the *project* path property to the given value.
7816    ///
7817    /// Even though the property as already been set when instantiating this call,
7818    /// we provide this method for API completeness.
7819    pub fn project(mut self, new_value: &str) -> InstanceAddServerCaCall<'a, C> {
7820        self._project = new_value.to_string();
7821        self
7822    }
7823    /// Cloud SQL instance ID. This does not include the project ID.
7824    ///
7825    /// Sets the *instance* path property to the given value.
7826    ///
7827    /// Even though the property as already been set when instantiating this call,
7828    /// we provide this method for API completeness.
7829    pub fn instance(mut self, new_value: &str) -> InstanceAddServerCaCall<'a, C> {
7830        self._instance = new_value.to_string();
7831        self
7832    }
7833    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7834    /// while executing the actual API request.
7835    ///
7836    /// ````text
7837    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7838    /// ````
7839    ///
7840    /// Sets the *delegate* property to the given value.
7841    pub fn delegate(
7842        mut self,
7843        new_value: &'a mut dyn common::Delegate,
7844    ) -> InstanceAddServerCaCall<'a, C> {
7845        self._delegate = Some(new_value);
7846        self
7847    }
7848
7849    /// Set any additional parameter of the query string used in the request.
7850    /// It should be used to set parameters which are not yet available through their own
7851    /// setters.
7852    ///
7853    /// Please note that this method must not be used to set any of the known parameters
7854    /// which have their own setter method. If done anyway, the request will fail.
7855    ///
7856    /// # Additional Parameters
7857    ///
7858    /// * *$.xgafv* (query-string) - V1 error format.
7859    /// * *access_token* (query-string) - OAuth access token.
7860    /// * *alt* (query-string) - Data format for response.
7861    /// * *callback* (query-string) - JSONP
7862    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7863    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7864    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7865    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7866    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7867    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7868    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7869    pub fn param<T>(mut self, name: T, value: T) -> InstanceAddServerCaCall<'a, C>
7870    where
7871        T: AsRef<str>,
7872    {
7873        self._additional_params
7874            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7875        self
7876    }
7877
7878    /// Identifies the authorization scope for the method you are building.
7879    ///
7880    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7881    /// [`Scope::CloudPlatform`].
7882    ///
7883    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7884    /// tokens for more than one scope.
7885    ///
7886    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7887    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7888    /// sufficient, a read-write scope will do as well.
7889    pub fn add_scope<St>(mut self, scope: St) -> InstanceAddServerCaCall<'a, C>
7890    where
7891        St: AsRef<str>,
7892    {
7893        self._scopes.insert(String::from(scope.as_ref()));
7894        self
7895    }
7896    /// Identifies the authorization scope(s) for the method you are building.
7897    ///
7898    /// See [`Self::add_scope()`] for details.
7899    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceAddServerCaCall<'a, C>
7900    where
7901        I: IntoIterator<Item = St>,
7902        St: AsRef<str>,
7903    {
7904        self._scopes
7905            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7906        self
7907    }
7908
7909    /// Removes all scopes, and no default scope will be used either.
7910    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7911    /// for details).
7912    pub fn clear_scopes(mut self) -> InstanceAddServerCaCall<'a, C> {
7913        self._scopes.clear();
7914        self
7915    }
7916}
7917
7918/// Creates a Cloud SQL instance as a clone of the source instance. Using this
7919/// operation might cause your instance to restart.
7920///
7921/// A builder for the *clone* method supported by a *instance* resource.
7922/// It is not used directly, but through a [`InstanceMethods`] instance.
7923///
7924/// # Example
7925///
7926/// Instantiate a resource method builder
7927///
7928/// ```test_harness,no_run
7929/// # extern crate hyper;
7930/// # extern crate hyper_rustls;
7931/// # extern crate google_sql1_beta4 as sql1_beta4;
7932/// use sql1_beta4::api::InstancesCloneRequest;
7933/// # async fn dox() {
7934/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7935///
7936/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7937/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7938/// #     .with_native_roots()
7939/// #     .unwrap()
7940/// #     .https_only()
7941/// #     .enable_http2()
7942/// #     .build();
7943///
7944/// # let executor = hyper_util::rt::TokioExecutor::new();
7945/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7946/// #     secret,
7947/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7948/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7949/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7950/// #     ),
7951/// # ).build().await.unwrap();
7952///
7953/// # let client = hyper_util::client::legacy::Client::builder(
7954/// #     hyper_util::rt::TokioExecutor::new()
7955/// # )
7956/// # .build(
7957/// #     hyper_rustls::HttpsConnectorBuilder::new()
7958/// #         .with_native_roots()
7959/// #         .unwrap()
7960/// #         .https_or_http()
7961/// #         .enable_http2()
7962/// #         .build()
7963/// # );
7964/// # let mut hub = SQLAdmin::new(client, auth);
7965/// // As the method needs a request, you would usually fill it with the desired information
7966/// // into the respective structure. Some of the parts shown here might not be applicable !
7967/// // Values shown here are possibly random and not representative !
7968/// let mut req = InstancesCloneRequest::default();
7969///
7970/// // You can configure optional parameters by calling the respective setters at will, and
7971/// // execute the final call using `doit()`.
7972/// // Values shown here are possibly random and not representative !
7973/// let result = hub.instances().clone(req, "project", "instance")
7974///              .doit().await;
7975/// # }
7976/// ```
7977pub struct InstanceCloneCall<'a, C>
7978where
7979    C: 'a,
7980{
7981    hub: &'a SQLAdmin<C>,
7982    _request: InstancesCloneRequest,
7983    _project: String,
7984    _instance: String,
7985    _delegate: Option<&'a mut dyn common::Delegate>,
7986    _additional_params: HashMap<String, String>,
7987    _scopes: BTreeSet<String>,
7988}
7989
7990impl<'a, C> common::CallBuilder for InstanceCloneCall<'a, C> {}
7991
7992impl<'a, C> InstanceCloneCall<'a, C>
7993where
7994    C: common::Connector,
7995{
7996    /// Perform the operation you have build so far.
7997    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7998        use std::borrow::Cow;
7999        use std::io::{Read, Seek};
8000
8001        use common::{url::Params, ToParts};
8002        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8003
8004        let mut dd = common::DefaultDelegate;
8005        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8006        dlg.begin(common::MethodInfo {
8007            id: "sql.instances.clone",
8008            http_method: hyper::Method::POST,
8009        });
8010
8011        for &field in ["alt", "project", "instance"].iter() {
8012            if self._additional_params.contains_key(field) {
8013                dlg.finished(false);
8014                return Err(common::Error::FieldClash(field));
8015            }
8016        }
8017
8018        let mut params = Params::with_capacity(5 + self._additional_params.len());
8019        params.push("project", self._project);
8020        params.push("instance", self._instance);
8021
8022        params.extend(self._additional_params.iter());
8023
8024        params.push("alt", "json");
8025        let mut url = self.hub._base_url.clone()
8026            + "sql/v1beta4/projects/{project}/instances/{instance}/clone";
8027        if self._scopes.is_empty() {
8028            self._scopes
8029                .insert(Scope::CloudPlatform.as_ref().to_string());
8030        }
8031
8032        #[allow(clippy::single_element_loop)]
8033        for &(find_this, param_name) in
8034            [("{project}", "project"), ("{instance}", "instance")].iter()
8035        {
8036            url = params.uri_replacement(url, param_name, find_this, false);
8037        }
8038        {
8039            let to_remove = ["instance", "project"];
8040            params.remove_params(&to_remove);
8041        }
8042
8043        let url = params.parse_with_url(&url);
8044
8045        let mut json_mime_type = mime::APPLICATION_JSON;
8046        let mut request_value_reader = {
8047            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8048            common::remove_json_null_values(&mut value);
8049            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8050            serde_json::to_writer(&mut dst, &value).unwrap();
8051            dst
8052        };
8053        let request_size = request_value_reader
8054            .seek(std::io::SeekFrom::End(0))
8055            .unwrap();
8056        request_value_reader
8057            .seek(std::io::SeekFrom::Start(0))
8058            .unwrap();
8059
8060        loop {
8061            let token = match self
8062                .hub
8063                .auth
8064                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8065                .await
8066            {
8067                Ok(token) => token,
8068                Err(e) => match dlg.token(e) {
8069                    Ok(token) => token,
8070                    Err(e) => {
8071                        dlg.finished(false);
8072                        return Err(common::Error::MissingToken(e));
8073                    }
8074                },
8075            };
8076            request_value_reader
8077                .seek(std::io::SeekFrom::Start(0))
8078                .unwrap();
8079            let mut req_result = {
8080                let client = &self.hub.client;
8081                dlg.pre_request();
8082                let mut req_builder = hyper::Request::builder()
8083                    .method(hyper::Method::POST)
8084                    .uri(url.as_str())
8085                    .header(USER_AGENT, self.hub._user_agent.clone());
8086
8087                if let Some(token) = token.as_ref() {
8088                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8089                }
8090
8091                let request = req_builder
8092                    .header(CONTENT_TYPE, json_mime_type.to_string())
8093                    .header(CONTENT_LENGTH, request_size as u64)
8094                    .body(common::to_body(
8095                        request_value_reader.get_ref().clone().into(),
8096                    ));
8097
8098                client.request(request.unwrap()).await
8099            };
8100
8101            match req_result {
8102                Err(err) => {
8103                    if let common::Retry::After(d) = dlg.http_error(&err) {
8104                        sleep(d).await;
8105                        continue;
8106                    }
8107                    dlg.finished(false);
8108                    return Err(common::Error::HttpError(err));
8109                }
8110                Ok(res) => {
8111                    let (mut parts, body) = res.into_parts();
8112                    let mut body = common::Body::new(body);
8113                    if !parts.status.is_success() {
8114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8115                        let error = serde_json::from_str(&common::to_string(&bytes));
8116                        let response = common::to_response(parts, bytes.into());
8117
8118                        if let common::Retry::After(d) =
8119                            dlg.http_failure(&response, error.as_ref().ok())
8120                        {
8121                            sleep(d).await;
8122                            continue;
8123                        }
8124
8125                        dlg.finished(false);
8126
8127                        return Err(match error {
8128                            Ok(value) => common::Error::BadRequest(value),
8129                            _ => common::Error::Failure(response),
8130                        });
8131                    }
8132                    let response = {
8133                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8134                        let encoded = common::to_string(&bytes);
8135                        match serde_json::from_str(&encoded) {
8136                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8137                            Err(error) => {
8138                                dlg.response_json_decode_error(&encoded, &error);
8139                                return Err(common::Error::JsonDecodeError(
8140                                    encoded.to_string(),
8141                                    error,
8142                                ));
8143                            }
8144                        }
8145                    };
8146
8147                    dlg.finished(true);
8148                    return Ok(response);
8149                }
8150            }
8151        }
8152    }
8153
8154    ///
8155    /// Sets the *request* property to the given value.
8156    ///
8157    /// Even though the property as already been set when instantiating this call,
8158    /// we provide this method for API completeness.
8159    pub fn request(mut self, new_value: InstancesCloneRequest) -> InstanceCloneCall<'a, C> {
8160        self._request = new_value;
8161        self
8162    }
8163    /// Project ID of the source as well as the clone Cloud SQL instance.
8164    ///
8165    /// Sets the *project* path property to the given value.
8166    ///
8167    /// Even though the property as already been set when instantiating this call,
8168    /// we provide this method for API completeness.
8169    pub fn project(mut self, new_value: &str) -> InstanceCloneCall<'a, C> {
8170        self._project = new_value.to_string();
8171        self
8172    }
8173    /// The ID of the Cloud SQL instance to be cloned (source). This does not
8174    /// include the project ID.
8175    ///
8176    /// Sets the *instance* path property to the given value.
8177    ///
8178    /// Even though the property as already been set when instantiating this call,
8179    /// we provide this method for API completeness.
8180    pub fn instance(mut self, new_value: &str) -> InstanceCloneCall<'a, C> {
8181        self._instance = new_value.to_string();
8182        self
8183    }
8184    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8185    /// while executing the actual API request.
8186    ///
8187    /// ````text
8188    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8189    /// ````
8190    ///
8191    /// Sets the *delegate* property to the given value.
8192    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InstanceCloneCall<'a, C> {
8193        self._delegate = Some(new_value);
8194        self
8195    }
8196
8197    /// Set any additional parameter of the query string used in the request.
8198    /// It should be used to set parameters which are not yet available through their own
8199    /// setters.
8200    ///
8201    /// Please note that this method must not be used to set any of the known parameters
8202    /// which have their own setter method. If done anyway, the request will fail.
8203    ///
8204    /// # Additional Parameters
8205    ///
8206    /// * *$.xgafv* (query-string) - V1 error format.
8207    /// * *access_token* (query-string) - OAuth access token.
8208    /// * *alt* (query-string) - Data format for response.
8209    /// * *callback* (query-string) - JSONP
8210    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8211    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8212    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8213    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8214    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8215    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8216    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8217    pub fn param<T>(mut self, name: T, value: T) -> InstanceCloneCall<'a, C>
8218    where
8219        T: AsRef<str>,
8220    {
8221        self._additional_params
8222            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8223        self
8224    }
8225
8226    /// Identifies the authorization scope for the method you are building.
8227    ///
8228    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8229    /// [`Scope::CloudPlatform`].
8230    ///
8231    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8232    /// tokens for more than one scope.
8233    ///
8234    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8235    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8236    /// sufficient, a read-write scope will do as well.
8237    pub fn add_scope<St>(mut self, scope: St) -> InstanceCloneCall<'a, C>
8238    where
8239        St: AsRef<str>,
8240    {
8241        self._scopes.insert(String::from(scope.as_ref()));
8242        self
8243    }
8244    /// Identifies the authorization scope(s) for the method you are building.
8245    ///
8246    /// See [`Self::add_scope()`] for details.
8247    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceCloneCall<'a, C>
8248    where
8249        I: IntoIterator<Item = St>,
8250        St: AsRef<str>,
8251    {
8252        self._scopes
8253            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8254        self
8255    }
8256
8257    /// Removes all scopes, and no default scope will be used either.
8258    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8259    /// for details).
8260    pub fn clear_scopes(mut self) -> InstanceCloneCall<'a, C> {
8261        self._scopes.clear();
8262        self
8263    }
8264}
8265
8266/// Deletes a Cloud SQL instance.
8267///
8268/// A builder for the *delete* method supported by a *instance* resource.
8269/// It is not used directly, but through a [`InstanceMethods`] instance.
8270///
8271/// # Example
8272///
8273/// Instantiate a resource method builder
8274///
8275/// ```test_harness,no_run
8276/// # extern crate hyper;
8277/// # extern crate hyper_rustls;
8278/// # extern crate google_sql1_beta4 as sql1_beta4;
8279/// # async fn dox() {
8280/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8281///
8282/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8283/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8284/// #     .with_native_roots()
8285/// #     .unwrap()
8286/// #     .https_only()
8287/// #     .enable_http2()
8288/// #     .build();
8289///
8290/// # let executor = hyper_util::rt::TokioExecutor::new();
8291/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8292/// #     secret,
8293/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8294/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8295/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8296/// #     ),
8297/// # ).build().await.unwrap();
8298///
8299/// # let client = hyper_util::client::legacy::Client::builder(
8300/// #     hyper_util::rt::TokioExecutor::new()
8301/// # )
8302/// # .build(
8303/// #     hyper_rustls::HttpsConnectorBuilder::new()
8304/// #         .with_native_roots()
8305/// #         .unwrap()
8306/// #         .https_or_http()
8307/// #         .enable_http2()
8308/// #         .build()
8309/// # );
8310/// # let mut hub = SQLAdmin::new(client, auth);
8311/// // You can configure optional parameters by calling the respective setters at will, and
8312/// // execute the final call using `doit()`.
8313/// // Values shown here are possibly random and not representative !
8314/// let result = hub.instances().delete("project", "instance")
8315///              .doit().await;
8316/// # }
8317/// ```
8318pub struct InstanceDeleteCall<'a, C>
8319where
8320    C: 'a,
8321{
8322    hub: &'a SQLAdmin<C>,
8323    _project: String,
8324    _instance: String,
8325    _delegate: Option<&'a mut dyn common::Delegate>,
8326    _additional_params: HashMap<String, String>,
8327    _scopes: BTreeSet<String>,
8328}
8329
8330impl<'a, C> common::CallBuilder for InstanceDeleteCall<'a, C> {}
8331
8332impl<'a, C> InstanceDeleteCall<'a, C>
8333where
8334    C: common::Connector,
8335{
8336    /// Perform the operation you have build so far.
8337    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8338        use std::borrow::Cow;
8339        use std::io::{Read, Seek};
8340
8341        use common::{url::Params, ToParts};
8342        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8343
8344        let mut dd = common::DefaultDelegate;
8345        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8346        dlg.begin(common::MethodInfo {
8347            id: "sql.instances.delete",
8348            http_method: hyper::Method::DELETE,
8349        });
8350
8351        for &field in ["alt", "project", "instance"].iter() {
8352            if self._additional_params.contains_key(field) {
8353                dlg.finished(false);
8354                return Err(common::Error::FieldClash(field));
8355            }
8356        }
8357
8358        let mut params = Params::with_capacity(4 + self._additional_params.len());
8359        params.push("project", self._project);
8360        params.push("instance", self._instance);
8361
8362        params.extend(self._additional_params.iter());
8363
8364        params.push("alt", "json");
8365        let mut url =
8366            self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances/{instance}";
8367        if self._scopes.is_empty() {
8368            self._scopes
8369                .insert(Scope::CloudPlatform.as_ref().to_string());
8370        }
8371
8372        #[allow(clippy::single_element_loop)]
8373        for &(find_this, param_name) in
8374            [("{project}", "project"), ("{instance}", "instance")].iter()
8375        {
8376            url = params.uri_replacement(url, param_name, find_this, false);
8377        }
8378        {
8379            let to_remove = ["instance", "project"];
8380            params.remove_params(&to_remove);
8381        }
8382
8383        let url = params.parse_with_url(&url);
8384
8385        loop {
8386            let token = match self
8387                .hub
8388                .auth
8389                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8390                .await
8391            {
8392                Ok(token) => token,
8393                Err(e) => match dlg.token(e) {
8394                    Ok(token) => token,
8395                    Err(e) => {
8396                        dlg.finished(false);
8397                        return Err(common::Error::MissingToken(e));
8398                    }
8399                },
8400            };
8401            let mut req_result = {
8402                let client = &self.hub.client;
8403                dlg.pre_request();
8404                let mut req_builder = hyper::Request::builder()
8405                    .method(hyper::Method::DELETE)
8406                    .uri(url.as_str())
8407                    .header(USER_AGENT, self.hub._user_agent.clone());
8408
8409                if let Some(token) = token.as_ref() {
8410                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8411                }
8412
8413                let request = req_builder
8414                    .header(CONTENT_LENGTH, 0_u64)
8415                    .body(common::to_body::<String>(None));
8416
8417                client.request(request.unwrap()).await
8418            };
8419
8420            match req_result {
8421                Err(err) => {
8422                    if let common::Retry::After(d) = dlg.http_error(&err) {
8423                        sleep(d).await;
8424                        continue;
8425                    }
8426                    dlg.finished(false);
8427                    return Err(common::Error::HttpError(err));
8428                }
8429                Ok(res) => {
8430                    let (mut parts, body) = res.into_parts();
8431                    let mut body = common::Body::new(body);
8432                    if !parts.status.is_success() {
8433                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8434                        let error = serde_json::from_str(&common::to_string(&bytes));
8435                        let response = common::to_response(parts, bytes.into());
8436
8437                        if let common::Retry::After(d) =
8438                            dlg.http_failure(&response, error.as_ref().ok())
8439                        {
8440                            sleep(d).await;
8441                            continue;
8442                        }
8443
8444                        dlg.finished(false);
8445
8446                        return Err(match error {
8447                            Ok(value) => common::Error::BadRequest(value),
8448                            _ => common::Error::Failure(response),
8449                        });
8450                    }
8451                    let response = {
8452                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8453                        let encoded = common::to_string(&bytes);
8454                        match serde_json::from_str(&encoded) {
8455                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8456                            Err(error) => {
8457                                dlg.response_json_decode_error(&encoded, &error);
8458                                return Err(common::Error::JsonDecodeError(
8459                                    encoded.to_string(),
8460                                    error,
8461                                ));
8462                            }
8463                        }
8464                    };
8465
8466                    dlg.finished(true);
8467                    return Ok(response);
8468                }
8469            }
8470        }
8471    }
8472
8473    /// Project ID of the project that contains the instance to be deleted.
8474    ///
8475    /// Sets the *project* path property to the given value.
8476    ///
8477    /// Even though the property as already been set when instantiating this call,
8478    /// we provide this method for API completeness.
8479    pub fn project(mut self, new_value: &str) -> InstanceDeleteCall<'a, C> {
8480        self._project = new_value.to_string();
8481        self
8482    }
8483    /// Cloud SQL instance ID. This does not include the project ID.
8484    ///
8485    /// Sets the *instance* path property to the given value.
8486    ///
8487    /// Even though the property as already been set when instantiating this call,
8488    /// we provide this method for API completeness.
8489    pub fn instance(mut self, new_value: &str) -> InstanceDeleteCall<'a, C> {
8490        self._instance = new_value.to_string();
8491        self
8492    }
8493    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8494    /// while executing the actual API request.
8495    ///
8496    /// ````text
8497    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8498    /// ````
8499    ///
8500    /// Sets the *delegate* property to the given value.
8501    pub fn delegate(
8502        mut self,
8503        new_value: &'a mut dyn common::Delegate,
8504    ) -> InstanceDeleteCall<'a, C> {
8505        self._delegate = Some(new_value);
8506        self
8507    }
8508
8509    /// Set any additional parameter of the query string used in the request.
8510    /// It should be used to set parameters which are not yet available through their own
8511    /// setters.
8512    ///
8513    /// Please note that this method must not be used to set any of the known parameters
8514    /// which have their own setter method. If done anyway, the request will fail.
8515    ///
8516    /// # Additional Parameters
8517    ///
8518    /// * *$.xgafv* (query-string) - V1 error format.
8519    /// * *access_token* (query-string) - OAuth access token.
8520    /// * *alt* (query-string) - Data format for response.
8521    /// * *callback* (query-string) - JSONP
8522    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8523    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8524    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8525    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8526    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8527    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8528    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8529    pub fn param<T>(mut self, name: T, value: T) -> InstanceDeleteCall<'a, C>
8530    where
8531        T: AsRef<str>,
8532    {
8533        self._additional_params
8534            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8535        self
8536    }
8537
8538    /// Identifies the authorization scope for the method you are building.
8539    ///
8540    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8541    /// [`Scope::CloudPlatform`].
8542    ///
8543    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8544    /// tokens for more than one scope.
8545    ///
8546    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8547    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8548    /// sufficient, a read-write scope will do as well.
8549    pub fn add_scope<St>(mut self, scope: St) -> InstanceDeleteCall<'a, C>
8550    where
8551        St: AsRef<str>,
8552    {
8553        self._scopes.insert(String::from(scope.as_ref()));
8554        self
8555    }
8556    /// Identifies the authorization scope(s) for the method you are building.
8557    ///
8558    /// See [`Self::add_scope()`] for details.
8559    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceDeleteCall<'a, C>
8560    where
8561        I: IntoIterator<Item = St>,
8562        St: AsRef<str>,
8563    {
8564        self._scopes
8565            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8566        self
8567    }
8568
8569    /// Removes all scopes, and no default scope will be used either.
8570    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8571    /// for details).
8572    pub fn clear_scopes(mut self) -> InstanceDeleteCall<'a, C> {
8573        self._scopes.clear();
8574        self
8575    }
8576}
8577
8578/// Demotes the stand-alone instance to be a Cloud SQL read replica for an
8579/// external database server.
8580///
8581/// A builder for the *demoteMaster* method supported by a *instance* resource.
8582/// It is not used directly, but through a [`InstanceMethods`] instance.
8583///
8584/// # Example
8585///
8586/// Instantiate a resource method builder
8587///
8588/// ```test_harness,no_run
8589/// # extern crate hyper;
8590/// # extern crate hyper_rustls;
8591/// # extern crate google_sql1_beta4 as sql1_beta4;
8592/// use sql1_beta4::api::InstancesDemoteMasterRequest;
8593/// # async fn dox() {
8594/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8595///
8596/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8597/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8598/// #     .with_native_roots()
8599/// #     .unwrap()
8600/// #     .https_only()
8601/// #     .enable_http2()
8602/// #     .build();
8603///
8604/// # let executor = hyper_util::rt::TokioExecutor::new();
8605/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8606/// #     secret,
8607/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8608/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8609/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8610/// #     ),
8611/// # ).build().await.unwrap();
8612///
8613/// # let client = hyper_util::client::legacy::Client::builder(
8614/// #     hyper_util::rt::TokioExecutor::new()
8615/// # )
8616/// # .build(
8617/// #     hyper_rustls::HttpsConnectorBuilder::new()
8618/// #         .with_native_roots()
8619/// #         .unwrap()
8620/// #         .https_or_http()
8621/// #         .enable_http2()
8622/// #         .build()
8623/// # );
8624/// # let mut hub = SQLAdmin::new(client, auth);
8625/// // As the method needs a request, you would usually fill it with the desired information
8626/// // into the respective structure. Some of the parts shown here might not be applicable !
8627/// // Values shown here are possibly random and not representative !
8628/// let mut req = InstancesDemoteMasterRequest::default();
8629///
8630/// // You can configure optional parameters by calling the respective setters at will, and
8631/// // execute the final call using `doit()`.
8632/// // Values shown here are possibly random and not representative !
8633/// let result = hub.instances().demote_master(req, "project", "instance")
8634///              .doit().await;
8635/// # }
8636/// ```
8637pub struct InstanceDemoteMasterCall<'a, C>
8638where
8639    C: 'a,
8640{
8641    hub: &'a SQLAdmin<C>,
8642    _request: InstancesDemoteMasterRequest,
8643    _project: String,
8644    _instance: String,
8645    _delegate: Option<&'a mut dyn common::Delegate>,
8646    _additional_params: HashMap<String, String>,
8647    _scopes: BTreeSet<String>,
8648}
8649
8650impl<'a, C> common::CallBuilder for InstanceDemoteMasterCall<'a, C> {}
8651
8652impl<'a, C> InstanceDemoteMasterCall<'a, C>
8653where
8654    C: common::Connector,
8655{
8656    /// Perform the operation you have build so far.
8657    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8658        use std::borrow::Cow;
8659        use std::io::{Read, Seek};
8660
8661        use common::{url::Params, ToParts};
8662        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8663
8664        let mut dd = common::DefaultDelegate;
8665        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8666        dlg.begin(common::MethodInfo {
8667            id: "sql.instances.demoteMaster",
8668            http_method: hyper::Method::POST,
8669        });
8670
8671        for &field in ["alt", "project", "instance"].iter() {
8672            if self._additional_params.contains_key(field) {
8673                dlg.finished(false);
8674                return Err(common::Error::FieldClash(field));
8675            }
8676        }
8677
8678        let mut params = Params::with_capacity(5 + self._additional_params.len());
8679        params.push("project", self._project);
8680        params.push("instance", self._instance);
8681
8682        params.extend(self._additional_params.iter());
8683
8684        params.push("alt", "json");
8685        let mut url = self.hub._base_url.clone()
8686            + "sql/v1beta4/projects/{project}/instances/{instance}/demoteMaster";
8687        if self._scopes.is_empty() {
8688            self._scopes
8689                .insert(Scope::CloudPlatform.as_ref().to_string());
8690        }
8691
8692        #[allow(clippy::single_element_loop)]
8693        for &(find_this, param_name) in
8694            [("{project}", "project"), ("{instance}", "instance")].iter()
8695        {
8696            url = params.uri_replacement(url, param_name, find_this, false);
8697        }
8698        {
8699            let to_remove = ["instance", "project"];
8700            params.remove_params(&to_remove);
8701        }
8702
8703        let url = params.parse_with_url(&url);
8704
8705        let mut json_mime_type = mime::APPLICATION_JSON;
8706        let mut request_value_reader = {
8707            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8708            common::remove_json_null_values(&mut value);
8709            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8710            serde_json::to_writer(&mut dst, &value).unwrap();
8711            dst
8712        };
8713        let request_size = request_value_reader
8714            .seek(std::io::SeekFrom::End(0))
8715            .unwrap();
8716        request_value_reader
8717            .seek(std::io::SeekFrom::Start(0))
8718            .unwrap();
8719
8720        loop {
8721            let token = match self
8722                .hub
8723                .auth
8724                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8725                .await
8726            {
8727                Ok(token) => token,
8728                Err(e) => match dlg.token(e) {
8729                    Ok(token) => token,
8730                    Err(e) => {
8731                        dlg.finished(false);
8732                        return Err(common::Error::MissingToken(e));
8733                    }
8734                },
8735            };
8736            request_value_reader
8737                .seek(std::io::SeekFrom::Start(0))
8738                .unwrap();
8739            let mut req_result = {
8740                let client = &self.hub.client;
8741                dlg.pre_request();
8742                let mut req_builder = hyper::Request::builder()
8743                    .method(hyper::Method::POST)
8744                    .uri(url.as_str())
8745                    .header(USER_AGENT, self.hub._user_agent.clone());
8746
8747                if let Some(token) = token.as_ref() {
8748                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8749                }
8750
8751                let request = req_builder
8752                    .header(CONTENT_TYPE, json_mime_type.to_string())
8753                    .header(CONTENT_LENGTH, request_size as u64)
8754                    .body(common::to_body(
8755                        request_value_reader.get_ref().clone().into(),
8756                    ));
8757
8758                client.request(request.unwrap()).await
8759            };
8760
8761            match req_result {
8762                Err(err) => {
8763                    if let common::Retry::After(d) = dlg.http_error(&err) {
8764                        sleep(d).await;
8765                        continue;
8766                    }
8767                    dlg.finished(false);
8768                    return Err(common::Error::HttpError(err));
8769                }
8770                Ok(res) => {
8771                    let (mut parts, body) = res.into_parts();
8772                    let mut body = common::Body::new(body);
8773                    if !parts.status.is_success() {
8774                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8775                        let error = serde_json::from_str(&common::to_string(&bytes));
8776                        let response = common::to_response(parts, bytes.into());
8777
8778                        if let common::Retry::After(d) =
8779                            dlg.http_failure(&response, error.as_ref().ok())
8780                        {
8781                            sleep(d).await;
8782                            continue;
8783                        }
8784
8785                        dlg.finished(false);
8786
8787                        return Err(match error {
8788                            Ok(value) => common::Error::BadRequest(value),
8789                            _ => common::Error::Failure(response),
8790                        });
8791                    }
8792                    let response = {
8793                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8794                        let encoded = common::to_string(&bytes);
8795                        match serde_json::from_str(&encoded) {
8796                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8797                            Err(error) => {
8798                                dlg.response_json_decode_error(&encoded, &error);
8799                                return Err(common::Error::JsonDecodeError(
8800                                    encoded.to_string(),
8801                                    error,
8802                                ));
8803                            }
8804                        }
8805                    };
8806
8807                    dlg.finished(true);
8808                    return Ok(response);
8809                }
8810            }
8811        }
8812    }
8813
8814    ///
8815    /// Sets the *request* property to the given value.
8816    ///
8817    /// Even though the property as already been set when instantiating this call,
8818    /// we provide this method for API completeness.
8819    pub fn request(
8820        mut self,
8821        new_value: InstancesDemoteMasterRequest,
8822    ) -> InstanceDemoteMasterCall<'a, C> {
8823        self._request = new_value;
8824        self
8825    }
8826    /// ID of the project that contains the instance.
8827    ///
8828    /// Sets the *project* path property to the given value.
8829    ///
8830    /// Even though the property as already been set when instantiating this call,
8831    /// we provide this method for API completeness.
8832    pub fn project(mut self, new_value: &str) -> InstanceDemoteMasterCall<'a, C> {
8833        self._project = new_value.to_string();
8834        self
8835    }
8836    /// Cloud SQL instance name.
8837    ///
8838    /// Sets the *instance* path property to the given value.
8839    ///
8840    /// Even though the property as already been set when instantiating this call,
8841    /// we provide this method for API completeness.
8842    pub fn instance(mut self, new_value: &str) -> InstanceDemoteMasterCall<'a, C> {
8843        self._instance = new_value.to_string();
8844        self
8845    }
8846    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8847    /// while executing the actual API request.
8848    ///
8849    /// ````text
8850    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8851    /// ````
8852    ///
8853    /// Sets the *delegate* property to the given value.
8854    pub fn delegate(
8855        mut self,
8856        new_value: &'a mut dyn common::Delegate,
8857    ) -> InstanceDemoteMasterCall<'a, C> {
8858        self._delegate = Some(new_value);
8859        self
8860    }
8861
8862    /// Set any additional parameter of the query string used in the request.
8863    /// It should be used to set parameters which are not yet available through their own
8864    /// setters.
8865    ///
8866    /// Please note that this method must not be used to set any of the known parameters
8867    /// which have their own setter method. If done anyway, the request will fail.
8868    ///
8869    /// # Additional Parameters
8870    ///
8871    /// * *$.xgafv* (query-string) - V1 error format.
8872    /// * *access_token* (query-string) - OAuth access token.
8873    /// * *alt* (query-string) - Data format for response.
8874    /// * *callback* (query-string) - JSONP
8875    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8876    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8877    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8878    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8879    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8880    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8881    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8882    pub fn param<T>(mut self, name: T, value: T) -> InstanceDemoteMasterCall<'a, C>
8883    where
8884        T: AsRef<str>,
8885    {
8886        self._additional_params
8887            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8888        self
8889    }
8890
8891    /// Identifies the authorization scope for the method you are building.
8892    ///
8893    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8894    /// [`Scope::CloudPlatform`].
8895    ///
8896    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8897    /// tokens for more than one scope.
8898    ///
8899    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8900    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8901    /// sufficient, a read-write scope will do as well.
8902    pub fn add_scope<St>(mut self, scope: St) -> InstanceDemoteMasterCall<'a, C>
8903    where
8904        St: AsRef<str>,
8905    {
8906        self._scopes.insert(String::from(scope.as_ref()));
8907        self
8908    }
8909    /// Identifies the authorization scope(s) for the method you are building.
8910    ///
8911    /// See [`Self::add_scope()`] for details.
8912    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceDemoteMasterCall<'a, C>
8913    where
8914        I: IntoIterator<Item = St>,
8915        St: AsRef<str>,
8916    {
8917        self._scopes
8918            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8919        self
8920    }
8921
8922    /// Removes all scopes, and no default scope will be used either.
8923    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8924    /// for details).
8925    pub fn clear_scopes(mut self) -> InstanceDemoteMasterCall<'a, C> {
8926        self._scopes.clear();
8927        self
8928    }
8929}
8930
8931/// Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL
8932/// dump or CSV file.
8933///
8934/// A builder for the *export* method supported by a *instance* resource.
8935/// It is not used directly, but through a [`InstanceMethods`] instance.
8936///
8937/// # Example
8938///
8939/// Instantiate a resource method builder
8940///
8941/// ```test_harness,no_run
8942/// # extern crate hyper;
8943/// # extern crate hyper_rustls;
8944/// # extern crate google_sql1_beta4 as sql1_beta4;
8945/// use sql1_beta4::api::InstancesExportRequest;
8946/// # async fn dox() {
8947/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8948///
8949/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8950/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8951/// #     .with_native_roots()
8952/// #     .unwrap()
8953/// #     .https_only()
8954/// #     .enable_http2()
8955/// #     .build();
8956///
8957/// # let executor = hyper_util::rt::TokioExecutor::new();
8958/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8959/// #     secret,
8960/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8961/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8962/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8963/// #     ),
8964/// # ).build().await.unwrap();
8965///
8966/// # let client = hyper_util::client::legacy::Client::builder(
8967/// #     hyper_util::rt::TokioExecutor::new()
8968/// # )
8969/// # .build(
8970/// #     hyper_rustls::HttpsConnectorBuilder::new()
8971/// #         .with_native_roots()
8972/// #         .unwrap()
8973/// #         .https_or_http()
8974/// #         .enable_http2()
8975/// #         .build()
8976/// # );
8977/// # let mut hub = SQLAdmin::new(client, auth);
8978/// // As the method needs a request, you would usually fill it with the desired information
8979/// // into the respective structure. Some of the parts shown here might not be applicable !
8980/// // Values shown here are possibly random and not representative !
8981/// let mut req = InstancesExportRequest::default();
8982///
8983/// // You can configure optional parameters by calling the respective setters at will, and
8984/// // execute the final call using `doit()`.
8985/// // Values shown here are possibly random and not representative !
8986/// let result = hub.instances().export(req, "project", "instance")
8987///              .doit().await;
8988/// # }
8989/// ```
8990pub struct InstanceExportCall<'a, C>
8991where
8992    C: 'a,
8993{
8994    hub: &'a SQLAdmin<C>,
8995    _request: InstancesExportRequest,
8996    _project: String,
8997    _instance: String,
8998    _delegate: Option<&'a mut dyn common::Delegate>,
8999    _additional_params: HashMap<String, String>,
9000    _scopes: BTreeSet<String>,
9001}
9002
9003impl<'a, C> common::CallBuilder for InstanceExportCall<'a, C> {}
9004
9005impl<'a, C> InstanceExportCall<'a, C>
9006where
9007    C: common::Connector,
9008{
9009    /// Perform the operation you have build so far.
9010    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9011        use std::borrow::Cow;
9012        use std::io::{Read, Seek};
9013
9014        use common::{url::Params, ToParts};
9015        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9016
9017        let mut dd = common::DefaultDelegate;
9018        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9019        dlg.begin(common::MethodInfo {
9020            id: "sql.instances.export",
9021            http_method: hyper::Method::POST,
9022        });
9023
9024        for &field in ["alt", "project", "instance"].iter() {
9025            if self._additional_params.contains_key(field) {
9026                dlg.finished(false);
9027                return Err(common::Error::FieldClash(field));
9028            }
9029        }
9030
9031        let mut params = Params::with_capacity(5 + self._additional_params.len());
9032        params.push("project", self._project);
9033        params.push("instance", self._instance);
9034
9035        params.extend(self._additional_params.iter());
9036
9037        params.push("alt", "json");
9038        let mut url = self.hub._base_url.clone()
9039            + "sql/v1beta4/projects/{project}/instances/{instance}/export";
9040        if self._scopes.is_empty() {
9041            self._scopes
9042                .insert(Scope::CloudPlatform.as_ref().to_string());
9043        }
9044
9045        #[allow(clippy::single_element_loop)]
9046        for &(find_this, param_name) in
9047            [("{project}", "project"), ("{instance}", "instance")].iter()
9048        {
9049            url = params.uri_replacement(url, param_name, find_this, false);
9050        }
9051        {
9052            let to_remove = ["instance", "project"];
9053            params.remove_params(&to_remove);
9054        }
9055
9056        let url = params.parse_with_url(&url);
9057
9058        let mut json_mime_type = mime::APPLICATION_JSON;
9059        let mut request_value_reader = {
9060            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9061            common::remove_json_null_values(&mut value);
9062            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9063            serde_json::to_writer(&mut dst, &value).unwrap();
9064            dst
9065        };
9066        let request_size = request_value_reader
9067            .seek(std::io::SeekFrom::End(0))
9068            .unwrap();
9069        request_value_reader
9070            .seek(std::io::SeekFrom::Start(0))
9071            .unwrap();
9072
9073        loop {
9074            let token = match self
9075                .hub
9076                .auth
9077                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9078                .await
9079            {
9080                Ok(token) => token,
9081                Err(e) => match dlg.token(e) {
9082                    Ok(token) => token,
9083                    Err(e) => {
9084                        dlg.finished(false);
9085                        return Err(common::Error::MissingToken(e));
9086                    }
9087                },
9088            };
9089            request_value_reader
9090                .seek(std::io::SeekFrom::Start(0))
9091                .unwrap();
9092            let mut req_result = {
9093                let client = &self.hub.client;
9094                dlg.pre_request();
9095                let mut req_builder = hyper::Request::builder()
9096                    .method(hyper::Method::POST)
9097                    .uri(url.as_str())
9098                    .header(USER_AGENT, self.hub._user_agent.clone());
9099
9100                if let Some(token) = token.as_ref() {
9101                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9102                }
9103
9104                let request = req_builder
9105                    .header(CONTENT_TYPE, json_mime_type.to_string())
9106                    .header(CONTENT_LENGTH, request_size as u64)
9107                    .body(common::to_body(
9108                        request_value_reader.get_ref().clone().into(),
9109                    ));
9110
9111                client.request(request.unwrap()).await
9112            };
9113
9114            match req_result {
9115                Err(err) => {
9116                    if let common::Retry::After(d) = dlg.http_error(&err) {
9117                        sleep(d).await;
9118                        continue;
9119                    }
9120                    dlg.finished(false);
9121                    return Err(common::Error::HttpError(err));
9122                }
9123                Ok(res) => {
9124                    let (mut parts, body) = res.into_parts();
9125                    let mut body = common::Body::new(body);
9126                    if !parts.status.is_success() {
9127                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9128                        let error = serde_json::from_str(&common::to_string(&bytes));
9129                        let response = common::to_response(parts, bytes.into());
9130
9131                        if let common::Retry::After(d) =
9132                            dlg.http_failure(&response, error.as_ref().ok())
9133                        {
9134                            sleep(d).await;
9135                            continue;
9136                        }
9137
9138                        dlg.finished(false);
9139
9140                        return Err(match error {
9141                            Ok(value) => common::Error::BadRequest(value),
9142                            _ => common::Error::Failure(response),
9143                        });
9144                    }
9145                    let response = {
9146                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9147                        let encoded = common::to_string(&bytes);
9148                        match serde_json::from_str(&encoded) {
9149                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9150                            Err(error) => {
9151                                dlg.response_json_decode_error(&encoded, &error);
9152                                return Err(common::Error::JsonDecodeError(
9153                                    encoded.to_string(),
9154                                    error,
9155                                ));
9156                            }
9157                        }
9158                    };
9159
9160                    dlg.finished(true);
9161                    return Ok(response);
9162                }
9163            }
9164        }
9165    }
9166
9167    ///
9168    /// Sets the *request* property to the given value.
9169    ///
9170    /// Even though the property as already been set when instantiating this call,
9171    /// we provide this method for API completeness.
9172    pub fn request(mut self, new_value: InstancesExportRequest) -> InstanceExportCall<'a, C> {
9173        self._request = new_value;
9174        self
9175    }
9176    /// Project ID of the project that contains the instance to be exported.
9177    ///
9178    /// Sets the *project* path property to the given value.
9179    ///
9180    /// Even though the property as already been set when instantiating this call,
9181    /// we provide this method for API completeness.
9182    pub fn project(mut self, new_value: &str) -> InstanceExportCall<'a, C> {
9183        self._project = new_value.to_string();
9184        self
9185    }
9186    /// Cloud SQL instance ID. This does not include the project ID.
9187    ///
9188    /// Sets the *instance* path property to the given value.
9189    ///
9190    /// Even though the property as already been set when instantiating this call,
9191    /// we provide this method for API completeness.
9192    pub fn instance(mut self, new_value: &str) -> InstanceExportCall<'a, C> {
9193        self._instance = new_value.to_string();
9194        self
9195    }
9196    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9197    /// while executing the actual API request.
9198    ///
9199    /// ````text
9200    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9201    /// ````
9202    ///
9203    /// Sets the *delegate* property to the given value.
9204    pub fn delegate(
9205        mut self,
9206        new_value: &'a mut dyn common::Delegate,
9207    ) -> InstanceExportCall<'a, C> {
9208        self._delegate = Some(new_value);
9209        self
9210    }
9211
9212    /// Set any additional parameter of the query string used in the request.
9213    /// It should be used to set parameters which are not yet available through their own
9214    /// setters.
9215    ///
9216    /// Please note that this method must not be used to set any of the known parameters
9217    /// which have their own setter method. If done anyway, the request will fail.
9218    ///
9219    /// # Additional Parameters
9220    ///
9221    /// * *$.xgafv* (query-string) - V1 error format.
9222    /// * *access_token* (query-string) - OAuth access token.
9223    /// * *alt* (query-string) - Data format for response.
9224    /// * *callback* (query-string) - JSONP
9225    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9226    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9227    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9228    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9229    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9230    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9231    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9232    pub fn param<T>(mut self, name: T, value: T) -> InstanceExportCall<'a, C>
9233    where
9234        T: AsRef<str>,
9235    {
9236        self._additional_params
9237            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9238        self
9239    }
9240
9241    /// Identifies the authorization scope for the method you are building.
9242    ///
9243    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9244    /// [`Scope::CloudPlatform`].
9245    ///
9246    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9247    /// tokens for more than one scope.
9248    ///
9249    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9250    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9251    /// sufficient, a read-write scope will do as well.
9252    pub fn add_scope<St>(mut self, scope: St) -> InstanceExportCall<'a, C>
9253    where
9254        St: AsRef<str>,
9255    {
9256        self._scopes.insert(String::from(scope.as_ref()));
9257        self
9258    }
9259    /// Identifies the authorization scope(s) for the method you are building.
9260    ///
9261    /// See [`Self::add_scope()`] for details.
9262    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceExportCall<'a, C>
9263    where
9264        I: IntoIterator<Item = St>,
9265        St: AsRef<str>,
9266    {
9267        self._scopes
9268            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9269        self
9270    }
9271
9272    /// Removes all scopes, and no default scope will be used either.
9273    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9274    /// for details).
9275    pub fn clear_scopes(mut self) -> InstanceExportCall<'a, C> {
9276        self._scopes.clear();
9277        self
9278    }
9279}
9280
9281/// Failover the instance to its failover replica instance. Using this
9282/// operation might cause your instance to restart.
9283///
9284/// A builder for the *failover* method supported by a *instance* resource.
9285/// It is not used directly, but through a [`InstanceMethods`] instance.
9286///
9287/// # Example
9288///
9289/// Instantiate a resource method builder
9290///
9291/// ```test_harness,no_run
9292/// # extern crate hyper;
9293/// # extern crate hyper_rustls;
9294/// # extern crate google_sql1_beta4 as sql1_beta4;
9295/// use sql1_beta4::api::InstancesFailoverRequest;
9296/// # async fn dox() {
9297/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9298///
9299/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9300/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9301/// #     .with_native_roots()
9302/// #     .unwrap()
9303/// #     .https_only()
9304/// #     .enable_http2()
9305/// #     .build();
9306///
9307/// # let executor = hyper_util::rt::TokioExecutor::new();
9308/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9309/// #     secret,
9310/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9311/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9312/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9313/// #     ),
9314/// # ).build().await.unwrap();
9315///
9316/// # let client = hyper_util::client::legacy::Client::builder(
9317/// #     hyper_util::rt::TokioExecutor::new()
9318/// # )
9319/// # .build(
9320/// #     hyper_rustls::HttpsConnectorBuilder::new()
9321/// #         .with_native_roots()
9322/// #         .unwrap()
9323/// #         .https_or_http()
9324/// #         .enable_http2()
9325/// #         .build()
9326/// # );
9327/// # let mut hub = SQLAdmin::new(client, auth);
9328/// // As the method needs a request, you would usually fill it with the desired information
9329/// // into the respective structure. Some of the parts shown here might not be applicable !
9330/// // Values shown here are possibly random and not representative !
9331/// let mut req = InstancesFailoverRequest::default();
9332///
9333/// // You can configure optional parameters by calling the respective setters at will, and
9334/// // execute the final call using `doit()`.
9335/// // Values shown here are possibly random and not representative !
9336/// let result = hub.instances().failover(req, "project", "instance")
9337///              .doit().await;
9338/// # }
9339/// ```
9340pub struct InstanceFailoverCall<'a, C>
9341where
9342    C: 'a,
9343{
9344    hub: &'a SQLAdmin<C>,
9345    _request: InstancesFailoverRequest,
9346    _project: String,
9347    _instance: String,
9348    _delegate: Option<&'a mut dyn common::Delegate>,
9349    _additional_params: HashMap<String, String>,
9350    _scopes: BTreeSet<String>,
9351}
9352
9353impl<'a, C> common::CallBuilder for InstanceFailoverCall<'a, C> {}
9354
9355impl<'a, C> InstanceFailoverCall<'a, C>
9356where
9357    C: common::Connector,
9358{
9359    /// Perform the operation you have build so far.
9360    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9361        use std::borrow::Cow;
9362        use std::io::{Read, Seek};
9363
9364        use common::{url::Params, ToParts};
9365        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9366
9367        let mut dd = common::DefaultDelegate;
9368        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9369        dlg.begin(common::MethodInfo {
9370            id: "sql.instances.failover",
9371            http_method: hyper::Method::POST,
9372        });
9373
9374        for &field in ["alt", "project", "instance"].iter() {
9375            if self._additional_params.contains_key(field) {
9376                dlg.finished(false);
9377                return Err(common::Error::FieldClash(field));
9378            }
9379        }
9380
9381        let mut params = Params::with_capacity(5 + self._additional_params.len());
9382        params.push("project", self._project);
9383        params.push("instance", self._instance);
9384
9385        params.extend(self._additional_params.iter());
9386
9387        params.push("alt", "json");
9388        let mut url = self.hub._base_url.clone()
9389            + "sql/v1beta4/projects/{project}/instances/{instance}/failover";
9390        if self._scopes.is_empty() {
9391            self._scopes
9392                .insert(Scope::CloudPlatform.as_ref().to_string());
9393        }
9394
9395        #[allow(clippy::single_element_loop)]
9396        for &(find_this, param_name) in
9397            [("{project}", "project"), ("{instance}", "instance")].iter()
9398        {
9399            url = params.uri_replacement(url, param_name, find_this, false);
9400        }
9401        {
9402            let to_remove = ["instance", "project"];
9403            params.remove_params(&to_remove);
9404        }
9405
9406        let url = params.parse_with_url(&url);
9407
9408        let mut json_mime_type = mime::APPLICATION_JSON;
9409        let mut request_value_reader = {
9410            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9411            common::remove_json_null_values(&mut value);
9412            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9413            serde_json::to_writer(&mut dst, &value).unwrap();
9414            dst
9415        };
9416        let request_size = request_value_reader
9417            .seek(std::io::SeekFrom::End(0))
9418            .unwrap();
9419        request_value_reader
9420            .seek(std::io::SeekFrom::Start(0))
9421            .unwrap();
9422
9423        loop {
9424            let token = match self
9425                .hub
9426                .auth
9427                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9428                .await
9429            {
9430                Ok(token) => token,
9431                Err(e) => match dlg.token(e) {
9432                    Ok(token) => token,
9433                    Err(e) => {
9434                        dlg.finished(false);
9435                        return Err(common::Error::MissingToken(e));
9436                    }
9437                },
9438            };
9439            request_value_reader
9440                .seek(std::io::SeekFrom::Start(0))
9441                .unwrap();
9442            let mut req_result = {
9443                let client = &self.hub.client;
9444                dlg.pre_request();
9445                let mut req_builder = hyper::Request::builder()
9446                    .method(hyper::Method::POST)
9447                    .uri(url.as_str())
9448                    .header(USER_AGENT, self.hub._user_agent.clone());
9449
9450                if let Some(token) = token.as_ref() {
9451                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9452                }
9453
9454                let request = req_builder
9455                    .header(CONTENT_TYPE, json_mime_type.to_string())
9456                    .header(CONTENT_LENGTH, request_size as u64)
9457                    .body(common::to_body(
9458                        request_value_reader.get_ref().clone().into(),
9459                    ));
9460
9461                client.request(request.unwrap()).await
9462            };
9463
9464            match req_result {
9465                Err(err) => {
9466                    if let common::Retry::After(d) = dlg.http_error(&err) {
9467                        sleep(d).await;
9468                        continue;
9469                    }
9470                    dlg.finished(false);
9471                    return Err(common::Error::HttpError(err));
9472                }
9473                Ok(res) => {
9474                    let (mut parts, body) = res.into_parts();
9475                    let mut body = common::Body::new(body);
9476                    if !parts.status.is_success() {
9477                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9478                        let error = serde_json::from_str(&common::to_string(&bytes));
9479                        let response = common::to_response(parts, bytes.into());
9480
9481                        if let common::Retry::After(d) =
9482                            dlg.http_failure(&response, error.as_ref().ok())
9483                        {
9484                            sleep(d).await;
9485                            continue;
9486                        }
9487
9488                        dlg.finished(false);
9489
9490                        return Err(match error {
9491                            Ok(value) => common::Error::BadRequest(value),
9492                            _ => common::Error::Failure(response),
9493                        });
9494                    }
9495                    let response = {
9496                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9497                        let encoded = common::to_string(&bytes);
9498                        match serde_json::from_str(&encoded) {
9499                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9500                            Err(error) => {
9501                                dlg.response_json_decode_error(&encoded, &error);
9502                                return Err(common::Error::JsonDecodeError(
9503                                    encoded.to_string(),
9504                                    error,
9505                                ));
9506                            }
9507                        }
9508                    };
9509
9510                    dlg.finished(true);
9511                    return Ok(response);
9512                }
9513            }
9514        }
9515    }
9516
9517    ///
9518    /// Sets the *request* property to the given value.
9519    ///
9520    /// Even though the property as already been set when instantiating this call,
9521    /// we provide this method for API completeness.
9522    pub fn request(mut self, new_value: InstancesFailoverRequest) -> InstanceFailoverCall<'a, C> {
9523        self._request = new_value;
9524        self
9525    }
9526    /// ID of the project that contains the read replica.
9527    ///
9528    /// Sets the *project* path property to the given value.
9529    ///
9530    /// Even though the property as already been set when instantiating this call,
9531    /// we provide this method for API completeness.
9532    pub fn project(mut self, new_value: &str) -> InstanceFailoverCall<'a, C> {
9533        self._project = new_value.to_string();
9534        self
9535    }
9536    /// Cloud SQL instance ID. This does not include the project ID.
9537    ///
9538    /// Sets the *instance* path property to the given value.
9539    ///
9540    /// Even though the property as already been set when instantiating this call,
9541    /// we provide this method for API completeness.
9542    pub fn instance(mut self, new_value: &str) -> InstanceFailoverCall<'a, C> {
9543        self._instance = new_value.to_string();
9544        self
9545    }
9546    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9547    /// while executing the actual API request.
9548    ///
9549    /// ````text
9550    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9551    /// ````
9552    ///
9553    /// Sets the *delegate* property to the given value.
9554    pub fn delegate(
9555        mut self,
9556        new_value: &'a mut dyn common::Delegate,
9557    ) -> InstanceFailoverCall<'a, C> {
9558        self._delegate = Some(new_value);
9559        self
9560    }
9561
9562    /// Set any additional parameter of the query string used in the request.
9563    /// It should be used to set parameters which are not yet available through their own
9564    /// setters.
9565    ///
9566    /// Please note that this method must not be used to set any of the known parameters
9567    /// which have their own setter method. If done anyway, the request will fail.
9568    ///
9569    /// # Additional Parameters
9570    ///
9571    /// * *$.xgafv* (query-string) - V1 error format.
9572    /// * *access_token* (query-string) - OAuth access token.
9573    /// * *alt* (query-string) - Data format for response.
9574    /// * *callback* (query-string) - JSONP
9575    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9576    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9577    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9578    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9579    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9580    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9581    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9582    pub fn param<T>(mut self, name: T, value: T) -> InstanceFailoverCall<'a, C>
9583    where
9584        T: AsRef<str>,
9585    {
9586        self._additional_params
9587            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9588        self
9589    }
9590
9591    /// Identifies the authorization scope for the method you are building.
9592    ///
9593    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9594    /// [`Scope::CloudPlatform`].
9595    ///
9596    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9597    /// tokens for more than one scope.
9598    ///
9599    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9600    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9601    /// sufficient, a read-write scope will do as well.
9602    pub fn add_scope<St>(mut self, scope: St) -> InstanceFailoverCall<'a, C>
9603    where
9604        St: AsRef<str>,
9605    {
9606        self._scopes.insert(String::from(scope.as_ref()));
9607        self
9608    }
9609    /// Identifies the authorization scope(s) for the method you are building.
9610    ///
9611    /// See [`Self::add_scope()`] for details.
9612    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceFailoverCall<'a, C>
9613    where
9614        I: IntoIterator<Item = St>,
9615        St: AsRef<str>,
9616    {
9617        self._scopes
9618            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9619        self
9620    }
9621
9622    /// Removes all scopes, and no default scope will be used either.
9623    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9624    /// for details).
9625    pub fn clear_scopes(mut self) -> InstanceFailoverCall<'a, C> {
9626        self._scopes.clear();
9627        self
9628    }
9629}
9630
9631/// Retrieves a resource containing information about a Cloud SQL instance.
9632///
9633/// A builder for the *get* method supported by a *instance* resource.
9634/// It is not used directly, but through a [`InstanceMethods`] instance.
9635///
9636/// # Example
9637///
9638/// Instantiate a resource method builder
9639///
9640/// ```test_harness,no_run
9641/// # extern crate hyper;
9642/// # extern crate hyper_rustls;
9643/// # extern crate google_sql1_beta4 as sql1_beta4;
9644/// # async fn dox() {
9645/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9646///
9647/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9648/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9649/// #     .with_native_roots()
9650/// #     .unwrap()
9651/// #     .https_only()
9652/// #     .enable_http2()
9653/// #     .build();
9654///
9655/// # let executor = hyper_util::rt::TokioExecutor::new();
9656/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9657/// #     secret,
9658/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9659/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9660/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9661/// #     ),
9662/// # ).build().await.unwrap();
9663///
9664/// # let client = hyper_util::client::legacy::Client::builder(
9665/// #     hyper_util::rt::TokioExecutor::new()
9666/// # )
9667/// # .build(
9668/// #     hyper_rustls::HttpsConnectorBuilder::new()
9669/// #         .with_native_roots()
9670/// #         .unwrap()
9671/// #         .https_or_http()
9672/// #         .enable_http2()
9673/// #         .build()
9674/// # );
9675/// # let mut hub = SQLAdmin::new(client, auth);
9676/// // You can configure optional parameters by calling the respective setters at will, and
9677/// // execute the final call using `doit()`.
9678/// // Values shown here are possibly random and not representative !
9679/// let result = hub.instances().get("project", "instance")
9680///              .doit().await;
9681/// # }
9682/// ```
9683pub struct InstanceGetCall<'a, C>
9684where
9685    C: 'a,
9686{
9687    hub: &'a SQLAdmin<C>,
9688    _project: String,
9689    _instance: String,
9690    _delegate: Option<&'a mut dyn common::Delegate>,
9691    _additional_params: HashMap<String, String>,
9692    _scopes: BTreeSet<String>,
9693}
9694
9695impl<'a, C> common::CallBuilder for InstanceGetCall<'a, C> {}
9696
9697impl<'a, C> InstanceGetCall<'a, C>
9698where
9699    C: common::Connector,
9700{
9701    /// Perform the operation you have build so far.
9702    pub async fn doit(mut self) -> common::Result<(common::Response, DatabaseInstance)> {
9703        use std::borrow::Cow;
9704        use std::io::{Read, Seek};
9705
9706        use common::{url::Params, ToParts};
9707        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9708
9709        let mut dd = common::DefaultDelegate;
9710        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9711        dlg.begin(common::MethodInfo {
9712            id: "sql.instances.get",
9713            http_method: hyper::Method::GET,
9714        });
9715
9716        for &field in ["alt", "project", "instance"].iter() {
9717            if self._additional_params.contains_key(field) {
9718                dlg.finished(false);
9719                return Err(common::Error::FieldClash(field));
9720            }
9721        }
9722
9723        let mut params = Params::with_capacity(4 + self._additional_params.len());
9724        params.push("project", self._project);
9725        params.push("instance", self._instance);
9726
9727        params.extend(self._additional_params.iter());
9728
9729        params.push("alt", "json");
9730        let mut url =
9731            self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances/{instance}";
9732        if self._scopes.is_empty() {
9733            self._scopes
9734                .insert(Scope::CloudPlatform.as_ref().to_string());
9735        }
9736
9737        #[allow(clippy::single_element_loop)]
9738        for &(find_this, param_name) in
9739            [("{project}", "project"), ("{instance}", "instance")].iter()
9740        {
9741            url = params.uri_replacement(url, param_name, find_this, false);
9742        }
9743        {
9744            let to_remove = ["instance", "project"];
9745            params.remove_params(&to_remove);
9746        }
9747
9748        let url = params.parse_with_url(&url);
9749
9750        loop {
9751            let token = match self
9752                .hub
9753                .auth
9754                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9755                .await
9756            {
9757                Ok(token) => token,
9758                Err(e) => match dlg.token(e) {
9759                    Ok(token) => token,
9760                    Err(e) => {
9761                        dlg.finished(false);
9762                        return Err(common::Error::MissingToken(e));
9763                    }
9764                },
9765            };
9766            let mut req_result = {
9767                let client = &self.hub.client;
9768                dlg.pre_request();
9769                let mut req_builder = hyper::Request::builder()
9770                    .method(hyper::Method::GET)
9771                    .uri(url.as_str())
9772                    .header(USER_AGENT, self.hub._user_agent.clone());
9773
9774                if let Some(token) = token.as_ref() {
9775                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9776                }
9777
9778                let request = req_builder
9779                    .header(CONTENT_LENGTH, 0_u64)
9780                    .body(common::to_body::<String>(None));
9781
9782                client.request(request.unwrap()).await
9783            };
9784
9785            match req_result {
9786                Err(err) => {
9787                    if let common::Retry::After(d) = dlg.http_error(&err) {
9788                        sleep(d).await;
9789                        continue;
9790                    }
9791                    dlg.finished(false);
9792                    return Err(common::Error::HttpError(err));
9793                }
9794                Ok(res) => {
9795                    let (mut parts, body) = res.into_parts();
9796                    let mut body = common::Body::new(body);
9797                    if !parts.status.is_success() {
9798                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9799                        let error = serde_json::from_str(&common::to_string(&bytes));
9800                        let response = common::to_response(parts, bytes.into());
9801
9802                        if let common::Retry::After(d) =
9803                            dlg.http_failure(&response, error.as_ref().ok())
9804                        {
9805                            sleep(d).await;
9806                            continue;
9807                        }
9808
9809                        dlg.finished(false);
9810
9811                        return Err(match error {
9812                            Ok(value) => common::Error::BadRequest(value),
9813                            _ => common::Error::Failure(response),
9814                        });
9815                    }
9816                    let response = {
9817                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9818                        let encoded = common::to_string(&bytes);
9819                        match serde_json::from_str(&encoded) {
9820                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9821                            Err(error) => {
9822                                dlg.response_json_decode_error(&encoded, &error);
9823                                return Err(common::Error::JsonDecodeError(
9824                                    encoded.to_string(),
9825                                    error,
9826                                ));
9827                            }
9828                        }
9829                    };
9830
9831                    dlg.finished(true);
9832                    return Ok(response);
9833                }
9834            }
9835        }
9836    }
9837
9838    /// Project ID of the project that contains the instance.
9839    ///
9840    /// Sets the *project* path property to the given value.
9841    ///
9842    /// Even though the property as already been set when instantiating this call,
9843    /// we provide this method for API completeness.
9844    pub fn project(mut self, new_value: &str) -> InstanceGetCall<'a, C> {
9845        self._project = new_value.to_string();
9846        self
9847    }
9848    /// Database instance ID. This does not include the project ID.
9849    ///
9850    /// Sets the *instance* path property to the given value.
9851    ///
9852    /// Even though the property as already been set when instantiating this call,
9853    /// we provide this method for API completeness.
9854    pub fn instance(mut self, new_value: &str) -> InstanceGetCall<'a, C> {
9855        self._instance = new_value.to_string();
9856        self
9857    }
9858    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9859    /// while executing the actual API request.
9860    ///
9861    /// ````text
9862    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9863    /// ````
9864    ///
9865    /// Sets the *delegate* property to the given value.
9866    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InstanceGetCall<'a, C> {
9867        self._delegate = Some(new_value);
9868        self
9869    }
9870
9871    /// Set any additional parameter of the query string used in the request.
9872    /// It should be used to set parameters which are not yet available through their own
9873    /// setters.
9874    ///
9875    /// Please note that this method must not be used to set any of the known parameters
9876    /// which have their own setter method. If done anyway, the request will fail.
9877    ///
9878    /// # Additional Parameters
9879    ///
9880    /// * *$.xgafv* (query-string) - V1 error format.
9881    /// * *access_token* (query-string) - OAuth access token.
9882    /// * *alt* (query-string) - Data format for response.
9883    /// * *callback* (query-string) - JSONP
9884    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9885    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9886    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9887    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9888    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9889    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9890    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9891    pub fn param<T>(mut self, name: T, value: T) -> InstanceGetCall<'a, C>
9892    where
9893        T: AsRef<str>,
9894    {
9895        self._additional_params
9896            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9897        self
9898    }
9899
9900    /// Identifies the authorization scope for the method you are building.
9901    ///
9902    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9903    /// [`Scope::CloudPlatform`].
9904    ///
9905    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9906    /// tokens for more than one scope.
9907    ///
9908    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9909    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9910    /// sufficient, a read-write scope will do as well.
9911    pub fn add_scope<St>(mut self, scope: St) -> InstanceGetCall<'a, C>
9912    where
9913        St: AsRef<str>,
9914    {
9915        self._scopes.insert(String::from(scope.as_ref()));
9916        self
9917    }
9918    /// Identifies the authorization scope(s) for the method you are building.
9919    ///
9920    /// See [`Self::add_scope()`] for details.
9921    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGetCall<'a, C>
9922    where
9923        I: IntoIterator<Item = St>,
9924        St: AsRef<str>,
9925    {
9926        self._scopes
9927            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9928        self
9929    }
9930
9931    /// Removes all scopes, and no default scope will be used either.
9932    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9933    /// for details).
9934    pub fn clear_scopes(mut self) -> InstanceGetCall<'a, C> {
9935        self._scopes.clear();
9936        self
9937    }
9938}
9939
9940/// Imports data into a Cloud SQL instance from a SQL dump  or CSV file in
9941/// Cloud Storage.
9942///
9943/// A builder for the *import* method supported by a *instance* resource.
9944/// It is not used directly, but through a [`InstanceMethods`] instance.
9945///
9946/// # Example
9947///
9948/// Instantiate a resource method builder
9949///
9950/// ```test_harness,no_run
9951/// # extern crate hyper;
9952/// # extern crate hyper_rustls;
9953/// # extern crate google_sql1_beta4 as sql1_beta4;
9954/// use sql1_beta4::api::InstancesImportRequest;
9955/// # async fn dox() {
9956/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9957///
9958/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9959/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9960/// #     .with_native_roots()
9961/// #     .unwrap()
9962/// #     .https_only()
9963/// #     .enable_http2()
9964/// #     .build();
9965///
9966/// # let executor = hyper_util::rt::TokioExecutor::new();
9967/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9968/// #     secret,
9969/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9970/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9971/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9972/// #     ),
9973/// # ).build().await.unwrap();
9974///
9975/// # let client = hyper_util::client::legacy::Client::builder(
9976/// #     hyper_util::rt::TokioExecutor::new()
9977/// # )
9978/// # .build(
9979/// #     hyper_rustls::HttpsConnectorBuilder::new()
9980/// #         .with_native_roots()
9981/// #         .unwrap()
9982/// #         .https_or_http()
9983/// #         .enable_http2()
9984/// #         .build()
9985/// # );
9986/// # let mut hub = SQLAdmin::new(client, auth);
9987/// // As the method needs a request, you would usually fill it with the desired information
9988/// // into the respective structure. Some of the parts shown here might not be applicable !
9989/// // Values shown here are possibly random and not representative !
9990/// let mut req = InstancesImportRequest::default();
9991///
9992/// // You can configure optional parameters by calling the respective setters at will, and
9993/// // execute the final call using `doit()`.
9994/// // Values shown here are possibly random and not representative !
9995/// let result = hub.instances().import(req, "project", "instance")
9996///              .doit().await;
9997/// # }
9998/// ```
9999pub struct InstanceImportCall<'a, C>
10000where
10001    C: 'a,
10002{
10003    hub: &'a SQLAdmin<C>,
10004    _request: InstancesImportRequest,
10005    _project: String,
10006    _instance: String,
10007    _delegate: Option<&'a mut dyn common::Delegate>,
10008    _additional_params: HashMap<String, String>,
10009    _scopes: BTreeSet<String>,
10010}
10011
10012impl<'a, C> common::CallBuilder for InstanceImportCall<'a, C> {}
10013
10014impl<'a, C> InstanceImportCall<'a, C>
10015where
10016    C: common::Connector,
10017{
10018    /// Perform the operation you have build so far.
10019    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10020        use std::borrow::Cow;
10021        use std::io::{Read, Seek};
10022
10023        use common::{url::Params, ToParts};
10024        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10025
10026        let mut dd = common::DefaultDelegate;
10027        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10028        dlg.begin(common::MethodInfo {
10029            id: "sql.instances.import",
10030            http_method: hyper::Method::POST,
10031        });
10032
10033        for &field in ["alt", "project", "instance"].iter() {
10034            if self._additional_params.contains_key(field) {
10035                dlg.finished(false);
10036                return Err(common::Error::FieldClash(field));
10037            }
10038        }
10039
10040        let mut params = Params::with_capacity(5 + self._additional_params.len());
10041        params.push("project", self._project);
10042        params.push("instance", self._instance);
10043
10044        params.extend(self._additional_params.iter());
10045
10046        params.push("alt", "json");
10047        let mut url = self.hub._base_url.clone()
10048            + "sql/v1beta4/projects/{project}/instances/{instance}/import";
10049        if self._scopes.is_empty() {
10050            self._scopes
10051                .insert(Scope::CloudPlatform.as_ref().to_string());
10052        }
10053
10054        #[allow(clippy::single_element_loop)]
10055        for &(find_this, param_name) in
10056            [("{project}", "project"), ("{instance}", "instance")].iter()
10057        {
10058            url = params.uri_replacement(url, param_name, find_this, false);
10059        }
10060        {
10061            let to_remove = ["instance", "project"];
10062            params.remove_params(&to_remove);
10063        }
10064
10065        let url = params.parse_with_url(&url);
10066
10067        let mut json_mime_type = mime::APPLICATION_JSON;
10068        let mut request_value_reader = {
10069            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10070            common::remove_json_null_values(&mut value);
10071            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10072            serde_json::to_writer(&mut dst, &value).unwrap();
10073            dst
10074        };
10075        let request_size = request_value_reader
10076            .seek(std::io::SeekFrom::End(0))
10077            .unwrap();
10078        request_value_reader
10079            .seek(std::io::SeekFrom::Start(0))
10080            .unwrap();
10081
10082        loop {
10083            let token = match self
10084                .hub
10085                .auth
10086                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10087                .await
10088            {
10089                Ok(token) => token,
10090                Err(e) => match dlg.token(e) {
10091                    Ok(token) => token,
10092                    Err(e) => {
10093                        dlg.finished(false);
10094                        return Err(common::Error::MissingToken(e));
10095                    }
10096                },
10097            };
10098            request_value_reader
10099                .seek(std::io::SeekFrom::Start(0))
10100                .unwrap();
10101            let mut req_result = {
10102                let client = &self.hub.client;
10103                dlg.pre_request();
10104                let mut req_builder = hyper::Request::builder()
10105                    .method(hyper::Method::POST)
10106                    .uri(url.as_str())
10107                    .header(USER_AGENT, self.hub._user_agent.clone());
10108
10109                if let Some(token) = token.as_ref() {
10110                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10111                }
10112
10113                let request = req_builder
10114                    .header(CONTENT_TYPE, json_mime_type.to_string())
10115                    .header(CONTENT_LENGTH, request_size as u64)
10116                    .body(common::to_body(
10117                        request_value_reader.get_ref().clone().into(),
10118                    ));
10119
10120                client.request(request.unwrap()).await
10121            };
10122
10123            match req_result {
10124                Err(err) => {
10125                    if let common::Retry::After(d) = dlg.http_error(&err) {
10126                        sleep(d).await;
10127                        continue;
10128                    }
10129                    dlg.finished(false);
10130                    return Err(common::Error::HttpError(err));
10131                }
10132                Ok(res) => {
10133                    let (mut parts, body) = res.into_parts();
10134                    let mut body = common::Body::new(body);
10135                    if !parts.status.is_success() {
10136                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10137                        let error = serde_json::from_str(&common::to_string(&bytes));
10138                        let response = common::to_response(parts, bytes.into());
10139
10140                        if let common::Retry::After(d) =
10141                            dlg.http_failure(&response, error.as_ref().ok())
10142                        {
10143                            sleep(d).await;
10144                            continue;
10145                        }
10146
10147                        dlg.finished(false);
10148
10149                        return Err(match error {
10150                            Ok(value) => common::Error::BadRequest(value),
10151                            _ => common::Error::Failure(response),
10152                        });
10153                    }
10154                    let response = {
10155                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10156                        let encoded = common::to_string(&bytes);
10157                        match serde_json::from_str(&encoded) {
10158                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10159                            Err(error) => {
10160                                dlg.response_json_decode_error(&encoded, &error);
10161                                return Err(common::Error::JsonDecodeError(
10162                                    encoded.to_string(),
10163                                    error,
10164                                ));
10165                            }
10166                        }
10167                    };
10168
10169                    dlg.finished(true);
10170                    return Ok(response);
10171                }
10172            }
10173        }
10174    }
10175
10176    ///
10177    /// Sets the *request* property to the given value.
10178    ///
10179    /// Even though the property as already been set when instantiating this call,
10180    /// we provide this method for API completeness.
10181    pub fn request(mut self, new_value: InstancesImportRequest) -> InstanceImportCall<'a, C> {
10182        self._request = new_value;
10183        self
10184    }
10185    /// Project ID of the project that contains the instance.
10186    ///
10187    /// Sets the *project* path property to the given value.
10188    ///
10189    /// Even though the property as already been set when instantiating this call,
10190    /// we provide this method for API completeness.
10191    pub fn project(mut self, new_value: &str) -> InstanceImportCall<'a, C> {
10192        self._project = new_value.to_string();
10193        self
10194    }
10195    /// Cloud SQL instance ID. This does not include the project ID.
10196    ///
10197    /// Sets the *instance* path property to the given value.
10198    ///
10199    /// Even though the property as already been set when instantiating this call,
10200    /// we provide this method for API completeness.
10201    pub fn instance(mut self, new_value: &str) -> InstanceImportCall<'a, C> {
10202        self._instance = new_value.to_string();
10203        self
10204    }
10205    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10206    /// while executing the actual API request.
10207    ///
10208    /// ````text
10209    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10210    /// ````
10211    ///
10212    /// Sets the *delegate* property to the given value.
10213    pub fn delegate(
10214        mut self,
10215        new_value: &'a mut dyn common::Delegate,
10216    ) -> InstanceImportCall<'a, C> {
10217        self._delegate = Some(new_value);
10218        self
10219    }
10220
10221    /// Set any additional parameter of the query string used in the request.
10222    /// It should be used to set parameters which are not yet available through their own
10223    /// setters.
10224    ///
10225    /// Please note that this method must not be used to set any of the known parameters
10226    /// which have their own setter method. If done anyway, the request will fail.
10227    ///
10228    /// # Additional Parameters
10229    ///
10230    /// * *$.xgafv* (query-string) - V1 error format.
10231    /// * *access_token* (query-string) - OAuth access token.
10232    /// * *alt* (query-string) - Data format for response.
10233    /// * *callback* (query-string) - JSONP
10234    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10235    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10236    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10237    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10238    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10239    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10240    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10241    pub fn param<T>(mut self, name: T, value: T) -> InstanceImportCall<'a, C>
10242    where
10243        T: AsRef<str>,
10244    {
10245        self._additional_params
10246            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10247        self
10248    }
10249
10250    /// Identifies the authorization scope for the method you are building.
10251    ///
10252    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10253    /// [`Scope::CloudPlatform`].
10254    ///
10255    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10256    /// tokens for more than one scope.
10257    ///
10258    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10259    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10260    /// sufficient, a read-write scope will do as well.
10261    pub fn add_scope<St>(mut self, scope: St) -> InstanceImportCall<'a, C>
10262    where
10263        St: AsRef<str>,
10264    {
10265        self._scopes.insert(String::from(scope.as_ref()));
10266        self
10267    }
10268    /// Identifies the authorization scope(s) for the method you are building.
10269    ///
10270    /// See [`Self::add_scope()`] for details.
10271    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceImportCall<'a, C>
10272    where
10273        I: IntoIterator<Item = St>,
10274        St: AsRef<str>,
10275    {
10276        self._scopes
10277            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10278        self
10279    }
10280
10281    /// Removes all scopes, and no default scope will be used either.
10282    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10283    /// for details).
10284    pub fn clear_scopes(mut self) -> InstanceImportCall<'a, C> {
10285        self._scopes.clear();
10286        self
10287    }
10288}
10289
10290/// Creates a new Cloud SQL instance.
10291///
10292/// A builder for the *insert* method supported by a *instance* resource.
10293/// It is not used directly, but through a [`InstanceMethods`] instance.
10294///
10295/// # Example
10296///
10297/// Instantiate a resource method builder
10298///
10299/// ```test_harness,no_run
10300/// # extern crate hyper;
10301/// # extern crate hyper_rustls;
10302/// # extern crate google_sql1_beta4 as sql1_beta4;
10303/// use sql1_beta4::api::DatabaseInstance;
10304/// # async fn dox() {
10305/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10306///
10307/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10308/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10309/// #     .with_native_roots()
10310/// #     .unwrap()
10311/// #     .https_only()
10312/// #     .enable_http2()
10313/// #     .build();
10314///
10315/// # let executor = hyper_util::rt::TokioExecutor::new();
10316/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10317/// #     secret,
10318/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10319/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10320/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10321/// #     ),
10322/// # ).build().await.unwrap();
10323///
10324/// # let client = hyper_util::client::legacy::Client::builder(
10325/// #     hyper_util::rt::TokioExecutor::new()
10326/// # )
10327/// # .build(
10328/// #     hyper_rustls::HttpsConnectorBuilder::new()
10329/// #         .with_native_roots()
10330/// #         .unwrap()
10331/// #         .https_or_http()
10332/// #         .enable_http2()
10333/// #         .build()
10334/// # );
10335/// # let mut hub = SQLAdmin::new(client, auth);
10336/// // As the method needs a request, you would usually fill it with the desired information
10337/// // into the respective structure. Some of the parts shown here might not be applicable !
10338/// // Values shown here are possibly random and not representative !
10339/// let mut req = DatabaseInstance::default();
10340///
10341/// // You can configure optional parameters by calling the respective setters at will, and
10342/// // execute the final call using `doit()`.
10343/// // Values shown here are possibly random and not representative !
10344/// let result = hub.instances().insert(req, "project")
10345///              .doit().await;
10346/// # }
10347/// ```
10348pub struct InstanceInsertCall<'a, C>
10349where
10350    C: 'a,
10351{
10352    hub: &'a SQLAdmin<C>,
10353    _request: DatabaseInstance,
10354    _project: String,
10355    _delegate: Option<&'a mut dyn common::Delegate>,
10356    _additional_params: HashMap<String, String>,
10357    _scopes: BTreeSet<String>,
10358}
10359
10360impl<'a, C> common::CallBuilder for InstanceInsertCall<'a, C> {}
10361
10362impl<'a, C> InstanceInsertCall<'a, C>
10363where
10364    C: common::Connector,
10365{
10366    /// Perform the operation you have build so far.
10367    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10368        use std::borrow::Cow;
10369        use std::io::{Read, Seek};
10370
10371        use common::{url::Params, ToParts};
10372        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10373
10374        let mut dd = common::DefaultDelegate;
10375        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10376        dlg.begin(common::MethodInfo {
10377            id: "sql.instances.insert",
10378            http_method: hyper::Method::POST,
10379        });
10380
10381        for &field in ["alt", "project"].iter() {
10382            if self._additional_params.contains_key(field) {
10383                dlg.finished(false);
10384                return Err(common::Error::FieldClash(field));
10385            }
10386        }
10387
10388        let mut params = Params::with_capacity(4 + self._additional_params.len());
10389        params.push("project", self._project);
10390
10391        params.extend(self._additional_params.iter());
10392
10393        params.push("alt", "json");
10394        let mut url = self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances";
10395        if self._scopes.is_empty() {
10396            self._scopes
10397                .insert(Scope::CloudPlatform.as_ref().to_string());
10398        }
10399
10400        #[allow(clippy::single_element_loop)]
10401        for &(find_this, param_name) in [("{project}", "project")].iter() {
10402            url = params.uri_replacement(url, param_name, find_this, false);
10403        }
10404        {
10405            let to_remove = ["project"];
10406            params.remove_params(&to_remove);
10407        }
10408
10409        let url = params.parse_with_url(&url);
10410
10411        let mut json_mime_type = mime::APPLICATION_JSON;
10412        let mut request_value_reader = {
10413            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10414            common::remove_json_null_values(&mut value);
10415            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10416            serde_json::to_writer(&mut dst, &value).unwrap();
10417            dst
10418        };
10419        let request_size = request_value_reader
10420            .seek(std::io::SeekFrom::End(0))
10421            .unwrap();
10422        request_value_reader
10423            .seek(std::io::SeekFrom::Start(0))
10424            .unwrap();
10425
10426        loop {
10427            let token = match self
10428                .hub
10429                .auth
10430                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10431                .await
10432            {
10433                Ok(token) => token,
10434                Err(e) => match dlg.token(e) {
10435                    Ok(token) => token,
10436                    Err(e) => {
10437                        dlg.finished(false);
10438                        return Err(common::Error::MissingToken(e));
10439                    }
10440                },
10441            };
10442            request_value_reader
10443                .seek(std::io::SeekFrom::Start(0))
10444                .unwrap();
10445            let mut req_result = {
10446                let client = &self.hub.client;
10447                dlg.pre_request();
10448                let mut req_builder = hyper::Request::builder()
10449                    .method(hyper::Method::POST)
10450                    .uri(url.as_str())
10451                    .header(USER_AGENT, self.hub._user_agent.clone());
10452
10453                if let Some(token) = token.as_ref() {
10454                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10455                }
10456
10457                let request = req_builder
10458                    .header(CONTENT_TYPE, json_mime_type.to_string())
10459                    .header(CONTENT_LENGTH, request_size as u64)
10460                    .body(common::to_body(
10461                        request_value_reader.get_ref().clone().into(),
10462                    ));
10463
10464                client.request(request.unwrap()).await
10465            };
10466
10467            match req_result {
10468                Err(err) => {
10469                    if let common::Retry::After(d) = dlg.http_error(&err) {
10470                        sleep(d).await;
10471                        continue;
10472                    }
10473                    dlg.finished(false);
10474                    return Err(common::Error::HttpError(err));
10475                }
10476                Ok(res) => {
10477                    let (mut parts, body) = res.into_parts();
10478                    let mut body = common::Body::new(body);
10479                    if !parts.status.is_success() {
10480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10481                        let error = serde_json::from_str(&common::to_string(&bytes));
10482                        let response = common::to_response(parts, bytes.into());
10483
10484                        if let common::Retry::After(d) =
10485                            dlg.http_failure(&response, error.as_ref().ok())
10486                        {
10487                            sleep(d).await;
10488                            continue;
10489                        }
10490
10491                        dlg.finished(false);
10492
10493                        return Err(match error {
10494                            Ok(value) => common::Error::BadRequest(value),
10495                            _ => common::Error::Failure(response),
10496                        });
10497                    }
10498                    let response = {
10499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10500                        let encoded = common::to_string(&bytes);
10501                        match serde_json::from_str(&encoded) {
10502                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10503                            Err(error) => {
10504                                dlg.response_json_decode_error(&encoded, &error);
10505                                return Err(common::Error::JsonDecodeError(
10506                                    encoded.to_string(),
10507                                    error,
10508                                ));
10509                            }
10510                        }
10511                    };
10512
10513                    dlg.finished(true);
10514                    return Ok(response);
10515                }
10516            }
10517        }
10518    }
10519
10520    ///
10521    /// Sets the *request* property to the given value.
10522    ///
10523    /// Even though the property as already been set when instantiating this call,
10524    /// we provide this method for API completeness.
10525    pub fn request(mut self, new_value: DatabaseInstance) -> InstanceInsertCall<'a, C> {
10526        self._request = new_value;
10527        self
10528    }
10529    /// Project ID of the project to which the newly created Cloud SQL instances
10530    /// should belong.
10531    ///
10532    /// Sets the *project* path property to the given value.
10533    ///
10534    /// Even though the property as already been set when instantiating this call,
10535    /// we provide this method for API completeness.
10536    pub fn project(mut self, new_value: &str) -> InstanceInsertCall<'a, C> {
10537        self._project = new_value.to_string();
10538        self
10539    }
10540    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10541    /// while executing the actual API request.
10542    ///
10543    /// ````text
10544    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10545    /// ````
10546    ///
10547    /// Sets the *delegate* property to the given value.
10548    pub fn delegate(
10549        mut self,
10550        new_value: &'a mut dyn common::Delegate,
10551    ) -> InstanceInsertCall<'a, C> {
10552        self._delegate = Some(new_value);
10553        self
10554    }
10555
10556    /// Set any additional parameter of the query string used in the request.
10557    /// It should be used to set parameters which are not yet available through their own
10558    /// setters.
10559    ///
10560    /// Please note that this method must not be used to set any of the known parameters
10561    /// which have their own setter method. If done anyway, the request will fail.
10562    ///
10563    /// # Additional Parameters
10564    ///
10565    /// * *$.xgafv* (query-string) - V1 error format.
10566    /// * *access_token* (query-string) - OAuth access token.
10567    /// * *alt* (query-string) - Data format for response.
10568    /// * *callback* (query-string) - JSONP
10569    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10570    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10571    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10572    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10573    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10574    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10575    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10576    pub fn param<T>(mut self, name: T, value: T) -> InstanceInsertCall<'a, C>
10577    where
10578        T: AsRef<str>,
10579    {
10580        self._additional_params
10581            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10582        self
10583    }
10584
10585    /// Identifies the authorization scope for the method you are building.
10586    ///
10587    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10588    /// [`Scope::CloudPlatform`].
10589    ///
10590    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10591    /// tokens for more than one scope.
10592    ///
10593    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10594    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10595    /// sufficient, a read-write scope will do as well.
10596    pub fn add_scope<St>(mut self, scope: St) -> InstanceInsertCall<'a, C>
10597    where
10598        St: AsRef<str>,
10599    {
10600        self._scopes.insert(String::from(scope.as_ref()));
10601        self
10602    }
10603    /// Identifies the authorization scope(s) for the method you are building.
10604    ///
10605    /// See [`Self::add_scope()`] for details.
10606    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceInsertCall<'a, C>
10607    where
10608        I: IntoIterator<Item = St>,
10609        St: AsRef<str>,
10610    {
10611        self._scopes
10612            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10613        self
10614    }
10615
10616    /// Removes all scopes, and no default scope will be used either.
10617    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10618    /// for details).
10619    pub fn clear_scopes(mut self) -> InstanceInsertCall<'a, C> {
10620        self._scopes.clear();
10621        self
10622    }
10623}
10624
10625/// Lists instances under a given project.
10626///
10627/// A builder for the *list* method supported by a *instance* resource.
10628/// It is not used directly, but through a [`InstanceMethods`] instance.
10629///
10630/// # Example
10631///
10632/// Instantiate a resource method builder
10633///
10634/// ```test_harness,no_run
10635/// # extern crate hyper;
10636/// # extern crate hyper_rustls;
10637/// # extern crate google_sql1_beta4 as sql1_beta4;
10638/// # async fn dox() {
10639/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10640///
10641/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10642/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10643/// #     .with_native_roots()
10644/// #     .unwrap()
10645/// #     .https_only()
10646/// #     .enable_http2()
10647/// #     .build();
10648///
10649/// # let executor = hyper_util::rt::TokioExecutor::new();
10650/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10651/// #     secret,
10652/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10653/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10654/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10655/// #     ),
10656/// # ).build().await.unwrap();
10657///
10658/// # let client = hyper_util::client::legacy::Client::builder(
10659/// #     hyper_util::rt::TokioExecutor::new()
10660/// # )
10661/// # .build(
10662/// #     hyper_rustls::HttpsConnectorBuilder::new()
10663/// #         .with_native_roots()
10664/// #         .unwrap()
10665/// #         .https_or_http()
10666/// #         .enable_http2()
10667/// #         .build()
10668/// # );
10669/// # let mut hub = SQLAdmin::new(client, auth);
10670/// // You can configure optional parameters by calling the respective setters at will, and
10671/// // execute the final call using `doit()`.
10672/// // Values shown here are possibly random and not representative !
10673/// let result = hub.instances().list("project")
10674///              .page_token("et")
10675///              .max_results(79)
10676///              .filter("sadipscing")
10677///              .doit().await;
10678/// # }
10679/// ```
10680pub struct InstanceListCall<'a, C>
10681where
10682    C: 'a,
10683{
10684    hub: &'a SQLAdmin<C>,
10685    _project: String,
10686    _page_token: Option<String>,
10687    _max_results: Option<u32>,
10688    _filter: Option<String>,
10689    _delegate: Option<&'a mut dyn common::Delegate>,
10690    _additional_params: HashMap<String, String>,
10691    _scopes: BTreeSet<String>,
10692}
10693
10694impl<'a, C> common::CallBuilder for InstanceListCall<'a, C> {}
10695
10696impl<'a, C> InstanceListCall<'a, C>
10697where
10698    C: common::Connector,
10699{
10700    /// Perform the operation you have build so far.
10701    pub async fn doit(mut self) -> common::Result<(common::Response, InstancesListResponse)> {
10702        use std::borrow::Cow;
10703        use std::io::{Read, Seek};
10704
10705        use common::{url::Params, ToParts};
10706        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10707
10708        let mut dd = common::DefaultDelegate;
10709        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10710        dlg.begin(common::MethodInfo {
10711            id: "sql.instances.list",
10712            http_method: hyper::Method::GET,
10713        });
10714
10715        for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() {
10716            if self._additional_params.contains_key(field) {
10717                dlg.finished(false);
10718                return Err(common::Error::FieldClash(field));
10719            }
10720        }
10721
10722        let mut params = Params::with_capacity(6 + self._additional_params.len());
10723        params.push("project", self._project);
10724        if let Some(value) = self._page_token.as_ref() {
10725            params.push("pageToken", value);
10726        }
10727        if let Some(value) = self._max_results.as_ref() {
10728            params.push("maxResults", value.to_string());
10729        }
10730        if let Some(value) = self._filter.as_ref() {
10731            params.push("filter", value);
10732        }
10733
10734        params.extend(self._additional_params.iter());
10735
10736        params.push("alt", "json");
10737        let mut url = self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances";
10738        if self._scopes.is_empty() {
10739            self._scopes
10740                .insert(Scope::CloudPlatform.as_ref().to_string());
10741        }
10742
10743        #[allow(clippy::single_element_loop)]
10744        for &(find_this, param_name) in [("{project}", "project")].iter() {
10745            url = params.uri_replacement(url, param_name, find_this, false);
10746        }
10747        {
10748            let to_remove = ["project"];
10749            params.remove_params(&to_remove);
10750        }
10751
10752        let url = params.parse_with_url(&url);
10753
10754        loop {
10755            let token = match self
10756                .hub
10757                .auth
10758                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10759                .await
10760            {
10761                Ok(token) => token,
10762                Err(e) => match dlg.token(e) {
10763                    Ok(token) => token,
10764                    Err(e) => {
10765                        dlg.finished(false);
10766                        return Err(common::Error::MissingToken(e));
10767                    }
10768                },
10769            };
10770            let mut req_result = {
10771                let client = &self.hub.client;
10772                dlg.pre_request();
10773                let mut req_builder = hyper::Request::builder()
10774                    .method(hyper::Method::GET)
10775                    .uri(url.as_str())
10776                    .header(USER_AGENT, self.hub._user_agent.clone());
10777
10778                if let Some(token) = token.as_ref() {
10779                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10780                }
10781
10782                let request = req_builder
10783                    .header(CONTENT_LENGTH, 0_u64)
10784                    .body(common::to_body::<String>(None));
10785
10786                client.request(request.unwrap()).await
10787            };
10788
10789            match req_result {
10790                Err(err) => {
10791                    if let common::Retry::After(d) = dlg.http_error(&err) {
10792                        sleep(d).await;
10793                        continue;
10794                    }
10795                    dlg.finished(false);
10796                    return Err(common::Error::HttpError(err));
10797                }
10798                Ok(res) => {
10799                    let (mut parts, body) = res.into_parts();
10800                    let mut body = common::Body::new(body);
10801                    if !parts.status.is_success() {
10802                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10803                        let error = serde_json::from_str(&common::to_string(&bytes));
10804                        let response = common::to_response(parts, bytes.into());
10805
10806                        if let common::Retry::After(d) =
10807                            dlg.http_failure(&response, error.as_ref().ok())
10808                        {
10809                            sleep(d).await;
10810                            continue;
10811                        }
10812
10813                        dlg.finished(false);
10814
10815                        return Err(match error {
10816                            Ok(value) => common::Error::BadRequest(value),
10817                            _ => common::Error::Failure(response),
10818                        });
10819                    }
10820                    let response = {
10821                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10822                        let encoded = common::to_string(&bytes);
10823                        match serde_json::from_str(&encoded) {
10824                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10825                            Err(error) => {
10826                                dlg.response_json_decode_error(&encoded, &error);
10827                                return Err(common::Error::JsonDecodeError(
10828                                    encoded.to_string(),
10829                                    error,
10830                                ));
10831                            }
10832                        }
10833                    };
10834
10835                    dlg.finished(true);
10836                    return Ok(response);
10837                }
10838            }
10839        }
10840    }
10841
10842    /// Project ID of the project for which to list Cloud SQL instances.
10843    ///
10844    /// Sets the *project* path property to the given value.
10845    ///
10846    /// Even though the property as already been set when instantiating this call,
10847    /// we provide this method for API completeness.
10848    pub fn project(mut self, new_value: &str) -> InstanceListCall<'a, C> {
10849        self._project = new_value.to_string();
10850        self
10851    }
10852    /// A previously-returned page token representing part of the larger set of
10853    /// results to view.
10854    ///
10855    /// Sets the *page token* query property to the given value.
10856    pub fn page_token(mut self, new_value: &str) -> InstanceListCall<'a, C> {
10857        self._page_token = Some(new_value.to_string());
10858        self
10859    }
10860    /// The maximum number of results to return per response.
10861    ///
10862    /// Sets the *max results* query property to the given value.
10863    pub fn max_results(mut self, new_value: u32) -> InstanceListCall<'a, C> {
10864        self._max_results = Some(new_value);
10865        self
10866    }
10867    /// A filter expression that filters resources listed in the response.
10868    /// The expression is in the form of field:value. For example,
10869    /// 'instanceType:CLOUD_SQL_INSTANCE'. Fields can be nested as needed as per
10870    /// their JSON representation, such as 'settings.userLabels.auto_start:true'.
10871    ///
10872    /// Multiple filter queries are space-separated. For example.
10873    /// 'state:RUNNABLE instanceType:CLOUD_SQL_INSTANCE'. By default, each
10874    /// expression is an AND expression. However, you can include AND and OR
10875    /// expressions explicitly.
10876    ///
10877    /// Sets the *filter* query property to the given value.
10878    pub fn filter(mut self, new_value: &str) -> InstanceListCall<'a, C> {
10879        self._filter = Some(new_value.to_string());
10880        self
10881    }
10882    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10883    /// while executing the actual API request.
10884    ///
10885    /// ````text
10886    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10887    /// ````
10888    ///
10889    /// Sets the *delegate* property to the given value.
10890    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InstanceListCall<'a, C> {
10891        self._delegate = Some(new_value);
10892        self
10893    }
10894
10895    /// Set any additional parameter of the query string used in the request.
10896    /// It should be used to set parameters which are not yet available through their own
10897    /// setters.
10898    ///
10899    /// Please note that this method must not be used to set any of the known parameters
10900    /// which have their own setter method. If done anyway, the request will fail.
10901    ///
10902    /// # Additional Parameters
10903    ///
10904    /// * *$.xgafv* (query-string) - V1 error format.
10905    /// * *access_token* (query-string) - OAuth access token.
10906    /// * *alt* (query-string) - Data format for response.
10907    /// * *callback* (query-string) - JSONP
10908    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10909    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10910    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10911    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10912    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10913    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10914    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10915    pub fn param<T>(mut self, name: T, value: T) -> InstanceListCall<'a, C>
10916    where
10917        T: AsRef<str>,
10918    {
10919        self._additional_params
10920            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10921        self
10922    }
10923
10924    /// Identifies the authorization scope for the method you are building.
10925    ///
10926    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10927    /// [`Scope::CloudPlatform`].
10928    ///
10929    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10930    /// tokens for more than one scope.
10931    ///
10932    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10933    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10934    /// sufficient, a read-write scope will do as well.
10935    pub fn add_scope<St>(mut self, scope: St) -> InstanceListCall<'a, C>
10936    where
10937        St: AsRef<str>,
10938    {
10939        self._scopes.insert(String::from(scope.as_ref()));
10940        self
10941    }
10942    /// Identifies the authorization scope(s) for the method you are building.
10943    ///
10944    /// See [`Self::add_scope()`] for details.
10945    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceListCall<'a, C>
10946    where
10947        I: IntoIterator<Item = St>,
10948        St: AsRef<str>,
10949    {
10950        self._scopes
10951            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10952        self
10953    }
10954
10955    /// Removes all scopes, and no default scope will be used either.
10956    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10957    /// for details).
10958    pub fn clear_scopes(mut self) -> InstanceListCall<'a, C> {
10959        self._scopes.clear();
10960        self
10961    }
10962}
10963
10964/// Lists all of the trusted Certificate Authorities (CAs) for the specified
10965/// instance. There can be up to three CAs listed: the CA that was used to sign
10966/// the certificate that is currently in use, a CA that has been added but not
10967/// yet used to sign a certificate, and a CA used to sign a certificate that
10968/// has previously rotated out.
10969///
10970/// A builder for the *listServerCas* method supported by a *instance* resource.
10971/// It is not used directly, but through a [`InstanceMethods`] instance.
10972///
10973/// # Example
10974///
10975/// Instantiate a resource method builder
10976///
10977/// ```test_harness,no_run
10978/// # extern crate hyper;
10979/// # extern crate hyper_rustls;
10980/// # extern crate google_sql1_beta4 as sql1_beta4;
10981/// # async fn dox() {
10982/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10983///
10984/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10985/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10986/// #     .with_native_roots()
10987/// #     .unwrap()
10988/// #     .https_only()
10989/// #     .enable_http2()
10990/// #     .build();
10991///
10992/// # let executor = hyper_util::rt::TokioExecutor::new();
10993/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10994/// #     secret,
10995/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10996/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10997/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10998/// #     ),
10999/// # ).build().await.unwrap();
11000///
11001/// # let client = hyper_util::client::legacy::Client::builder(
11002/// #     hyper_util::rt::TokioExecutor::new()
11003/// # )
11004/// # .build(
11005/// #     hyper_rustls::HttpsConnectorBuilder::new()
11006/// #         .with_native_roots()
11007/// #         .unwrap()
11008/// #         .https_or_http()
11009/// #         .enable_http2()
11010/// #         .build()
11011/// # );
11012/// # let mut hub = SQLAdmin::new(client, auth);
11013/// // You can configure optional parameters by calling the respective setters at will, and
11014/// // execute the final call using `doit()`.
11015/// // Values shown here are possibly random and not representative !
11016/// let result = hub.instances().list_server_cas("project", "instance")
11017///              .doit().await;
11018/// # }
11019/// ```
11020pub struct InstanceListServerCaCall<'a, C>
11021where
11022    C: 'a,
11023{
11024    hub: &'a SQLAdmin<C>,
11025    _project: String,
11026    _instance: String,
11027    _delegate: Option<&'a mut dyn common::Delegate>,
11028    _additional_params: HashMap<String, String>,
11029    _scopes: BTreeSet<String>,
11030}
11031
11032impl<'a, C> common::CallBuilder for InstanceListServerCaCall<'a, C> {}
11033
11034impl<'a, C> InstanceListServerCaCall<'a, C>
11035where
11036    C: common::Connector,
11037{
11038    /// Perform the operation you have build so far.
11039    pub async fn doit(
11040        mut self,
11041    ) -> common::Result<(common::Response, InstancesListServerCasResponse)> {
11042        use std::borrow::Cow;
11043        use std::io::{Read, Seek};
11044
11045        use common::{url::Params, ToParts};
11046        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11047
11048        let mut dd = common::DefaultDelegate;
11049        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11050        dlg.begin(common::MethodInfo {
11051            id: "sql.instances.listServerCas",
11052            http_method: hyper::Method::GET,
11053        });
11054
11055        for &field in ["alt", "project", "instance"].iter() {
11056            if self._additional_params.contains_key(field) {
11057                dlg.finished(false);
11058                return Err(common::Error::FieldClash(field));
11059            }
11060        }
11061
11062        let mut params = Params::with_capacity(4 + self._additional_params.len());
11063        params.push("project", self._project);
11064        params.push("instance", self._instance);
11065
11066        params.extend(self._additional_params.iter());
11067
11068        params.push("alt", "json");
11069        let mut url = self.hub._base_url.clone()
11070            + "sql/v1beta4/projects/{project}/instances/{instance}/listServerCas";
11071        if self._scopes.is_empty() {
11072            self._scopes
11073                .insert(Scope::CloudPlatform.as_ref().to_string());
11074        }
11075
11076        #[allow(clippy::single_element_loop)]
11077        for &(find_this, param_name) in
11078            [("{project}", "project"), ("{instance}", "instance")].iter()
11079        {
11080            url = params.uri_replacement(url, param_name, find_this, false);
11081        }
11082        {
11083            let to_remove = ["instance", "project"];
11084            params.remove_params(&to_remove);
11085        }
11086
11087        let url = params.parse_with_url(&url);
11088
11089        loop {
11090            let token = match self
11091                .hub
11092                .auth
11093                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11094                .await
11095            {
11096                Ok(token) => token,
11097                Err(e) => match dlg.token(e) {
11098                    Ok(token) => token,
11099                    Err(e) => {
11100                        dlg.finished(false);
11101                        return Err(common::Error::MissingToken(e));
11102                    }
11103                },
11104            };
11105            let mut req_result = {
11106                let client = &self.hub.client;
11107                dlg.pre_request();
11108                let mut req_builder = hyper::Request::builder()
11109                    .method(hyper::Method::GET)
11110                    .uri(url.as_str())
11111                    .header(USER_AGENT, self.hub._user_agent.clone());
11112
11113                if let Some(token) = token.as_ref() {
11114                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11115                }
11116
11117                let request = req_builder
11118                    .header(CONTENT_LENGTH, 0_u64)
11119                    .body(common::to_body::<String>(None));
11120
11121                client.request(request.unwrap()).await
11122            };
11123
11124            match req_result {
11125                Err(err) => {
11126                    if let common::Retry::After(d) = dlg.http_error(&err) {
11127                        sleep(d).await;
11128                        continue;
11129                    }
11130                    dlg.finished(false);
11131                    return Err(common::Error::HttpError(err));
11132                }
11133                Ok(res) => {
11134                    let (mut parts, body) = res.into_parts();
11135                    let mut body = common::Body::new(body);
11136                    if !parts.status.is_success() {
11137                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11138                        let error = serde_json::from_str(&common::to_string(&bytes));
11139                        let response = common::to_response(parts, bytes.into());
11140
11141                        if let common::Retry::After(d) =
11142                            dlg.http_failure(&response, error.as_ref().ok())
11143                        {
11144                            sleep(d).await;
11145                            continue;
11146                        }
11147
11148                        dlg.finished(false);
11149
11150                        return Err(match error {
11151                            Ok(value) => common::Error::BadRequest(value),
11152                            _ => common::Error::Failure(response),
11153                        });
11154                    }
11155                    let response = {
11156                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11157                        let encoded = common::to_string(&bytes);
11158                        match serde_json::from_str(&encoded) {
11159                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11160                            Err(error) => {
11161                                dlg.response_json_decode_error(&encoded, &error);
11162                                return Err(common::Error::JsonDecodeError(
11163                                    encoded.to_string(),
11164                                    error,
11165                                ));
11166                            }
11167                        }
11168                    };
11169
11170                    dlg.finished(true);
11171                    return Ok(response);
11172                }
11173            }
11174        }
11175    }
11176
11177    /// Project ID of the project that contains the instance.
11178    ///
11179    /// Sets the *project* path property to the given value.
11180    ///
11181    /// Even though the property as already been set when instantiating this call,
11182    /// we provide this method for API completeness.
11183    pub fn project(mut self, new_value: &str) -> InstanceListServerCaCall<'a, C> {
11184        self._project = new_value.to_string();
11185        self
11186    }
11187    /// Cloud SQL instance ID. This does not include the project ID.
11188    ///
11189    /// Sets the *instance* path property to the given value.
11190    ///
11191    /// Even though the property as already been set when instantiating this call,
11192    /// we provide this method for API completeness.
11193    pub fn instance(mut self, new_value: &str) -> InstanceListServerCaCall<'a, C> {
11194        self._instance = new_value.to_string();
11195        self
11196    }
11197    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11198    /// while executing the actual API request.
11199    ///
11200    /// ````text
11201    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11202    /// ````
11203    ///
11204    /// Sets the *delegate* property to the given value.
11205    pub fn delegate(
11206        mut self,
11207        new_value: &'a mut dyn common::Delegate,
11208    ) -> InstanceListServerCaCall<'a, C> {
11209        self._delegate = Some(new_value);
11210        self
11211    }
11212
11213    /// Set any additional parameter of the query string used in the request.
11214    /// It should be used to set parameters which are not yet available through their own
11215    /// setters.
11216    ///
11217    /// Please note that this method must not be used to set any of the known parameters
11218    /// which have their own setter method. If done anyway, the request will fail.
11219    ///
11220    /// # Additional Parameters
11221    ///
11222    /// * *$.xgafv* (query-string) - V1 error format.
11223    /// * *access_token* (query-string) - OAuth access token.
11224    /// * *alt* (query-string) - Data format for response.
11225    /// * *callback* (query-string) - JSONP
11226    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11227    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11228    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11229    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11230    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11231    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11232    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11233    pub fn param<T>(mut self, name: T, value: T) -> InstanceListServerCaCall<'a, C>
11234    where
11235        T: AsRef<str>,
11236    {
11237        self._additional_params
11238            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11239        self
11240    }
11241
11242    /// Identifies the authorization scope for the method you are building.
11243    ///
11244    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11245    /// [`Scope::CloudPlatform`].
11246    ///
11247    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11248    /// tokens for more than one scope.
11249    ///
11250    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11251    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11252    /// sufficient, a read-write scope will do as well.
11253    pub fn add_scope<St>(mut self, scope: St) -> InstanceListServerCaCall<'a, C>
11254    where
11255        St: AsRef<str>,
11256    {
11257        self._scopes.insert(String::from(scope.as_ref()));
11258        self
11259    }
11260    /// Identifies the authorization scope(s) for the method you are building.
11261    ///
11262    /// See [`Self::add_scope()`] for details.
11263    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceListServerCaCall<'a, C>
11264    where
11265        I: IntoIterator<Item = St>,
11266        St: AsRef<str>,
11267    {
11268        self._scopes
11269            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11270        self
11271    }
11272
11273    /// Removes all scopes, and no default scope will be used either.
11274    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11275    /// for details).
11276    pub fn clear_scopes(mut self) -> InstanceListServerCaCall<'a, C> {
11277        self._scopes.clear();
11278        self
11279    }
11280}
11281
11282/// Updates settings of a Cloud SQL instance.
11283/// This method supports patch semantics.
11284///
11285/// A builder for the *patch* method supported by a *instance* resource.
11286/// It is not used directly, but through a [`InstanceMethods`] instance.
11287///
11288/// # Example
11289///
11290/// Instantiate a resource method builder
11291///
11292/// ```test_harness,no_run
11293/// # extern crate hyper;
11294/// # extern crate hyper_rustls;
11295/// # extern crate google_sql1_beta4 as sql1_beta4;
11296/// use sql1_beta4::api::DatabaseInstance;
11297/// # async fn dox() {
11298/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11299///
11300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11301/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11302/// #     .with_native_roots()
11303/// #     .unwrap()
11304/// #     .https_only()
11305/// #     .enable_http2()
11306/// #     .build();
11307///
11308/// # let executor = hyper_util::rt::TokioExecutor::new();
11309/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11310/// #     secret,
11311/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11312/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11313/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11314/// #     ),
11315/// # ).build().await.unwrap();
11316///
11317/// # let client = hyper_util::client::legacy::Client::builder(
11318/// #     hyper_util::rt::TokioExecutor::new()
11319/// # )
11320/// # .build(
11321/// #     hyper_rustls::HttpsConnectorBuilder::new()
11322/// #         .with_native_roots()
11323/// #         .unwrap()
11324/// #         .https_or_http()
11325/// #         .enable_http2()
11326/// #         .build()
11327/// # );
11328/// # let mut hub = SQLAdmin::new(client, auth);
11329/// // As the method needs a request, you would usually fill it with the desired information
11330/// // into the respective structure. Some of the parts shown here might not be applicable !
11331/// // Values shown here are possibly random and not representative !
11332/// let mut req = DatabaseInstance::default();
11333///
11334/// // You can configure optional parameters by calling the respective setters at will, and
11335/// // execute the final call using `doit()`.
11336/// // Values shown here are possibly random and not representative !
11337/// let result = hub.instances().patch(req, "project", "instance")
11338///              .doit().await;
11339/// # }
11340/// ```
11341pub struct InstancePatchCall<'a, C>
11342where
11343    C: 'a,
11344{
11345    hub: &'a SQLAdmin<C>,
11346    _request: DatabaseInstance,
11347    _project: String,
11348    _instance: String,
11349    _delegate: Option<&'a mut dyn common::Delegate>,
11350    _additional_params: HashMap<String, String>,
11351    _scopes: BTreeSet<String>,
11352}
11353
11354impl<'a, C> common::CallBuilder for InstancePatchCall<'a, C> {}
11355
11356impl<'a, C> InstancePatchCall<'a, C>
11357where
11358    C: common::Connector,
11359{
11360    /// Perform the operation you have build so far.
11361    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11362        use std::borrow::Cow;
11363        use std::io::{Read, Seek};
11364
11365        use common::{url::Params, ToParts};
11366        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11367
11368        let mut dd = common::DefaultDelegate;
11369        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11370        dlg.begin(common::MethodInfo {
11371            id: "sql.instances.patch",
11372            http_method: hyper::Method::PATCH,
11373        });
11374
11375        for &field in ["alt", "project", "instance"].iter() {
11376            if self._additional_params.contains_key(field) {
11377                dlg.finished(false);
11378                return Err(common::Error::FieldClash(field));
11379            }
11380        }
11381
11382        let mut params = Params::with_capacity(5 + self._additional_params.len());
11383        params.push("project", self._project);
11384        params.push("instance", self._instance);
11385
11386        params.extend(self._additional_params.iter());
11387
11388        params.push("alt", "json");
11389        let mut url =
11390            self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances/{instance}";
11391        if self._scopes.is_empty() {
11392            self._scopes
11393                .insert(Scope::CloudPlatform.as_ref().to_string());
11394        }
11395
11396        #[allow(clippy::single_element_loop)]
11397        for &(find_this, param_name) in
11398            [("{project}", "project"), ("{instance}", "instance")].iter()
11399        {
11400            url = params.uri_replacement(url, param_name, find_this, false);
11401        }
11402        {
11403            let to_remove = ["instance", "project"];
11404            params.remove_params(&to_remove);
11405        }
11406
11407        let url = params.parse_with_url(&url);
11408
11409        let mut json_mime_type = mime::APPLICATION_JSON;
11410        let mut request_value_reader = {
11411            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11412            common::remove_json_null_values(&mut value);
11413            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11414            serde_json::to_writer(&mut dst, &value).unwrap();
11415            dst
11416        };
11417        let request_size = request_value_reader
11418            .seek(std::io::SeekFrom::End(0))
11419            .unwrap();
11420        request_value_reader
11421            .seek(std::io::SeekFrom::Start(0))
11422            .unwrap();
11423
11424        loop {
11425            let token = match self
11426                .hub
11427                .auth
11428                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11429                .await
11430            {
11431                Ok(token) => token,
11432                Err(e) => match dlg.token(e) {
11433                    Ok(token) => token,
11434                    Err(e) => {
11435                        dlg.finished(false);
11436                        return Err(common::Error::MissingToken(e));
11437                    }
11438                },
11439            };
11440            request_value_reader
11441                .seek(std::io::SeekFrom::Start(0))
11442                .unwrap();
11443            let mut req_result = {
11444                let client = &self.hub.client;
11445                dlg.pre_request();
11446                let mut req_builder = hyper::Request::builder()
11447                    .method(hyper::Method::PATCH)
11448                    .uri(url.as_str())
11449                    .header(USER_AGENT, self.hub._user_agent.clone());
11450
11451                if let Some(token) = token.as_ref() {
11452                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11453                }
11454
11455                let request = req_builder
11456                    .header(CONTENT_TYPE, json_mime_type.to_string())
11457                    .header(CONTENT_LENGTH, request_size as u64)
11458                    .body(common::to_body(
11459                        request_value_reader.get_ref().clone().into(),
11460                    ));
11461
11462                client.request(request.unwrap()).await
11463            };
11464
11465            match req_result {
11466                Err(err) => {
11467                    if let common::Retry::After(d) = dlg.http_error(&err) {
11468                        sleep(d).await;
11469                        continue;
11470                    }
11471                    dlg.finished(false);
11472                    return Err(common::Error::HttpError(err));
11473                }
11474                Ok(res) => {
11475                    let (mut parts, body) = res.into_parts();
11476                    let mut body = common::Body::new(body);
11477                    if !parts.status.is_success() {
11478                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11479                        let error = serde_json::from_str(&common::to_string(&bytes));
11480                        let response = common::to_response(parts, bytes.into());
11481
11482                        if let common::Retry::After(d) =
11483                            dlg.http_failure(&response, error.as_ref().ok())
11484                        {
11485                            sleep(d).await;
11486                            continue;
11487                        }
11488
11489                        dlg.finished(false);
11490
11491                        return Err(match error {
11492                            Ok(value) => common::Error::BadRequest(value),
11493                            _ => common::Error::Failure(response),
11494                        });
11495                    }
11496                    let response = {
11497                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11498                        let encoded = common::to_string(&bytes);
11499                        match serde_json::from_str(&encoded) {
11500                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11501                            Err(error) => {
11502                                dlg.response_json_decode_error(&encoded, &error);
11503                                return Err(common::Error::JsonDecodeError(
11504                                    encoded.to_string(),
11505                                    error,
11506                                ));
11507                            }
11508                        }
11509                    };
11510
11511                    dlg.finished(true);
11512                    return Ok(response);
11513                }
11514            }
11515        }
11516    }
11517
11518    ///
11519    /// Sets the *request* property to the given value.
11520    ///
11521    /// Even though the property as already been set when instantiating this call,
11522    /// we provide this method for API completeness.
11523    pub fn request(mut self, new_value: DatabaseInstance) -> InstancePatchCall<'a, C> {
11524        self._request = new_value;
11525        self
11526    }
11527    /// Project ID of the project that contains the instance.
11528    ///
11529    /// Sets the *project* path property to the given value.
11530    ///
11531    /// Even though the property as already been set when instantiating this call,
11532    /// we provide this method for API completeness.
11533    pub fn project(mut self, new_value: &str) -> InstancePatchCall<'a, C> {
11534        self._project = new_value.to_string();
11535        self
11536    }
11537    /// Cloud SQL instance ID. This does not include the project ID.
11538    ///
11539    /// Sets the *instance* path property to the given value.
11540    ///
11541    /// Even though the property as already been set when instantiating this call,
11542    /// we provide this method for API completeness.
11543    pub fn instance(mut self, new_value: &str) -> InstancePatchCall<'a, C> {
11544        self._instance = new_value.to_string();
11545        self
11546    }
11547    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11548    /// while executing the actual API request.
11549    ///
11550    /// ````text
11551    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11552    /// ````
11553    ///
11554    /// Sets the *delegate* property to the given value.
11555    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InstancePatchCall<'a, C> {
11556        self._delegate = Some(new_value);
11557        self
11558    }
11559
11560    /// Set any additional parameter of the query string used in the request.
11561    /// It should be used to set parameters which are not yet available through their own
11562    /// setters.
11563    ///
11564    /// Please note that this method must not be used to set any of the known parameters
11565    /// which have their own setter method. If done anyway, the request will fail.
11566    ///
11567    /// # Additional Parameters
11568    ///
11569    /// * *$.xgafv* (query-string) - V1 error format.
11570    /// * *access_token* (query-string) - OAuth access token.
11571    /// * *alt* (query-string) - Data format for response.
11572    /// * *callback* (query-string) - JSONP
11573    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11574    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11575    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11576    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11577    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11578    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11579    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11580    pub fn param<T>(mut self, name: T, value: T) -> InstancePatchCall<'a, C>
11581    where
11582        T: AsRef<str>,
11583    {
11584        self._additional_params
11585            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11586        self
11587    }
11588
11589    /// Identifies the authorization scope for the method you are building.
11590    ///
11591    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11592    /// [`Scope::CloudPlatform`].
11593    ///
11594    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11595    /// tokens for more than one scope.
11596    ///
11597    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11598    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11599    /// sufficient, a read-write scope will do as well.
11600    pub fn add_scope<St>(mut self, scope: St) -> InstancePatchCall<'a, C>
11601    where
11602        St: AsRef<str>,
11603    {
11604        self._scopes.insert(String::from(scope.as_ref()));
11605        self
11606    }
11607    /// Identifies the authorization scope(s) for the method you are building.
11608    ///
11609    /// See [`Self::add_scope()`] for details.
11610    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstancePatchCall<'a, C>
11611    where
11612        I: IntoIterator<Item = St>,
11613        St: AsRef<str>,
11614    {
11615        self._scopes
11616            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11617        self
11618    }
11619
11620    /// Removes all scopes, and no default scope will be used either.
11621    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11622    /// for details).
11623    pub fn clear_scopes(mut self) -> InstancePatchCall<'a, C> {
11624        self._scopes.clear();
11625        self
11626    }
11627}
11628
11629/// Promotes the read replica instance to be a stand-alone Cloud SQL instance.
11630/// Using this operation might cause your instance to restart.
11631///
11632/// A builder for the *promoteReplica* method supported by a *instance* resource.
11633/// It is not used directly, but through a [`InstanceMethods`] instance.
11634///
11635/// # Example
11636///
11637/// Instantiate a resource method builder
11638///
11639/// ```test_harness,no_run
11640/// # extern crate hyper;
11641/// # extern crate hyper_rustls;
11642/// # extern crate google_sql1_beta4 as sql1_beta4;
11643/// # async fn dox() {
11644/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11645///
11646/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11647/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11648/// #     .with_native_roots()
11649/// #     .unwrap()
11650/// #     .https_only()
11651/// #     .enable_http2()
11652/// #     .build();
11653///
11654/// # let executor = hyper_util::rt::TokioExecutor::new();
11655/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11656/// #     secret,
11657/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11658/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11659/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11660/// #     ),
11661/// # ).build().await.unwrap();
11662///
11663/// # let client = hyper_util::client::legacy::Client::builder(
11664/// #     hyper_util::rt::TokioExecutor::new()
11665/// # )
11666/// # .build(
11667/// #     hyper_rustls::HttpsConnectorBuilder::new()
11668/// #         .with_native_roots()
11669/// #         .unwrap()
11670/// #         .https_or_http()
11671/// #         .enable_http2()
11672/// #         .build()
11673/// # );
11674/// # let mut hub = SQLAdmin::new(client, auth);
11675/// // You can configure optional parameters by calling the respective setters at will, and
11676/// // execute the final call using `doit()`.
11677/// // Values shown here are possibly random and not representative !
11678/// let result = hub.instances().promote_replica("project", "instance")
11679///              .doit().await;
11680/// # }
11681/// ```
11682pub struct InstancePromoteReplicaCall<'a, C>
11683where
11684    C: 'a,
11685{
11686    hub: &'a SQLAdmin<C>,
11687    _project: String,
11688    _instance: String,
11689    _delegate: Option<&'a mut dyn common::Delegate>,
11690    _additional_params: HashMap<String, String>,
11691    _scopes: BTreeSet<String>,
11692}
11693
11694impl<'a, C> common::CallBuilder for InstancePromoteReplicaCall<'a, C> {}
11695
11696impl<'a, C> InstancePromoteReplicaCall<'a, C>
11697where
11698    C: common::Connector,
11699{
11700    /// Perform the operation you have build so far.
11701    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11702        use std::borrow::Cow;
11703        use std::io::{Read, Seek};
11704
11705        use common::{url::Params, ToParts};
11706        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11707
11708        let mut dd = common::DefaultDelegate;
11709        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11710        dlg.begin(common::MethodInfo {
11711            id: "sql.instances.promoteReplica",
11712            http_method: hyper::Method::POST,
11713        });
11714
11715        for &field in ["alt", "project", "instance"].iter() {
11716            if self._additional_params.contains_key(field) {
11717                dlg.finished(false);
11718                return Err(common::Error::FieldClash(field));
11719            }
11720        }
11721
11722        let mut params = Params::with_capacity(4 + self._additional_params.len());
11723        params.push("project", self._project);
11724        params.push("instance", self._instance);
11725
11726        params.extend(self._additional_params.iter());
11727
11728        params.push("alt", "json");
11729        let mut url = self.hub._base_url.clone()
11730            + "sql/v1beta4/projects/{project}/instances/{instance}/promoteReplica";
11731        if self._scopes.is_empty() {
11732            self._scopes
11733                .insert(Scope::CloudPlatform.as_ref().to_string());
11734        }
11735
11736        #[allow(clippy::single_element_loop)]
11737        for &(find_this, param_name) in
11738            [("{project}", "project"), ("{instance}", "instance")].iter()
11739        {
11740            url = params.uri_replacement(url, param_name, find_this, false);
11741        }
11742        {
11743            let to_remove = ["instance", "project"];
11744            params.remove_params(&to_remove);
11745        }
11746
11747        let url = params.parse_with_url(&url);
11748
11749        loop {
11750            let token = match self
11751                .hub
11752                .auth
11753                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11754                .await
11755            {
11756                Ok(token) => token,
11757                Err(e) => match dlg.token(e) {
11758                    Ok(token) => token,
11759                    Err(e) => {
11760                        dlg.finished(false);
11761                        return Err(common::Error::MissingToken(e));
11762                    }
11763                },
11764            };
11765            let mut req_result = {
11766                let client = &self.hub.client;
11767                dlg.pre_request();
11768                let mut req_builder = hyper::Request::builder()
11769                    .method(hyper::Method::POST)
11770                    .uri(url.as_str())
11771                    .header(USER_AGENT, self.hub._user_agent.clone());
11772
11773                if let Some(token) = token.as_ref() {
11774                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11775                }
11776
11777                let request = req_builder
11778                    .header(CONTENT_LENGTH, 0_u64)
11779                    .body(common::to_body::<String>(None));
11780
11781                client.request(request.unwrap()).await
11782            };
11783
11784            match req_result {
11785                Err(err) => {
11786                    if let common::Retry::After(d) = dlg.http_error(&err) {
11787                        sleep(d).await;
11788                        continue;
11789                    }
11790                    dlg.finished(false);
11791                    return Err(common::Error::HttpError(err));
11792                }
11793                Ok(res) => {
11794                    let (mut parts, body) = res.into_parts();
11795                    let mut body = common::Body::new(body);
11796                    if !parts.status.is_success() {
11797                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11798                        let error = serde_json::from_str(&common::to_string(&bytes));
11799                        let response = common::to_response(parts, bytes.into());
11800
11801                        if let common::Retry::After(d) =
11802                            dlg.http_failure(&response, error.as_ref().ok())
11803                        {
11804                            sleep(d).await;
11805                            continue;
11806                        }
11807
11808                        dlg.finished(false);
11809
11810                        return Err(match error {
11811                            Ok(value) => common::Error::BadRequest(value),
11812                            _ => common::Error::Failure(response),
11813                        });
11814                    }
11815                    let response = {
11816                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11817                        let encoded = common::to_string(&bytes);
11818                        match serde_json::from_str(&encoded) {
11819                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11820                            Err(error) => {
11821                                dlg.response_json_decode_error(&encoded, &error);
11822                                return Err(common::Error::JsonDecodeError(
11823                                    encoded.to_string(),
11824                                    error,
11825                                ));
11826                            }
11827                        }
11828                    };
11829
11830                    dlg.finished(true);
11831                    return Ok(response);
11832                }
11833            }
11834        }
11835    }
11836
11837    /// ID of the project that contains the read replica.
11838    ///
11839    /// Sets the *project* path property to the given value.
11840    ///
11841    /// Even though the property as already been set when instantiating this call,
11842    /// we provide this method for API completeness.
11843    pub fn project(mut self, new_value: &str) -> InstancePromoteReplicaCall<'a, C> {
11844        self._project = new_value.to_string();
11845        self
11846    }
11847    /// Cloud SQL read replica instance name.
11848    ///
11849    /// Sets the *instance* path property to the given value.
11850    ///
11851    /// Even though the property as already been set when instantiating this call,
11852    /// we provide this method for API completeness.
11853    pub fn instance(mut self, new_value: &str) -> InstancePromoteReplicaCall<'a, C> {
11854        self._instance = new_value.to_string();
11855        self
11856    }
11857    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11858    /// while executing the actual API request.
11859    ///
11860    /// ````text
11861    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11862    /// ````
11863    ///
11864    /// Sets the *delegate* property to the given value.
11865    pub fn delegate(
11866        mut self,
11867        new_value: &'a mut dyn common::Delegate,
11868    ) -> InstancePromoteReplicaCall<'a, C> {
11869        self._delegate = Some(new_value);
11870        self
11871    }
11872
11873    /// Set any additional parameter of the query string used in the request.
11874    /// It should be used to set parameters which are not yet available through their own
11875    /// setters.
11876    ///
11877    /// Please note that this method must not be used to set any of the known parameters
11878    /// which have their own setter method. If done anyway, the request will fail.
11879    ///
11880    /// # Additional Parameters
11881    ///
11882    /// * *$.xgafv* (query-string) - V1 error format.
11883    /// * *access_token* (query-string) - OAuth access token.
11884    /// * *alt* (query-string) - Data format for response.
11885    /// * *callback* (query-string) - JSONP
11886    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11887    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11888    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11889    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11890    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11891    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11892    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11893    pub fn param<T>(mut self, name: T, value: T) -> InstancePromoteReplicaCall<'a, C>
11894    where
11895        T: AsRef<str>,
11896    {
11897        self._additional_params
11898            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11899        self
11900    }
11901
11902    /// Identifies the authorization scope for the method you are building.
11903    ///
11904    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11905    /// [`Scope::CloudPlatform`].
11906    ///
11907    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11908    /// tokens for more than one scope.
11909    ///
11910    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11911    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11912    /// sufficient, a read-write scope will do as well.
11913    pub fn add_scope<St>(mut self, scope: St) -> InstancePromoteReplicaCall<'a, C>
11914    where
11915        St: AsRef<str>,
11916    {
11917        self._scopes.insert(String::from(scope.as_ref()));
11918        self
11919    }
11920    /// Identifies the authorization scope(s) for the method you are building.
11921    ///
11922    /// See [`Self::add_scope()`] for details.
11923    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstancePromoteReplicaCall<'a, C>
11924    where
11925        I: IntoIterator<Item = St>,
11926        St: AsRef<str>,
11927    {
11928        self._scopes
11929            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11930        self
11931    }
11932
11933    /// Removes all scopes, and no default scope will be used either.
11934    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11935    /// for details).
11936    pub fn clear_scopes(mut self) -> InstancePromoteReplicaCall<'a, C> {
11937        self._scopes.clear();
11938        self
11939    }
11940}
11941
11942/// Deletes all client certificates and generates a new server SSL certificate
11943/// for the instance.
11944///
11945/// A builder for the *resetSslConfig* method supported by a *instance* resource.
11946/// It is not used directly, but through a [`InstanceMethods`] instance.
11947///
11948/// # Example
11949///
11950/// Instantiate a resource method builder
11951///
11952/// ```test_harness,no_run
11953/// # extern crate hyper;
11954/// # extern crate hyper_rustls;
11955/// # extern crate google_sql1_beta4 as sql1_beta4;
11956/// # async fn dox() {
11957/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11958///
11959/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11960/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11961/// #     .with_native_roots()
11962/// #     .unwrap()
11963/// #     .https_only()
11964/// #     .enable_http2()
11965/// #     .build();
11966///
11967/// # let executor = hyper_util::rt::TokioExecutor::new();
11968/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11969/// #     secret,
11970/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11971/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11972/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11973/// #     ),
11974/// # ).build().await.unwrap();
11975///
11976/// # let client = hyper_util::client::legacy::Client::builder(
11977/// #     hyper_util::rt::TokioExecutor::new()
11978/// # )
11979/// # .build(
11980/// #     hyper_rustls::HttpsConnectorBuilder::new()
11981/// #         .with_native_roots()
11982/// #         .unwrap()
11983/// #         .https_or_http()
11984/// #         .enable_http2()
11985/// #         .build()
11986/// # );
11987/// # let mut hub = SQLAdmin::new(client, auth);
11988/// // You can configure optional parameters by calling the respective setters at will, and
11989/// // execute the final call using `doit()`.
11990/// // Values shown here are possibly random and not representative !
11991/// let result = hub.instances().reset_ssl_config("project", "instance")
11992///              .doit().await;
11993/// # }
11994/// ```
11995pub struct InstanceResetSslConfigCall<'a, C>
11996where
11997    C: 'a,
11998{
11999    hub: &'a SQLAdmin<C>,
12000    _project: String,
12001    _instance: String,
12002    _delegate: Option<&'a mut dyn common::Delegate>,
12003    _additional_params: HashMap<String, String>,
12004    _scopes: BTreeSet<String>,
12005}
12006
12007impl<'a, C> common::CallBuilder for InstanceResetSslConfigCall<'a, C> {}
12008
12009impl<'a, C> InstanceResetSslConfigCall<'a, C>
12010where
12011    C: common::Connector,
12012{
12013    /// Perform the operation you have build so far.
12014    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12015        use std::borrow::Cow;
12016        use std::io::{Read, Seek};
12017
12018        use common::{url::Params, ToParts};
12019        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12020
12021        let mut dd = common::DefaultDelegate;
12022        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12023        dlg.begin(common::MethodInfo {
12024            id: "sql.instances.resetSslConfig",
12025            http_method: hyper::Method::POST,
12026        });
12027
12028        for &field in ["alt", "project", "instance"].iter() {
12029            if self._additional_params.contains_key(field) {
12030                dlg.finished(false);
12031                return Err(common::Error::FieldClash(field));
12032            }
12033        }
12034
12035        let mut params = Params::with_capacity(4 + self._additional_params.len());
12036        params.push("project", self._project);
12037        params.push("instance", self._instance);
12038
12039        params.extend(self._additional_params.iter());
12040
12041        params.push("alt", "json");
12042        let mut url = self.hub._base_url.clone()
12043            + "sql/v1beta4/projects/{project}/instances/{instance}/resetSslConfig";
12044        if self._scopes.is_empty() {
12045            self._scopes
12046                .insert(Scope::CloudPlatform.as_ref().to_string());
12047        }
12048
12049        #[allow(clippy::single_element_loop)]
12050        for &(find_this, param_name) in
12051            [("{project}", "project"), ("{instance}", "instance")].iter()
12052        {
12053            url = params.uri_replacement(url, param_name, find_this, false);
12054        }
12055        {
12056            let to_remove = ["instance", "project"];
12057            params.remove_params(&to_remove);
12058        }
12059
12060        let url = params.parse_with_url(&url);
12061
12062        loop {
12063            let token = match self
12064                .hub
12065                .auth
12066                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12067                .await
12068            {
12069                Ok(token) => token,
12070                Err(e) => match dlg.token(e) {
12071                    Ok(token) => token,
12072                    Err(e) => {
12073                        dlg.finished(false);
12074                        return Err(common::Error::MissingToken(e));
12075                    }
12076                },
12077            };
12078            let mut req_result = {
12079                let client = &self.hub.client;
12080                dlg.pre_request();
12081                let mut req_builder = hyper::Request::builder()
12082                    .method(hyper::Method::POST)
12083                    .uri(url.as_str())
12084                    .header(USER_AGENT, self.hub._user_agent.clone());
12085
12086                if let Some(token) = token.as_ref() {
12087                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12088                }
12089
12090                let request = req_builder
12091                    .header(CONTENT_LENGTH, 0_u64)
12092                    .body(common::to_body::<String>(None));
12093
12094                client.request(request.unwrap()).await
12095            };
12096
12097            match req_result {
12098                Err(err) => {
12099                    if let common::Retry::After(d) = dlg.http_error(&err) {
12100                        sleep(d).await;
12101                        continue;
12102                    }
12103                    dlg.finished(false);
12104                    return Err(common::Error::HttpError(err));
12105                }
12106                Ok(res) => {
12107                    let (mut parts, body) = res.into_parts();
12108                    let mut body = common::Body::new(body);
12109                    if !parts.status.is_success() {
12110                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12111                        let error = serde_json::from_str(&common::to_string(&bytes));
12112                        let response = common::to_response(parts, bytes.into());
12113
12114                        if let common::Retry::After(d) =
12115                            dlg.http_failure(&response, error.as_ref().ok())
12116                        {
12117                            sleep(d).await;
12118                            continue;
12119                        }
12120
12121                        dlg.finished(false);
12122
12123                        return Err(match error {
12124                            Ok(value) => common::Error::BadRequest(value),
12125                            _ => common::Error::Failure(response),
12126                        });
12127                    }
12128                    let response = {
12129                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12130                        let encoded = common::to_string(&bytes);
12131                        match serde_json::from_str(&encoded) {
12132                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12133                            Err(error) => {
12134                                dlg.response_json_decode_error(&encoded, &error);
12135                                return Err(common::Error::JsonDecodeError(
12136                                    encoded.to_string(),
12137                                    error,
12138                                ));
12139                            }
12140                        }
12141                    };
12142
12143                    dlg.finished(true);
12144                    return Ok(response);
12145                }
12146            }
12147        }
12148    }
12149
12150    /// Project ID of the project that contains the instance.
12151    ///
12152    /// Sets the *project* path property to the given value.
12153    ///
12154    /// Even though the property as already been set when instantiating this call,
12155    /// we provide this method for API completeness.
12156    pub fn project(mut self, new_value: &str) -> InstanceResetSslConfigCall<'a, C> {
12157        self._project = new_value.to_string();
12158        self
12159    }
12160    /// Cloud SQL instance ID. This does not include the project ID.
12161    ///
12162    /// Sets the *instance* path property to the given value.
12163    ///
12164    /// Even though the property as already been set when instantiating this call,
12165    /// we provide this method for API completeness.
12166    pub fn instance(mut self, new_value: &str) -> InstanceResetSslConfigCall<'a, C> {
12167        self._instance = new_value.to_string();
12168        self
12169    }
12170    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12171    /// while executing the actual API request.
12172    ///
12173    /// ````text
12174    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12175    /// ````
12176    ///
12177    /// Sets the *delegate* property to the given value.
12178    pub fn delegate(
12179        mut self,
12180        new_value: &'a mut dyn common::Delegate,
12181    ) -> InstanceResetSslConfigCall<'a, C> {
12182        self._delegate = Some(new_value);
12183        self
12184    }
12185
12186    /// Set any additional parameter of the query string used in the request.
12187    /// It should be used to set parameters which are not yet available through their own
12188    /// setters.
12189    ///
12190    /// Please note that this method must not be used to set any of the known parameters
12191    /// which have their own setter method. If done anyway, the request will fail.
12192    ///
12193    /// # Additional Parameters
12194    ///
12195    /// * *$.xgafv* (query-string) - V1 error format.
12196    /// * *access_token* (query-string) - OAuth access token.
12197    /// * *alt* (query-string) - Data format for response.
12198    /// * *callback* (query-string) - JSONP
12199    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12200    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12201    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12202    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12203    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12204    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12205    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12206    pub fn param<T>(mut self, name: T, value: T) -> InstanceResetSslConfigCall<'a, C>
12207    where
12208        T: AsRef<str>,
12209    {
12210        self._additional_params
12211            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12212        self
12213    }
12214
12215    /// Identifies the authorization scope for the method you are building.
12216    ///
12217    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12218    /// [`Scope::CloudPlatform`].
12219    ///
12220    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12221    /// tokens for more than one scope.
12222    ///
12223    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12224    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12225    /// sufficient, a read-write scope will do as well.
12226    pub fn add_scope<St>(mut self, scope: St) -> InstanceResetSslConfigCall<'a, C>
12227    where
12228        St: AsRef<str>,
12229    {
12230        self._scopes.insert(String::from(scope.as_ref()));
12231        self
12232    }
12233    /// Identifies the authorization scope(s) for the method you are building.
12234    ///
12235    /// See [`Self::add_scope()`] for details.
12236    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceResetSslConfigCall<'a, C>
12237    where
12238        I: IntoIterator<Item = St>,
12239        St: AsRef<str>,
12240    {
12241        self._scopes
12242            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12243        self
12244    }
12245
12246    /// Removes all scopes, and no default scope will be used either.
12247    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12248    /// for details).
12249    pub fn clear_scopes(mut self) -> InstanceResetSslConfigCall<'a, C> {
12250        self._scopes.clear();
12251        self
12252    }
12253}
12254
12255/// Restarts a Cloud SQL instance.
12256///
12257/// A builder for the *restart* method supported by a *instance* resource.
12258/// It is not used directly, but through a [`InstanceMethods`] instance.
12259///
12260/// # Example
12261///
12262/// Instantiate a resource method builder
12263///
12264/// ```test_harness,no_run
12265/// # extern crate hyper;
12266/// # extern crate hyper_rustls;
12267/// # extern crate google_sql1_beta4 as sql1_beta4;
12268/// # async fn dox() {
12269/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12270///
12271/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12272/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12273/// #     .with_native_roots()
12274/// #     .unwrap()
12275/// #     .https_only()
12276/// #     .enable_http2()
12277/// #     .build();
12278///
12279/// # let executor = hyper_util::rt::TokioExecutor::new();
12280/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12281/// #     secret,
12282/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12283/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12284/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12285/// #     ),
12286/// # ).build().await.unwrap();
12287///
12288/// # let client = hyper_util::client::legacy::Client::builder(
12289/// #     hyper_util::rt::TokioExecutor::new()
12290/// # )
12291/// # .build(
12292/// #     hyper_rustls::HttpsConnectorBuilder::new()
12293/// #         .with_native_roots()
12294/// #         .unwrap()
12295/// #         .https_or_http()
12296/// #         .enable_http2()
12297/// #         .build()
12298/// # );
12299/// # let mut hub = SQLAdmin::new(client, auth);
12300/// // You can configure optional parameters by calling the respective setters at will, and
12301/// // execute the final call using `doit()`.
12302/// // Values shown here are possibly random and not representative !
12303/// let result = hub.instances().restart("project", "instance")
12304///              .doit().await;
12305/// # }
12306/// ```
12307pub struct InstanceRestartCall<'a, C>
12308where
12309    C: 'a,
12310{
12311    hub: &'a SQLAdmin<C>,
12312    _project: String,
12313    _instance: String,
12314    _delegate: Option<&'a mut dyn common::Delegate>,
12315    _additional_params: HashMap<String, String>,
12316    _scopes: BTreeSet<String>,
12317}
12318
12319impl<'a, C> common::CallBuilder for InstanceRestartCall<'a, C> {}
12320
12321impl<'a, C> InstanceRestartCall<'a, C>
12322where
12323    C: common::Connector,
12324{
12325    /// Perform the operation you have build so far.
12326    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12327        use std::borrow::Cow;
12328        use std::io::{Read, Seek};
12329
12330        use common::{url::Params, ToParts};
12331        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12332
12333        let mut dd = common::DefaultDelegate;
12334        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12335        dlg.begin(common::MethodInfo {
12336            id: "sql.instances.restart",
12337            http_method: hyper::Method::POST,
12338        });
12339
12340        for &field in ["alt", "project", "instance"].iter() {
12341            if self._additional_params.contains_key(field) {
12342                dlg.finished(false);
12343                return Err(common::Error::FieldClash(field));
12344            }
12345        }
12346
12347        let mut params = Params::with_capacity(4 + self._additional_params.len());
12348        params.push("project", self._project);
12349        params.push("instance", self._instance);
12350
12351        params.extend(self._additional_params.iter());
12352
12353        params.push("alt", "json");
12354        let mut url = self.hub._base_url.clone()
12355            + "sql/v1beta4/projects/{project}/instances/{instance}/restart";
12356        if self._scopes.is_empty() {
12357            self._scopes
12358                .insert(Scope::CloudPlatform.as_ref().to_string());
12359        }
12360
12361        #[allow(clippy::single_element_loop)]
12362        for &(find_this, param_name) in
12363            [("{project}", "project"), ("{instance}", "instance")].iter()
12364        {
12365            url = params.uri_replacement(url, param_name, find_this, false);
12366        }
12367        {
12368            let to_remove = ["instance", "project"];
12369            params.remove_params(&to_remove);
12370        }
12371
12372        let url = params.parse_with_url(&url);
12373
12374        loop {
12375            let token = match self
12376                .hub
12377                .auth
12378                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12379                .await
12380            {
12381                Ok(token) => token,
12382                Err(e) => match dlg.token(e) {
12383                    Ok(token) => token,
12384                    Err(e) => {
12385                        dlg.finished(false);
12386                        return Err(common::Error::MissingToken(e));
12387                    }
12388                },
12389            };
12390            let mut req_result = {
12391                let client = &self.hub.client;
12392                dlg.pre_request();
12393                let mut req_builder = hyper::Request::builder()
12394                    .method(hyper::Method::POST)
12395                    .uri(url.as_str())
12396                    .header(USER_AGENT, self.hub._user_agent.clone());
12397
12398                if let Some(token) = token.as_ref() {
12399                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12400                }
12401
12402                let request = req_builder
12403                    .header(CONTENT_LENGTH, 0_u64)
12404                    .body(common::to_body::<String>(None));
12405
12406                client.request(request.unwrap()).await
12407            };
12408
12409            match req_result {
12410                Err(err) => {
12411                    if let common::Retry::After(d) = dlg.http_error(&err) {
12412                        sleep(d).await;
12413                        continue;
12414                    }
12415                    dlg.finished(false);
12416                    return Err(common::Error::HttpError(err));
12417                }
12418                Ok(res) => {
12419                    let (mut parts, body) = res.into_parts();
12420                    let mut body = common::Body::new(body);
12421                    if !parts.status.is_success() {
12422                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12423                        let error = serde_json::from_str(&common::to_string(&bytes));
12424                        let response = common::to_response(parts, bytes.into());
12425
12426                        if let common::Retry::After(d) =
12427                            dlg.http_failure(&response, error.as_ref().ok())
12428                        {
12429                            sleep(d).await;
12430                            continue;
12431                        }
12432
12433                        dlg.finished(false);
12434
12435                        return Err(match error {
12436                            Ok(value) => common::Error::BadRequest(value),
12437                            _ => common::Error::Failure(response),
12438                        });
12439                    }
12440                    let response = {
12441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12442                        let encoded = common::to_string(&bytes);
12443                        match serde_json::from_str(&encoded) {
12444                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12445                            Err(error) => {
12446                                dlg.response_json_decode_error(&encoded, &error);
12447                                return Err(common::Error::JsonDecodeError(
12448                                    encoded.to_string(),
12449                                    error,
12450                                ));
12451                            }
12452                        }
12453                    };
12454
12455                    dlg.finished(true);
12456                    return Ok(response);
12457                }
12458            }
12459        }
12460    }
12461
12462    /// Project ID of the project that contains the instance to be restarted.
12463    ///
12464    /// Sets the *project* path property to the given value.
12465    ///
12466    /// Even though the property as already been set when instantiating this call,
12467    /// we provide this method for API completeness.
12468    pub fn project(mut self, new_value: &str) -> InstanceRestartCall<'a, C> {
12469        self._project = new_value.to_string();
12470        self
12471    }
12472    /// Cloud SQL instance ID. This does not include the project ID.
12473    ///
12474    /// Sets the *instance* path property to the given value.
12475    ///
12476    /// Even though the property as already been set when instantiating this call,
12477    /// we provide this method for API completeness.
12478    pub fn instance(mut self, new_value: &str) -> InstanceRestartCall<'a, C> {
12479        self._instance = new_value.to_string();
12480        self
12481    }
12482    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12483    /// while executing the actual API request.
12484    ///
12485    /// ````text
12486    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12487    /// ````
12488    ///
12489    /// Sets the *delegate* property to the given value.
12490    pub fn delegate(
12491        mut self,
12492        new_value: &'a mut dyn common::Delegate,
12493    ) -> InstanceRestartCall<'a, C> {
12494        self._delegate = Some(new_value);
12495        self
12496    }
12497
12498    /// Set any additional parameter of the query string used in the request.
12499    /// It should be used to set parameters which are not yet available through their own
12500    /// setters.
12501    ///
12502    /// Please note that this method must not be used to set any of the known parameters
12503    /// which have their own setter method. If done anyway, the request will fail.
12504    ///
12505    /// # Additional Parameters
12506    ///
12507    /// * *$.xgafv* (query-string) - V1 error format.
12508    /// * *access_token* (query-string) - OAuth access token.
12509    /// * *alt* (query-string) - Data format for response.
12510    /// * *callback* (query-string) - JSONP
12511    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12512    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12513    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12514    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12515    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12516    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12517    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12518    pub fn param<T>(mut self, name: T, value: T) -> InstanceRestartCall<'a, C>
12519    where
12520        T: AsRef<str>,
12521    {
12522        self._additional_params
12523            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12524        self
12525    }
12526
12527    /// Identifies the authorization scope for the method you are building.
12528    ///
12529    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12530    /// [`Scope::CloudPlatform`].
12531    ///
12532    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12533    /// tokens for more than one scope.
12534    ///
12535    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12536    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12537    /// sufficient, a read-write scope will do as well.
12538    pub fn add_scope<St>(mut self, scope: St) -> InstanceRestartCall<'a, C>
12539    where
12540        St: AsRef<str>,
12541    {
12542        self._scopes.insert(String::from(scope.as_ref()));
12543        self
12544    }
12545    /// Identifies the authorization scope(s) for the method you are building.
12546    ///
12547    /// See [`Self::add_scope()`] for details.
12548    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceRestartCall<'a, C>
12549    where
12550        I: IntoIterator<Item = St>,
12551        St: AsRef<str>,
12552    {
12553        self._scopes
12554            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12555        self
12556    }
12557
12558    /// Removes all scopes, and no default scope will be used either.
12559    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12560    /// for details).
12561    pub fn clear_scopes(mut self) -> InstanceRestartCall<'a, C> {
12562        self._scopes.clear();
12563        self
12564    }
12565}
12566
12567/// Restores a backup of a Cloud SQL instance. Using this operation might cause
12568/// your instance to restart.
12569///
12570/// A builder for the *restoreBackup* method supported by a *instance* resource.
12571/// It is not used directly, but through a [`InstanceMethods`] instance.
12572///
12573/// # Example
12574///
12575/// Instantiate a resource method builder
12576///
12577/// ```test_harness,no_run
12578/// # extern crate hyper;
12579/// # extern crate hyper_rustls;
12580/// # extern crate google_sql1_beta4 as sql1_beta4;
12581/// use sql1_beta4::api::InstancesRestoreBackupRequest;
12582/// # async fn dox() {
12583/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12584///
12585/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12586/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12587/// #     .with_native_roots()
12588/// #     .unwrap()
12589/// #     .https_only()
12590/// #     .enable_http2()
12591/// #     .build();
12592///
12593/// # let executor = hyper_util::rt::TokioExecutor::new();
12594/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12595/// #     secret,
12596/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12597/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12598/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12599/// #     ),
12600/// # ).build().await.unwrap();
12601///
12602/// # let client = hyper_util::client::legacy::Client::builder(
12603/// #     hyper_util::rt::TokioExecutor::new()
12604/// # )
12605/// # .build(
12606/// #     hyper_rustls::HttpsConnectorBuilder::new()
12607/// #         .with_native_roots()
12608/// #         .unwrap()
12609/// #         .https_or_http()
12610/// #         .enable_http2()
12611/// #         .build()
12612/// # );
12613/// # let mut hub = SQLAdmin::new(client, auth);
12614/// // As the method needs a request, you would usually fill it with the desired information
12615/// // into the respective structure. Some of the parts shown here might not be applicable !
12616/// // Values shown here are possibly random and not representative !
12617/// let mut req = InstancesRestoreBackupRequest::default();
12618///
12619/// // You can configure optional parameters by calling the respective setters at will, and
12620/// // execute the final call using `doit()`.
12621/// // Values shown here are possibly random and not representative !
12622/// let result = hub.instances().restore_backup(req, "project", "instance")
12623///              .doit().await;
12624/// # }
12625/// ```
12626pub struct InstanceRestoreBackupCall<'a, C>
12627where
12628    C: 'a,
12629{
12630    hub: &'a SQLAdmin<C>,
12631    _request: InstancesRestoreBackupRequest,
12632    _project: String,
12633    _instance: String,
12634    _delegate: Option<&'a mut dyn common::Delegate>,
12635    _additional_params: HashMap<String, String>,
12636    _scopes: BTreeSet<String>,
12637}
12638
12639impl<'a, C> common::CallBuilder for InstanceRestoreBackupCall<'a, C> {}
12640
12641impl<'a, C> InstanceRestoreBackupCall<'a, C>
12642where
12643    C: common::Connector,
12644{
12645    /// Perform the operation you have build so far.
12646    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12647        use std::borrow::Cow;
12648        use std::io::{Read, Seek};
12649
12650        use common::{url::Params, ToParts};
12651        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12652
12653        let mut dd = common::DefaultDelegate;
12654        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12655        dlg.begin(common::MethodInfo {
12656            id: "sql.instances.restoreBackup",
12657            http_method: hyper::Method::POST,
12658        });
12659
12660        for &field in ["alt", "project", "instance"].iter() {
12661            if self._additional_params.contains_key(field) {
12662                dlg.finished(false);
12663                return Err(common::Error::FieldClash(field));
12664            }
12665        }
12666
12667        let mut params = Params::with_capacity(5 + self._additional_params.len());
12668        params.push("project", self._project);
12669        params.push("instance", self._instance);
12670
12671        params.extend(self._additional_params.iter());
12672
12673        params.push("alt", "json");
12674        let mut url = self.hub._base_url.clone()
12675            + "sql/v1beta4/projects/{project}/instances/{instance}/restoreBackup";
12676        if self._scopes.is_empty() {
12677            self._scopes
12678                .insert(Scope::CloudPlatform.as_ref().to_string());
12679        }
12680
12681        #[allow(clippy::single_element_loop)]
12682        for &(find_this, param_name) in
12683            [("{project}", "project"), ("{instance}", "instance")].iter()
12684        {
12685            url = params.uri_replacement(url, param_name, find_this, false);
12686        }
12687        {
12688            let to_remove = ["instance", "project"];
12689            params.remove_params(&to_remove);
12690        }
12691
12692        let url = params.parse_with_url(&url);
12693
12694        let mut json_mime_type = mime::APPLICATION_JSON;
12695        let mut request_value_reader = {
12696            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12697            common::remove_json_null_values(&mut value);
12698            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12699            serde_json::to_writer(&mut dst, &value).unwrap();
12700            dst
12701        };
12702        let request_size = request_value_reader
12703            .seek(std::io::SeekFrom::End(0))
12704            .unwrap();
12705        request_value_reader
12706            .seek(std::io::SeekFrom::Start(0))
12707            .unwrap();
12708
12709        loop {
12710            let token = match self
12711                .hub
12712                .auth
12713                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12714                .await
12715            {
12716                Ok(token) => token,
12717                Err(e) => match dlg.token(e) {
12718                    Ok(token) => token,
12719                    Err(e) => {
12720                        dlg.finished(false);
12721                        return Err(common::Error::MissingToken(e));
12722                    }
12723                },
12724            };
12725            request_value_reader
12726                .seek(std::io::SeekFrom::Start(0))
12727                .unwrap();
12728            let mut req_result = {
12729                let client = &self.hub.client;
12730                dlg.pre_request();
12731                let mut req_builder = hyper::Request::builder()
12732                    .method(hyper::Method::POST)
12733                    .uri(url.as_str())
12734                    .header(USER_AGENT, self.hub._user_agent.clone());
12735
12736                if let Some(token) = token.as_ref() {
12737                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12738                }
12739
12740                let request = req_builder
12741                    .header(CONTENT_TYPE, json_mime_type.to_string())
12742                    .header(CONTENT_LENGTH, request_size as u64)
12743                    .body(common::to_body(
12744                        request_value_reader.get_ref().clone().into(),
12745                    ));
12746
12747                client.request(request.unwrap()).await
12748            };
12749
12750            match req_result {
12751                Err(err) => {
12752                    if let common::Retry::After(d) = dlg.http_error(&err) {
12753                        sleep(d).await;
12754                        continue;
12755                    }
12756                    dlg.finished(false);
12757                    return Err(common::Error::HttpError(err));
12758                }
12759                Ok(res) => {
12760                    let (mut parts, body) = res.into_parts();
12761                    let mut body = common::Body::new(body);
12762                    if !parts.status.is_success() {
12763                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12764                        let error = serde_json::from_str(&common::to_string(&bytes));
12765                        let response = common::to_response(parts, bytes.into());
12766
12767                        if let common::Retry::After(d) =
12768                            dlg.http_failure(&response, error.as_ref().ok())
12769                        {
12770                            sleep(d).await;
12771                            continue;
12772                        }
12773
12774                        dlg.finished(false);
12775
12776                        return Err(match error {
12777                            Ok(value) => common::Error::BadRequest(value),
12778                            _ => common::Error::Failure(response),
12779                        });
12780                    }
12781                    let response = {
12782                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12783                        let encoded = common::to_string(&bytes);
12784                        match serde_json::from_str(&encoded) {
12785                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12786                            Err(error) => {
12787                                dlg.response_json_decode_error(&encoded, &error);
12788                                return Err(common::Error::JsonDecodeError(
12789                                    encoded.to_string(),
12790                                    error,
12791                                ));
12792                            }
12793                        }
12794                    };
12795
12796                    dlg.finished(true);
12797                    return Ok(response);
12798                }
12799            }
12800        }
12801    }
12802
12803    ///
12804    /// Sets the *request* property to the given value.
12805    ///
12806    /// Even though the property as already been set when instantiating this call,
12807    /// we provide this method for API completeness.
12808    pub fn request(
12809        mut self,
12810        new_value: InstancesRestoreBackupRequest,
12811    ) -> InstanceRestoreBackupCall<'a, C> {
12812        self._request = new_value;
12813        self
12814    }
12815    /// Project ID of the project that contains the instance.
12816    ///
12817    /// Sets the *project* path property to the given value.
12818    ///
12819    /// Even though the property as already been set when instantiating this call,
12820    /// we provide this method for API completeness.
12821    pub fn project(mut self, new_value: &str) -> InstanceRestoreBackupCall<'a, C> {
12822        self._project = new_value.to_string();
12823        self
12824    }
12825    /// Cloud SQL instance ID. This does not include the project ID.
12826    ///
12827    /// Sets the *instance* path property to the given value.
12828    ///
12829    /// Even though the property as already been set when instantiating this call,
12830    /// we provide this method for API completeness.
12831    pub fn instance(mut self, new_value: &str) -> InstanceRestoreBackupCall<'a, C> {
12832        self._instance = new_value.to_string();
12833        self
12834    }
12835    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12836    /// while executing the actual API request.
12837    ///
12838    /// ````text
12839    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12840    /// ````
12841    ///
12842    /// Sets the *delegate* property to the given value.
12843    pub fn delegate(
12844        mut self,
12845        new_value: &'a mut dyn common::Delegate,
12846    ) -> InstanceRestoreBackupCall<'a, C> {
12847        self._delegate = Some(new_value);
12848        self
12849    }
12850
12851    /// Set any additional parameter of the query string used in the request.
12852    /// It should be used to set parameters which are not yet available through their own
12853    /// setters.
12854    ///
12855    /// Please note that this method must not be used to set any of the known parameters
12856    /// which have their own setter method. If done anyway, the request will fail.
12857    ///
12858    /// # Additional Parameters
12859    ///
12860    /// * *$.xgafv* (query-string) - V1 error format.
12861    /// * *access_token* (query-string) - OAuth access token.
12862    /// * *alt* (query-string) - Data format for response.
12863    /// * *callback* (query-string) - JSONP
12864    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12865    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12866    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12867    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12868    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12869    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12870    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12871    pub fn param<T>(mut self, name: T, value: T) -> InstanceRestoreBackupCall<'a, C>
12872    where
12873        T: AsRef<str>,
12874    {
12875        self._additional_params
12876            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12877        self
12878    }
12879
12880    /// Identifies the authorization scope for the method you are building.
12881    ///
12882    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12883    /// [`Scope::CloudPlatform`].
12884    ///
12885    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12886    /// tokens for more than one scope.
12887    ///
12888    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12889    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12890    /// sufficient, a read-write scope will do as well.
12891    pub fn add_scope<St>(mut self, scope: St) -> InstanceRestoreBackupCall<'a, C>
12892    where
12893        St: AsRef<str>,
12894    {
12895        self._scopes.insert(String::from(scope.as_ref()));
12896        self
12897    }
12898    /// Identifies the authorization scope(s) for the method you are building.
12899    ///
12900    /// See [`Self::add_scope()`] for details.
12901    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceRestoreBackupCall<'a, C>
12902    where
12903        I: IntoIterator<Item = St>,
12904        St: AsRef<str>,
12905    {
12906        self._scopes
12907            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12908        self
12909    }
12910
12911    /// Removes all scopes, and no default scope will be used either.
12912    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12913    /// for details).
12914    pub fn clear_scopes(mut self) -> InstanceRestoreBackupCall<'a, C> {
12915        self._scopes.clear();
12916        self
12917    }
12918}
12919
12920/// Rotates the server certificate to one signed by the Certificate Authority
12921/// (CA) version previously added with the addServerCA method.
12922///
12923/// A builder for the *rotateServerCa* method supported by a *instance* resource.
12924/// It is not used directly, but through a [`InstanceMethods`] instance.
12925///
12926/// # Example
12927///
12928/// Instantiate a resource method builder
12929///
12930/// ```test_harness,no_run
12931/// # extern crate hyper;
12932/// # extern crate hyper_rustls;
12933/// # extern crate google_sql1_beta4 as sql1_beta4;
12934/// use sql1_beta4::api::InstancesRotateServerCaRequest;
12935/// # async fn dox() {
12936/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12937///
12938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12939/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12940/// #     .with_native_roots()
12941/// #     .unwrap()
12942/// #     .https_only()
12943/// #     .enable_http2()
12944/// #     .build();
12945///
12946/// # let executor = hyper_util::rt::TokioExecutor::new();
12947/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12948/// #     secret,
12949/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12950/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12951/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12952/// #     ),
12953/// # ).build().await.unwrap();
12954///
12955/// # let client = hyper_util::client::legacy::Client::builder(
12956/// #     hyper_util::rt::TokioExecutor::new()
12957/// # )
12958/// # .build(
12959/// #     hyper_rustls::HttpsConnectorBuilder::new()
12960/// #         .with_native_roots()
12961/// #         .unwrap()
12962/// #         .https_or_http()
12963/// #         .enable_http2()
12964/// #         .build()
12965/// # );
12966/// # let mut hub = SQLAdmin::new(client, auth);
12967/// // As the method needs a request, you would usually fill it with the desired information
12968/// // into the respective structure. Some of the parts shown here might not be applicable !
12969/// // Values shown here are possibly random and not representative !
12970/// let mut req = InstancesRotateServerCaRequest::default();
12971///
12972/// // You can configure optional parameters by calling the respective setters at will, and
12973/// // execute the final call using `doit()`.
12974/// // Values shown here are possibly random and not representative !
12975/// let result = hub.instances().rotate_server_ca(req, "project", "instance")
12976///              .doit().await;
12977/// # }
12978/// ```
12979pub struct InstanceRotateServerCaCall<'a, C>
12980where
12981    C: 'a,
12982{
12983    hub: &'a SQLAdmin<C>,
12984    _request: InstancesRotateServerCaRequest,
12985    _project: String,
12986    _instance: String,
12987    _delegate: Option<&'a mut dyn common::Delegate>,
12988    _additional_params: HashMap<String, String>,
12989    _scopes: BTreeSet<String>,
12990}
12991
12992impl<'a, C> common::CallBuilder for InstanceRotateServerCaCall<'a, C> {}
12993
12994impl<'a, C> InstanceRotateServerCaCall<'a, C>
12995where
12996    C: common::Connector,
12997{
12998    /// Perform the operation you have build so far.
12999    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13000        use std::borrow::Cow;
13001        use std::io::{Read, Seek};
13002
13003        use common::{url::Params, ToParts};
13004        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13005
13006        let mut dd = common::DefaultDelegate;
13007        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13008        dlg.begin(common::MethodInfo {
13009            id: "sql.instances.rotateServerCa",
13010            http_method: hyper::Method::POST,
13011        });
13012
13013        for &field in ["alt", "project", "instance"].iter() {
13014            if self._additional_params.contains_key(field) {
13015                dlg.finished(false);
13016                return Err(common::Error::FieldClash(field));
13017            }
13018        }
13019
13020        let mut params = Params::with_capacity(5 + self._additional_params.len());
13021        params.push("project", self._project);
13022        params.push("instance", self._instance);
13023
13024        params.extend(self._additional_params.iter());
13025
13026        params.push("alt", "json");
13027        let mut url = self.hub._base_url.clone()
13028            + "sql/v1beta4/projects/{project}/instances/{instance}/rotateServerCa";
13029        if self._scopes.is_empty() {
13030            self._scopes
13031                .insert(Scope::CloudPlatform.as_ref().to_string());
13032        }
13033
13034        #[allow(clippy::single_element_loop)]
13035        for &(find_this, param_name) in
13036            [("{project}", "project"), ("{instance}", "instance")].iter()
13037        {
13038            url = params.uri_replacement(url, param_name, find_this, false);
13039        }
13040        {
13041            let to_remove = ["instance", "project"];
13042            params.remove_params(&to_remove);
13043        }
13044
13045        let url = params.parse_with_url(&url);
13046
13047        let mut json_mime_type = mime::APPLICATION_JSON;
13048        let mut request_value_reader = {
13049            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13050            common::remove_json_null_values(&mut value);
13051            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13052            serde_json::to_writer(&mut dst, &value).unwrap();
13053            dst
13054        };
13055        let request_size = request_value_reader
13056            .seek(std::io::SeekFrom::End(0))
13057            .unwrap();
13058        request_value_reader
13059            .seek(std::io::SeekFrom::Start(0))
13060            .unwrap();
13061
13062        loop {
13063            let token = match self
13064                .hub
13065                .auth
13066                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13067                .await
13068            {
13069                Ok(token) => token,
13070                Err(e) => match dlg.token(e) {
13071                    Ok(token) => token,
13072                    Err(e) => {
13073                        dlg.finished(false);
13074                        return Err(common::Error::MissingToken(e));
13075                    }
13076                },
13077            };
13078            request_value_reader
13079                .seek(std::io::SeekFrom::Start(0))
13080                .unwrap();
13081            let mut req_result = {
13082                let client = &self.hub.client;
13083                dlg.pre_request();
13084                let mut req_builder = hyper::Request::builder()
13085                    .method(hyper::Method::POST)
13086                    .uri(url.as_str())
13087                    .header(USER_AGENT, self.hub._user_agent.clone());
13088
13089                if let Some(token) = token.as_ref() {
13090                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13091                }
13092
13093                let request = req_builder
13094                    .header(CONTENT_TYPE, json_mime_type.to_string())
13095                    .header(CONTENT_LENGTH, request_size as u64)
13096                    .body(common::to_body(
13097                        request_value_reader.get_ref().clone().into(),
13098                    ));
13099
13100                client.request(request.unwrap()).await
13101            };
13102
13103            match req_result {
13104                Err(err) => {
13105                    if let common::Retry::After(d) = dlg.http_error(&err) {
13106                        sleep(d).await;
13107                        continue;
13108                    }
13109                    dlg.finished(false);
13110                    return Err(common::Error::HttpError(err));
13111                }
13112                Ok(res) => {
13113                    let (mut parts, body) = res.into_parts();
13114                    let mut body = common::Body::new(body);
13115                    if !parts.status.is_success() {
13116                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13117                        let error = serde_json::from_str(&common::to_string(&bytes));
13118                        let response = common::to_response(parts, bytes.into());
13119
13120                        if let common::Retry::After(d) =
13121                            dlg.http_failure(&response, error.as_ref().ok())
13122                        {
13123                            sleep(d).await;
13124                            continue;
13125                        }
13126
13127                        dlg.finished(false);
13128
13129                        return Err(match error {
13130                            Ok(value) => common::Error::BadRequest(value),
13131                            _ => common::Error::Failure(response),
13132                        });
13133                    }
13134                    let response = {
13135                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13136                        let encoded = common::to_string(&bytes);
13137                        match serde_json::from_str(&encoded) {
13138                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13139                            Err(error) => {
13140                                dlg.response_json_decode_error(&encoded, &error);
13141                                return Err(common::Error::JsonDecodeError(
13142                                    encoded.to_string(),
13143                                    error,
13144                                ));
13145                            }
13146                        }
13147                    };
13148
13149                    dlg.finished(true);
13150                    return Ok(response);
13151                }
13152            }
13153        }
13154    }
13155
13156    ///
13157    /// Sets the *request* property to the given value.
13158    ///
13159    /// Even though the property as already been set when instantiating this call,
13160    /// we provide this method for API completeness.
13161    pub fn request(
13162        mut self,
13163        new_value: InstancesRotateServerCaRequest,
13164    ) -> InstanceRotateServerCaCall<'a, C> {
13165        self._request = new_value;
13166        self
13167    }
13168    /// Project ID of the project that contains the instance.
13169    ///
13170    /// Sets the *project* path property to the given value.
13171    ///
13172    /// Even though the property as already been set when instantiating this call,
13173    /// we provide this method for API completeness.
13174    pub fn project(mut self, new_value: &str) -> InstanceRotateServerCaCall<'a, C> {
13175        self._project = new_value.to_string();
13176        self
13177    }
13178    /// Cloud SQL instance ID. This does not include the project ID.
13179    ///
13180    /// Sets the *instance* path property to the given value.
13181    ///
13182    /// Even though the property as already been set when instantiating this call,
13183    /// we provide this method for API completeness.
13184    pub fn instance(mut self, new_value: &str) -> InstanceRotateServerCaCall<'a, C> {
13185        self._instance = new_value.to_string();
13186        self
13187    }
13188    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13189    /// while executing the actual API request.
13190    ///
13191    /// ````text
13192    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13193    /// ````
13194    ///
13195    /// Sets the *delegate* property to the given value.
13196    pub fn delegate(
13197        mut self,
13198        new_value: &'a mut dyn common::Delegate,
13199    ) -> InstanceRotateServerCaCall<'a, C> {
13200        self._delegate = Some(new_value);
13201        self
13202    }
13203
13204    /// Set any additional parameter of the query string used in the request.
13205    /// It should be used to set parameters which are not yet available through their own
13206    /// setters.
13207    ///
13208    /// Please note that this method must not be used to set any of the known parameters
13209    /// which have their own setter method. If done anyway, the request will fail.
13210    ///
13211    /// # Additional Parameters
13212    ///
13213    /// * *$.xgafv* (query-string) - V1 error format.
13214    /// * *access_token* (query-string) - OAuth access token.
13215    /// * *alt* (query-string) - Data format for response.
13216    /// * *callback* (query-string) - JSONP
13217    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13218    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13219    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13220    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13221    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13222    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13223    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13224    pub fn param<T>(mut self, name: T, value: T) -> InstanceRotateServerCaCall<'a, C>
13225    where
13226        T: AsRef<str>,
13227    {
13228        self._additional_params
13229            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13230        self
13231    }
13232
13233    /// Identifies the authorization scope for the method you are building.
13234    ///
13235    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13236    /// [`Scope::CloudPlatform`].
13237    ///
13238    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13239    /// tokens for more than one scope.
13240    ///
13241    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13242    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13243    /// sufficient, a read-write scope will do as well.
13244    pub fn add_scope<St>(mut self, scope: St) -> InstanceRotateServerCaCall<'a, C>
13245    where
13246        St: AsRef<str>,
13247    {
13248        self._scopes.insert(String::from(scope.as_ref()));
13249        self
13250    }
13251    /// Identifies the authorization scope(s) for the method you are building.
13252    ///
13253    /// See [`Self::add_scope()`] for details.
13254    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceRotateServerCaCall<'a, C>
13255    where
13256        I: IntoIterator<Item = St>,
13257        St: AsRef<str>,
13258    {
13259        self._scopes
13260            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13261        self
13262    }
13263
13264    /// Removes all scopes, and no default scope will be used either.
13265    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13266    /// for details).
13267    pub fn clear_scopes(mut self) -> InstanceRotateServerCaCall<'a, C> {
13268        self._scopes.clear();
13269        self
13270    }
13271}
13272
13273/// Starts the replication in the read replica instance.
13274///
13275/// A builder for the *startReplica* method supported by a *instance* resource.
13276/// It is not used directly, but through a [`InstanceMethods`] instance.
13277///
13278/// # Example
13279///
13280/// Instantiate a resource method builder
13281///
13282/// ```test_harness,no_run
13283/// # extern crate hyper;
13284/// # extern crate hyper_rustls;
13285/// # extern crate google_sql1_beta4 as sql1_beta4;
13286/// # async fn dox() {
13287/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13288///
13289/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13290/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13291/// #     .with_native_roots()
13292/// #     .unwrap()
13293/// #     .https_only()
13294/// #     .enable_http2()
13295/// #     .build();
13296///
13297/// # let executor = hyper_util::rt::TokioExecutor::new();
13298/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13299/// #     secret,
13300/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13301/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13302/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13303/// #     ),
13304/// # ).build().await.unwrap();
13305///
13306/// # let client = hyper_util::client::legacy::Client::builder(
13307/// #     hyper_util::rt::TokioExecutor::new()
13308/// # )
13309/// # .build(
13310/// #     hyper_rustls::HttpsConnectorBuilder::new()
13311/// #         .with_native_roots()
13312/// #         .unwrap()
13313/// #         .https_or_http()
13314/// #         .enable_http2()
13315/// #         .build()
13316/// # );
13317/// # let mut hub = SQLAdmin::new(client, auth);
13318/// // You can configure optional parameters by calling the respective setters at will, and
13319/// // execute the final call using `doit()`.
13320/// // Values shown here are possibly random and not representative !
13321/// let result = hub.instances().start_replica("project", "instance")
13322///              .doit().await;
13323/// # }
13324/// ```
13325pub struct InstanceStartReplicaCall<'a, C>
13326where
13327    C: 'a,
13328{
13329    hub: &'a SQLAdmin<C>,
13330    _project: String,
13331    _instance: String,
13332    _delegate: Option<&'a mut dyn common::Delegate>,
13333    _additional_params: HashMap<String, String>,
13334    _scopes: BTreeSet<String>,
13335}
13336
13337impl<'a, C> common::CallBuilder for InstanceStartReplicaCall<'a, C> {}
13338
13339impl<'a, C> InstanceStartReplicaCall<'a, C>
13340where
13341    C: common::Connector,
13342{
13343    /// Perform the operation you have build so far.
13344    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13345        use std::borrow::Cow;
13346        use std::io::{Read, Seek};
13347
13348        use common::{url::Params, ToParts};
13349        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13350
13351        let mut dd = common::DefaultDelegate;
13352        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13353        dlg.begin(common::MethodInfo {
13354            id: "sql.instances.startReplica",
13355            http_method: hyper::Method::POST,
13356        });
13357
13358        for &field in ["alt", "project", "instance"].iter() {
13359            if self._additional_params.contains_key(field) {
13360                dlg.finished(false);
13361                return Err(common::Error::FieldClash(field));
13362            }
13363        }
13364
13365        let mut params = Params::with_capacity(4 + self._additional_params.len());
13366        params.push("project", self._project);
13367        params.push("instance", self._instance);
13368
13369        params.extend(self._additional_params.iter());
13370
13371        params.push("alt", "json");
13372        let mut url = self.hub._base_url.clone()
13373            + "sql/v1beta4/projects/{project}/instances/{instance}/startReplica";
13374        if self._scopes.is_empty() {
13375            self._scopes
13376                .insert(Scope::CloudPlatform.as_ref().to_string());
13377        }
13378
13379        #[allow(clippy::single_element_loop)]
13380        for &(find_this, param_name) in
13381            [("{project}", "project"), ("{instance}", "instance")].iter()
13382        {
13383            url = params.uri_replacement(url, param_name, find_this, false);
13384        }
13385        {
13386            let to_remove = ["instance", "project"];
13387            params.remove_params(&to_remove);
13388        }
13389
13390        let url = params.parse_with_url(&url);
13391
13392        loop {
13393            let token = match self
13394                .hub
13395                .auth
13396                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13397                .await
13398            {
13399                Ok(token) => token,
13400                Err(e) => match dlg.token(e) {
13401                    Ok(token) => token,
13402                    Err(e) => {
13403                        dlg.finished(false);
13404                        return Err(common::Error::MissingToken(e));
13405                    }
13406                },
13407            };
13408            let mut req_result = {
13409                let client = &self.hub.client;
13410                dlg.pre_request();
13411                let mut req_builder = hyper::Request::builder()
13412                    .method(hyper::Method::POST)
13413                    .uri(url.as_str())
13414                    .header(USER_AGENT, self.hub._user_agent.clone());
13415
13416                if let Some(token) = token.as_ref() {
13417                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13418                }
13419
13420                let request = req_builder
13421                    .header(CONTENT_LENGTH, 0_u64)
13422                    .body(common::to_body::<String>(None));
13423
13424                client.request(request.unwrap()).await
13425            };
13426
13427            match req_result {
13428                Err(err) => {
13429                    if let common::Retry::After(d) = dlg.http_error(&err) {
13430                        sleep(d).await;
13431                        continue;
13432                    }
13433                    dlg.finished(false);
13434                    return Err(common::Error::HttpError(err));
13435                }
13436                Ok(res) => {
13437                    let (mut parts, body) = res.into_parts();
13438                    let mut body = common::Body::new(body);
13439                    if !parts.status.is_success() {
13440                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13441                        let error = serde_json::from_str(&common::to_string(&bytes));
13442                        let response = common::to_response(parts, bytes.into());
13443
13444                        if let common::Retry::After(d) =
13445                            dlg.http_failure(&response, error.as_ref().ok())
13446                        {
13447                            sleep(d).await;
13448                            continue;
13449                        }
13450
13451                        dlg.finished(false);
13452
13453                        return Err(match error {
13454                            Ok(value) => common::Error::BadRequest(value),
13455                            _ => common::Error::Failure(response),
13456                        });
13457                    }
13458                    let response = {
13459                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13460                        let encoded = common::to_string(&bytes);
13461                        match serde_json::from_str(&encoded) {
13462                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13463                            Err(error) => {
13464                                dlg.response_json_decode_error(&encoded, &error);
13465                                return Err(common::Error::JsonDecodeError(
13466                                    encoded.to_string(),
13467                                    error,
13468                                ));
13469                            }
13470                        }
13471                    };
13472
13473                    dlg.finished(true);
13474                    return Ok(response);
13475                }
13476            }
13477        }
13478    }
13479
13480    /// ID of the project that contains the read replica.
13481    ///
13482    /// Sets the *project* path property to the given value.
13483    ///
13484    /// Even though the property as already been set when instantiating this call,
13485    /// we provide this method for API completeness.
13486    pub fn project(mut self, new_value: &str) -> InstanceStartReplicaCall<'a, C> {
13487        self._project = new_value.to_string();
13488        self
13489    }
13490    /// Cloud SQL read replica instance name.
13491    ///
13492    /// Sets the *instance* path property to the given value.
13493    ///
13494    /// Even though the property as already been set when instantiating this call,
13495    /// we provide this method for API completeness.
13496    pub fn instance(mut self, new_value: &str) -> InstanceStartReplicaCall<'a, C> {
13497        self._instance = new_value.to_string();
13498        self
13499    }
13500    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13501    /// while executing the actual API request.
13502    ///
13503    /// ````text
13504    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13505    /// ````
13506    ///
13507    /// Sets the *delegate* property to the given value.
13508    pub fn delegate(
13509        mut self,
13510        new_value: &'a mut dyn common::Delegate,
13511    ) -> InstanceStartReplicaCall<'a, C> {
13512        self._delegate = Some(new_value);
13513        self
13514    }
13515
13516    /// Set any additional parameter of the query string used in the request.
13517    /// It should be used to set parameters which are not yet available through their own
13518    /// setters.
13519    ///
13520    /// Please note that this method must not be used to set any of the known parameters
13521    /// which have their own setter method. If done anyway, the request will fail.
13522    ///
13523    /// # Additional Parameters
13524    ///
13525    /// * *$.xgafv* (query-string) - V1 error format.
13526    /// * *access_token* (query-string) - OAuth access token.
13527    /// * *alt* (query-string) - Data format for response.
13528    /// * *callback* (query-string) - JSONP
13529    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13530    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13531    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13532    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13533    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13534    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13535    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13536    pub fn param<T>(mut self, name: T, value: T) -> InstanceStartReplicaCall<'a, C>
13537    where
13538        T: AsRef<str>,
13539    {
13540        self._additional_params
13541            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13542        self
13543    }
13544
13545    /// Identifies the authorization scope for the method you are building.
13546    ///
13547    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13548    /// [`Scope::CloudPlatform`].
13549    ///
13550    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13551    /// tokens for more than one scope.
13552    ///
13553    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13554    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13555    /// sufficient, a read-write scope will do as well.
13556    pub fn add_scope<St>(mut self, scope: St) -> InstanceStartReplicaCall<'a, C>
13557    where
13558        St: AsRef<str>,
13559    {
13560        self._scopes.insert(String::from(scope.as_ref()));
13561        self
13562    }
13563    /// Identifies the authorization scope(s) for the method you are building.
13564    ///
13565    /// See [`Self::add_scope()`] for details.
13566    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceStartReplicaCall<'a, C>
13567    where
13568        I: IntoIterator<Item = St>,
13569        St: AsRef<str>,
13570    {
13571        self._scopes
13572            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13573        self
13574    }
13575
13576    /// Removes all scopes, and no default scope will be used either.
13577    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13578    /// for details).
13579    pub fn clear_scopes(mut self) -> InstanceStartReplicaCall<'a, C> {
13580        self._scopes.clear();
13581        self
13582    }
13583}
13584
13585/// Stops the replication in the read replica instance.
13586///
13587/// A builder for the *stopReplica* method supported by a *instance* resource.
13588/// It is not used directly, but through a [`InstanceMethods`] instance.
13589///
13590/// # Example
13591///
13592/// Instantiate a resource method builder
13593///
13594/// ```test_harness,no_run
13595/// # extern crate hyper;
13596/// # extern crate hyper_rustls;
13597/// # extern crate google_sql1_beta4 as sql1_beta4;
13598/// # async fn dox() {
13599/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13600///
13601/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13602/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13603/// #     .with_native_roots()
13604/// #     .unwrap()
13605/// #     .https_only()
13606/// #     .enable_http2()
13607/// #     .build();
13608///
13609/// # let executor = hyper_util::rt::TokioExecutor::new();
13610/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13611/// #     secret,
13612/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13613/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13614/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13615/// #     ),
13616/// # ).build().await.unwrap();
13617///
13618/// # let client = hyper_util::client::legacy::Client::builder(
13619/// #     hyper_util::rt::TokioExecutor::new()
13620/// # )
13621/// # .build(
13622/// #     hyper_rustls::HttpsConnectorBuilder::new()
13623/// #         .with_native_roots()
13624/// #         .unwrap()
13625/// #         .https_or_http()
13626/// #         .enable_http2()
13627/// #         .build()
13628/// # );
13629/// # let mut hub = SQLAdmin::new(client, auth);
13630/// // You can configure optional parameters by calling the respective setters at will, and
13631/// // execute the final call using `doit()`.
13632/// // Values shown here are possibly random and not representative !
13633/// let result = hub.instances().stop_replica("project", "instance")
13634///              .doit().await;
13635/// # }
13636/// ```
13637pub struct InstanceStopReplicaCall<'a, C>
13638where
13639    C: 'a,
13640{
13641    hub: &'a SQLAdmin<C>,
13642    _project: String,
13643    _instance: String,
13644    _delegate: Option<&'a mut dyn common::Delegate>,
13645    _additional_params: HashMap<String, String>,
13646    _scopes: BTreeSet<String>,
13647}
13648
13649impl<'a, C> common::CallBuilder for InstanceStopReplicaCall<'a, C> {}
13650
13651impl<'a, C> InstanceStopReplicaCall<'a, C>
13652where
13653    C: common::Connector,
13654{
13655    /// Perform the operation you have build so far.
13656    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13657        use std::borrow::Cow;
13658        use std::io::{Read, Seek};
13659
13660        use common::{url::Params, ToParts};
13661        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13662
13663        let mut dd = common::DefaultDelegate;
13664        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13665        dlg.begin(common::MethodInfo {
13666            id: "sql.instances.stopReplica",
13667            http_method: hyper::Method::POST,
13668        });
13669
13670        for &field in ["alt", "project", "instance"].iter() {
13671            if self._additional_params.contains_key(field) {
13672                dlg.finished(false);
13673                return Err(common::Error::FieldClash(field));
13674            }
13675        }
13676
13677        let mut params = Params::with_capacity(4 + self._additional_params.len());
13678        params.push("project", self._project);
13679        params.push("instance", self._instance);
13680
13681        params.extend(self._additional_params.iter());
13682
13683        params.push("alt", "json");
13684        let mut url = self.hub._base_url.clone()
13685            + "sql/v1beta4/projects/{project}/instances/{instance}/stopReplica";
13686        if self._scopes.is_empty() {
13687            self._scopes
13688                .insert(Scope::CloudPlatform.as_ref().to_string());
13689        }
13690
13691        #[allow(clippy::single_element_loop)]
13692        for &(find_this, param_name) in
13693            [("{project}", "project"), ("{instance}", "instance")].iter()
13694        {
13695            url = params.uri_replacement(url, param_name, find_this, false);
13696        }
13697        {
13698            let to_remove = ["instance", "project"];
13699            params.remove_params(&to_remove);
13700        }
13701
13702        let url = params.parse_with_url(&url);
13703
13704        loop {
13705            let token = match self
13706                .hub
13707                .auth
13708                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13709                .await
13710            {
13711                Ok(token) => token,
13712                Err(e) => match dlg.token(e) {
13713                    Ok(token) => token,
13714                    Err(e) => {
13715                        dlg.finished(false);
13716                        return Err(common::Error::MissingToken(e));
13717                    }
13718                },
13719            };
13720            let mut req_result = {
13721                let client = &self.hub.client;
13722                dlg.pre_request();
13723                let mut req_builder = hyper::Request::builder()
13724                    .method(hyper::Method::POST)
13725                    .uri(url.as_str())
13726                    .header(USER_AGENT, self.hub._user_agent.clone());
13727
13728                if let Some(token) = token.as_ref() {
13729                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13730                }
13731
13732                let request = req_builder
13733                    .header(CONTENT_LENGTH, 0_u64)
13734                    .body(common::to_body::<String>(None));
13735
13736                client.request(request.unwrap()).await
13737            };
13738
13739            match req_result {
13740                Err(err) => {
13741                    if let common::Retry::After(d) = dlg.http_error(&err) {
13742                        sleep(d).await;
13743                        continue;
13744                    }
13745                    dlg.finished(false);
13746                    return Err(common::Error::HttpError(err));
13747                }
13748                Ok(res) => {
13749                    let (mut parts, body) = res.into_parts();
13750                    let mut body = common::Body::new(body);
13751                    if !parts.status.is_success() {
13752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13753                        let error = serde_json::from_str(&common::to_string(&bytes));
13754                        let response = common::to_response(parts, bytes.into());
13755
13756                        if let common::Retry::After(d) =
13757                            dlg.http_failure(&response, error.as_ref().ok())
13758                        {
13759                            sleep(d).await;
13760                            continue;
13761                        }
13762
13763                        dlg.finished(false);
13764
13765                        return Err(match error {
13766                            Ok(value) => common::Error::BadRequest(value),
13767                            _ => common::Error::Failure(response),
13768                        });
13769                    }
13770                    let response = {
13771                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13772                        let encoded = common::to_string(&bytes);
13773                        match serde_json::from_str(&encoded) {
13774                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13775                            Err(error) => {
13776                                dlg.response_json_decode_error(&encoded, &error);
13777                                return Err(common::Error::JsonDecodeError(
13778                                    encoded.to_string(),
13779                                    error,
13780                                ));
13781                            }
13782                        }
13783                    };
13784
13785                    dlg.finished(true);
13786                    return Ok(response);
13787                }
13788            }
13789        }
13790    }
13791
13792    /// ID of the project that contains the read replica.
13793    ///
13794    /// Sets the *project* path property to the given value.
13795    ///
13796    /// Even though the property as already been set when instantiating this call,
13797    /// we provide this method for API completeness.
13798    pub fn project(mut self, new_value: &str) -> InstanceStopReplicaCall<'a, C> {
13799        self._project = new_value.to_string();
13800        self
13801    }
13802    /// Cloud SQL read replica instance name.
13803    ///
13804    /// Sets the *instance* path property to the given value.
13805    ///
13806    /// Even though the property as already been set when instantiating this call,
13807    /// we provide this method for API completeness.
13808    pub fn instance(mut self, new_value: &str) -> InstanceStopReplicaCall<'a, C> {
13809        self._instance = new_value.to_string();
13810        self
13811    }
13812    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13813    /// while executing the actual API request.
13814    ///
13815    /// ````text
13816    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13817    /// ````
13818    ///
13819    /// Sets the *delegate* property to the given value.
13820    pub fn delegate(
13821        mut self,
13822        new_value: &'a mut dyn common::Delegate,
13823    ) -> InstanceStopReplicaCall<'a, C> {
13824        self._delegate = Some(new_value);
13825        self
13826    }
13827
13828    /// Set any additional parameter of the query string used in the request.
13829    /// It should be used to set parameters which are not yet available through their own
13830    /// setters.
13831    ///
13832    /// Please note that this method must not be used to set any of the known parameters
13833    /// which have their own setter method. If done anyway, the request will fail.
13834    ///
13835    /// # Additional Parameters
13836    ///
13837    /// * *$.xgafv* (query-string) - V1 error format.
13838    /// * *access_token* (query-string) - OAuth access token.
13839    /// * *alt* (query-string) - Data format for response.
13840    /// * *callback* (query-string) - JSONP
13841    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13842    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13843    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13844    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13845    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13846    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13847    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13848    pub fn param<T>(mut self, name: T, value: T) -> InstanceStopReplicaCall<'a, C>
13849    where
13850        T: AsRef<str>,
13851    {
13852        self._additional_params
13853            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13854        self
13855    }
13856
13857    /// Identifies the authorization scope for the method you are building.
13858    ///
13859    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13860    /// [`Scope::CloudPlatform`].
13861    ///
13862    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13863    /// tokens for more than one scope.
13864    ///
13865    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13866    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13867    /// sufficient, a read-write scope will do as well.
13868    pub fn add_scope<St>(mut self, scope: St) -> InstanceStopReplicaCall<'a, C>
13869    where
13870        St: AsRef<str>,
13871    {
13872        self._scopes.insert(String::from(scope.as_ref()));
13873        self
13874    }
13875    /// Identifies the authorization scope(s) for the method you are building.
13876    ///
13877    /// See [`Self::add_scope()`] for details.
13878    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceStopReplicaCall<'a, C>
13879    where
13880        I: IntoIterator<Item = St>,
13881        St: AsRef<str>,
13882    {
13883        self._scopes
13884            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13885        self
13886    }
13887
13888    /// Removes all scopes, and no default scope will be used either.
13889    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13890    /// for details).
13891    pub fn clear_scopes(mut self) -> InstanceStopReplicaCall<'a, C> {
13892        self._scopes.clear();
13893        self
13894    }
13895}
13896
13897/// Truncate MySQL general and slow query log tables
13898///
13899/// A builder for the *truncateLog* method supported by a *instance* resource.
13900/// It is not used directly, but through a [`InstanceMethods`] instance.
13901///
13902/// # Example
13903///
13904/// Instantiate a resource method builder
13905///
13906/// ```test_harness,no_run
13907/// # extern crate hyper;
13908/// # extern crate hyper_rustls;
13909/// # extern crate google_sql1_beta4 as sql1_beta4;
13910/// use sql1_beta4::api::InstancesTruncateLogRequest;
13911/// # async fn dox() {
13912/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13913///
13914/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13915/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13916/// #     .with_native_roots()
13917/// #     .unwrap()
13918/// #     .https_only()
13919/// #     .enable_http2()
13920/// #     .build();
13921///
13922/// # let executor = hyper_util::rt::TokioExecutor::new();
13923/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13924/// #     secret,
13925/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13926/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13927/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13928/// #     ),
13929/// # ).build().await.unwrap();
13930///
13931/// # let client = hyper_util::client::legacy::Client::builder(
13932/// #     hyper_util::rt::TokioExecutor::new()
13933/// # )
13934/// # .build(
13935/// #     hyper_rustls::HttpsConnectorBuilder::new()
13936/// #         .with_native_roots()
13937/// #         .unwrap()
13938/// #         .https_or_http()
13939/// #         .enable_http2()
13940/// #         .build()
13941/// # );
13942/// # let mut hub = SQLAdmin::new(client, auth);
13943/// // As the method needs a request, you would usually fill it with the desired information
13944/// // into the respective structure. Some of the parts shown here might not be applicable !
13945/// // Values shown here are possibly random and not representative !
13946/// let mut req = InstancesTruncateLogRequest::default();
13947///
13948/// // You can configure optional parameters by calling the respective setters at will, and
13949/// // execute the final call using `doit()`.
13950/// // Values shown here are possibly random and not representative !
13951/// let result = hub.instances().truncate_log(req, "project", "instance")
13952///              .doit().await;
13953/// # }
13954/// ```
13955pub struct InstanceTruncateLogCall<'a, C>
13956where
13957    C: 'a,
13958{
13959    hub: &'a SQLAdmin<C>,
13960    _request: InstancesTruncateLogRequest,
13961    _project: String,
13962    _instance: String,
13963    _delegate: Option<&'a mut dyn common::Delegate>,
13964    _additional_params: HashMap<String, String>,
13965    _scopes: BTreeSet<String>,
13966}
13967
13968impl<'a, C> common::CallBuilder for InstanceTruncateLogCall<'a, C> {}
13969
13970impl<'a, C> InstanceTruncateLogCall<'a, C>
13971where
13972    C: common::Connector,
13973{
13974    /// Perform the operation you have build so far.
13975    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13976        use std::borrow::Cow;
13977        use std::io::{Read, Seek};
13978
13979        use common::{url::Params, ToParts};
13980        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13981
13982        let mut dd = common::DefaultDelegate;
13983        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13984        dlg.begin(common::MethodInfo {
13985            id: "sql.instances.truncateLog",
13986            http_method: hyper::Method::POST,
13987        });
13988
13989        for &field in ["alt", "project", "instance"].iter() {
13990            if self._additional_params.contains_key(field) {
13991                dlg.finished(false);
13992                return Err(common::Error::FieldClash(field));
13993            }
13994        }
13995
13996        let mut params = Params::with_capacity(5 + self._additional_params.len());
13997        params.push("project", self._project);
13998        params.push("instance", self._instance);
13999
14000        params.extend(self._additional_params.iter());
14001
14002        params.push("alt", "json");
14003        let mut url = self.hub._base_url.clone()
14004            + "sql/v1beta4/projects/{project}/instances/{instance}/truncateLog";
14005        if self._scopes.is_empty() {
14006            self._scopes
14007                .insert(Scope::CloudPlatform.as_ref().to_string());
14008        }
14009
14010        #[allow(clippy::single_element_loop)]
14011        for &(find_this, param_name) in
14012            [("{project}", "project"), ("{instance}", "instance")].iter()
14013        {
14014            url = params.uri_replacement(url, param_name, find_this, false);
14015        }
14016        {
14017            let to_remove = ["instance", "project"];
14018            params.remove_params(&to_remove);
14019        }
14020
14021        let url = params.parse_with_url(&url);
14022
14023        let mut json_mime_type = mime::APPLICATION_JSON;
14024        let mut request_value_reader = {
14025            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14026            common::remove_json_null_values(&mut value);
14027            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14028            serde_json::to_writer(&mut dst, &value).unwrap();
14029            dst
14030        };
14031        let request_size = request_value_reader
14032            .seek(std::io::SeekFrom::End(0))
14033            .unwrap();
14034        request_value_reader
14035            .seek(std::io::SeekFrom::Start(0))
14036            .unwrap();
14037
14038        loop {
14039            let token = match self
14040                .hub
14041                .auth
14042                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14043                .await
14044            {
14045                Ok(token) => token,
14046                Err(e) => match dlg.token(e) {
14047                    Ok(token) => token,
14048                    Err(e) => {
14049                        dlg.finished(false);
14050                        return Err(common::Error::MissingToken(e));
14051                    }
14052                },
14053            };
14054            request_value_reader
14055                .seek(std::io::SeekFrom::Start(0))
14056                .unwrap();
14057            let mut req_result = {
14058                let client = &self.hub.client;
14059                dlg.pre_request();
14060                let mut req_builder = hyper::Request::builder()
14061                    .method(hyper::Method::POST)
14062                    .uri(url.as_str())
14063                    .header(USER_AGENT, self.hub._user_agent.clone());
14064
14065                if let Some(token) = token.as_ref() {
14066                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14067                }
14068
14069                let request = req_builder
14070                    .header(CONTENT_TYPE, json_mime_type.to_string())
14071                    .header(CONTENT_LENGTH, request_size as u64)
14072                    .body(common::to_body(
14073                        request_value_reader.get_ref().clone().into(),
14074                    ));
14075
14076                client.request(request.unwrap()).await
14077            };
14078
14079            match req_result {
14080                Err(err) => {
14081                    if let common::Retry::After(d) = dlg.http_error(&err) {
14082                        sleep(d).await;
14083                        continue;
14084                    }
14085                    dlg.finished(false);
14086                    return Err(common::Error::HttpError(err));
14087                }
14088                Ok(res) => {
14089                    let (mut parts, body) = res.into_parts();
14090                    let mut body = common::Body::new(body);
14091                    if !parts.status.is_success() {
14092                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14093                        let error = serde_json::from_str(&common::to_string(&bytes));
14094                        let response = common::to_response(parts, bytes.into());
14095
14096                        if let common::Retry::After(d) =
14097                            dlg.http_failure(&response, error.as_ref().ok())
14098                        {
14099                            sleep(d).await;
14100                            continue;
14101                        }
14102
14103                        dlg.finished(false);
14104
14105                        return Err(match error {
14106                            Ok(value) => common::Error::BadRequest(value),
14107                            _ => common::Error::Failure(response),
14108                        });
14109                    }
14110                    let response = {
14111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14112                        let encoded = common::to_string(&bytes);
14113                        match serde_json::from_str(&encoded) {
14114                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14115                            Err(error) => {
14116                                dlg.response_json_decode_error(&encoded, &error);
14117                                return Err(common::Error::JsonDecodeError(
14118                                    encoded.to_string(),
14119                                    error,
14120                                ));
14121                            }
14122                        }
14123                    };
14124
14125                    dlg.finished(true);
14126                    return Ok(response);
14127                }
14128            }
14129        }
14130    }
14131
14132    ///
14133    /// Sets the *request* property to the given value.
14134    ///
14135    /// Even though the property as already been set when instantiating this call,
14136    /// we provide this method for API completeness.
14137    pub fn request(
14138        mut self,
14139        new_value: InstancesTruncateLogRequest,
14140    ) -> InstanceTruncateLogCall<'a, C> {
14141        self._request = new_value;
14142        self
14143    }
14144    /// Project ID of the Cloud SQL project.
14145    ///
14146    /// Sets the *project* path property to the given value.
14147    ///
14148    /// Even though the property as already been set when instantiating this call,
14149    /// we provide this method for API completeness.
14150    pub fn project(mut self, new_value: &str) -> InstanceTruncateLogCall<'a, C> {
14151        self._project = new_value.to_string();
14152        self
14153    }
14154    /// Cloud SQL instance ID. This does not include the project ID.
14155    ///
14156    /// Sets the *instance* path property to the given value.
14157    ///
14158    /// Even though the property as already been set when instantiating this call,
14159    /// we provide this method for API completeness.
14160    pub fn instance(mut self, new_value: &str) -> InstanceTruncateLogCall<'a, C> {
14161        self._instance = new_value.to_string();
14162        self
14163    }
14164    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14165    /// while executing the actual API request.
14166    ///
14167    /// ````text
14168    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14169    /// ````
14170    ///
14171    /// Sets the *delegate* property to the given value.
14172    pub fn delegate(
14173        mut self,
14174        new_value: &'a mut dyn common::Delegate,
14175    ) -> InstanceTruncateLogCall<'a, C> {
14176        self._delegate = Some(new_value);
14177        self
14178    }
14179
14180    /// Set any additional parameter of the query string used in the request.
14181    /// It should be used to set parameters which are not yet available through their own
14182    /// setters.
14183    ///
14184    /// Please note that this method must not be used to set any of the known parameters
14185    /// which have their own setter method. If done anyway, the request will fail.
14186    ///
14187    /// # Additional Parameters
14188    ///
14189    /// * *$.xgafv* (query-string) - V1 error format.
14190    /// * *access_token* (query-string) - OAuth access token.
14191    /// * *alt* (query-string) - Data format for response.
14192    /// * *callback* (query-string) - JSONP
14193    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14194    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14195    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14196    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14197    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14198    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14199    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14200    pub fn param<T>(mut self, name: T, value: T) -> InstanceTruncateLogCall<'a, C>
14201    where
14202        T: AsRef<str>,
14203    {
14204        self._additional_params
14205            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14206        self
14207    }
14208
14209    /// Identifies the authorization scope for the method you are building.
14210    ///
14211    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14212    /// [`Scope::CloudPlatform`].
14213    ///
14214    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14215    /// tokens for more than one scope.
14216    ///
14217    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14218    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14219    /// sufficient, a read-write scope will do as well.
14220    pub fn add_scope<St>(mut self, scope: St) -> InstanceTruncateLogCall<'a, C>
14221    where
14222        St: AsRef<str>,
14223    {
14224        self._scopes.insert(String::from(scope.as_ref()));
14225        self
14226    }
14227    /// Identifies the authorization scope(s) for the method you are building.
14228    ///
14229    /// See [`Self::add_scope()`] for details.
14230    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceTruncateLogCall<'a, C>
14231    where
14232        I: IntoIterator<Item = St>,
14233        St: AsRef<str>,
14234    {
14235        self._scopes
14236            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14237        self
14238    }
14239
14240    /// Removes all scopes, and no default scope will be used either.
14241    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14242    /// for details).
14243    pub fn clear_scopes(mut self) -> InstanceTruncateLogCall<'a, C> {
14244        self._scopes.clear();
14245        self
14246    }
14247}
14248
14249/// Updates settings of a Cloud SQL instance. Using this operation might cause
14250/// your instance to restart.
14251///
14252/// A builder for the *update* method supported by a *instance* resource.
14253/// It is not used directly, but through a [`InstanceMethods`] instance.
14254///
14255/// # Example
14256///
14257/// Instantiate a resource method builder
14258///
14259/// ```test_harness,no_run
14260/// # extern crate hyper;
14261/// # extern crate hyper_rustls;
14262/// # extern crate google_sql1_beta4 as sql1_beta4;
14263/// use sql1_beta4::api::DatabaseInstance;
14264/// # async fn dox() {
14265/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14266///
14267/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14268/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14269/// #     .with_native_roots()
14270/// #     .unwrap()
14271/// #     .https_only()
14272/// #     .enable_http2()
14273/// #     .build();
14274///
14275/// # let executor = hyper_util::rt::TokioExecutor::new();
14276/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14277/// #     secret,
14278/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14279/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14280/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14281/// #     ),
14282/// # ).build().await.unwrap();
14283///
14284/// # let client = hyper_util::client::legacy::Client::builder(
14285/// #     hyper_util::rt::TokioExecutor::new()
14286/// # )
14287/// # .build(
14288/// #     hyper_rustls::HttpsConnectorBuilder::new()
14289/// #         .with_native_roots()
14290/// #         .unwrap()
14291/// #         .https_or_http()
14292/// #         .enable_http2()
14293/// #         .build()
14294/// # );
14295/// # let mut hub = SQLAdmin::new(client, auth);
14296/// // As the method needs a request, you would usually fill it with the desired information
14297/// // into the respective structure. Some of the parts shown here might not be applicable !
14298/// // Values shown here are possibly random and not representative !
14299/// let mut req = DatabaseInstance::default();
14300///
14301/// // You can configure optional parameters by calling the respective setters at will, and
14302/// // execute the final call using `doit()`.
14303/// // Values shown here are possibly random and not representative !
14304/// let result = hub.instances().update(req, "project", "instance")
14305///              .doit().await;
14306/// # }
14307/// ```
14308pub struct InstanceUpdateCall<'a, C>
14309where
14310    C: 'a,
14311{
14312    hub: &'a SQLAdmin<C>,
14313    _request: DatabaseInstance,
14314    _project: String,
14315    _instance: String,
14316    _delegate: Option<&'a mut dyn common::Delegate>,
14317    _additional_params: HashMap<String, String>,
14318    _scopes: BTreeSet<String>,
14319}
14320
14321impl<'a, C> common::CallBuilder for InstanceUpdateCall<'a, C> {}
14322
14323impl<'a, C> InstanceUpdateCall<'a, C>
14324where
14325    C: common::Connector,
14326{
14327    /// Perform the operation you have build so far.
14328    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14329        use std::borrow::Cow;
14330        use std::io::{Read, Seek};
14331
14332        use common::{url::Params, ToParts};
14333        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14334
14335        let mut dd = common::DefaultDelegate;
14336        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14337        dlg.begin(common::MethodInfo {
14338            id: "sql.instances.update",
14339            http_method: hyper::Method::PUT,
14340        });
14341
14342        for &field in ["alt", "project", "instance"].iter() {
14343            if self._additional_params.contains_key(field) {
14344                dlg.finished(false);
14345                return Err(common::Error::FieldClash(field));
14346            }
14347        }
14348
14349        let mut params = Params::with_capacity(5 + self._additional_params.len());
14350        params.push("project", self._project);
14351        params.push("instance", self._instance);
14352
14353        params.extend(self._additional_params.iter());
14354
14355        params.push("alt", "json");
14356        let mut url =
14357            self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances/{instance}";
14358        if self._scopes.is_empty() {
14359            self._scopes
14360                .insert(Scope::CloudPlatform.as_ref().to_string());
14361        }
14362
14363        #[allow(clippy::single_element_loop)]
14364        for &(find_this, param_name) in
14365            [("{project}", "project"), ("{instance}", "instance")].iter()
14366        {
14367            url = params.uri_replacement(url, param_name, find_this, false);
14368        }
14369        {
14370            let to_remove = ["instance", "project"];
14371            params.remove_params(&to_remove);
14372        }
14373
14374        let url = params.parse_with_url(&url);
14375
14376        let mut json_mime_type = mime::APPLICATION_JSON;
14377        let mut request_value_reader = {
14378            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14379            common::remove_json_null_values(&mut value);
14380            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14381            serde_json::to_writer(&mut dst, &value).unwrap();
14382            dst
14383        };
14384        let request_size = request_value_reader
14385            .seek(std::io::SeekFrom::End(0))
14386            .unwrap();
14387        request_value_reader
14388            .seek(std::io::SeekFrom::Start(0))
14389            .unwrap();
14390
14391        loop {
14392            let token = match self
14393                .hub
14394                .auth
14395                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14396                .await
14397            {
14398                Ok(token) => token,
14399                Err(e) => match dlg.token(e) {
14400                    Ok(token) => token,
14401                    Err(e) => {
14402                        dlg.finished(false);
14403                        return Err(common::Error::MissingToken(e));
14404                    }
14405                },
14406            };
14407            request_value_reader
14408                .seek(std::io::SeekFrom::Start(0))
14409                .unwrap();
14410            let mut req_result = {
14411                let client = &self.hub.client;
14412                dlg.pre_request();
14413                let mut req_builder = hyper::Request::builder()
14414                    .method(hyper::Method::PUT)
14415                    .uri(url.as_str())
14416                    .header(USER_AGENT, self.hub._user_agent.clone());
14417
14418                if let Some(token) = token.as_ref() {
14419                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14420                }
14421
14422                let request = req_builder
14423                    .header(CONTENT_TYPE, json_mime_type.to_string())
14424                    .header(CONTENT_LENGTH, request_size as u64)
14425                    .body(common::to_body(
14426                        request_value_reader.get_ref().clone().into(),
14427                    ));
14428
14429                client.request(request.unwrap()).await
14430            };
14431
14432            match req_result {
14433                Err(err) => {
14434                    if let common::Retry::After(d) = dlg.http_error(&err) {
14435                        sleep(d).await;
14436                        continue;
14437                    }
14438                    dlg.finished(false);
14439                    return Err(common::Error::HttpError(err));
14440                }
14441                Ok(res) => {
14442                    let (mut parts, body) = res.into_parts();
14443                    let mut body = common::Body::new(body);
14444                    if !parts.status.is_success() {
14445                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14446                        let error = serde_json::from_str(&common::to_string(&bytes));
14447                        let response = common::to_response(parts, bytes.into());
14448
14449                        if let common::Retry::After(d) =
14450                            dlg.http_failure(&response, error.as_ref().ok())
14451                        {
14452                            sleep(d).await;
14453                            continue;
14454                        }
14455
14456                        dlg.finished(false);
14457
14458                        return Err(match error {
14459                            Ok(value) => common::Error::BadRequest(value),
14460                            _ => common::Error::Failure(response),
14461                        });
14462                    }
14463                    let response = {
14464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14465                        let encoded = common::to_string(&bytes);
14466                        match serde_json::from_str(&encoded) {
14467                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14468                            Err(error) => {
14469                                dlg.response_json_decode_error(&encoded, &error);
14470                                return Err(common::Error::JsonDecodeError(
14471                                    encoded.to_string(),
14472                                    error,
14473                                ));
14474                            }
14475                        }
14476                    };
14477
14478                    dlg.finished(true);
14479                    return Ok(response);
14480                }
14481            }
14482        }
14483    }
14484
14485    ///
14486    /// Sets the *request* property to the given value.
14487    ///
14488    /// Even though the property as already been set when instantiating this call,
14489    /// we provide this method for API completeness.
14490    pub fn request(mut self, new_value: DatabaseInstance) -> InstanceUpdateCall<'a, C> {
14491        self._request = new_value;
14492        self
14493    }
14494    /// Project ID of the project that contains the instance.
14495    ///
14496    /// Sets the *project* path property to the given value.
14497    ///
14498    /// Even though the property as already been set when instantiating this call,
14499    /// we provide this method for API completeness.
14500    pub fn project(mut self, new_value: &str) -> InstanceUpdateCall<'a, C> {
14501        self._project = new_value.to_string();
14502        self
14503    }
14504    /// Cloud SQL instance ID. This does not include the project ID.
14505    ///
14506    /// Sets the *instance* path property to the given value.
14507    ///
14508    /// Even though the property as already been set when instantiating this call,
14509    /// we provide this method for API completeness.
14510    pub fn instance(mut self, new_value: &str) -> InstanceUpdateCall<'a, C> {
14511        self._instance = new_value.to_string();
14512        self
14513    }
14514    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14515    /// while executing the actual API request.
14516    ///
14517    /// ````text
14518    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14519    /// ````
14520    ///
14521    /// Sets the *delegate* property to the given value.
14522    pub fn delegate(
14523        mut self,
14524        new_value: &'a mut dyn common::Delegate,
14525    ) -> InstanceUpdateCall<'a, C> {
14526        self._delegate = Some(new_value);
14527        self
14528    }
14529
14530    /// Set any additional parameter of the query string used in the request.
14531    /// It should be used to set parameters which are not yet available through their own
14532    /// setters.
14533    ///
14534    /// Please note that this method must not be used to set any of the known parameters
14535    /// which have their own setter method. If done anyway, the request will fail.
14536    ///
14537    /// # Additional Parameters
14538    ///
14539    /// * *$.xgafv* (query-string) - V1 error format.
14540    /// * *access_token* (query-string) - OAuth access token.
14541    /// * *alt* (query-string) - Data format for response.
14542    /// * *callback* (query-string) - JSONP
14543    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14544    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14545    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14546    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14547    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14548    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14549    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14550    pub fn param<T>(mut self, name: T, value: T) -> InstanceUpdateCall<'a, C>
14551    where
14552        T: AsRef<str>,
14553    {
14554        self._additional_params
14555            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14556        self
14557    }
14558
14559    /// Identifies the authorization scope for the method you are building.
14560    ///
14561    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14562    /// [`Scope::CloudPlatform`].
14563    ///
14564    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14565    /// tokens for more than one scope.
14566    ///
14567    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14568    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14569    /// sufficient, a read-write scope will do as well.
14570    pub fn add_scope<St>(mut self, scope: St) -> InstanceUpdateCall<'a, C>
14571    where
14572        St: AsRef<str>,
14573    {
14574        self._scopes.insert(String::from(scope.as_ref()));
14575        self
14576    }
14577    /// Identifies the authorization scope(s) for the method you are building.
14578    ///
14579    /// See [`Self::add_scope()`] for details.
14580    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceUpdateCall<'a, C>
14581    where
14582        I: IntoIterator<Item = St>,
14583        St: AsRef<str>,
14584    {
14585        self._scopes
14586            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14587        self
14588    }
14589
14590    /// Removes all scopes, and no default scope will be used either.
14591    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14592    /// for details).
14593    pub fn clear_scopes(mut self) -> InstanceUpdateCall<'a, C> {
14594        self._scopes.clear();
14595        self
14596    }
14597}
14598
14599/// Retrieves an instance operation that has been performed on an instance.
14600///
14601/// A builder for the *get* method supported by a *operation* resource.
14602/// It is not used directly, but through a [`OperationMethods`] instance.
14603///
14604/// # Example
14605///
14606/// Instantiate a resource method builder
14607///
14608/// ```test_harness,no_run
14609/// # extern crate hyper;
14610/// # extern crate hyper_rustls;
14611/// # extern crate google_sql1_beta4 as sql1_beta4;
14612/// # async fn dox() {
14613/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14614///
14615/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14616/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14617/// #     .with_native_roots()
14618/// #     .unwrap()
14619/// #     .https_only()
14620/// #     .enable_http2()
14621/// #     .build();
14622///
14623/// # let executor = hyper_util::rt::TokioExecutor::new();
14624/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14625/// #     secret,
14626/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14627/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14628/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14629/// #     ),
14630/// # ).build().await.unwrap();
14631///
14632/// # let client = hyper_util::client::legacy::Client::builder(
14633/// #     hyper_util::rt::TokioExecutor::new()
14634/// # )
14635/// # .build(
14636/// #     hyper_rustls::HttpsConnectorBuilder::new()
14637/// #         .with_native_roots()
14638/// #         .unwrap()
14639/// #         .https_or_http()
14640/// #         .enable_http2()
14641/// #         .build()
14642/// # );
14643/// # let mut hub = SQLAdmin::new(client, auth);
14644/// // You can configure optional parameters by calling the respective setters at will, and
14645/// // execute the final call using `doit()`.
14646/// // Values shown here are possibly random and not representative !
14647/// let result = hub.operations().get("project", "operation")
14648///              .doit().await;
14649/// # }
14650/// ```
14651pub struct OperationGetCall<'a, C>
14652where
14653    C: 'a,
14654{
14655    hub: &'a SQLAdmin<C>,
14656    _project: String,
14657    _operation: String,
14658    _delegate: Option<&'a mut dyn common::Delegate>,
14659    _additional_params: HashMap<String, String>,
14660    _scopes: BTreeSet<String>,
14661}
14662
14663impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
14664
14665impl<'a, C> OperationGetCall<'a, C>
14666where
14667    C: common::Connector,
14668{
14669    /// Perform the operation you have build so far.
14670    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14671        use std::borrow::Cow;
14672        use std::io::{Read, Seek};
14673
14674        use common::{url::Params, ToParts};
14675        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14676
14677        let mut dd = common::DefaultDelegate;
14678        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14679        dlg.begin(common::MethodInfo {
14680            id: "sql.operations.get",
14681            http_method: hyper::Method::GET,
14682        });
14683
14684        for &field in ["alt", "project", "operation"].iter() {
14685            if self._additional_params.contains_key(field) {
14686                dlg.finished(false);
14687                return Err(common::Error::FieldClash(field));
14688            }
14689        }
14690
14691        let mut params = Params::with_capacity(4 + self._additional_params.len());
14692        params.push("project", self._project);
14693        params.push("operation", self._operation);
14694
14695        params.extend(self._additional_params.iter());
14696
14697        params.push("alt", "json");
14698        let mut url =
14699            self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/operations/{operation}";
14700        if self._scopes.is_empty() {
14701            self._scopes
14702                .insert(Scope::CloudPlatform.as_ref().to_string());
14703        }
14704
14705        #[allow(clippy::single_element_loop)]
14706        for &(find_this, param_name) in
14707            [("{project}", "project"), ("{operation}", "operation")].iter()
14708        {
14709            url = params.uri_replacement(url, param_name, find_this, false);
14710        }
14711        {
14712            let to_remove = ["operation", "project"];
14713            params.remove_params(&to_remove);
14714        }
14715
14716        let url = params.parse_with_url(&url);
14717
14718        loop {
14719            let token = match self
14720                .hub
14721                .auth
14722                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14723                .await
14724            {
14725                Ok(token) => token,
14726                Err(e) => match dlg.token(e) {
14727                    Ok(token) => token,
14728                    Err(e) => {
14729                        dlg.finished(false);
14730                        return Err(common::Error::MissingToken(e));
14731                    }
14732                },
14733            };
14734            let mut req_result = {
14735                let client = &self.hub.client;
14736                dlg.pre_request();
14737                let mut req_builder = hyper::Request::builder()
14738                    .method(hyper::Method::GET)
14739                    .uri(url.as_str())
14740                    .header(USER_AGENT, self.hub._user_agent.clone());
14741
14742                if let Some(token) = token.as_ref() {
14743                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14744                }
14745
14746                let request = req_builder
14747                    .header(CONTENT_LENGTH, 0_u64)
14748                    .body(common::to_body::<String>(None));
14749
14750                client.request(request.unwrap()).await
14751            };
14752
14753            match req_result {
14754                Err(err) => {
14755                    if let common::Retry::After(d) = dlg.http_error(&err) {
14756                        sleep(d).await;
14757                        continue;
14758                    }
14759                    dlg.finished(false);
14760                    return Err(common::Error::HttpError(err));
14761                }
14762                Ok(res) => {
14763                    let (mut parts, body) = res.into_parts();
14764                    let mut body = common::Body::new(body);
14765                    if !parts.status.is_success() {
14766                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14767                        let error = serde_json::from_str(&common::to_string(&bytes));
14768                        let response = common::to_response(parts, bytes.into());
14769
14770                        if let common::Retry::After(d) =
14771                            dlg.http_failure(&response, error.as_ref().ok())
14772                        {
14773                            sleep(d).await;
14774                            continue;
14775                        }
14776
14777                        dlg.finished(false);
14778
14779                        return Err(match error {
14780                            Ok(value) => common::Error::BadRequest(value),
14781                            _ => common::Error::Failure(response),
14782                        });
14783                    }
14784                    let response = {
14785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14786                        let encoded = common::to_string(&bytes);
14787                        match serde_json::from_str(&encoded) {
14788                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14789                            Err(error) => {
14790                                dlg.response_json_decode_error(&encoded, &error);
14791                                return Err(common::Error::JsonDecodeError(
14792                                    encoded.to_string(),
14793                                    error,
14794                                ));
14795                            }
14796                        }
14797                    };
14798
14799                    dlg.finished(true);
14800                    return Ok(response);
14801                }
14802            }
14803        }
14804    }
14805
14806    /// Project ID of the project that contains the instance.
14807    ///
14808    /// Sets the *project* path property to the given value.
14809    ///
14810    /// Even though the property as already been set when instantiating this call,
14811    /// we provide this method for API completeness.
14812    pub fn project(mut self, new_value: &str) -> OperationGetCall<'a, C> {
14813        self._project = new_value.to_string();
14814        self
14815    }
14816    /// Instance operation ID.
14817    ///
14818    /// Sets the *operation* path property to the given value.
14819    ///
14820    /// Even though the property as already been set when instantiating this call,
14821    /// we provide this method for API completeness.
14822    pub fn operation(mut self, new_value: &str) -> OperationGetCall<'a, C> {
14823        self._operation = new_value.to_string();
14824        self
14825    }
14826    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14827    /// while executing the actual API request.
14828    ///
14829    /// ````text
14830    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14831    /// ````
14832    ///
14833    /// Sets the *delegate* property to the given value.
14834    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
14835        self._delegate = Some(new_value);
14836        self
14837    }
14838
14839    /// Set any additional parameter of the query string used in the request.
14840    /// It should be used to set parameters which are not yet available through their own
14841    /// setters.
14842    ///
14843    /// Please note that this method must not be used to set any of the known parameters
14844    /// which have their own setter method. If done anyway, the request will fail.
14845    ///
14846    /// # Additional Parameters
14847    ///
14848    /// * *$.xgafv* (query-string) - V1 error format.
14849    /// * *access_token* (query-string) - OAuth access token.
14850    /// * *alt* (query-string) - Data format for response.
14851    /// * *callback* (query-string) - JSONP
14852    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14853    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14854    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14855    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14856    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14857    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14858    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14859    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
14860    where
14861        T: AsRef<str>,
14862    {
14863        self._additional_params
14864            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14865        self
14866    }
14867
14868    /// Identifies the authorization scope for the method you are building.
14869    ///
14870    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14871    /// [`Scope::CloudPlatform`].
14872    ///
14873    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14874    /// tokens for more than one scope.
14875    ///
14876    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14877    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14878    /// sufficient, a read-write scope will do as well.
14879    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
14880    where
14881        St: AsRef<str>,
14882    {
14883        self._scopes.insert(String::from(scope.as_ref()));
14884        self
14885    }
14886    /// Identifies the authorization scope(s) for the method you are building.
14887    ///
14888    /// See [`Self::add_scope()`] for details.
14889    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
14890    where
14891        I: IntoIterator<Item = St>,
14892        St: AsRef<str>,
14893    {
14894        self._scopes
14895            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14896        self
14897    }
14898
14899    /// Removes all scopes, and no default scope will be used either.
14900    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14901    /// for details).
14902    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
14903        self._scopes.clear();
14904        self
14905    }
14906}
14907
14908/// Lists all instance operations that have been performed on the given Cloud
14909/// SQL instance in the reverse chronological order of the start time.
14910///
14911/// A builder for the *list* method supported by a *operation* resource.
14912/// It is not used directly, but through a [`OperationMethods`] instance.
14913///
14914/// # Example
14915///
14916/// Instantiate a resource method builder
14917///
14918/// ```test_harness,no_run
14919/// # extern crate hyper;
14920/// # extern crate hyper_rustls;
14921/// # extern crate google_sql1_beta4 as sql1_beta4;
14922/// # async fn dox() {
14923/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14924///
14925/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14926/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14927/// #     .with_native_roots()
14928/// #     .unwrap()
14929/// #     .https_only()
14930/// #     .enable_http2()
14931/// #     .build();
14932///
14933/// # let executor = hyper_util::rt::TokioExecutor::new();
14934/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14935/// #     secret,
14936/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14937/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14938/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14939/// #     ),
14940/// # ).build().await.unwrap();
14941///
14942/// # let client = hyper_util::client::legacy::Client::builder(
14943/// #     hyper_util::rt::TokioExecutor::new()
14944/// # )
14945/// # .build(
14946/// #     hyper_rustls::HttpsConnectorBuilder::new()
14947/// #         .with_native_roots()
14948/// #         .unwrap()
14949/// #         .https_or_http()
14950/// #         .enable_http2()
14951/// #         .build()
14952/// # );
14953/// # let mut hub = SQLAdmin::new(client, auth);
14954/// // You can configure optional parameters by calling the respective setters at will, and
14955/// // execute the final call using `doit()`.
14956/// // Values shown here are possibly random and not representative !
14957/// let result = hub.operations().list("project")
14958///              .page_token("et")
14959///              .max_results(78)
14960///              .instance("voluptua.")
14961///              .doit().await;
14962/// # }
14963/// ```
14964pub struct OperationListCall<'a, C>
14965where
14966    C: 'a,
14967{
14968    hub: &'a SQLAdmin<C>,
14969    _project: String,
14970    _page_token: Option<String>,
14971    _max_results: Option<u32>,
14972    _instance: Option<String>,
14973    _delegate: Option<&'a mut dyn common::Delegate>,
14974    _additional_params: HashMap<String, String>,
14975    _scopes: BTreeSet<String>,
14976}
14977
14978impl<'a, C> common::CallBuilder for OperationListCall<'a, C> {}
14979
14980impl<'a, C> OperationListCall<'a, C>
14981where
14982    C: common::Connector,
14983{
14984    /// Perform the operation you have build so far.
14985    pub async fn doit(mut self) -> common::Result<(common::Response, OperationsListResponse)> {
14986        use std::borrow::Cow;
14987        use std::io::{Read, Seek};
14988
14989        use common::{url::Params, ToParts};
14990        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14991
14992        let mut dd = common::DefaultDelegate;
14993        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14994        dlg.begin(common::MethodInfo {
14995            id: "sql.operations.list",
14996            http_method: hyper::Method::GET,
14997        });
14998
14999        for &field in ["alt", "project", "pageToken", "maxResults", "instance"].iter() {
15000            if self._additional_params.contains_key(field) {
15001                dlg.finished(false);
15002                return Err(common::Error::FieldClash(field));
15003            }
15004        }
15005
15006        let mut params = Params::with_capacity(6 + self._additional_params.len());
15007        params.push("project", self._project);
15008        if let Some(value) = self._page_token.as_ref() {
15009            params.push("pageToken", value);
15010        }
15011        if let Some(value) = self._max_results.as_ref() {
15012            params.push("maxResults", value.to_string());
15013        }
15014        if let Some(value) = self._instance.as_ref() {
15015            params.push("instance", value);
15016        }
15017
15018        params.extend(self._additional_params.iter());
15019
15020        params.push("alt", "json");
15021        let mut url = self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/operations";
15022        if self._scopes.is_empty() {
15023            self._scopes
15024                .insert(Scope::CloudPlatform.as_ref().to_string());
15025        }
15026
15027        #[allow(clippy::single_element_loop)]
15028        for &(find_this, param_name) in [("{project}", "project")].iter() {
15029            url = params.uri_replacement(url, param_name, find_this, false);
15030        }
15031        {
15032            let to_remove = ["project"];
15033            params.remove_params(&to_remove);
15034        }
15035
15036        let url = params.parse_with_url(&url);
15037
15038        loop {
15039            let token = match self
15040                .hub
15041                .auth
15042                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15043                .await
15044            {
15045                Ok(token) => token,
15046                Err(e) => match dlg.token(e) {
15047                    Ok(token) => token,
15048                    Err(e) => {
15049                        dlg.finished(false);
15050                        return Err(common::Error::MissingToken(e));
15051                    }
15052                },
15053            };
15054            let mut req_result = {
15055                let client = &self.hub.client;
15056                dlg.pre_request();
15057                let mut req_builder = hyper::Request::builder()
15058                    .method(hyper::Method::GET)
15059                    .uri(url.as_str())
15060                    .header(USER_AGENT, self.hub._user_agent.clone());
15061
15062                if let Some(token) = token.as_ref() {
15063                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15064                }
15065
15066                let request = req_builder
15067                    .header(CONTENT_LENGTH, 0_u64)
15068                    .body(common::to_body::<String>(None));
15069
15070                client.request(request.unwrap()).await
15071            };
15072
15073            match req_result {
15074                Err(err) => {
15075                    if let common::Retry::After(d) = dlg.http_error(&err) {
15076                        sleep(d).await;
15077                        continue;
15078                    }
15079                    dlg.finished(false);
15080                    return Err(common::Error::HttpError(err));
15081                }
15082                Ok(res) => {
15083                    let (mut parts, body) = res.into_parts();
15084                    let mut body = common::Body::new(body);
15085                    if !parts.status.is_success() {
15086                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15087                        let error = serde_json::from_str(&common::to_string(&bytes));
15088                        let response = common::to_response(parts, bytes.into());
15089
15090                        if let common::Retry::After(d) =
15091                            dlg.http_failure(&response, error.as_ref().ok())
15092                        {
15093                            sleep(d).await;
15094                            continue;
15095                        }
15096
15097                        dlg.finished(false);
15098
15099                        return Err(match error {
15100                            Ok(value) => common::Error::BadRequest(value),
15101                            _ => common::Error::Failure(response),
15102                        });
15103                    }
15104                    let response = {
15105                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15106                        let encoded = common::to_string(&bytes);
15107                        match serde_json::from_str(&encoded) {
15108                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15109                            Err(error) => {
15110                                dlg.response_json_decode_error(&encoded, &error);
15111                                return Err(common::Error::JsonDecodeError(
15112                                    encoded.to_string(),
15113                                    error,
15114                                ));
15115                            }
15116                        }
15117                    };
15118
15119                    dlg.finished(true);
15120                    return Ok(response);
15121                }
15122            }
15123        }
15124    }
15125
15126    /// Project ID of the project that contains the instance.
15127    ///
15128    /// Sets the *project* path property to the given value.
15129    ///
15130    /// Even though the property as already been set when instantiating this call,
15131    /// we provide this method for API completeness.
15132    pub fn project(mut self, new_value: &str) -> OperationListCall<'a, C> {
15133        self._project = new_value.to_string();
15134        self
15135    }
15136    /// A previously-returned page token representing part of the larger set of
15137    /// results to view.
15138    ///
15139    /// Sets the *page token* query property to the given value.
15140    pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C> {
15141        self._page_token = Some(new_value.to_string());
15142        self
15143    }
15144    /// Maximum number of operations per response.
15145    ///
15146    /// Sets the *max results* query property to the given value.
15147    pub fn max_results(mut self, new_value: u32) -> OperationListCall<'a, C> {
15148        self._max_results = Some(new_value);
15149        self
15150    }
15151    /// Cloud SQL instance ID. This does not include the project ID.
15152    ///
15153    /// Sets the *instance* query property to the given value.
15154    pub fn instance(mut self, new_value: &str) -> OperationListCall<'a, C> {
15155        self._instance = Some(new_value.to_string());
15156        self
15157    }
15158    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15159    /// while executing the actual API request.
15160    ///
15161    /// ````text
15162    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15163    /// ````
15164    ///
15165    /// Sets the *delegate* property to the given value.
15166    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationListCall<'a, C> {
15167        self._delegate = Some(new_value);
15168        self
15169    }
15170
15171    /// Set any additional parameter of the query string used in the request.
15172    /// It should be used to set parameters which are not yet available through their own
15173    /// setters.
15174    ///
15175    /// Please note that this method must not be used to set any of the known parameters
15176    /// which have their own setter method. If done anyway, the request will fail.
15177    ///
15178    /// # Additional Parameters
15179    ///
15180    /// * *$.xgafv* (query-string) - V1 error format.
15181    /// * *access_token* (query-string) - OAuth access token.
15182    /// * *alt* (query-string) - Data format for response.
15183    /// * *callback* (query-string) - JSONP
15184    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15185    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15186    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15187    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15188    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15189    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15190    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15191    pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C>
15192    where
15193        T: AsRef<str>,
15194    {
15195        self._additional_params
15196            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15197        self
15198    }
15199
15200    /// Identifies the authorization scope for the method you are building.
15201    ///
15202    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15203    /// [`Scope::CloudPlatform`].
15204    ///
15205    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15206    /// tokens for more than one scope.
15207    ///
15208    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15209    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15210    /// sufficient, a read-write scope will do as well.
15211    pub fn add_scope<St>(mut self, scope: St) -> OperationListCall<'a, C>
15212    where
15213        St: AsRef<str>,
15214    {
15215        self._scopes.insert(String::from(scope.as_ref()));
15216        self
15217    }
15218    /// Identifies the authorization scope(s) for the method you are building.
15219    ///
15220    /// See [`Self::add_scope()`] for details.
15221    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationListCall<'a, C>
15222    where
15223        I: IntoIterator<Item = St>,
15224        St: AsRef<str>,
15225    {
15226        self._scopes
15227            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15228        self
15229    }
15230
15231    /// Removes all scopes, and no default scope will be used either.
15232    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15233    /// for details).
15234    pub fn clear_scopes(mut self) -> OperationListCall<'a, C> {
15235        self._scopes.clear();
15236        self
15237    }
15238}
15239
15240/// Reschedules the maintenance on the given instance.
15241///
15242/// A builder for the *instances.rescheduleMaintenance* method supported by a *project* resource.
15243/// It is not used directly, but through a [`ProjectMethods`] instance.
15244///
15245/// # Example
15246///
15247/// Instantiate a resource method builder
15248///
15249/// ```test_harness,no_run
15250/// # extern crate hyper;
15251/// # extern crate hyper_rustls;
15252/// # extern crate google_sql1_beta4 as sql1_beta4;
15253/// use sql1_beta4::api::SqlInstancesRescheduleMaintenanceRequestBody;
15254/// # async fn dox() {
15255/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15256///
15257/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15258/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15259/// #     .with_native_roots()
15260/// #     .unwrap()
15261/// #     .https_only()
15262/// #     .enable_http2()
15263/// #     .build();
15264///
15265/// # let executor = hyper_util::rt::TokioExecutor::new();
15266/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15267/// #     secret,
15268/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15269/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15270/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15271/// #     ),
15272/// # ).build().await.unwrap();
15273///
15274/// # let client = hyper_util::client::legacy::Client::builder(
15275/// #     hyper_util::rt::TokioExecutor::new()
15276/// # )
15277/// # .build(
15278/// #     hyper_rustls::HttpsConnectorBuilder::new()
15279/// #         .with_native_roots()
15280/// #         .unwrap()
15281/// #         .https_or_http()
15282/// #         .enable_http2()
15283/// #         .build()
15284/// # );
15285/// # let mut hub = SQLAdmin::new(client, auth);
15286/// // As the method needs a request, you would usually fill it with the desired information
15287/// // into the respective structure. Some of the parts shown here might not be applicable !
15288/// // Values shown here are possibly random and not representative !
15289/// let mut req = SqlInstancesRescheduleMaintenanceRequestBody::default();
15290///
15291/// // You can configure optional parameters by calling the respective setters at will, and
15292/// // execute the final call using `doit()`.
15293/// // Values shown here are possibly random and not representative !
15294/// let result = hub.projects().instances_reschedule_maintenance(req, "project", "instance")
15295///              .doit().await;
15296/// # }
15297/// ```
15298pub struct ProjectInstanceRescheduleMaintenanceCall<'a, C>
15299where
15300    C: 'a,
15301{
15302    hub: &'a SQLAdmin<C>,
15303    _request: SqlInstancesRescheduleMaintenanceRequestBody,
15304    _project: String,
15305    _instance: String,
15306    _delegate: Option<&'a mut dyn common::Delegate>,
15307    _additional_params: HashMap<String, String>,
15308    _scopes: BTreeSet<String>,
15309}
15310
15311impl<'a, C> common::CallBuilder for ProjectInstanceRescheduleMaintenanceCall<'a, C> {}
15312
15313impl<'a, C> ProjectInstanceRescheduleMaintenanceCall<'a, C>
15314where
15315    C: common::Connector,
15316{
15317    /// Perform the operation you have build so far.
15318    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15319        use std::borrow::Cow;
15320        use std::io::{Read, Seek};
15321
15322        use common::{url::Params, ToParts};
15323        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15324
15325        let mut dd = common::DefaultDelegate;
15326        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15327        dlg.begin(common::MethodInfo {
15328            id: "sql.projects.instances.rescheduleMaintenance",
15329            http_method: hyper::Method::POST,
15330        });
15331
15332        for &field in ["alt", "project", "instance"].iter() {
15333            if self._additional_params.contains_key(field) {
15334                dlg.finished(false);
15335                return Err(common::Error::FieldClash(field));
15336            }
15337        }
15338
15339        let mut params = Params::with_capacity(5 + self._additional_params.len());
15340        params.push("project", self._project);
15341        params.push("instance", self._instance);
15342
15343        params.extend(self._additional_params.iter());
15344
15345        params.push("alt", "json");
15346        let mut url = self.hub._base_url.clone()
15347            + "sql/v1beta4/projects/{project}/instances/{instance}/rescheduleMaintenance";
15348        if self._scopes.is_empty() {
15349            self._scopes
15350                .insert(Scope::CloudPlatform.as_ref().to_string());
15351        }
15352
15353        #[allow(clippy::single_element_loop)]
15354        for &(find_this, param_name) in
15355            [("{project}", "project"), ("{instance}", "instance")].iter()
15356        {
15357            url = params.uri_replacement(url, param_name, find_this, false);
15358        }
15359        {
15360            let to_remove = ["instance", "project"];
15361            params.remove_params(&to_remove);
15362        }
15363
15364        let url = params.parse_with_url(&url);
15365
15366        let mut json_mime_type = mime::APPLICATION_JSON;
15367        let mut request_value_reader = {
15368            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15369            common::remove_json_null_values(&mut value);
15370            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15371            serde_json::to_writer(&mut dst, &value).unwrap();
15372            dst
15373        };
15374        let request_size = request_value_reader
15375            .seek(std::io::SeekFrom::End(0))
15376            .unwrap();
15377        request_value_reader
15378            .seek(std::io::SeekFrom::Start(0))
15379            .unwrap();
15380
15381        loop {
15382            let token = match self
15383                .hub
15384                .auth
15385                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15386                .await
15387            {
15388                Ok(token) => token,
15389                Err(e) => match dlg.token(e) {
15390                    Ok(token) => token,
15391                    Err(e) => {
15392                        dlg.finished(false);
15393                        return Err(common::Error::MissingToken(e));
15394                    }
15395                },
15396            };
15397            request_value_reader
15398                .seek(std::io::SeekFrom::Start(0))
15399                .unwrap();
15400            let mut req_result = {
15401                let client = &self.hub.client;
15402                dlg.pre_request();
15403                let mut req_builder = hyper::Request::builder()
15404                    .method(hyper::Method::POST)
15405                    .uri(url.as_str())
15406                    .header(USER_AGENT, self.hub._user_agent.clone());
15407
15408                if let Some(token) = token.as_ref() {
15409                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15410                }
15411
15412                let request = req_builder
15413                    .header(CONTENT_TYPE, json_mime_type.to_string())
15414                    .header(CONTENT_LENGTH, request_size as u64)
15415                    .body(common::to_body(
15416                        request_value_reader.get_ref().clone().into(),
15417                    ));
15418
15419                client.request(request.unwrap()).await
15420            };
15421
15422            match req_result {
15423                Err(err) => {
15424                    if let common::Retry::After(d) = dlg.http_error(&err) {
15425                        sleep(d).await;
15426                        continue;
15427                    }
15428                    dlg.finished(false);
15429                    return Err(common::Error::HttpError(err));
15430                }
15431                Ok(res) => {
15432                    let (mut parts, body) = res.into_parts();
15433                    let mut body = common::Body::new(body);
15434                    if !parts.status.is_success() {
15435                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15436                        let error = serde_json::from_str(&common::to_string(&bytes));
15437                        let response = common::to_response(parts, bytes.into());
15438
15439                        if let common::Retry::After(d) =
15440                            dlg.http_failure(&response, error.as_ref().ok())
15441                        {
15442                            sleep(d).await;
15443                            continue;
15444                        }
15445
15446                        dlg.finished(false);
15447
15448                        return Err(match error {
15449                            Ok(value) => common::Error::BadRequest(value),
15450                            _ => common::Error::Failure(response),
15451                        });
15452                    }
15453                    let response = {
15454                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15455                        let encoded = common::to_string(&bytes);
15456                        match serde_json::from_str(&encoded) {
15457                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15458                            Err(error) => {
15459                                dlg.response_json_decode_error(&encoded, &error);
15460                                return Err(common::Error::JsonDecodeError(
15461                                    encoded.to_string(),
15462                                    error,
15463                                ));
15464                            }
15465                        }
15466                    };
15467
15468                    dlg.finished(true);
15469                    return Ok(response);
15470                }
15471            }
15472        }
15473    }
15474
15475    ///
15476    /// Sets the *request* property to the given value.
15477    ///
15478    /// Even though the property as already been set when instantiating this call,
15479    /// we provide this method for API completeness.
15480    pub fn request(
15481        mut self,
15482        new_value: SqlInstancesRescheduleMaintenanceRequestBody,
15483    ) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
15484        self._request = new_value;
15485        self
15486    }
15487    /// ID of the project that contains the instance.
15488    ///
15489    /// Sets the *project* path property to the given value.
15490    ///
15491    /// Even though the property as already been set when instantiating this call,
15492    /// we provide this method for API completeness.
15493    pub fn project(mut self, new_value: &str) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
15494        self._project = new_value.to_string();
15495        self
15496    }
15497    /// Cloud SQL instance ID. This does not include the project ID.
15498    ///
15499    /// Sets the *instance* path property to the given value.
15500    ///
15501    /// Even though the property as already been set when instantiating this call,
15502    /// we provide this method for API completeness.
15503    pub fn instance(mut self, new_value: &str) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
15504        self._instance = new_value.to_string();
15505        self
15506    }
15507    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15508    /// while executing the actual API request.
15509    ///
15510    /// ````text
15511    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15512    /// ````
15513    ///
15514    /// Sets the *delegate* property to the given value.
15515    pub fn delegate(
15516        mut self,
15517        new_value: &'a mut dyn common::Delegate,
15518    ) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
15519        self._delegate = Some(new_value);
15520        self
15521    }
15522
15523    /// Set any additional parameter of the query string used in the request.
15524    /// It should be used to set parameters which are not yet available through their own
15525    /// setters.
15526    ///
15527    /// Please note that this method must not be used to set any of the known parameters
15528    /// which have their own setter method. If done anyway, the request will fail.
15529    ///
15530    /// # Additional Parameters
15531    ///
15532    /// * *$.xgafv* (query-string) - V1 error format.
15533    /// * *access_token* (query-string) - OAuth access token.
15534    /// * *alt* (query-string) - Data format for response.
15535    /// * *callback* (query-string) - JSONP
15536    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15537    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15538    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15539    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15540    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15541    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15542    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15543    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceRescheduleMaintenanceCall<'a, C>
15544    where
15545        T: AsRef<str>,
15546    {
15547        self._additional_params
15548            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15549        self
15550    }
15551
15552    /// Identifies the authorization scope for the method you are building.
15553    ///
15554    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15555    /// [`Scope::CloudPlatform`].
15556    ///
15557    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15558    /// tokens for more than one scope.
15559    ///
15560    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15561    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15562    /// sufficient, a read-write scope will do as well.
15563    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceRescheduleMaintenanceCall<'a, C>
15564    where
15565        St: AsRef<str>,
15566    {
15567        self._scopes.insert(String::from(scope.as_ref()));
15568        self
15569    }
15570    /// Identifies the authorization scope(s) for the method you are building.
15571    ///
15572    /// See [`Self::add_scope()`] for details.
15573    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceRescheduleMaintenanceCall<'a, C>
15574    where
15575        I: IntoIterator<Item = St>,
15576        St: AsRef<str>,
15577    {
15578        self._scopes
15579            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15580        self
15581    }
15582
15583    /// Removes all scopes, and no default scope will be used either.
15584    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15585    /// for details).
15586    pub fn clear_scopes(mut self) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
15587        self._scopes.clear();
15588        self
15589    }
15590}
15591
15592/// Start External master migration.
15593///
15594/// A builder for the *instances.startExternalSync* method supported by a *project* resource.
15595/// It is not used directly, but through a [`ProjectMethods`] instance.
15596///
15597/// # Example
15598///
15599/// Instantiate a resource method builder
15600///
15601/// ```test_harness,no_run
15602/// # extern crate hyper;
15603/// # extern crate hyper_rustls;
15604/// # extern crate google_sql1_beta4 as sql1_beta4;
15605/// # async fn dox() {
15606/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15607///
15608/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15609/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15610/// #     .with_native_roots()
15611/// #     .unwrap()
15612/// #     .https_only()
15613/// #     .enable_http2()
15614/// #     .build();
15615///
15616/// # let executor = hyper_util::rt::TokioExecutor::new();
15617/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15618/// #     secret,
15619/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15620/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15621/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15622/// #     ),
15623/// # ).build().await.unwrap();
15624///
15625/// # let client = hyper_util::client::legacy::Client::builder(
15626/// #     hyper_util::rt::TokioExecutor::new()
15627/// # )
15628/// # .build(
15629/// #     hyper_rustls::HttpsConnectorBuilder::new()
15630/// #         .with_native_roots()
15631/// #         .unwrap()
15632/// #         .https_or_http()
15633/// #         .enable_http2()
15634/// #         .build()
15635/// # );
15636/// # let mut hub = SQLAdmin::new(client, auth);
15637/// // You can configure optional parameters by calling the respective setters at will, and
15638/// // execute the final call using `doit()`.
15639/// // Values shown here are possibly random and not representative !
15640/// let result = hub.projects().instances_start_external_sync("project", "instance")
15641///              .sync_mode("amet.")
15642///              .doit().await;
15643/// # }
15644/// ```
15645pub struct ProjectInstanceStartExternalSyncCall<'a, C>
15646where
15647    C: 'a,
15648{
15649    hub: &'a SQLAdmin<C>,
15650    _project: String,
15651    _instance: String,
15652    _sync_mode: Option<String>,
15653    _delegate: Option<&'a mut dyn common::Delegate>,
15654    _additional_params: HashMap<String, String>,
15655    _scopes: BTreeSet<String>,
15656}
15657
15658impl<'a, C> common::CallBuilder for ProjectInstanceStartExternalSyncCall<'a, C> {}
15659
15660impl<'a, C> ProjectInstanceStartExternalSyncCall<'a, C>
15661where
15662    C: common::Connector,
15663{
15664    /// Perform the operation you have build so far.
15665    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15666        use std::borrow::Cow;
15667        use std::io::{Read, Seek};
15668
15669        use common::{url::Params, ToParts};
15670        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15671
15672        let mut dd = common::DefaultDelegate;
15673        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15674        dlg.begin(common::MethodInfo {
15675            id: "sql.projects.instances.startExternalSync",
15676            http_method: hyper::Method::POST,
15677        });
15678
15679        for &field in ["alt", "project", "instance", "syncMode"].iter() {
15680            if self._additional_params.contains_key(field) {
15681                dlg.finished(false);
15682                return Err(common::Error::FieldClash(field));
15683            }
15684        }
15685
15686        let mut params = Params::with_capacity(5 + self._additional_params.len());
15687        params.push("project", self._project);
15688        params.push("instance", self._instance);
15689        if let Some(value) = self._sync_mode.as_ref() {
15690            params.push("syncMode", value);
15691        }
15692
15693        params.extend(self._additional_params.iter());
15694
15695        params.push("alt", "json");
15696        let mut url = self.hub._base_url.clone()
15697            + "sql/v1beta4/projects/{project}/instances/{instance}/startExternalSync";
15698        if self._scopes.is_empty() {
15699            self._scopes
15700                .insert(Scope::CloudPlatform.as_ref().to_string());
15701        }
15702
15703        #[allow(clippy::single_element_loop)]
15704        for &(find_this, param_name) in
15705            [("{project}", "project"), ("{instance}", "instance")].iter()
15706        {
15707            url = params.uri_replacement(url, param_name, find_this, false);
15708        }
15709        {
15710            let to_remove = ["instance", "project"];
15711            params.remove_params(&to_remove);
15712        }
15713
15714        let url = params.parse_with_url(&url);
15715
15716        loop {
15717            let token = match self
15718                .hub
15719                .auth
15720                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15721                .await
15722            {
15723                Ok(token) => token,
15724                Err(e) => match dlg.token(e) {
15725                    Ok(token) => token,
15726                    Err(e) => {
15727                        dlg.finished(false);
15728                        return Err(common::Error::MissingToken(e));
15729                    }
15730                },
15731            };
15732            let mut req_result = {
15733                let client = &self.hub.client;
15734                dlg.pre_request();
15735                let mut req_builder = hyper::Request::builder()
15736                    .method(hyper::Method::POST)
15737                    .uri(url.as_str())
15738                    .header(USER_AGENT, self.hub._user_agent.clone());
15739
15740                if let Some(token) = token.as_ref() {
15741                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15742                }
15743
15744                let request = req_builder
15745                    .header(CONTENT_LENGTH, 0_u64)
15746                    .body(common::to_body::<String>(None));
15747
15748                client.request(request.unwrap()).await
15749            };
15750
15751            match req_result {
15752                Err(err) => {
15753                    if let common::Retry::After(d) = dlg.http_error(&err) {
15754                        sleep(d).await;
15755                        continue;
15756                    }
15757                    dlg.finished(false);
15758                    return Err(common::Error::HttpError(err));
15759                }
15760                Ok(res) => {
15761                    let (mut parts, body) = res.into_parts();
15762                    let mut body = common::Body::new(body);
15763                    if !parts.status.is_success() {
15764                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15765                        let error = serde_json::from_str(&common::to_string(&bytes));
15766                        let response = common::to_response(parts, bytes.into());
15767
15768                        if let common::Retry::After(d) =
15769                            dlg.http_failure(&response, error.as_ref().ok())
15770                        {
15771                            sleep(d).await;
15772                            continue;
15773                        }
15774
15775                        dlg.finished(false);
15776
15777                        return Err(match error {
15778                            Ok(value) => common::Error::BadRequest(value),
15779                            _ => common::Error::Failure(response),
15780                        });
15781                    }
15782                    let response = {
15783                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15784                        let encoded = common::to_string(&bytes);
15785                        match serde_json::from_str(&encoded) {
15786                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15787                            Err(error) => {
15788                                dlg.response_json_decode_error(&encoded, &error);
15789                                return Err(common::Error::JsonDecodeError(
15790                                    encoded.to_string(),
15791                                    error,
15792                                ));
15793                            }
15794                        }
15795                    };
15796
15797                    dlg.finished(true);
15798                    return Ok(response);
15799                }
15800            }
15801        }
15802    }
15803
15804    /// ID of the project that contains the first generation instance.
15805    ///
15806    /// Sets the *project* path property to the given value.
15807    ///
15808    /// Even though the property as already been set when instantiating this call,
15809    /// we provide this method for API completeness.
15810    pub fn project(mut self, new_value: &str) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15811        self._project = new_value.to_string();
15812        self
15813    }
15814    /// Cloud SQL instance ID. This does not include the project ID.
15815    ///
15816    /// Sets the *instance* path property to the given value.
15817    ///
15818    /// Even though the property as already been set when instantiating this call,
15819    /// we provide this method for API completeness.
15820    pub fn instance(mut self, new_value: &str) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15821        self._instance = new_value.to_string();
15822        self
15823    }
15824    /// External sync mode
15825    ///
15826    /// Sets the *sync mode* query property to the given value.
15827    pub fn sync_mode(mut self, new_value: &str) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15828        self._sync_mode = Some(new_value.to_string());
15829        self
15830    }
15831    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15832    /// while executing the actual API request.
15833    ///
15834    /// ````text
15835    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15836    /// ````
15837    ///
15838    /// Sets the *delegate* property to the given value.
15839    pub fn delegate(
15840        mut self,
15841        new_value: &'a mut dyn common::Delegate,
15842    ) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15843        self._delegate = Some(new_value);
15844        self
15845    }
15846
15847    /// Set any additional parameter of the query string used in the request.
15848    /// It should be used to set parameters which are not yet available through their own
15849    /// setters.
15850    ///
15851    /// Please note that this method must not be used to set any of the known parameters
15852    /// which have their own setter method. If done anyway, the request will fail.
15853    ///
15854    /// # Additional Parameters
15855    ///
15856    /// * *$.xgafv* (query-string) - V1 error format.
15857    /// * *access_token* (query-string) - OAuth access token.
15858    /// * *alt* (query-string) - Data format for response.
15859    /// * *callback* (query-string) - JSONP
15860    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15861    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15862    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15863    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15864    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15865    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15866    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15867    pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceStartExternalSyncCall<'a, C>
15868    where
15869        T: AsRef<str>,
15870    {
15871        self._additional_params
15872            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15873        self
15874    }
15875
15876    /// Identifies the authorization scope for the method you are building.
15877    ///
15878    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15879    /// [`Scope::CloudPlatform`].
15880    ///
15881    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15882    /// tokens for more than one scope.
15883    ///
15884    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15885    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15886    /// sufficient, a read-write scope will do as well.
15887    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceStartExternalSyncCall<'a, C>
15888    where
15889        St: AsRef<str>,
15890    {
15891        self._scopes.insert(String::from(scope.as_ref()));
15892        self
15893    }
15894    /// Identifies the authorization scope(s) for the method you are building.
15895    ///
15896    /// See [`Self::add_scope()`] for details.
15897    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceStartExternalSyncCall<'a, C>
15898    where
15899        I: IntoIterator<Item = St>,
15900        St: AsRef<str>,
15901    {
15902        self._scopes
15903            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15904        self
15905    }
15906
15907    /// Removes all scopes, and no default scope will be used either.
15908    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15909    /// for details).
15910    pub fn clear_scopes(mut self) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15911        self._scopes.clear();
15912        self
15913    }
15914}
15915
15916/// Verify External master external sync settings.
15917///
15918/// A builder for the *instances.verifyExternalSyncSettings* method supported by a *project* resource.
15919/// It is not used directly, but through a [`ProjectMethods`] instance.
15920///
15921/// # Example
15922///
15923/// Instantiate a resource method builder
15924///
15925/// ```test_harness,no_run
15926/// # extern crate hyper;
15927/// # extern crate hyper_rustls;
15928/// # extern crate google_sql1_beta4 as sql1_beta4;
15929/// # async fn dox() {
15930/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15931///
15932/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15933/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15934/// #     .with_native_roots()
15935/// #     .unwrap()
15936/// #     .https_only()
15937/// #     .enable_http2()
15938/// #     .build();
15939///
15940/// # let executor = hyper_util::rt::TokioExecutor::new();
15941/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15942/// #     secret,
15943/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15944/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15945/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15946/// #     ),
15947/// # ).build().await.unwrap();
15948///
15949/// # let client = hyper_util::client::legacy::Client::builder(
15950/// #     hyper_util::rt::TokioExecutor::new()
15951/// # )
15952/// # .build(
15953/// #     hyper_rustls::HttpsConnectorBuilder::new()
15954/// #         .with_native_roots()
15955/// #         .unwrap()
15956/// #         .https_or_http()
15957/// #         .enable_http2()
15958/// #         .build()
15959/// # );
15960/// # let mut hub = SQLAdmin::new(client, auth);
15961/// // You can configure optional parameters by calling the respective setters at will, and
15962/// // execute the final call using `doit()`.
15963/// // Values shown here are possibly random and not representative !
15964/// let result = hub.projects().instances_verify_external_sync_settings("project", "instance")
15965///              .verify_connection_only(true)
15966///              .sync_mode("no")
15967///              .doit().await;
15968/// # }
15969/// ```
15970pub struct ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
15971where
15972    C: 'a,
15973{
15974    hub: &'a SQLAdmin<C>,
15975    _project: String,
15976    _instance: String,
15977    _verify_connection_only: Option<bool>,
15978    _sync_mode: Option<String>,
15979    _delegate: Option<&'a mut dyn common::Delegate>,
15980    _additional_params: HashMap<String, String>,
15981    _scopes: BTreeSet<String>,
15982}
15983
15984impl<'a, C> common::CallBuilder for ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {}
15985
15986impl<'a, C> ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
15987where
15988    C: common::Connector,
15989{
15990    /// Perform the operation you have build so far.
15991    pub async fn doit(
15992        mut self,
15993    ) -> common::Result<(
15994        common::Response,
15995        SqlInstancesVerifyExternalSyncSettingsResponse,
15996    )> {
15997        use std::borrow::Cow;
15998        use std::io::{Read, Seek};
15999
16000        use common::{url::Params, ToParts};
16001        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16002
16003        let mut dd = common::DefaultDelegate;
16004        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16005        dlg.begin(common::MethodInfo {
16006            id: "sql.projects.instances.verifyExternalSyncSettings",
16007            http_method: hyper::Method::POST,
16008        });
16009
16010        for &field in [
16011            "alt",
16012            "project",
16013            "instance",
16014            "verifyConnectionOnly",
16015            "syncMode",
16016        ]
16017        .iter()
16018        {
16019            if self._additional_params.contains_key(field) {
16020                dlg.finished(false);
16021                return Err(common::Error::FieldClash(field));
16022            }
16023        }
16024
16025        let mut params = Params::with_capacity(6 + self._additional_params.len());
16026        params.push("project", self._project);
16027        params.push("instance", self._instance);
16028        if let Some(value) = self._verify_connection_only.as_ref() {
16029            params.push("verifyConnectionOnly", value.to_string());
16030        }
16031        if let Some(value) = self._sync_mode.as_ref() {
16032            params.push("syncMode", value);
16033        }
16034
16035        params.extend(self._additional_params.iter());
16036
16037        params.push("alt", "json");
16038        let mut url = self.hub._base_url.clone()
16039            + "sql/v1beta4/projects/{project}/instances/{instance}/verifyExternalSyncSettings";
16040        if self._scopes.is_empty() {
16041            self._scopes
16042                .insert(Scope::CloudPlatform.as_ref().to_string());
16043        }
16044
16045        #[allow(clippy::single_element_loop)]
16046        for &(find_this, param_name) in
16047            [("{project}", "project"), ("{instance}", "instance")].iter()
16048        {
16049            url = params.uri_replacement(url, param_name, find_this, false);
16050        }
16051        {
16052            let to_remove = ["instance", "project"];
16053            params.remove_params(&to_remove);
16054        }
16055
16056        let url = params.parse_with_url(&url);
16057
16058        loop {
16059            let token = match self
16060                .hub
16061                .auth
16062                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16063                .await
16064            {
16065                Ok(token) => token,
16066                Err(e) => match dlg.token(e) {
16067                    Ok(token) => token,
16068                    Err(e) => {
16069                        dlg.finished(false);
16070                        return Err(common::Error::MissingToken(e));
16071                    }
16072                },
16073            };
16074            let mut req_result = {
16075                let client = &self.hub.client;
16076                dlg.pre_request();
16077                let mut req_builder = hyper::Request::builder()
16078                    .method(hyper::Method::POST)
16079                    .uri(url.as_str())
16080                    .header(USER_AGENT, self.hub._user_agent.clone());
16081
16082                if let Some(token) = token.as_ref() {
16083                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16084                }
16085
16086                let request = req_builder
16087                    .header(CONTENT_LENGTH, 0_u64)
16088                    .body(common::to_body::<String>(None));
16089
16090                client.request(request.unwrap()).await
16091            };
16092
16093            match req_result {
16094                Err(err) => {
16095                    if let common::Retry::After(d) = dlg.http_error(&err) {
16096                        sleep(d).await;
16097                        continue;
16098                    }
16099                    dlg.finished(false);
16100                    return Err(common::Error::HttpError(err));
16101                }
16102                Ok(res) => {
16103                    let (mut parts, body) = res.into_parts();
16104                    let mut body = common::Body::new(body);
16105                    if !parts.status.is_success() {
16106                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16107                        let error = serde_json::from_str(&common::to_string(&bytes));
16108                        let response = common::to_response(parts, bytes.into());
16109
16110                        if let common::Retry::After(d) =
16111                            dlg.http_failure(&response, error.as_ref().ok())
16112                        {
16113                            sleep(d).await;
16114                            continue;
16115                        }
16116
16117                        dlg.finished(false);
16118
16119                        return Err(match error {
16120                            Ok(value) => common::Error::BadRequest(value),
16121                            _ => common::Error::Failure(response),
16122                        });
16123                    }
16124                    let response = {
16125                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16126                        let encoded = common::to_string(&bytes);
16127                        match serde_json::from_str(&encoded) {
16128                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16129                            Err(error) => {
16130                                dlg.response_json_decode_error(&encoded, &error);
16131                                return Err(common::Error::JsonDecodeError(
16132                                    encoded.to_string(),
16133                                    error,
16134                                ));
16135                            }
16136                        }
16137                    };
16138
16139                    dlg.finished(true);
16140                    return Ok(response);
16141                }
16142            }
16143        }
16144    }
16145
16146    /// Project ID of the project that contains the instance.
16147    ///
16148    /// Sets the *project* path property to the given value.
16149    ///
16150    /// Even though the property as already been set when instantiating this call,
16151    /// we provide this method for API completeness.
16152    pub fn project(
16153        mut self,
16154        new_value: &str,
16155    ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
16156        self._project = new_value.to_string();
16157        self
16158    }
16159    /// Cloud SQL instance ID. This does not include the project ID.
16160    ///
16161    /// Sets the *instance* path property to the given value.
16162    ///
16163    /// Even though the property as already been set when instantiating this call,
16164    /// we provide this method for API completeness.
16165    pub fn instance(
16166        mut self,
16167        new_value: &str,
16168    ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
16169        self._instance = new_value.to_string();
16170        self
16171    }
16172    /// Flag to enable verifying connection only
16173    ///
16174    /// Sets the *verify connection only* query property to the given value.
16175    pub fn verify_connection_only(
16176        mut self,
16177        new_value: bool,
16178    ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
16179        self._verify_connection_only = Some(new_value);
16180        self
16181    }
16182    /// External sync mode
16183    ///
16184    /// Sets the *sync mode* query property to the given value.
16185    pub fn sync_mode(
16186        mut self,
16187        new_value: &str,
16188    ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
16189        self._sync_mode = Some(new_value.to_string());
16190        self
16191    }
16192    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16193    /// while executing the actual API request.
16194    ///
16195    /// ````text
16196    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16197    /// ````
16198    ///
16199    /// Sets the *delegate* property to the given value.
16200    pub fn delegate(
16201        mut self,
16202        new_value: &'a mut dyn common::Delegate,
16203    ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
16204        self._delegate = Some(new_value);
16205        self
16206    }
16207
16208    /// Set any additional parameter of the query string used in the request.
16209    /// It should be used to set parameters which are not yet available through their own
16210    /// setters.
16211    ///
16212    /// Please note that this method must not be used to set any of the known parameters
16213    /// which have their own setter method. If done anyway, the request will fail.
16214    ///
16215    /// # Additional Parameters
16216    ///
16217    /// * *$.xgafv* (query-string) - V1 error format.
16218    /// * *access_token* (query-string) - OAuth access token.
16219    /// * *alt* (query-string) - Data format for response.
16220    /// * *callback* (query-string) - JSONP
16221    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16222    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16223    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16224    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16225    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16226    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16227    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16228    pub fn param<T>(
16229        mut self,
16230        name: T,
16231        value: T,
16232    ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
16233    where
16234        T: AsRef<str>,
16235    {
16236        self._additional_params
16237            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16238        self
16239    }
16240
16241    /// Identifies the authorization scope for the method you are building.
16242    ///
16243    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16244    /// [`Scope::CloudPlatform`].
16245    ///
16246    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16247    /// tokens for more than one scope.
16248    ///
16249    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16250    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16251    /// sufficient, a read-write scope will do as well.
16252    pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
16253    where
16254        St: AsRef<str>,
16255    {
16256        self._scopes.insert(String::from(scope.as_ref()));
16257        self
16258    }
16259    /// Identifies the authorization scope(s) for the method you are building.
16260    ///
16261    /// See [`Self::add_scope()`] for details.
16262    pub fn add_scopes<I, St>(
16263        mut self,
16264        scopes: I,
16265    ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
16266    where
16267        I: IntoIterator<Item = St>,
16268        St: AsRef<str>,
16269    {
16270        self._scopes
16271            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16272        self
16273    }
16274
16275    /// Removes all scopes, and no default scope will be used either.
16276    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16277    /// for details).
16278    pub fn clear_scopes(mut self) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
16279        self._scopes.clear();
16280        self
16281    }
16282}
16283
16284/// Generates a short-lived X509 certificate containing the provided public key
16285/// and signed by a private key specific to the target instance. Users may use
16286/// the certificate to authenticate as themselves when connecting to the
16287/// database.
16288///
16289/// A builder for the *createEphemeral* method supported by a *sslCert* resource.
16290/// It is not used directly, but through a [`SslCertMethods`] instance.
16291///
16292/// # Example
16293///
16294/// Instantiate a resource method builder
16295///
16296/// ```test_harness,no_run
16297/// # extern crate hyper;
16298/// # extern crate hyper_rustls;
16299/// # extern crate google_sql1_beta4 as sql1_beta4;
16300/// use sql1_beta4::api::SslCertsCreateEphemeralRequest;
16301/// # async fn dox() {
16302/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16303///
16304/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16305/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16306/// #     .with_native_roots()
16307/// #     .unwrap()
16308/// #     .https_only()
16309/// #     .enable_http2()
16310/// #     .build();
16311///
16312/// # let executor = hyper_util::rt::TokioExecutor::new();
16313/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16314/// #     secret,
16315/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16316/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16317/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16318/// #     ),
16319/// # ).build().await.unwrap();
16320///
16321/// # let client = hyper_util::client::legacy::Client::builder(
16322/// #     hyper_util::rt::TokioExecutor::new()
16323/// # )
16324/// # .build(
16325/// #     hyper_rustls::HttpsConnectorBuilder::new()
16326/// #         .with_native_roots()
16327/// #         .unwrap()
16328/// #         .https_or_http()
16329/// #         .enable_http2()
16330/// #         .build()
16331/// # );
16332/// # let mut hub = SQLAdmin::new(client, auth);
16333/// // As the method needs a request, you would usually fill it with the desired information
16334/// // into the respective structure. Some of the parts shown here might not be applicable !
16335/// // Values shown here are possibly random and not representative !
16336/// let mut req = SslCertsCreateEphemeralRequest::default();
16337///
16338/// // You can configure optional parameters by calling the respective setters at will, and
16339/// // execute the final call using `doit()`.
16340/// // Values shown here are possibly random and not representative !
16341/// let result = hub.ssl_certs().create_ephemeral(req, "project", "instance")
16342///              .doit().await;
16343/// # }
16344/// ```
16345pub struct SslCertCreateEphemeralCall<'a, C>
16346where
16347    C: 'a,
16348{
16349    hub: &'a SQLAdmin<C>,
16350    _request: SslCertsCreateEphemeralRequest,
16351    _project: String,
16352    _instance: String,
16353    _delegate: Option<&'a mut dyn common::Delegate>,
16354    _additional_params: HashMap<String, String>,
16355    _scopes: BTreeSet<String>,
16356}
16357
16358impl<'a, C> common::CallBuilder for SslCertCreateEphemeralCall<'a, C> {}
16359
16360impl<'a, C> SslCertCreateEphemeralCall<'a, C>
16361where
16362    C: common::Connector,
16363{
16364    /// Perform the operation you have build so far.
16365    pub async fn doit(mut self) -> common::Result<(common::Response, SslCert)> {
16366        use std::borrow::Cow;
16367        use std::io::{Read, Seek};
16368
16369        use common::{url::Params, ToParts};
16370        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16371
16372        let mut dd = common::DefaultDelegate;
16373        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16374        dlg.begin(common::MethodInfo {
16375            id: "sql.sslCerts.createEphemeral",
16376            http_method: hyper::Method::POST,
16377        });
16378
16379        for &field in ["alt", "project", "instance"].iter() {
16380            if self._additional_params.contains_key(field) {
16381                dlg.finished(false);
16382                return Err(common::Error::FieldClash(field));
16383            }
16384        }
16385
16386        let mut params = Params::with_capacity(5 + self._additional_params.len());
16387        params.push("project", self._project);
16388        params.push("instance", self._instance);
16389
16390        params.extend(self._additional_params.iter());
16391
16392        params.push("alt", "json");
16393        let mut url = self.hub._base_url.clone()
16394            + "sql/v1beta4/projects/{project}/instances/{instance}/createEphemeral";
16395        if self._scopes.is_empty() {
16396            self._scopes
16397                .insert(Scope::CloudPlatform.as_ref().to_string());
16398        }
16399
16400        #[allow(clippy::single_element_loop)]
16401        for &(find_this, param_name) in
16402            [("{project}", "project"), ("{instance}", "instance")].iter()
16403        {
16404            url = params.uri_replacement(url, param_name, find_this, false);
16405        }
16406        {
16407            let to_remove = ["instance", "project"];
16408            params.remove_params(&to_remove);
16409        }
16410
16411        let url = params.parse_with_url(&url);
16412
16413        let mut json_mime_type = mime::APPLICATION_JSON;
16414        let mut request_value_reader = {
16415            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16416            common::remove_json_null_values(&mut value);
16417            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16418            serde_json::to_writer(&mut dst, &value).unwrap();
16419            dst
16420        };
16421        let request_size = request_value_reader
16422            .seek(std::io::SeekFrom::End(0))
16423            .unwrap();
16424        request_value_reader
16425            .seek(std::io::SeekFrom::Start(0))
16426            .unwrap();
16427
16428        loop {
16429            let token = match self
16430                .hub
16431                .auth
16432                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16433                .await
16434            {
16435                Ok(token) => token,
16436                Err(e) => match dlg.token(e) {
16437                    Ok(token) => token,
16438                    Err(e) => {
16439                        dlg.finished(false);
16440                        return Err(common::Error::MissingToken(e));
16441                    }
16442                },
16443            };
16444            request_value_reader
16445                .seek(std::io::SeekFrom::Start(0))
16446                .unwrap();
16447            let mut req_result = {
16448                let client = &self.hub.client;
16449                dlg.pre_request();
16450                let mut req_builder = hyper::Request::builder()
16451                    .method(hyper::Method::POST)
16452                    .uri(url.as_str())
16453                    .header(USER_AGENT, self.hub._user_agent.clone());
16454
16455                if let Some(token) = token.as_ref() {
16456                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16457                }
16458
16459                let request = req_builder
16460                    .header(CONTENT_TYPE, json_mime_type.to_string())
16461                    .header(CONTENT_LENGTH, request_size as u64)
16462                    .body(common::to_body(
16463                        request_value_reader.get_ref().clone().into(),
16464                    ));
16465
16466                client.request(request.unwrap()).await
16467            };
16468
16469            match req_result {
16470                Err(err) => {
16471                    if let common::Retry::After(d) = dlg.http_error(&err) {
16472                        sleep(d).await;
16473                        continue;
16474                    }
16475                    dlg.finished(false);
16476                    return Err(common::Error::HttpError(err));
16477                }
16478                Ok(res) => {
16479                    let (mut parts, body) = res.into_parts();
16480                    let mut body = common::Body::new(body);
16481                    if !parts.status.is_success() {
16482                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16483                        let error = serde_json::from_str(&common::to_string(&bytes));
16484                        let response = common::to_response(parts, bytes.into());
16485
16486                        if let common::Retry::After(d) =
16487                            dlg.http_failure(&response, error.as_ref().ok())
16488                        {
16489                            sleep(d).await;
16490                            continue;
16491                        }
16492
16493                        dlg.finished(false);
16494
16495                        return Err(match error {
16496                            Ok(value) => common::Error::BadRequest(value),
16497                            _ => common::Error::Failure(response),
16498                        });
16499                    }
16500                    let response = {
16501                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16502                        let encoded = common::to_string(&bytes);
16503                        match serde_json::from_str(&encoded) {
16504                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16505                            Err(error) => {
16506                                dlg.response_json_decode_error(&encoded, &error);
16507                                return Err(common::Error::JsonDecodeError(
16508                                    encoded.to_string(),
16509                                    error,
16510                                ));
16511                            }
16512                        }
16513                    };
16514
16515                    dlg.finished(true);
16516                    return Ok(response);
16517                }
16518            }
16519        }
16520    }
16521
16522    ///
16523    /// Sets the *request* property to the given value.
16524    ///
16525    /// Even though the property as already been set when instantiating this call,
16526    /// we provide this method for API completeness.
16527    pub fn request(
16528        mut self,
16529        new_value: SslCertsCreateEphemeralRequest,
16530    ) -> SslCertCreateEphemeralCall<'a, C> {
16531        self._request = new_value;
16532        self
16533    }
16534    /// Project ID of the Cloud SQL project.
16535    ///
16536    /// Sets the *project* path property to the given value.
16537    ///
16538    /// Even though the property as already been set when instantiating this call,
16539    /// we provide this method for API completeness.
16540    pub fn project(mut self, new_value: &str) -> SslCertCreateEphemeralCall<'a, C> {
16541        self._project = new_value.to_string();
16542        self
16543    }
16544    /// Cloud SQL instance ID. This does not include the project ID.
16545    ///
16546    /// Sets the *instance* path property to the given value.
16547    ///
16548    /// Even though the property as already been set when instantiating this call,
16549    /// we provide this method for API completeness.
16550    pub fn instance(mut self, new_value: &str) -> SslCertCreateEphemeralCall<'a, C> {
16551        self._instance = new_value.to_string();
16552        self
16553    }
16554    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16555    /// while executing the actual API request.
16556    ///
16557    /// ````text
16558    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16559    /// ````
16560    ///
16561    /// Sets the *delegate* property to the given value.
16562    pub fn delegate(
16563        mut self,
16564        new_value: &'a mut dyn common::Delegate,
16565    ) -> SslCertCreateEphemeralCall<'a, C> {
16566        self._delegate = Some(new_value);
16567        self
16568    }
16569
16570    /// Set any additional parameter of the query string used in the request.
16571    /// It should be used to set parameters which are not yet available through their own
16572    /// setters.
16573    ///
16574    /// Please note that this method must not be used to set any of the known parameters
16575    /// which have their own setter method. If done anyway, the request will fail.
16576    ///
16577    /// # Additional Parameters
16578    ///
16579    /// * *$.xgafv* (query-string) - V1 error format.
16580    /// * *access_token* (query-string) - OAuth access token.
16581    /// * *alt* (query-string) - Data format for response.
16582    /// * *callback* (query-string) - JSONP
16583    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16584    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16585    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16586    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16587    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16588    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16589    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16590    pub fn param<T>(mut self, name: T, value: T) -> SslCertCreateEphemeralCall<'a, C>
16591    where
16592        T: AsRef<str>,
16593    {
16594        self._additional_params
16595            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16596        self
16597    }
16598
16599    /// Identifies the authorization scope for the method you are building.
16600    ///
16601    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16602    /// [`Scope::CloudPlatform`].
16603    ///
16604    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16605    /// tokens for more than one scope.
16606    ///
16607    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16608    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16609    /// sufficient, a read-write scope will do as well.
16610    pub fn add_scope<St>(mut self, scope: St) -> SslCertCreateEphemeralCall<'a, C>
16611    where
16612        St: AsRef<str>,
16613    {
16614        self._scopes.insert(String::from(scope.as_ref()));
16615        self
16616    }
16617    /// Identifies the authorization scope(s) for the method you are building.
16618    ///
16619    /// See [`Self::add_scope()`] for details.
16620    pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertCreateEphemeralCall<'a, C>
16621    where
16622        I: IntoIterator<Item = St>,
16623        St: AsRef<str>,
16624    {
16625        self._scopes
16626            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16627        self
16628    }
16629
16630    /// Removes all scopes, and no default scope will be used either.
16631    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16632    /// for details).
16633    pub fn clear_scopes(mut self) -> SslCertCreateEphemeralCall<'a, C> {
16634        self._scopes.clear();
16635        self
16636    }
16637}
16638
16639/// Deletes the SSL certificate. For First Generation instances, the
16640/// certificate remains valid until the instance is restarted.
16641///
16642/// A builder for the *delete* method supported by a *sslCert* resource.
16643/// It is not used directly, but through a [`SslCertMethods`] instance.
16644///
16645/// # Example
16646///
16647/// Instantiate a resource method builder
16648///
16649/// ```test_harness,no_run
16650/// # extern crate hyper;
16651/// # extern crate hyper_rustls;
16652/// # extern crate google_sql1_beta4 as sql1_beta4;
16653/// # async fn dox() {
16654/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16655///
16656/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16657/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16658/// #     .with_native_roots()
16659/// #     .unwrap()
16660/// #     .https_only()
16661/// #     .enable_http2()
16662/// #     .build();
16663///
16664/// # let executor = hyper_util::rt::TokioExecutor::new();
16665/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16666/// #     secret,
16667/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16668/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16669/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16670/// #     ),
16671/// # ).build().await.unwrap();
16672///
16673/// # let client = hyper_util::client::legacy::Client::builder(
16674/// #     hyper_util::rt::TokioExecutor::new()
16675/// # )
16676/// # .build(
16677/// #     hyper_rustls::HttpsConnectorBuilder::new()
16678/// #         .with_native_roots()
16679/// #         .unwrap()
16680/// #         .https_or_http()
16681/// #         .enable_http2()
16682/// #         .build()
16683/// # );
16684/// # let mut hub = SQLAdmin::new(client, auth);
16685/// // You can configure optional parameters by calling the respective setters at will, and
16686/// // execute the final call using `doit()`.
16687/// // Values shown here are possibly random and not representative !
16688/// let result = hub.ssl_certs().delete("project", "instance", "sha1Fingerprint")
16689///              .doit().await;
16690/// # }
16691/// ```
16692pub struct SslCertDeleteCall<'a, C>
16693where
16694    C: 'a,
16695{
16696    hub: &'a SQLAdmin<C>,
16697    _project: String,
16698    _instance: String,
16699    _sha1_fingerprint: String,
16700    _delegate: Option<&'a mut dyn common::Delegate>,
16701    _additional_params: HashMap<String, String>,
16702    _scopes: BTreeSet<String>,
16703}
16704
16705impl<'a, C> common::CallBuilder for SslCertDeleteCall<'a, C> {}
16706
16707impl<'a, C> SslCertDeleteCall<'a, C>
16708where
16709    C: common::Connector,
16710{
16711    /// Perform the operation you have build so far.
16712    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16713        use std::borrow::Cow;
16714        use std::io::{Read, Seek};
16715
16716        use common::{url::Params, ToParts};
16717        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16718
16719        let mut dd = common::DefaultDelegate;
16720        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16721        dlg.begin(common::MethodInfo {
16722            id: "sql.sslCerts.delete",
16723            http_method: hyper::Method::DELETE,
16724        });
16725
16726        for &field in ["alt", "project", "instance", "sha1Fingerprint"].iter() {
16727            if self._additional_params.contains_key(field) {
16728                dlg.finished(false);
16729                return Err(common::Error::FieldClash(field));
16730            }
16731        }
16732
16733        let mut params = Params::with_capacity(5 + self._additional_params.len());
16734        params.push("project", self._project);
16735        params.push("instance", self._instance);
16736        params.push("sha1Fingerprint", self._sha1_fingerprint);
16737
16738        params.extend(self._additional_params.iter());
16739
16740        params.push("alt", "json");
16741        let mut url = self.hub._base_url.clone()
16742            + "sql/v1beta4/projects/{project}/instances/{instance}/sslCerts/{sha1Fingerprint}";
16743        if self._scopes.is_empty() {
16744            self._scopes
16745                .insert(Scope::CloudPlatform.as_ref().to_string());
16746        }
16747
16748        #[allow(clippy::single_element_loop)]
16749        for &(find_this, param_name) in [
16750            ("{project}", "project"),
16751            ("{instance}", "instance"),
16752            ("{sha1Fingerprint}", "sha1Fingerprint"),
16753        ]
16754        .iter()
16755        {
16756            url = params.uri_replacement(url, param_name, find_this, false);
16757        }
16758        {
16759            let to_remove = ["sha1Fingerprint", "instance", "project"];
16760            params.remove_params(&to_remove);
16761        }
16762
16763        let url = params.parse_with_url(&url);
16764
16765        loop {
16766            let token = match self
16767                .hub
16768                .auth
16769                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16770                .await
16771            {
16772                Ok(token) => token,
16773                Err(e) => match dlg.token(e) {
16774                    Ok(token) => token,
16775                    Err(e) => {
16776                        dlg.finished(false);
16777                        return Err(common::Error::MissingToken(e));
16778                    }
16779                },
16780            };
16781            let mut req_result = {
16782                let client = &self.hub.client;
16783                dlg.pre_request();
16784                let mut req_builder = hyper::Request::builder()
16785                    .method(hyper::Method::DELETE)
16786                    .uri(url.as_str())
16787                    .header(USER_AGENT, self.hub._user_agent.clone());
16788
16789                if let Some(token) = token.as_ref() {
16790                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16791                }
16792
16793                let request = req_builder
16794                    .header(CONTENT_LENGTH, 0_u64)
16795                    .body(common::to_body::<String>(None));
16796
16797                client.request(request.unwrap()).await
16798            };
16799
16800            match req_result {
16801                Err(err) => {
16802                    if let common::Retry::After(d) = dlg.http_error(&err) {
16803                        sleep(d).await;
16804                        continue;
16805                    }
16806                    dlg.finished(false);
16807                    return Err(common::Error::HttpError(err));
16808                }
16809                Ok(res) => {
16810                    let (mut parts, body) = res.into_parts();
16811                    let mut body = common::Body::new(body);
16812                    if !parts.status.is_success() {
16813                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16814                        let error = serde_json::from_str(&common::to_string(&bytes));
16815                        let response = common::to_response(parts, bytes.into());
16816
16817                        if let common::Retry::After(d) =
16818                            dlg.http_failure(&response, error.as_ref().ok())
16819                        {
16820                            sleep(d).await;
16821                            continue;
16822                        }
16823
16824                        dlg.finished(false);
16825
16826                        return Err(match error {
16827                            Ok(value) => common::Error::BadRequest(value),
16828                            _ => common::Error::Failure(response),
16829                        });
16830                    }
16831                    let response = {
16832                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16833                        let encoded = common::to_string(&bytes);
16834                        match serde_json::from_str(&encoded) {
16835                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16836                            Err(error) => {
16837                                dlg.response_json_decode_error(&encoded, &error);
16838                                return Err(common::Error::JsonDecodeError(
16839                                    encoded.to_string(),
16840                                    error,
16841                                ));
16842                            }
16843                        }
16844                    };
16845
16846                    dlg.finished(true);
16847                    return Ok(response);
16848                }
16849            }
16850        }
16851    }
16852
16853    /// Project ID of the project that contains the instance.
16854    ///
16855    /// Sets the *project* path property to the given value.
16856    ///
16857    /// Even though the property as already been set when instantiating this call,
16858    /// we provide this method for API completeness.
16859    pub fn project(mut self, new_value: &str) -> SslCertDeleteCall<'a, C> {
16860        self._project = new_value.to_string();
16861        self
16862    }
16863    /// Cloud SQL instance ID. This does not include the project ID.
16864    ///
16865    /// Sets the *instance* path property to the given value.
16866    ///
16867    /// Even though the property as already been set when instantiating this call,
16868    /// we provide this method for API completeness.
16869    pub fn instance(mut self, new_value: &str) -> SslCertDeleteCall<'a, C> {
16870        self._instance = new_value.to_string();
16871        self
16872    }
16873    /// Sha1 FingerPrint.
16874    ///
16875    /// Sets the *sha1 fingerprint* path property to the given value.
16876    ///
16877    /// Even though the property as already been set when instantiating this call,
16878    /// we provide this method for API completeness.
16879    pub fn sha1_fingerprint(mut self, new_value: &str) -> SslCertDeleteCall<'a, C> {
16880        self._sha1_fingerprint = new_value.to_string();
16881        self
16882    }
16883    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16884    /// while executing the actual API request.
16885    ///
16886    /// ````text
16887    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16888    /// ````
16889    ///
16890    /// Sets the *delegate* property to the given value.
16891    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SslCertDeleteCall<'a, C> {
16892        self._delegate = Some(new_value);
16893        self
16894    }
16895
16896    /// Set any additional parameter of the query string used in the request.
16897    /// It should be used to set parameters which are not yet available through their own
16898    /// setters.
16899    ///
16900    /// Please note that this method must not be used to set any of the known parameters
16901    /// which have their own setter method. If done anyway, the request will fail.
16902    ///
16903    /// # Additional Parameters
16904    ///
16905    /// * *$.xgafv* (query-string) - V1 error format.
16906    /// * *access_token* (query-string) - OAuth access token.
16907    /// * *alt* (query-string) - Data format for response.
16908    /// * *callback* (query-string) - JSONP
16909    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16910    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16911    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16912    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16913    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16914    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16915    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16916    pub fn param<T>(mut self, name: T, value: T) -> SslCertDeleteCall<'a, C>
16917    where
16918        T: AsRef<str>,
16919    {
16920        self._additional_params
16921            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16922        self
16923    }
16924
16925    /// Identifies the authorization scope for the method you are building.
16926    ///
16927    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16928    /// [`Scope::CloudPlatform`].
16929    ///
16930    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16931    /// tokens for more than one scope.
16932    ///
16933    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16934    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16935    /// sufficient, a read-write scope will do as well.
16936    pub fn add_scope<St>(mut self, scope: St) -> SslCertDeleteCall<'a, C>
16937    where
16938        St: AsRef<str>,
16939    {
16940        self._scopes.insert(String::from(scope.as_ref()));
16941        self
16942    }
16943    /// Identifies the authorization scope(s) for the method you are building.
16944    ///
16945    /// See [`Self::add_scope()`] for details.
16946    pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertDeleteCall<'a, C>
16947    where
16948        I: IntoIterator<Item = St>,
16949        St: AsRef<str>,
16950    {
16951        self._scopes
16952            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16953        self
16954    }
16955
16956    /// Removes all scopes, and no default scope will be used either.
16957    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16958    /// for details).
16959    pub fn clear_scopes(mut self) -> SslCertDeleteCall<'a, C> {
16960        self._scopes.clear();
16961        self
16962    }
16963}
16964
16965/// Retrieves a particular SSL certificate.  Does not include the private key
16966/// (required for usage).  The private key must be saved from the response to
16967/// initial creation.
16968///
16969/// A builder for the *get* method supported by a *sslCert* resource.
16970/// It is not used directly, but through a [`SslCertMethods`] instance.
16971///
16972/// # Example
16973///
16974/// Instantiate a resource method builder
16975///
16976/// ```test_harness,no_run
16977/// # extern crate hyper;
16978/// # extern crate hyper_rustls;
16979/// # extern crate google_sql1_beta4 as sql1_beta4;
16980/// # async fn dox() {
16981/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16982///
16983/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16984/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16985/// #     .with_native_roots()
16986/// #     .unwrap()
16987/// #     .https_only()
16988/// #     .enable_http2()
16989/// #     .build();
16990///
16991/// # let executor = hyper_util::rt::TokioExecutor::new();
16992/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16993/// #     secret,
16994/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16995/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16996/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16997/// #     ),
16998/// # ).build().await.unwrap();
16999///
17000/// # let client = hyper_util::client::legacy::Client::builder(
17001/// #     hyper_util::rt::TokioExecutor::new()
17002/// # )
17003/// # .build(
17004/// #     hyper_rustls::HttpsConnectorBuilder::new()
17005/// #         .with_native_roots()
17006/// #         .unwrap()
17007/// #         .https_or_http()
17008/// #         .enable_http2()
17009/// #         .build()
17010/// # );
17011/// # let mut hub = SQLAdmin::new(client, auth);
17012/// // You can configure optional parameters by calling the respective setters at will, and
17013/// // execute the final call using `doit()`.
17014/// // Values shown here are possibly random and not representative !
17015/// let result = hub.ssl_certs().get("project", "instance", "sha1Fingerprint")
17016///              .doit().await;
17017/// # }
17018/// ```
17019pub struct SslCertGetCall<'a, C>
17020where
17021    C: 'a,
17022{
17023    hub: &'a SQLAdmin<C>,
17024    _project: String,
17025    _instance: String,
17026    _sha1_fingerprint: String,
17027    _delegate: Option<&'a mut dyn common::Delegate>,
17028    _additional_params: HashMap<String, String>,
17029    _scopes: BTreeSet<String>,
17030}
17031
17032impl<'a, C> common::CallBuilder for SslCertGetCall<'a, C> {}
17033
17034impl<'a, C> SslCertGetCall<'a, C>
17035where
17036    C: common::Connector,
17037{
17038    /// Perform the operation you have build so far.
17039    pub async fn doit(mut self) -> common::Result<(common::Response, SslCert)> {
17040        use std::borrow::Cow;
17041        use std::io::{Read, Seek};
17042
17043        use common::{url::Params, ToParts};
17044        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17045
17046        let mut dd = common::DefaultDelegate;
17047        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17048        dlg.begin(common::MethodInfo {
17049            id: "sql.sslCerts.get",
17050            http_method: hyper::Method::GET,
17051        });
17052
17053        for &field in ["alt", "project", "instance", "sha1Fingerprint"].iter() {
17054            if self._additional_params.contains_key(field) {
17055                dlg.finished(false);
17056                return Err(common::Error::FieldClash(field));
17057            }
17058        }
17059
17060        let mut params = Params::with_capacity(5 + self._additional_params.len());
17061        params.push("project", self._project);
17062        params.push("instance", self._instance);
17063        params.push("sha1Fingerprint", self._sha1_fingerprint);
17064
17065        params.extend(self._additional_params.iter());
17066
17067        params.push("alt", "json");
17068        let mut url = self.hub._base_url.clone()
17069            + "sql/v1beta4/projects/{project}/instances/{instance}/sslCerts/{sha1Fingerprint}";
17070        if self._scopes.is_empty() {
17071            self._scopes
17072                .insert(Scope::CloudPlatform.as_ref().to_string());
17073        }
17074
17075        #[allow(clippy::single_element_loop)]
17076        for &(find_this, param_name) in [
17077            ("{project}", "project"),
17078            ("{instance}", "instance"),
17079            ("{sha1Fingerprint}", "sha1Fingerprint"),
17080        ]
17081        .iter()
17082        {
17083            url = params.uri_replacement(url, param_name, find_this, false);
17084        }
17085        {
17086            let to_remove = ["sha1Fingerprint", "instance", "project"];
17087            params.remove_params(&to_remove);
17088        }
17089
17090        let url = params.parse_with_url(&url);
17091
17092        loop {
17093            let token = match self
17094                .hub
17095                .auth
17096                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17097                .await
17098            {
17099                Ok(token) => token,
17100                Err(e) => match dlg.token(e) {
17101                    Ok(token) => token,
17102                    Err(e) => {
17103                        dlg.finished(false);
17104                        return Err(common::Error::MissingToken(e));
17105                    }
17106                },
17107            };
17108            let mut req_result = {
17109                let client = &self.hub.client;
17110                dlg.pre_request();
17111                let mut req_builder = hyper::Request::builder()
17112                    .method(hyper::Method::GET)
17113                    .uri(url.as_str())
17114                    .header(USER_AGENT, self.hub._user_agent.clone());
17115
17116                if let Some(token) = token.as_ref() {
17117                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17118                }
17119
17120                let request = req_builder
17121                    .header(CONTENT_LENGTH, 0_u64)
17122                    .body(common::to_body::<String>(None));
17123
17124                client.request(request.unwrap()).await
17125            };
17126
17127            match req_result {
17128                Err(err) => {
17129                    if let common::Retry::After(d) = dlg.http_error(&err) {
17130                        sleep(d).await;
17131                        continue;
17132                    }
17133                    dlg.finished(false);
17134                    return Err(common::Error::HttpError(err));
17135                }
17136                Ok(res) => {
17137                    let (mut parts, body) = res.into_parts();
17138                    let mut body = common::Body::new(body);
17139                    if !parts.status.is_success() {
17140                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17141                        let error = serde_json::from_str(&common::to_string(&bytes));
17142                        let response = common::to_response(parts, bytes.into());
17143
17144                        if let common::Retry::After(d) =
17145                            dlg.http_failure(&response, error.as_ref().ok())
17146                        {
17147                            sleep(d).await;
17148                            continue;
17149                        }
17150
17151                        dlg.finished(false);
17152
17153                        return Err(match error {
17154                            Ok(value) => common::Error::BadRequest(value),
17155                            _ => common::Error::Failure(response),
17156                        });
17157                    }
17158                    let response = {
17159                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17160                        let encoded = common::to_string(&bytes);
17161                        match serde_json::from_str(&encoded) {
17162                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17163                            Err(error) => {
17164                                dlg.response_json_decode_error(&encoded, &error);
17165                                return Err(common::Error::JsonDecodeError(
17166                                    encoded.to_string(),
17167                                    error,
17168                                ));
17169                            }
17170                        }
17171                    };
17172
17173                    dlg.finished(true);
17174                    return Ok(response);
17175                }
17176            }
17177        }
17178    }
17179
17180    /// Project ID of the project that contains the instance.
17181    ///
17182    /// Sets the *project* path property to the given value.
17183    ///
17184    /// Even though the property as already been set when instantiating this call,
17185    /// we provide this method for API completeness.
17186    pub fn project(mut self, new_value: &str) -> SslCertGetCall<'a, C> {
17187        self._project = new_value.to_string();
17188        self
17189    }
17190    /// Cloud SQL instance ID. This does not include the project ID.
17191    ///
17192    /// Sets the *instance* path property to the given value.
17193    ///
17194    /// Even though the property as already been set when instantiating this call,
17195    /// we provide this method for API completeness.
17196    pub fn instance(mut self, new_value: &str) -> SslCertGetCall<'a, C> {
17197        self._instance = new_value.to_string();
17198        self
17199    }
17200    /// Sha1 FingerPrint.
17201    ///
17202    /// Sets the *sha1 fingerprint* path property to the given value.
17203    ///
17204    /// Even though the property as already been set when instantiating this call,
17205    /// we provide this method for API completeness.
17206    pub fn sha1_fingerprint(mut self, new_value: &str) -> SslCertGetCall<'a, C> {
17207        self._sha1_fingerprint = new_value.to_string();
17208        self
17209    }
17210    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17211    /// while executing the actual API request.
17212    ///
17213    /// ````text
17214    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17215    /// ````
17216    ///
17217    /// Sets the *delegate* property to the given value.
17218    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SslCertGetCall<'a, C> {
17219        self._delegate = Some(new_value);
17220        self
17221    }
17222
17223    /// Set any additional parameter of the query string used in the request.
17224    /// It should be used to set parameters which are not yet available through their own
17225    /// setters.
17226    ///
17227    /// Please note that this method must not be used to set any of the known parameters
17228    /// which have their own setter method. If done anyway, the request will fail.
17229    ///
17230    /// # Additional Parameters
17231    ///
17232    /// * *$.xgafv* (query-string) - V1 error format.
17233    /// * *access_token* (query-string) - OAuth access token.
17234    /// * *alt* (query-string) - Data format for response.
17235    /// * *callback* (query-string) - JSONP
17236    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17237    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17238    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17239    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17240    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17241    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17242    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17243    pub fn param<T>(mut self, name: T, value: T) -> SslCertGetCall<'a, C>
17244    where
17245        T: AsRef<str>,
17246    {
17247        self._additional_params
17248            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17249        self
17250    }
17251
17252    /// Identifies the authorization scope for the method you are building.
17253    ///
17254    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17255    /// [`Scope::CloudPlatform`].
17256    ///
17257    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17258    /// tokens for more than one scope.
17259    ///
17260    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17261    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17262    /// sufficient, a read-write scope will do as well.
17263    pub fn add_scope<St>(mut self, scope: St) -> SslCertGetCall<'a, C>
17264    where
17265        St: AsRef<str>,
17266    {
17267        self._scopes.insert(String::from(scope.as_ref()));
17268        self
17269    }
17270    /// Identifies the authorization scope(s) for the method you are building.
17271    ///
17272    /// See [`Self::add_scope()`] for details.
17273    pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertGetCall<'a, C>
17274    where
17275        I: IntoIterator<Item = St>,
17276        St: AsRef<str>,
17277    {
17278        self._scopes
17279            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17280        self
17281    }
17282
17283    /// Removes all scopes, and no default scope will be used either.
17284    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17285    /// for details).
17286    pub fn clear_scopes(mut self) -> SslCertGetCall<'a, C> {
17287        self._scopes.clear();
17288        self
17289    }
17290}
17291
17292/// Creates an SSL certificate and returns it along with the private key and
17293/// server certificate authority.  The new certificate will not be usable until
17294/// the instance is restarted.
17295///
17296/// A builder for the *insert* method supported by a *sslCert* resource.
17297/// It is not used directly, but through a [`SslCertMethods`] instance.
17298///
17299/// # Example
17300///
17301/// Instantiate a resource method builder
17302///
17303/// ```test_harness,no_run
17304/// # extern crate hyper;
17305/// # extern crate hyper_rustls;
17306/// # extern crate google_sql1_beta4 as sql1_beta4;
17307/// use sql1_beta4::api::SslCertsInsertRequest;
17308/// # async fn dox() {
17309/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17310///
17311/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17312/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17313/// #     .with_native_roots()
17314/// #     .unwrap()
17315/// #     .https_only()
17316/// #     .enable_http2()
17317/// #     .build();
17318///
17319/// # let executor = hyper_util::rt::TokioExecutor::new();
17320/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17321/// #     secret,
17322/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17323/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17324/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17325/// #     ),
17326/// # ).build().await.unwrap();
17327///
17328/// # let client = hyper_util::client::legacy::Client::builder(
17329/// #     hyper_util::rt::TokioExecutor::new()
17330/// # )
17331/// # .build(
17332/// #     hyper_rustls::HttpsConnectorBuilder::new()
17333/// #         .with_native_roots()
17334/// #         .unwrap()
17335/// #         .https_or_http()
17336/// #         .enable_http2()
17337/// #         .build()
17338/// # );
17339/// # let mut hub = SQLAdmin::new(client, auth);
17340/// // As the method needs a request, you would usually fill it with the desired information
17341/// // into the respective structure. Some of the parts shown here might not be applicable !
17342/// // Values shown here are possibly random and not representative !
17343/// let mut req = SslCertsInsertRequest::default();
17344///
17345/// // You can configure optional parameters by calling the respective setters at will, and
17346/// // execute the final call using `doit()`.
17347/// // Values shown here are possibly random and not representative !
17348/// let result = hub.ssl_certs().insert(req, "project", "instance")
17349///              .doit().await;
17350/// # }
17351/// ```
17352pub struct SslCertInsertCall<'a, C>
17353where
17354    C: 'a,
17355{
17356    hub: &'a SQLAdmin<C>,
17357    _request: SslCertsInsertRequest,
17358    _project: String,
17359    _instance: String,
17360    _delegate: Option<&'a mut dyn common::Delegate>,
17361    _additional_params: HashMap<String, String>,
17362    _scopes: BTreeSet<String>,
17363}
17364
17365impl<'a, C> common::CallBuilder for SslCertInsertCall<'a, C> {}
17366
17367impl<'a, C> SslCertInsertCall<'a, C>
17368where
17369    C: common::Connector,
17370{
17371    /// Perform the operation you have build so far.
17372    pub async fn doit(mut self) -> common::Result<(common::Response, SslCertsInsertResponse)> {
17373        use std::borrow::Cow;
17374        use std::io::{Read, Seek};
17375
17376        use common::{url::Params, ToParts};
17377        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17378
17379        let mut dd = common::DefaultDelegate;
17380        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17381        dlg.begin(common::MethodInfo {
17382            id: "sql.sslCerts.insert",
17383            http_method: hyper::Method::POST,
17384        });
17385
17386        for &field in ["alt", "project", "instance"].iter() {
17387            if self._additional_params.contains_key(field) {
17388                dlg.finished(false);
17389                return Err(common::Error::FieldClash(field));
17390            }
17391        }
17392
17393        let mut params = Params::with_capacity(5 + self._additional_params.len());
17394        params.push("project", self._project);
17395        params.push("instance", self._instance);
17396
17397        params.extend(self._additional_params.iter());
17398
17399        params.push("alt", "json");
17400        let mut url = self.hub._base_url.clone()
17401            + "sql/v1beta4/projects/{project}/instances/{instance}/sslCerts";
17402        if self._scopes.is_empty() {
17403            self._scopes
17404                .insert(Scope::CloudPlatform.as_ref().to_string());
17405        }
17406
17407        #[allow(clippy::single_element_loop)]
17408        for &(find_this, param_name) in
17409            [("{project}", "project"), ("{instance}", "instance")].iter()
17410        {
17411            url = params.uri_replacement(url, param_name, find_this, false);
17412        }
17413        {
17414            let to_remove = ["instance", "project"];
17415            params.remove_params(&to_remove);
17416        }
17417
17418        let url = params.parse_with_url(&url);
17419
17420        let mut json_mime_type = mime::APPLICATION_JSON;
17421        let mut request_value_reader = {
17422            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17423            common::remove_json_null_values(&mut value);
17424            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17425            serde_json::to_writer(&mut dst, &value).unwrap();
17426            dst
17427        };
17428        let request_size = request_value_reader
17429            .seek(std::io::SeekFrom::End(0))
17430            .unwrap();
17431        request_value_reader
17432            .seek(std::io::SeekFrom::Start(0))
17433            .unwrap();
17434
17435        loop {
17436            let token = match self
17437                .hub
17438                .auth
17439                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17440                .await
17441            {
17442                Ok(token) => token,
17443                Err(e) => match dlg.token(e) {
17444                    Ok(token) => token,
17445                    Err(e) => {
17446                        dlg.finished(false);
17447                        return Err(common::Error::MissingToken(e));
17448                    }
17449                },
17450            };
17451            request_value_reader
17452                .seek(std::io::SeekFrom::Start(0))
17453                .unwrap();
17454            let mut req_result = {
17455                let client = &self.hub.client;
17456                dlg.pre_request();
17457                let mut req_builder = hyper::Request::builder()
17458                    .method(hyper::Method::POST)
17459                    .uri(url.as_str())
17460                    .header(USER_AGENT, self.hub._user_agent.clone());
17461
17462                if let Some(token) = token.as_ref() {
17463                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17464                }
17465
17466                let request = req_builder
17467                    .header(CONTENT_TYPE, json_mime_type.to_string())
17468                    .header(CONTENT_LENGTH, request_size as u64)
17469                    .body(common::to_body(
17470                        request_value_reader.get_ref().clone().into(),
17471                    ));
17472
17473                client.request(request.unwrap()).await
17474            };
17475
17476            match req_result {
17477                Err(err) => {
17478                    if let common::Retry::After(d) = dlg.http_error(&err) {
17479                        sleep(d).await;
17480                        continue;
17481                    }
17482                    dlg.finished(false);
17483                    return Err(common::Error::HttpError(err));
17484                }
17485                Ok(res) => {
17486                    let (mut parts, body) = res.into_parts();
17487                    let mut body = common::Body::new(body);
17488                    if !parts.status.is_success() {
17489                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17490                        let error = serde_json::from_str(&common::to_string(&bytes));
17491                        let response = common::to_response(parts, bytes.into());
17492
17493                        if let common::Retry::After(d) =
17494                            dlg.http_failure(&response, error.as_ref().ok())
17495                        {
17496                            sleep(d).await;
17497                            continue;
17498                        }
17499
17500                        dlg.finished(false);
17501
17502                        return Err(match error {
17503                            Ok(value) => common::Error::BadRequest(value),
17504                            _ => common::Error::Failure(response),
17505                        });
17506                    }
17507                    let response = {
17508                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17509                        let encoded = common::to_string(&bytes);
17510                        match serde_json::from_str(&encoded) {
17511                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17512                            Err(error) => {
17513                                dlg.response_json_decode_error(&encoded, &error);
17514                                return Err(common::Error::JsonDecodeError(
17515                                    encoded.to_string(),
17516                                    error,
17517                                ));
17518                            }
17519                        }
17520                    };
17521
17522                    dlg.finished(true);
17523                    return Ok(response);
17524                }
17525            }
17526        }
17527    }
17528
17529    ///
17530    /// Sets the *request* property to the given value.
17531    ///
17532    /// Even though the property as already been set when instantiating this call,
17533    /// we provide this method for API completeness.
17534    pub fn request(mut self, new_value: SslCertsInsertRequest) -> SslCertInsertCall<'a, C> {
17535        self._request = new_value;
17536        self
17537    }
17538    /// Project ID of the project that contains the instance.
17539    ///
17540    /// Sets the *project* path property to the given value.
17541    ///
17542    /// Even though the property as already been set when instantiating this call,
17543    /// we provide this method for API completeness.
17544    pub fn project(mut self, new_value: &str) -> SslCertInsertCall<'a, C> {
17545        self._project = new_value.to_string();
17546        self
17547    }
17548    /// Cloud SQL instance ID. This does not include the project ID.
17549    ///
17550    /// Sets the *instance* path property to the given value.
17551    ///
17552    /// Even though the property as already been set when instantiating this call,
17553    /// we provide this method for API completeness.
17554    pub fn instance(mut self, new_value: &str) -> SslCertInsertCall<'a, C> {
17555        self._instance = new_value.to_string();
17556        self
17557    }
17558    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17559    /// while executing the actual API request.
17560    ///
17561    /// ````text
17562    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17563    /// ````
17564    ///
17565    /// Sets the *delegate* property to the given value.
17566    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SslCertInsertCall<'a, C> {
17567        self._delegate = Some(new_value);
17568        self
17569    }
17570
17571    /// Set any additional parameter of the query string used in the request.
17572    /// It should be used to set parameters which are not yet available through their own
17573    /// setters.
17574    ///
17575    /// Please note that this method must not be used to set any of the known parameters
17576    /// which have their own setter method. If done anyway, the request will fail.
17577    ///
17578    /// # Additional Parameters
17579    ///
17580    /// * *$.xgafv* (query-string) - V1 error format.
17581    /// * *access_token* (query-string) - OAuth access token.
17582    /// * *alt* (query-string) - Data format for response.
17583    /// * *callback* (query-string) - JSONP
17584    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17585    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17586    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17587    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17588    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17589    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17590    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17591    pub fn param<T>(mut self, name: T, value: T) -> SslCertInsertCall<'a, C>
17592    where
17593        T: AsRef<str>,
17594    {
17595        self._additional_params
17596            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17597        self
17598    }
17599
17600    /// Identifies the authorization scope for the method you are building.
17601    ///
17602    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17603    /// [`Scope::CloudPlatform`].
17604    ///
17605    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17606    /// tokens for more than one scope.
17607    ///
17608    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17609    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17610    /// sufficient, a read-write scope will do as well.
17611    pub fn add_scope<St>(mut self, scope: St) -> SslCertInsertCall<'a, C>
17612    where
17613        St: AsRef<str>,
17614    {
17615        self._scopes.insert(String::from(scope.as_ref()));
17616        self
17617    }
17618    /// Identifies the authorization scope(s) for the method you are building.
17619    ///
17620    /// See [`Self::add_scope()`] for details.
17621    pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertInsertCall<'a, C>
17622    where
17623        I: IntoIterator<Item = St>,
17624        St: AsRef<str>,
17625    {
17626        self._scopes
17627            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17628        self
17629    }
17630
17631    /// Removes all scopes, and no default scope will be used either.
17632    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17633    /// for details).
17634    pub fn clear_scopes(mut self) -> SslCertInsertCall<'a, C> {
17635        self._scopes.clear();
17636        self
17637    }
17638}
17639
17640/// Lists all of the current SSL certificates for the instance.
17641///
17642/// A builder for the *list* method supported by a *sslCert* resource.
17643/// It is not used directly, but through a [`SslCertMethods`] instance.
17644///
17645/// # Example
17646///
17647/// Instantiate a resource method builder
17648///
17649/// ```test_harness,no_run
17650/// # extern crate hyper;
17651/// # extern crate hyper_rustls;
17652/// # extern crate google_sql1_beta4 as sql1_beta4;
17653/// # async fn dox() {
17654/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17655///
17656/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17657/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17658/// #     .with_native_roots()
17659/// #     .unwrap()
17660/// #     .https_only()
17661/// #     .enable_http2()
17662/// #     .build();
17663///
17664/// # let executor = hyper_util::rt::TokioExecutor::new();
17665/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17666/// #     secret,
17667/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17668/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17669/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17670/// #     ),
17671/// # ).build().await.unwrap();
17672///
17673/// # let client = hyper_util::client::legacy::Client::builder(
17674/// #     hyper_util::rt::TokioExecutor::new()
17675/// # )
17676/// # .build(
17677/// #     hyper_rustls::HttpsConnectorBuilder::new()
17678/// #         .with_native_roots()
17679/// #         .unwrap()
17680/// #         .https_or_http()
17681/// #         .enable_http2()
17682/// #         .build()
17683/// # );
17684/// # let mut hub = SQLAdmin::new(client, auth);
17685/// // You can configure optional parameters by calling the respective setters at will, and
17686/// // execute the final call using `doit()`.
17687/// // Values shown here are possibly random and not representative !
17688/// let result = hub.ssl_certs().list("project", "instance")
17689///              .doit().await;
17690/// # }
17691/// ```
17692pub struct SslCertListCall<'a, C>
17693where
17694    C: 'a,
17695{
17696    hub: &'a SQLAdmin<C>,
17697    _project: String,
17698    _instance: String,
17699    _delegate: Option<&'a mut dyn common::Delegate>,
17700    _additional_params: HashMap<String, String>,
17701    _scopes: BTreeSet<String>,
17702}
17703
17704impl<'a, C> common::CallBuilder for SslCertListCall<'a, C> {}
17705
17706impl<'a, C> SslCertListCall<'a, C>
17707where
17708    C: common::Connector,
17709{
17710    /// Perform the operation you have build so far.
17711    pub async fn doit(mut self) -> common::Result<(common::Response, SslCertsListResponse)> {
17712        use std::borrow::Cow;
17713        use std::io::{Read, Seek};
17714
17715        use common::{url::Params, ToParts};
17716        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17717
17718        let mut dd = common::DefaultDelegate;
17719        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17720        dlg.begin(common::MethodInfo {
17721            id: "sql.sslCerts.list",
17722            http_method: hyper::Method::GET,
17723        });
17724
17725        for &field in ["alt", "project", "instance"].iter() {
17726            if self._additional_params.contains_key(field) {
17727                dlg.finished(false);
17728                return Err(common::Error::FieldClash(field));
17729            }
17730        }
17731
17732        let mut params = Params::with_capacity(4 + self._additional_params.len());
17733        params.push("project", self._project);
17734        params.push("instance", self._instance);
17735
17736        params.extend(self._additional_params.iter());
17737
17738        params.push("alt", "json");
17739        let mut url = self.hub._base_url.clone()
17740            + "sql/v1beta4/projects/{project}/instances/{instance}/sslCerts";
17741        if self._scopes.is_empty() {
17742            self._scopes
17743                .insert(Scope::CloudPlatform.as_ref().to_string());
17744        }
17745
17746        #[allow(clippy::single_element_loop)]
17747        for &(find_this, param_name) in
17748            [("{project}", "project"), ("{instance}", "instance")].iter()
17749        {
17750            url = params.uri_replacement(url, param_name, find_this, false);
17751        }
17752        {
17753            let to_remove = ["instance", "project"];
17754            params.remove_params(&to_remove);
17755        }
17756
17757        let url = params.parse_with_url(&url);
17758
17759        loop {
17760            let token = match self
17761                .hub
17762                .auth
17763                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17764                .await
17765            {
17766                Ok(token) => token,
17767                Err(e) => match dlg.token(e) {
17768                    Ok(token) => token,
17769                    Err(e) => {
17770                        dlg.finished(false);
17771                        return Err(common::Error::MissingToken(e));
17772                    }
17773                },
17774            };
17775            let mut req_result = {
17776                let client = &self.hub.client;
17777                dlg.pre_request();
17778                let mut req_builder = hyper::Request::builder()
17779                    .method(hyper::Method::GET)
17780                    .uri(url.as_str())
17781                    .header(USER_AGENT, self.hub._user_agent.clone());
17782
17783                if let Some(token) = token.as_ref() {
17784                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17785                }
17786
17787                let request = req_builder
17788                    .header(CONTENT_LENGTH, 0_u64)
17789                    .body(common::to_body::<String>(None));
17790
17791                client.request(request.unwrap()).await
17792            };
17793
17794            match req_result {
17795                Err(err) => {
17796                    if let common::Retry::After(d) = dlg.http_error(&err) {
17797                        sleep(d).await;
17798                        continue;
17799                    }
17800                    dlg.finished(false);
17801                    return Err(common::Error::HttpError(err));
17802                }
17803                Ok(res) => {
17804                    let (mut parts, body) = res.into_parts();
17805                    let mut body = common::Body::new(body);
17806                    if !parts.status.is_success() {
17807                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17808                        let error = serde_json::from_str(&common::to_string(&bytes));
17809                        let response = common::to_response(parts, bytes.into());
17810
17811                        if let common::Retry::After(d) =
17812                            dlg.http_failure(&response, error.as_ref().ok())
17813                        {
17814                            sleep(d).await;
17815                            continue;
17816                        }
17817
17818                        dlg.finished(false);
17819
17820                        return Err(match error {
17821                            Ok(value) => common::Error::BadRequest(value),
17822                            _ => common::Error::Failure(response),
17823                        });
17824                    }
17825                    let response = {
17826                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17827                        let encoded = common::to_string(&bytes);
17828                        match serde_json::from_str(&encoded) {
17829                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17830                            Err(error) => {
17831                                dlg.response_json_decode_error(&encoded, &error);
17832                                return Err(common::Error::JsonDecodeError(
17833                                    encoded.to_string(),
17834                                    error,
17835                                ));
17836                            }
17837                        }
17838                    };
17839
17840                    dlg.finished(true);
17841                    return Ok(response);
17842                }
17843            }
17844        }
17845    }
17846
17847    /// Project ID of the project that contains the instance.
17848    ///
17849    /// Sets the *project* path property to the given value.
17850    ///
17851    /// Even though the property as already been set when instantiating this call,
17852    /// we provide this method for API completeness.
17853    pub fn project(mut self, new_value: &str) -> SslCertListCall<'a, C> {
17854        self._project = new_value.to_string();
17855        self
17856    }
17857    /// Cloud SQL instance ID. This does not include the project ID.
17858    ///
17859    /// Sets the *instance* path property to the given value.
17860    ///
17861    /// Even though the property as already been set when instantiating this call,
17862    /// we provide this method for API completeness.
17863    pub fn instance(mut self, new_value: &str) -> SslCertListCall<'a, C> {
17864        self._instance = new_value.to_string();
17865        self
17866    }
17867    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17868    /// while executing the actual API request.
17869    ///
17870    /// ````text
17871    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17872    /// ````
17873    ///
17874    /// Sets the *delegate* property to the given value.
17875    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SslCertListCall<'a, C> {
17876        self._delegate = Some(new_value);
17877        self
17878    }
17879
17880    /// Set any additional parameter of the query string used in the request.
17881    /// It should be used to set parameters which are not yet available through their own
17882    /// setters.
17883    ///
17884    /// Please note that this method must not be used to set any of the known parameters
17885    /// which have their own setter method. If done anyway, the request will fail.
17886    ///
17887    /// # Additional Parameters
17888    ///
17889    /// * *$.xgafv* (query-string) - V1 error format.
17890    /// * *access_token* (query-string) - OAuth access token.
17891    /// * *alt* (query-string) - Data format for response.
17892    /// * *callback* (query-string) - JSONP
17893    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17894    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17895    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17896    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17897    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17898    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17899    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17900    pub fn param<T>(mut self, name: T, value: T) -> SslCertListCall<'a, C>
17901    where
17902        T: AsRef<str>,
17903    {
17904        self._additional_params
17905            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17906        self
17907    }
17908
17909    /// Identifies the authorization scope for the method you are building.
17910    ///
17911    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17912    /// [`Scope::CloudPlatform`].
17913    ///
17914    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17915    /// tokens for more than one scope.
17916    ///
17917    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17918    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17919    /// sufficient, a read-write scope will do as well.
17920    pub fn add_scope<St>(mut self, scope: St) -> SslCertListCall<'a, C>
17921    where
17922        St: AsRef<str>,
17923    {
17924        self._scopes.insert(String::from(scope.as_ref()));
17925        self
17926    }
17927    /// Identifies the authorization scope(s) for the method you are building.
17928    ///
17929    /// See [`Self::add_scope()`] for details.
17930    pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertListCall<'a, C>
17931    where
17932        I: IntoIterator<Item = St>,
17933        St: AsRef<str>,
17934    {
17935        self._scopes
17936            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17937        self
17938    }
17939
17940    /// Removes all scopes, and no default scope will be used either.
17941    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17942    /// for details).
17943    pub fn clear_scopes(mut self) -> SslCertListCall<'a, C> {
17944        self._scopes.clear();
17945        self
17946    }
17947}
17948
17949/// Lists all available machine types (tiers) for Cloud SQL, for example,
17950/// db-n1-standard-1. For related information, see <a
17951/// href="/sql/pricing">Pricing</a>.
17952///
17953/// A builder for the *list* method supported by a *tier* resource.
17954/// It is not used directly, but through a [`TierMethods`] instance.
17955///
17956/// # Example
17957///
17958/// Instantiate a resource method builder
17959///
17960/// ```test_harness,no_run
17961/// # extern crate hyper;
17962/// # extern crate hyper_rustls;
17963/// # extern crate google_sql1_beta4 as sql1_beta4;
17964/// # async fn dox() {
17965/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17966///
17967/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17968/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17969/// #     .with_native_roots()
17970/// #     .unwrap()
17971/// #     .https_only()
17972/// #     .enable_http2()
17973/// #     .build();
17974///
17975/// # let executor = hyper_util::rt::TokioExecutor::new();
17976/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17977/// #     secret,
17978/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17979/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17980/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17981/// #     ),
17982/// # ).build().await.unwrap();
17983///
17984/// # let client = hyper_util::client::legacy::Client::builder(
17985/// #     hyper_util::rt::TokioExecutor::new()
17986/// # )
17987/// # .build(
17988/// #     hyper_rustls::HttpsConnectorBuilder::new()
17989/// #         .with_native_roots()
17990/// #         .unwrap()
17991/// #         .https_or_http()
17992/// #         .enable_http2()
17993/// #         .build()
17994/// # );
17995/// # let mut hub = SQLAdmin::new(client, auth);
17996/// // You can configure optional parameters by calling the respective setters at will, and
17997/// // execute the final call using `doit()`.
17998/// // Values shown here are possibly random and not representative !
17999/// let result = hub.tiers().list("project")
18000///              .doit().await;
18001/// # }
18002/// ```
18003pub struct TierListCall<'a, C>
18004where
18005    C: 'a,
18006{
18007    hub: &'a SQLAdmin<C>,
18008    _project: String,
18009    _delegate: Option<&'a mut dyn common::Delegate>,
18010    _additional_params: HashMap<String, String>,
18011    _scopes: BTreeSet<String>,
18012}
18013
18014impl<'a, C> common::CallBuilder for TierListCall<'a, C> {}
18015
18016impl<'a, C> TierListCall<'a, C>
18017where
18018    C: common::Connector,
18019{
18020    /// Perform the operation you have build so far.
18021    pub async fn doit(mut self) -> common::Result<(common::Response, TiersListResponse)> {
18022        use std::borrow::Cow;
18023        use std::io::{Read, Seek};
18024
18025        use common::{url::Params, ToParts};
18026        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18027
18028        let mut dd = common::DefaultDelegate;
18029        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18030        dlg.begin(common::MethodInfo {
18031            id: "sql.tiers.list",
18032            http_method: hyper::Method::GET,
18033        });
18034
18035        for &field in ["alt", "project"].iter() {
18036            if self._additional_params.contains_key(field) {
18037                dlg.finished(false);
18038                return Err(common::Error::FieldClash(field));
18039            }
18040        }
18041
18042        let mut params = Params::with_capacity(3 + self._additional_params.len());
18043        params.push("project", self._project);
18044
18045        params.extend(self._additional_params.iter());
18046
18047        params.push("alt", "json");
18048        let mut url = self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/tiers";
18049        if self._scopes.is_empty() {
18050            self._scopes
18051                .insert(Scope::CloudPlatform.as_ref().to_string());
18052        }
18053
18054        #[allow(clippy::single_element_loop)]
18055        for &(find_this, param_name) in [("{project}", "project")].iter() {
18056            url = params.uri_replacement(url, param_name, find_this, false);
18057        }
18058        {
18059            let to_remove = ["project"];
18060            params.remove_params(&to_remove);
18061        }
18062
18063        let url = params.parse_with_url(&url);
18064
18065        loop {
18066            let token = match self
18067                .hub
18068                .auth
18069                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18070                .await
18071            {
18072                Ok(token) => token,
18073                Err(e) => match dlg.token(e) {
18074                    Ok(token) => token,
18075                    Err(e) => {
18076                        dlg.finished(false);
18077                        return Err(common::Error::MissingToken(e));
18078                    }
18079                },
18080            };
18081            let mut req_result = {
18082                let client = &self.hub.client;
18083                dlg.pre_request();
18084                let mut req_builder = hyper::Request::builder()
18085                    .method(hyper::Method::GET)
18086                    .uri(url.as_str())
18087                    .header(USER_AGENT, self.hub._user_agent.clone());
18088
18089                if let Some(token) = token.as_ref() {
18090                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18091                }
18092
18093                let request = req_builder
18094                    .header(CONTENT_LENGTH, 0_u64)
18095                    .body(common::to_body::<String>(None));
18096
18097                client.request(request.unwrap()).await
18098            };
18099
18100            match req_result {
18101                Err(err) => {
18102                    if let common::Retry::After(d) = dlg.http_error(&err) {
18103                        sleep(d).await;
18104                        continue;
18105                    }
18106                    dlg.finished(false);
18107                    return Err(common::Error::HttpError(err));
18108                }
18109                Ok(res) => {
18110                    let (mut parts, body) = res.into_parts();
18111                    let mut body = common::Body::new(body);
18112                    if !parts.status.is_success() {
18113                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18114                        let error = serde_json::from_str(&common::to_string(&bytes));
18115                        let response = common::to_response(parts, bytes.into());
18116
18117                        if let common::Retry::After(d) =
18118                            dlg.http_failure(&response, error.as_ref().ok())
18119                        {
18120                            sleep(d).await;
18121                            continue;
18122                        }
18123
18124                        dlg.finished(false);
18125
18126                        return Err(match error {
18127                            Ok(value) => common::Error::BadRequest(value),
18128                            _ => common::Error::Failure(response),
18129                        });
18130                    }
18131                    let response = {
18132                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18133                        let encoded = common::to_string(&bytes);
18134                        match serde_json::from_str(&encoded) {
18135                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18136                            Err(error) => {
18137                                dlg.response_json_decode_error(&encoded, &error);
18138                                return Err(common::Error::JsonDecodeError(
18139                                    encoded.to_string(),
18140                                    error,
18141                                ));
18142                            }
18143                        }
18144                    };
18145
18146                    dlg.finished(true);
18147                    return Ok(response);
18148                }
18149            }
18150        }
18151    }
18152
18153    /// Project ID of the project for which to list tiers.
18154    ///
18155    /// Sets the *project* path property to the given value.
18156    ///
18157    /// Even though the property as already been set when instantiating this call,
18158    /// we provide this method for API completeness.
18159    pub fn project(mut self, new_value: &str) -> TierListCall<'a, C> {
18160        self._project = new_value.to_string();
18161        self
18162    }
18163    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18164    /// while executing the actual API request.
18165    ///
18166    /// ````text
18167    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18168    /// ````
18169    ///
18170    /// Sets the *delegate* property to the given value.
18171    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TierListCall<'a, C> {
18172        self._delegate = Some(new_value);
18173        self
18174    }
18175
18176    /// Set any additional parameter of the query string used in the request.
18177    /// It should be used to set parameters which are not yet available through their own
18178    /// setters.
18179    ///
18180    /// Please note that this method must not be used to set any of the known parameters
18181    /// which have their own setter method. If done anyway, the request will fail.
18182    ///
18183    /// # Additional Parameters
18184    ///
18185    /// * *$.xgafv* (query-string) - V1 error format.
18186    /// * *access_token* (query-string) - OAuth access token.
18187    /// * *alt* (query-string) - Data format for response.
18188    /// * *callback* (query-string) - JSONP
18189    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18190    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18191    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18192    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18193    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18194    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18195    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18196    pub fn param<T>(mut self, name: T, value: T) -> TierListCall<'a, C>
18197    where
18198        T: AsRef<str>,
18199    {
18200        self._additional_params
18201            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18202        self
18203    }
18204
18205    /// Identifies the authorization scope for the method you are building.
18206    ///
18207    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18208    /// [`Scope::CloudPlatform`].
18209    ///
18210    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18211    /// tokens for more than one scope.
18212    ///
18213    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18214    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18215    /// sufficient, a read-write scope will do as well.
18216    pub fn add_scope<St>(mut self, scope: St) -> TierListCall<'a, C>
18217    where
18218        St: AsRef<str>,
18219    {
18220        self._scopes.insert(String::from(scope.as_ref()));
18221        self
18222    }
18223    /// Identifies the authorization scope(s) for the method you are building.
18224    ///
18225    /// See [`Self::add_scope()`] for details.
18226    pub fn add_scopes<I, St>(mut self, scopes: I) -> TierListCall<'a, C>
18227    where
18228        I: IntoIterator<Item = St>,
18229        St: AsRef<str>,
18230    {
18231        self._scopes
18232            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18233        self
18234    }
18235
18236    /// Removes all scopes, and no default scope will be used either.
18237    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18238    /// for details).
18239    pub fn clear_scopes(mut self) -> TierListCall<'a, C> {
18240        self._scopes.clear();
18241        self
18242    }
18243}
18244
18245/// Deletes a user from a Cloud SQL instance.
18246///
18247/// A builder for the *delete* method supported by a *user* resource.
18248/// It is not used directly, but through a [`UserMethods`] instance.
18249///
18250/// # Example
18251///
18252/// Instantiate a resource method builder
18253///
18254/// ```test_harness,no_run
18255/// # extern crate hyper;
18256/// # extern crate hyper_rustls;
18257/// # extern crate google_sql1_beta4 as sql1_beta4;
18258/// # async fn dox() {
18259/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18260///
18261/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18262/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18263/// #     .with_native_roots()
18264/// #     .unwrap()
18265/// #     .https_only()
18266/// #     .enable_http2()
18267/// #     .build();
18268///
18269/// # let executor = hyper_util::rt::TokioExecutor::new();
18270/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18271/// #     secret,
18272/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18273/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18274/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18275/// #     ),
18276/// # ).build().await.unwrap();
18277///
18278/// # let client = hyper_util::client::legacy::Client::builder(
18279/// #     hyper_util::rt::TokioExecutor::new()
18280/// # )
18281/// # .build(
18282/// #     hyper_rustls::HttpsConnectorBuilder::new()
18283/// #         .with_native_roots()
18284/// #         .unwrap()
18285/// #         .https_or_http()
18286/// #         .enable_http2()
18287/// #         .build()
18288/// # );
18289/// # let mut hub = SQLAdmin::new(client, auth);
18290/// // You can configure optional parameters by calling the respective setters at will, and
18291/// // execute the final call using `doit()`.
18292/// // Values shown here are possibly random and not representative !
18293/// let result = hub.users().delete("project", "instance")
18294///              .name("dolores")
18295///              .host("et")
18296///              .doit().await;
18297/// # }
18298/// ```
18299pub struct UserDeleteCall<'a, C>
18300where
18301    C: 'a,
18302{
18303    hub: &'a SQLAdmin<C>,
18304    _project: String,
18305    _instance: String,
18306    _name: Option<String>,
18307    _host: Option<String>,
18308    _delegate: Option<&'a mut dyn common::Delegate>,
18309    _additional_params: HashMap<String, String>,
18310    _scopes: BTreeSet<String>,
18311}
18312
18313impl<'a, C> common::CallBuilder for UserDeleteCall<'a, C> {}
18314
18315impl<'a, C> UserDeleteCall<'a, C>
18316where
18317    C: common::Connector,
18318{
18319    /// Perform the operation you have build so far.
18320    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18321        use std::borrow::Cow;
18322        use std::io::{Read, Seek};
18323
18324        use common::{url::Params, ToParts};
18325        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18326
18327        let mut dd = common::DefaultDelegate;
18328        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18329        dlg.begin(common::MethodInfo {
18330            id: "sql.users.delete",
18331            http_method: hyper::Method::DELETE,
18332        });
18333
18334        for &field in ["alt", "project", "instance", "name", "host"].iter() {
18335            if self._additional_params.contains_key(field) {
18336                dlg.finished(false);
18337                return Err(common::Error::FieldClash(field));
18338            }
18339        }
18340
18341        let mut params = Params::with_capacity(6 + self._additional_params.len());
18342        params.push("project", self._project);
18343        params.push("instance", self._instance);
18344        if let Some(value) = self._name.as_ref() {
18345            params.push("name", value);
18346        }
18347        if let Some(value) = self._host.as_ref() {
18348            params.push("host", value);
18349        }
18350
18351        params.extend(self._additional_params.iter());
18352
18353        params.push("alt", "json");
18354        let mut url = self.hub._base_url.clone()
18355            + "sql/v1beta4/projects/{project}/instances/{instance}/users";
18356        if self._scopes.is_empty() {
18357            self._scopes
18358                .insert(Scope::CloudPlatform.as_ref().to_string());
18359        }
18360
18361        #[allow(clippy::single_element_loop)]
18362        for &(find_this, param_name) in
18363            [("{project}", "project"), ("{instance}", "instance")].iter()
18364        {
18365            url = params.uri_replacement(url, param_name, find_this, false);
18366        }
18367        {
18368            let to_remove = ["instance", "project"];
18369            params.remove_params(&to_remove);
18370        }
18371
18372        let url = params.parse_with_url(&url);
18373
18374        loop {
18375            let token = match self
18376                .hub
18377                .auth
18378                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18379                .await
18380            {
18381                Ok(token) => token,
18382                Err(e) => match dlg.token(e) {
18383                    Ok(token) => token,
18384                    Err(e) => {
18385                        dlg.finished(false);
18386                        return Err(common::Error::MissingToken(e));
18387                    }
18388                },
18389            };
18390            let mut req_result = {
18391                let client = &self.hub.client;
18392                dlg.pre_request();
18393                let mut req_builder = hyper::Request::builder()
18394                    .method(hyper::Method::DELETE)
18395                    .uri(url.as_str())
18396                    .header(USER_AGENT, self.hub._user_agent.clone());
18397
18398                if let Some(token) = token.as_ref() {
18399                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18400                }
18401
18402                let request = req_builder
18403                    .header(CONTENT_LENGTH, 0_u64)
18404                    .body(common::to_body::<String>(None));
18405
18406                client.request(request.unwrap()).await
18407            };
18408
18409            match req_result {
18410                Err(err) => {
18411                    if let common::Retry::After(d) = dlg.http_error(&err) {
18412                        sleep(d).await;
18413                        continue;
18414                    }
18415                    dlg.finished(false);
18416                    return Err(common::Error::HttpError(err));
18417                }
18418                Ok(res) => {
18419                    let (mut parts, body) = res.into_parts();
18420                    let mut body = common::Body::new(body);
18421                    if !parts.status.is_success() {
18422                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18423                        let error = serde_json::from_str(&common::to_string(&bytes));
18424                        let response = common::to_response(parts, bytes.into());
18425
18426                        if let common::Retry::After(d) =
18427                            dlg.http_failure(&response, error.as_ref().ok())
18428                        {
18429                            sleep(d).await;
18430                            continue;
18431                        }
18432
18433                        dlg.finished(false);
18434
18435                        return Err(match error {
18436                            Ok(value) => common::Error::BadRequest(value),
18437                            _ => common::Error::Failure(response),
18438                        });
18439                    }
18440                    let response = {
18441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18442                        let encoded = common::to_string(&bytes);
18443                        match serde_json::from_str(&encoded) {
18444                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18445                            Err(error) => {
18446                                dlg.response_json_decode_error(&encoded, &error);
18447                                return Err(common::Error::JsonDecodeError(
18448                                    encoded.to_string(),
18449                                    error,
18450                                ));
18451                            }
18452                        }
18453                    };
18454
18455                    dlg.finished(true);
18456                    return Ok(response);
18457                }
18458            }
18459        }
18460    }
18461
18462    /// Project ID of the project that contains the instance.
18463    ///
18464    /// Sets the *project* path property to the given value.
18465    ///
18466    /// Even though the property as already been set when instantiating this call,
18467    /// we provide this method for API completeness.
18468    pub fn project(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
18469        self._project = new_value.to_string();
18470        self
18471    }
18472    /// Database instance ID. This does not include the project ID.
18473    ///
18474    /// Sets the *instance* path property to the given value.
18475    ///
18476    /// Even though the property as already been set when instantiating this call,
18477    /// we provide this method for API completeness.
18478    pub fn instance(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
18479        self._instance = new_value.to_string();
18480        self
18481    }
18482    /// Name of the user in the instance.
18483    ///
18484    /// Sets the *name* query property to the given value.
18485    pub fn name(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
18486        self._name = Some(new_value.to_string());
18487        self
18488    }
18489    /// Host of the user in the instance.
18490    ///
18491    /// Sets the *host* query property to the given value.
18492    pub fn host(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
18493        self._host = Some(new_value.to_string());
18494        self
18495    }
18496    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18497    /// while executing the actual API request.
18498    ///
18499    /// ````text
18500    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18501    /// ````
18502    ///
18503    /// Sets the *delegate* property to the given value.
18504    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserDeleteCall<'a, C> {
18505        self._delegate = Some(new_value);
18506        self
18507    }
18508
18509    /// Set any additional parameter of the query string used in the request.
18510    /// It should be used to set parameters which are not yet available through their own
18511    /// setters.
18512    ///
18513    /// Please note that this method must not be used to set any of the known parameters
18514    /// which have their own setter method. If done anyway, the request will fail.
18515    ///
18516    /// # Additional Parameters
18517    ///
18518    /// * *$.xgafv* (query-string) - V1 error format.
18519    /// * *access_token* (query-string) - OAuth access token.
18520    /// * *alt* (query-string) - Data format for response.
18521    /// * *callback* (query-string) - JSONP
18522    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18523    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18524    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18525    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18526    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18527    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18528    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18529    pub fn param<T>(mut self, name: T, value: T) -> UserDeleteCall<'a, C>
18530    where
18531        T: AsRef<str>,
18532    {
18533        self._additional_params
18534            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18535        self
18536    }
18537
18538    /// Identifies the authorization scope for the method you are building.
18539    ///
18540    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18541    /// [`Scope::CloudPlatform`].
18542    ///
18543    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18544    /// tokens for more than one scope.
18545    ///
18546    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18547    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18548    /// sufficient, a read-write scope will do as well.
18549    pub fn add_scope<St>(mut self, scope: St) -> UserDeleteCall<'a, C>
18550    where
18551        St: AsRef<str>,
18552    {
18553        self._scopes.insert(String::from(scope.as_ref()));
18554        self
18555    }
18556    /// Identifies the authorization scope(s) for the method you are building.
18557    ///
18558    /// See [`Self::add_scope()`] for details.
18559    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDeleteCall<'a, C>
18560    where
18561        I: IntoIterator<Item = St>,
18562        St: AsRef<str>,
18563    {
18564        self._scopes
18565            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18566        self
18567    }
18568
18569    /// Removes all scopes, and no default scope will be used either.
18570    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18571    /// for details).
18572    pub fn clear_scopes(mut self) -> UserDeleteCall<'a, C> {
18573        self._scopes.clear();
18574        self
18575    }
18576}
18577
18578/// Creates a new user in a Cloud SQL instance.
18579///
18580/// A builder for the *insert* method supported by a *user* resource.
18581/// It is not used directly, but through a [`UserMethods`] instance.
18582///
18583/// # Example
18584///
18585/// Instantiate a resource method builder
18586///
18587/// ```test_harness,no_run
18588/// # extern crate hyper;
18589/// # extern crate hyper_rustls;
18590/// # extern crate google_sql1_beta4 as sql1_beta4;
18591/// use sql1_beta4::api::User;
18592/// # async fn dox() {
18593/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18594///
18595/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18596/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18597/// #     .with_native_roots()
18598/// #     .unwrap()
18599/// #     .https_only()
18600/// #     .enable_http2()
18601/// #     .build();
18602///
18603/// # let executor = hyper_util::rt::TokioExecutor::new();
18604/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18605/// #     secret,
18606/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18607/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18608/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18609/// #     ),
18610/// # ).build().await.unwrap();
18611///
18612/// # let client = hyper_util::client::legacy::Client::builder(
18613/// #     hyper_util::rt::TokioExecutor::new()
18614/// # )
18615/// # .build(
18616/// #     hyper_rustls::HttpsConnectorBuilder::new()
18617/// #         .with_native_roots()
18618/// #         .unwrap()
18619/// #         .https_or_http()
18620/// #         .enable_http2()
18621/// #         .build()
18622/// # );
18623/// # let mut hub = SQLAdmin::new(client, auth);
18624/// // As the method needs a request, you would usually fill it with the desired information
18625/// // into the respective structure. Some of the parts shown here might not be applicable !
18626/// // Values shown here are possibly random and not representative !
18627/// let mut req = User::default();
18628///
18629/// // You can configure optional parameters by calling the respective setters at will, and
18630/// // execute the final call using `doit()`.
18631/// // Values shown here are possibly random and not representative !
18632/// let result = hub.users().insert(req, "project", "instance")
18633///              .doit().await;
18634/// # }
18635/// ```
18636pub struct UserInsertCall<'a, C>
18637where
18638    C: 'a,
18639{
18640    hub: &'a SQLAdmin<C>,
18641    _request: User,
18642    _project: String,
18643    _instance: String,
18644    _delegate: Option<&'a mut dyn common::Delegate>,
18645    _additional_params: HashMap<String, String>,
18646    _scopes: BTreeSet<String>,
18647}
18648
18649impl<'a, C> common::CallBuilder for UserInsertCall<'a, C> {}
18650
18651impl<'a, C> UserInsertCall<'a, C>
18652where
18653    C: common::Connector,
18654{
18655    /// Perform the operation you have build so far.
18656    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18657        use std::borrow::Cow;
18658        use std::io::{Read, Seek};
18659
18660        use common::{url::Params, ToParts};
18661        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18662
18663        let mut dd = common::DefaultDelegate;
18664        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18665        dlg.begin(common::MethodInfo {
18666            id: "sql.users.insert",
18667            http_method: hyper::Method::POST,
18668        });
18669
18670        for &field in ["alt", "project", "instance"].iter() {
18671            if self._additional_params.contains_key(field) {
18672                dlg.finished(false);
18673                return Err(common::Error::FieldClash(field));
18674            }
18675        }
18676
18677        let mut params = Params::with_capacity(5 + self._additional_params.len());
18678        params.push("project", self._project);
18679        params.push("instance", self._instance);
18680
18681        params.extend(self._additional_params.iter());
18682
18683        params.push("alt", "json");
18684        let mut url = self.hub._base_url.clone()
18685            + "sql/v1beta4/projects/{project}/instances/{instance}/users";
18686        if self._scopes.is_empty() {
18687            self._scopes
18688                .insert(Scope::CloudPlatform.as_ref().to_string());
18689        }
18690
18691        #[allow(clippy::single_element_loop)]
18692        for &(find_this, param_name) in
18693            [("{project}", "project"), ("{instance}", "instance")].iter()
18694        {
18695            url = params.uri_replacement(url, param_name, find_this, false);
18696        }
18697        {
18698            let to_remove = ["instance", "project"];
18699            params.remove_params(&to_remove);
18700        }
18701
18702        let url = params.parse_with_url(&url);
18703
18704        let mut json_mime_type = mime::APPLICATION_JSON;
18705        let mut request_value_reader = {
18706            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18707            common::remove_json_null_values(&mut value);
18708            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18709            serde_json::to_writer(&mut dst, &value).unwrap();
18710            dst
18711        };
18712        let request_size = request_value_reader
18713            .seek(std::io::SeekFrom::End(0))
18714            .unwrap();
18715        request_value_reader
18716            .seek(std::io::SeekFrom::Start(0))
18717            .unwrap();
18718
18719        loop {
18720            let token = match self
18721                .hub
18722                .auth
18723                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18724                .await
18725            {
18726                Ok(token) => token,
18727                Err(e) => match dlg.token(e) {
18728                    Ok(token) => token,
18729                    Err(e) => {
18730                        dlg.finished(false);
18731                        return Err(common::Error::MissingToken(e));
18732                    }
18733                },
18734            };
18735            request_value_reader
18736                .seek(std::io::SeekFrom::Start(0))
18737                .unwrap();
18738            let mut req_result = {
18739                let client = &self.hub.client;
18740                dlg.pre_request();
18741                let mut req_builder = hyper::Request::builder()
18742                    .method(hyper::Method::POST)
18743                    .uri(url.as_str())
18744                    .header(USER_AGENT, self.hub._user_agent.clone());
18745
18746                if let Some(token) = token.as_ref() {
18747                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18748                }
18749
18750                let request = req_builder
18751                    .header(CONTENT_TYPE, json_mime_type.to_string())
18752                    .header(CONTENT_LENGTH, request_size as u64)
18753                    .body(common::to_body(
18754                        request_value_reader.get_ref().clone().into(),
18755                    ));
18756
18757                client.request(request.unwrap()).await
18758            };
18759
18760            match req_result {
18761                Err(err) => {
18762                    if let common::Retry::After(d) = dlg.http_error(&err) {
18763                        sleep(d).await;
18764                        continue;
18765                    }
18766                    dlg.finished(false);
18767                    return Err(common::Error::HttpError(err));
18768                }
18769                Ok(res) => {
18770                    let (mut parts, body) = res.into_parts();
18771                    let mut body = common::Body::new(body);
18772                    if !parts.status.is_success() {
18773                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18774                        let error = serde_json::from_str(&common::to_string(&bytes));
18775                        let response = common::to_response(parts, bytes.into());
18776
18777                        if let common::Retry::After(d) =
18778                            dlg.http_failure(&response, error.as_ref().ok())
18779                        {
18780                            sleep(d).await;
18781                            continue;
18782                        }
18783
18784                        dlg.finished(false);
18785
18786                        return Err(match error {
18787                            Ok(value) => common::Error::BadRequest(value),
18788                            _ => common::Error::Failure(response),
18789                        });
18790                    }
18791                    let response = {
18792                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18793                        let encoded = common::to_string(&bytes);
18794                        match serde_json::from_str(&encoded) {
18795                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18796                            Err(error) => {
18797                                dlg.response_json_decode_error(&encoded, &error);
18798                                return Err(common::Error::JsonDecodeError(
18799                                    encoded.to_string(),
18800                                    error,
18801                                ));
18802                            }
18803                        }
18804                    };
18805
18806                    dlg.finished(true);
18807                    return Ok(response);
18808                }
18809            }
18810        }
18811    }
18812
18813    ///
18814    /// Sets the *request* property to the given value.
18815    ///
18816    /// Even though the property as already been set when instantiating this call,
18817    /// we provide this method for API completeness.
18818    pub fn request(mut self, new_value: User) -> UserInsertCall<'a, C> {
18819        self._request = new_value;
18820        self
18821    }
18822    /// Project ID of the project that contains the instance.
18823    ///
18824    /// Sets the *project* path property to the given value.
18825    ///
18826    /// Even though the property as already been set when instantiating this call,
18827    /// we provide this method for API completeness.
18828    pub fn project(mut self, new_value: &str) -> UserInsertCall<'a, C> {
18829        self._project = new_value.to_string();
18830        self
18831    }
18832    /// Database instance ID. This does not include the project ID.
18833    ///
18834    /// Sets the *instance* path property to the given value.
18835    ///
18836    /// Even though the property as already been set when instantiating this call,
18837    /// we provide this method for API completeness.
18838    pub fn instance(mut self, new_value: &str) -> UserInsertCall<'a, C> {
18839        self._instance = new_value.to_string();
18840        self
18841    }
18842    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18843    /// while executing the actual API request.
18844    ///
18845    /// ````text
18846    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18847    /// ````
18848    ///
18849    /// Sets the *delegate* property to the given value.
18850    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserInsertCall<'a, C> {
18851        self._delegate = Some(new_value);
18852        self
18853    }
18854
18855    /// Set any additional parameter of the query string used in the request.
18856    /// It should be used to set parameters which are not yet available through their own
18857    /// setters.
18858    ///
18859    /// Please note that this method must not be used to set any of the known parameters
18860    /// which have their own setter method. If done anyway, the request will fail.
18861    ///
18862    /// # Additional Parameters
18863    ///
18864    /// * *$.xgafv* (query-string) - V1 error format.
18865    /// * *access_token* (query-string) - OAuth access token.
18866    /// * *alt* (query-string) - Data format for response.
18867    /// * *callback* (query-string) - JSONP
18868    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18869    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18870    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18871    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18872    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18873    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18874    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18875    pub fn param<T>(mut self, name: T, value: T) -> UserInsertCall<'a, C>
18876    where
18877        T: AsRef<str>,
18878    {
18879        self._additional_params
18880            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18881        self
18882    }
18883
18884    /// Identifies the authorization scope for the method you are building.
18885    ///
18886    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18887    /// [`Scope::CloudPlatform`].
18888    ///
18889    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18890    /// tokens for more than one scope.
18891    ///
18892    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18893    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18894    /// sufficient, a read-write scope will do as well.
18895    pub fn add_scope<St>(mut self, scope: St) -> UserInsertCall<'a, C>
18896    where
18897        St: AsRef<str>,
18898    {
18899        self._scopes.insert(String::from(scope.as_ref()));
18900        self
18901    }
18902    /// Identifies the authorization scope(s) for the method you are building.
18903    ///
18904    /// See [`Self::add_scope()`] for details.
18905    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserInsertCall<'a, C>
18906    where
18907        I: IntoIterator<Item = St>,
18908        St: AsRef<str>,
18909    {
18910        self._scopes
18911            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18912        self
18913    }
18914
18915    /// Removes all scopes, and no default scope will be used either.
18916    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18917    /// for details).
18918    pub fn clear_scopes(mut self) -> UserInsertCall<'a, C> {
18919        self._scopes.clear();
18920        self
18921    }
18922}
18923
18924/// Lists users in the specified Cloud SQL instance.
18925///
18926/// A builder for the *list* method supported by a *user* resource.
18927/// It is not used directly, but through a [`UserMethods`] instance.
18928///
18929/// # Example
18930///
18931/// Instantiate a resource method builder
18932///
18933/// ```test_harness,no_run
18934/// # extern crate hyper;
18935/// # extern crate hyper_rustls;
18936/// # extern crate google_sql1_beta4 as sql1_beta4;
18937/// # async fn dox() {
18938/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18939///
18940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18941/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18942/// #     .with_native_roots()
18943/// #     .unwrap()
18944/// #     .https_only()
18945/// #     .enable_http2()
18946/// #     .build();
18947///
18948/// # let executor = hyper_util::rt::TokioExecutor::new();
18949/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18950/// #     secret,
18951/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18952/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18953/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18954/// #     ),
18955/// # ).build().await.unwrap();
18956///
18957/// # let client = hyper_util::client::legacy::Client::builder(
18958/// #     hyper_util::rt::TokioExecutor::new()
18959/// # )
18960/// # .build(
18961/// #     hyper_rustls::HttpsConnectorBuilder::new()
18962/// #         .with_native_roots()
18963/// #         .unwrap()
18964/// #         .https_or_http()
18965/// #         .enable_http2()
18966/// #         .build()
18967/// # );
18968/// # let mut hub = SQLAdmin::new(client, auth);
18969/// // You can configure optional parameters by calling the respective setters at will, and
18970/// // execute the final call using `doit()`.
18971/// // Values shown here are possibly random and not representative !
18972/// let result = hub.users().list("project", "instance")
18973///              .doit().await;
18974/// # }
18975/// ```
18976pub struct UserListCall<'a, C>
18977where
18978    C: 'a,
18979{
18980    hub: &'a SQLAdmin<C>,
18981    _project: String,
18982    _instance: String,
18983    _delegate: Option<&'a mut dyn common::Delegate>,
18984    _additional_params: HashMap<String, String>,
18985    _scopes: BTreeSet<String>,
18986}
18987
18988impl<'a, C> common::CallBuilder for UserListCall<'a, C> {}
18989
18990impl<'a, C> UserListCall<'a, C>
18991where
18992    C: common::Connector,
18993{
18994    /// Perform the operation you have build so far.
18995    pub async fn doit(mut self) -> common::Result<(common::Response, UsersListResponse)> {
18996        use std::borrow::Cow;
18997        use std::io::{Read, Seek};
18998
18999        use common::{url::Params, ToParts};
19000        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19001
19002        let mut dd = common::DefaultDelegate;
19003        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19004        dlg.begin(common::MethodInfo {
19005            id: "sql.users.list",
19006            http_method: hyper::Method::GET,
19007        });
19008
19009        for &field in ["alt", "project", "instance"].iter() {
19010            if self._additional_params.contains_key(field) {
19011                dlg.finished(false);
19012                return Err(common::Error::FieldClash(field));
19013            }
19014        }
19015
19016        let mut params = Params::with_capacity(4 + self._additional_params.len());
19017        params.push("project", self._project);
19018        params.push("instance", self._instance);
19019
19020        params.extend(self._additional_params.iter());
19021
19022        params.push("alt", "json");
19023        let mut url = self.hub._base_url.clone()
19024            + "sql/v1beta4/projects/{project}/instances/{instance}/users";
19025        if self._scopes.is_empty() {
19026            self._scopes
19027                .insert(Scope::CloudPlatform.as_ref().to_string());
19028        }
19029
19030        #[allow(clippy::single_element_loop)]
19031        for &(find_this, param_name) in
19032            [("{project}", "project"), ("{instance}", "instance")].iter()
19033        {
19034            url = params.uri_replacement(url, param_name, find_this, false);
19035        }
19036        {
19037            let to_remove = ["instance", "project"];
19038            params.remove_params(&to_remove);
19039        }
19040
19041        let url = params.parse_with_url(&url);
19042
19043        loop {
19044            let token = match self
19045                .hub
19046                .auth
19047                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19048                .await
19049            {
19050                Ok(token) => token,
19051                Err(e) => match dlg.token(e) {
19052                    Ok(token) => token,
19053                    Err(e) => {
19054                        dlg.finished(false);
19055                        return Err(common::Error::MissingToken(e));
19056                    }
19057                },
19058            };
19059            let mut req_result = {
19060                let client = &self.hub.client;
19061                dlg.pre_request();
19062                let mut req_builder = hyper::Request::builder()
19063                    .method(hyper::Method::GET)
19064                    .uri(url.as_str())
19065                    .header(USER_AGENT, self.hub._user_agent.clone());
19066
19067                if let Some(token) = token.as_ref() {
19068                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19069                }
19070
19071                let request = req_builder
19072                    .header(CONTENT_LENGTH, 0_u64)
19073                    .body(common::to_body::<String>(None));
19074
19075                client.request(request.unwrap()).await
19076            };
19077
19078            match req_result {
19079                Err(err) => {
19080                    if let common::Retry::After(d) = dlg.http_error(&err) {
19081                        sleep(d).await;
19082                        continue;
19083                    }
19084                    dlg.finished(false);
19085                    return Err(common::Error::HttpError(err));
19086                }
19087                Ok(res) => {
19088                    let (mut parts, body) = res.into_parts();
19089                    let mut body = common::Body::new(body);
19090                    if !parts.status.is_success() {
19091                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19092                        let error = serde_json::from_str(&common::to_string(&bytes));
19093                        let response = common::to_response(parts, bytes.into());
19094
19095                        if let common::Retry::After(d) =
19096                            dlg.http_failure(&response, error.as_ref().ok())
19097                        {
19098                            sleep(d).await;
19099                            continue;
19100                        }
19101
19102                        dlg.finished(false);
19103
19104                        return Err(match error {
19105                            Ok(value) => common::Error::BadRequest(value),
19106                            _ => common::Error::Failure(response),
19107                        });
19108                    }
19109                    let response = {
19110                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19111                        let encoded = common::to_string(&bytes);
19112                        match serde_json::from_str(&encoded) {
19113                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19114                            Err(error) => {
19115                                dlg.response_json_decode_error(&encoded, &error);
19116                                return Err(common::Error::JsonDecodeError(
19117                                    encoded.to_string(),
19118                                    error,
19119                                ));
19120                            }
19121                        }
19122                    };
19123
19124                    dlg.finished(true);
19125                    return Ok(response);
19126                }
19127            }
19128        }
19129    }
19130
19131    /// Project ID of the project that contains the instance.
19132    ///
19133    /// Sets the *project* path property to the given value.
19134    ///
19135    /// Even though the property as already been set when instantiating this call,
19136    /// we provide this method for API completeness.
19137    pub fn project(mut self, new_value: &str) -> UserListCall<'a, C> {
19138        self._project = new_value.to_string();
19139        self
19140    }
19141    /// Database instance ID. This does not include the project ID.
19142    ///
19143    /// Sets the *instance* path property to the given value.
19144    ///
19145    /// Even though the property as already been set when instantiating this call,
19146    /// we provide this method for API completeness.
19147    pub fn instance(mut self, new_value: &str) -> UserListCall<'a, C> {
19148        self._instance = new_value.to_string();
19149        self
19150    }
19151    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19152    /// while executing the actual API request.
19153    ///
19154    /// ````text
19155    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19156    /// ````
19157    ///
19158    /// Sets the *delegate* property to the given value.
19159    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserListCall<'a, C> {
19160        self._delegate = Some(new_value);
19161        self
19162    }
19163
19164    /// Set any additional parameter of the query string used in the request.
19165    /// It should be used to set parameters which are not yet available through their own
19166    /// setters.
19167    ///
19168    /// Please note that this method must not be used to set any of the known parameters
19169    /// which have their own setter method. If done anyway, the request will fail.
19170    ///
19171    /// # Additional Parameters
19172    ///
19173    /// * *$.xgafv* (query-string) - V1 error format.
19174    /// * *access_token* (query-string) - OAuth access token.
19175    /// * *alt* (query-string) - Data format for response.
19176    /// * *callback* (query-string) - JSONP
19177    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19178    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19179    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19180    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19181    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19182    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19183    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19184    pub fn param<T>(mut self, name: T, value: T) -> UserListCall<'a, C>
19185    where
19186        T: AsRef<str>,
19187    {
19188        self._additional_params
19189            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19190        self
19191    }
19192
19193    /// Identifies the authorization scope for the method you are building.
19194    ///
19195    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19196    /// [`Scope::CloudPlatform`].
19197    ///
19198    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19199    /// tokens for more than one scope.
19200    ///
19201    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19202    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19203    /// sufficient, a read-write scope will do as well.
19204    pub fn add_scope<St>(mut self, scope: St) -> UserListCall<'a, C>
19205    where
19206        St: AsRef<str>,
19207    {
19208        self._scopes.insert(String::from(scope.as_ref()));
19209        self
19210    }
19211    /// Identifies the authorization scope(s) for the method you are building.
19212    ///
19213    /// See [`Self::add_scope()`] for details.
19214    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserListCall<'a, C>
19215    where
19216        I: IntoIterator<Item = St>,
19217        St: AsRef<str>,
19218    {
19219        self._scopes
19220            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19221        self
19222    }
19223
19224    /// Removes all scopes, and no default scope will be used either.
19225    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19226    /// for details).
19227    pub fn clear_scopes(mut self) -> UserListCall<'a, C> {
19228        self._scopes.clear();
19229        self
19230    }
19231}
19232
19233/// Updates an existing user in a Cloud SQL instance.
19234///
19235/// A builder for the *update* method supported by a *user* resource.
19236/// It is not used directly, but through a [`UserMethods`] instance.
19237///
19238/// # Example
19239///
19240/// Instantiate a resource method builder
19241///
19242/// ```test_harness,no_run
19243/// # extern crate hyper;
19244/// # extern crate hyper_rustls;
19245/// # extern crate google_sql1_beta4 as sql1_beta4;
19246/// use sql1_beta4::api::User;
19247/// # async fn dox() {
19248/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19249///
19250/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19251/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19252/// #     .with_native_roots()
19253/// #     .unwrap()
19254/// #     .https_only()
19255/// #     .enable_http2()
19256/// #     .build();
19257///
19258/// # let executor = hyper_util::rt::TokioExecutor::new();
19259/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19260/// #     secret,
19261/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19262/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19263/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19264/// #     ),
19265/// # ).build().await.unwrap();
19266///
19267/// # let client = hyper_util::client::legacy::Client::builder(
19268/// #     hyper_util::rt::TokioExecutor::new()
19269/// # )
19270/// # .build(
19271/// #     hyper_rustls::HttpsConnectorBuilder::new()
19272/// #         .with_native_roots()
19273/// #         .unwrap()
19274/// #         .https_or_http()
19275/// #         .enable_http2()
19276/// #         .build()
19277/// # );
19278/// # let mut hub = SQLAdmin::new(client, auth);
19279/// // As the method needs a request, you would usually fill it with the desired information
19280/// // into the respective structure. Some of the parts shown here might not be applicable !
19281/// // Values shown here are possibly random and not representative !
19282/// let mut req = User::default();
19283///
19284/// // You can configure optional parameters by calling the respective setters at will, and
19285/// // execute the final call using `doit()`.
19286/// // Values shown here are possibly random and not representative !
19287/// let result = hub.users().update(req, "project", "instance")
19288///              .name("nonumy")
19289///              .host("At")
19290///              .doit().await;
19291/// # }
19292/// ```
19293pub struct UserUpdateCall<'a, C>
19294where
19295    C: 'a,
19296{
19297    hub: &'a SQLAdmin<C>,
19298    _request: User,
19299    _project: String,
19300    _instance: String,
19301    _name: Option<String>,
19302    _host: Option<String>,
19303    _delegate: Option<&'a mut dyn common::Delegate>,
19304    _additional_params: HashMap<String, String>,
19305    _scopes: BTreeSet<String>,
19306}
19307
19308impl<'a, C> common::CallBuilder for UserUpdateCall<'a, C> {}
19309
19310impl<'a, C> UserUpdateCall<'a, C>
19311where
19312    C: common::Connector,
19313{
19314    /// Perform the operation you have build so far.
19315    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19316        use std::borrow::Cow;
19317        use std::io::{Read, Seek};
19318
19319        use common::{url::Params, ToParts};
19320        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19321
19322        let mut dd = common::DefaultDelegate;
19323        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19324        dlg.begin(common::MethodInfo {
19325            id: "sql.users.update",
19326            http_method: hyper::Method::PUT,
19327        });
19328
19329        for &field in ["alt", "project", "instance", "name", "host"].iter() {
19330            if self._additional_params.contains_key(field) {
19331                dlg.finished(false);
19332                return Err(common::Error::FieldClash(field));
19333            }
19334        }
19335
19336        let mut params = Params::with_capacity(7 + self._additional_params.len());
19337        params.push("project", self._project);
19338        params.push("instance", self._instance);
19339        if let Some(value) = self._name.as_ref() {
19340            params.push("name", value);
19341        }
19342        if let Some(value) = self._host.as_ref() {
19343            params.push("host", value);
19344        }
19345
19346        params.extend(self._additional_params.iter());
19347
19348        params.push("alt", "json");
19349        let mut url = self.hub._base_url.clone()
19350            + "sql/v1beta4/projects/{project}/instances/{instance}/users";
19351        if self._scopes.is_empty() {
19352            self._scopes
19353                .insert(Scope::CloudPlatform.as_ref().to_string());
19354        }
19355
19356        #[allow(clippy::single_element_loop)]
19357        for &(find_this, param_name) in
19358            [("{project}", "project"), ("{instance}", "instance")].iter()
19359        {
19360            url = params.uri_replacement(url, param_name, find_this, false);
19361        }
19362        {
19363            let to_remove = ["instance", "project"];
19364            params.remove_params(&to_remove);
19365        }
19366
19367        let url = params.parse_with_url(&url);
19368
19369        let mut json_mime_type = mime::APPLICATION_JSON;
19370        let mut request_value_reader = {
19371            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19372            common::remove_json_null_values(&mut value);
19373            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19374            serde_json::to_writer(&mut dst, &value).unwrap();
19375            dst
19376        };
19377        let request_size = request_value_reader
19378            .seek(std::io::SeekFrom::End(0))
19379            .unwrap();
19380        request_value_reader
19381            .seek(std::io::SeekFrom::Start(0))
19382            .unwrap();
19383
19384        loop {
19385            let token = match self
19386                .hub
19387                .auth
19388                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19389                .await
19390            {
19391                Ok(token) => token,
19392                Err(e) => match dlg.token(e) {
19393                    Ok(token) => token,
19394                    Err(e) => {
19395                        dlg.finished(false);
19396                        return Err(common::Error::MissingToken(e));
19397                    }
19398                },
19399            };
19400            request_value_reader
19401                .seek(std::io::SeekFrom::Start(0))
19402                .unwrap();
19403            let mut req_result = {
19404                let client = &self.hub.client;
19405                dlg.pre_request();
19406                let mut req_builder = hyper::Request::builder()
19407                    .method(hyper::Method::PUT)
19408                    .uri(url.as_str())
19409                    .header(USER_AGENT, self.hub._user_agent.clone());
19410
19411                if let Some(token) = token.as_ref() {
19412                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19413                }
19414
19415                let request = req_builder
19416                    .header(CONTENT_TYPE, json_mime_type.to_string())
19417                    .header(CONTENT_LENGTH, request_size as u64)
19418                    .body(common::to_body(
19419                        request_value_reader.get_ref().clone().into(),
19420                    ));
19421
19422                client.request(request.unwrap()).await
19423            };
19424
19425            match req_result {
19426                Err(err) => {
19427                    if let common::Retry::After(d) = dlg.http_error(&err) {
19428                        sleep(d).await;
19429                        continue;
19430                    }
19431                    dlg.finished(false);
19432                    return Err(common::Error::HttpError(err));
19433                }
19434                Ok(res) => {
19435                    let (mut parts, body) = res.into_parts();
19436                    let mut body = common::Body::new(body);
19437                    if !parts.status.is_success() {
19438                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19439                        let error = serde_json::from_str(&common::to_string(&bytes));
19440                        let response = common::to_response(parts, bytes.into());
19441
19442                        if let common::Retry::After(d) =
19443                            dlg.http_failure(&response, error.as_ref().ok())
19444                        {
19445                            sleep(d).await;
19446                            continue;
19447                        }
19448
19449                        dlg.finished(false);
19450
19451                        return Err(match error {
19452                            Ok(value) => common::Error::BadRequest(value),
19453                            _ => common::Error::Failure(response),
19454                        });
19455                    }
19456                    let response = {
19457                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19458                        let encoded = common::to_string(&bytes);
19459                        match serde_json::from_str(&encoded) {
19460                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19461                            Err(error) => {
19462                                dlg.response_json_decode_error(&encoded, &error);
19463                                return Err(common::Error::JsonDecodeError(
19464                                    encoded.to_string(),
19465                                    error,
19466                                ));
19467                            }
19468                        }
19469                    };
19470
19471                    dlg.finished(true);
19472                    return Ok(response);
19473                }
19474            }
19475        }
19476    }
19477
19478    ///
19479    /// Sets the *request* property to the given value.
19480    ///
19481    /// Even though the property as already been set when instantiating this call,
19482    /// we provide this method for API completeness.
19483    pub fn request(mut self, new_value: User) -> UserUpdateCall<'a, C> {
19484        self._request = new_value;
19485        self
19486    }
19487    /// Project ID of the project that contains the instance.
19488    ///
19489    /// Sets the *project* path property to the given value.
19490    ///
19491    /// Even though the property as already been set when instantiating this call,
19492    /// we provide this method for API completeness.
19493    pub fn project(mut self, new_value: &str) -> UserUpdateCall<'a, C> {
19494        self._project = new_value.to_string();
19495        self
19496    }
19497    /// Database instance ID. This does not include the project ID.
19498    ///
19499    /// Sets the *instance* 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 instance(mut self, new_value: &str) -> UserUpdateCall<'a, C> {
19504        self._instance = new_value.to_string();
19505        self
19506    }
19507    /// Name of the user in the instance.
19508    ///
19509    /// Sets the *name* query property to the given value.
19510    pub fn name(mut self, new_value: &str) -> UserUpdateCall<'a, C> {
19511        self._name = Some(new_value.to_string());
19512        self
19513    }
19514    /// Optional. Host of the user in the instance.
19515    ///
19516    /// Sets the *host* query property to the given value.
19517    pub fn host(mut self, new_value: &str) -> UserUpdateCall<'a, C> {
19518        self._host = Some(new_value.to_string());
19519        self
19520    }
19521    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19522    /// while executing the actual API request.
19523    ///
19524    /// ````text
19525    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19526    /// ````
19527    ///
19528    /// Sets the *delegate* property to the given value.
19529    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserUpdateCall<'a, C> {
19530        self._delegate = Some(new_value);
19531        self
19532    }
19533
19534    /// Set any additional parameter of the query string used in the request.
19535    /// It should be used to set parameters which are not yet available through their own
19536    /// setters.
19537    ///
19538    /// Please note that this method must not be used to set any of the known parameters
19539    /// which have their own setter method. If done anyway, the request will fail.
19540    ///
19541    /// # Additional Parameters
19542    ///
19543    /// * *$.xgafv* (query-string) - V1 error format.
19544    /// * *access_token* (query-string) - OAuth access token.
19545    /// * *alt* (query-string) - Data format for response.
19546    /// * *callback* (query-string) - JSONP
19547    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19548    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19549    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19550    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19551    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19552    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19553    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19554    pub fn param<T>(mut self, name: T, value: T) -> UserUpdateCall<'a, C>
19555    where
19556        T: AsRef<str>,
19557    {
19558        self._additional_params
19559            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19560        self
19561    }
19562
19563    /// Identifies the authorization scope for the method you are building.
19564    ///
19565    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19566    /// [`Scope::CloudPlatform`].
19567    ///
19568    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19569    /// tokens for more than one scope.
19570    ///
19571    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19572    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19573    /// sufficient, a read-write scope will do as well.
19574    pub fn add_scope<St>(mut self, scope: St) -> UserUpdateCall<'a, C>
19575    where
19576        St: AsRef<str>,
19577    {
19578        self._scopes.insert(String::from(scope.as_ref()));
19579        self
19580    }
19581    /// Identifies the authorization scope(s) for the method you are building.
19582    ///
19583    /// See [`Self::add_scope()`] for details.
19584    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserUpdateCall<'a, C>
19585    where
19586        I: IntoIterator<Item = St>,
19587        St: AsRef<str>,
19588    {
19589        self._scopes
19590            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19591        self
19592    }
19593
19594    /// Removes all scopes, and no default scope will be used either.
19595    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19596    /// for details).
19597    pub fn clear_scopes(mut self) -> UserUpdateCall<'a, C> {
19598        self._scopes.clear();
19599        self
19600    }
19601}