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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67/// secret,
68/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69/// ).build().await.unwrap();
70///
71/// let client = hyper_util::client::legacy::Client::builder(
72/// hyper_util::rt::TokioExecutor::new()
73/// )
74/// .build(
75/// hyper_rustls::HttpsConnectorBuilder::new()
76/// .with_native_roots()
77/// .unwrap()
78/// .https_or_http()
79/// .enable_http1()
80/// .build()
81/// );
82/// let mut hub = SQLAdmin::new(client, auth);
83/// // As the method needs a request, you would usually fill it with the desired information
84/// // into the respective structure. Some of the parts shown here might not be applicable !
85/// // Values shown here are possibly random and not representative !
86/// let mut req = User::default();
87///
88/// // You can configure optional parameters by calling the respective setters at will, and
89/// // execute the final call using `doit()`.
90/// // Values shown here are possibly random and not representative !
91/// let result = hub.users().update(req, "project", "instance")
92/// .name("amet.")
93/// .host("duo")
94/// .doit().await;
95///
96/// match result {
97/// Err(e) => match e {
98/// // The Error enum provides details about what exactly happened.
99/// // You can also just use its `Debug`, `Display` or `Error` traits
100/// Error::HttpError(_)
101/// |Error::Io(_)
102/// |Error::MissingAPIKey
103/// |Error::MissingToken(_)
104/// |Error::Cancelled
105/// |Error::UploadSizeLimitExceeded(_, _)
106/// |Error::Failure(_)
107/// |Error::BadRequest(_)
108/// |Error::FieldClash(_)
109/// |Error::JsonDecodeError(_, _) => println!("{}", e),
110/// },
111/// Ok(res) => println!("Success: {:?}", res),
112/// }
113/// # }
114/// ```
115#[derive(Clone)]
116pub struct SQLAdmin<C> {
117 pub client: common::Client<C>,
118 pub auth: Box<dyn common::GetToken>,
119 _user_agent: String,
120 _base_url: String,
121 _root_url: String,
122}
123
124impl<C> common::Hub for SQLAdmin<C> {}
125
126impl<'a, C> SQLAdmin<C> {
127 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> SQLAdmin<C> {
128 SQLAdmin {
129 client,
130 auth: Box::new(auth),
131 _user_agent: "google-api-rust-client/6.0.0".to_string(),
132 _base_url: "https://sqladmin.googleapis.com/".to_string(),
133 _root_url: "https://sqladmin.googleapis.com/".to_string(),
134 }
135 }
136
137 pub fn backup_runs(&'a self) -> BackupRunMethods<'a, C> {
138 BackupRunMethods { hub: self }
139 }
140 pub fn databases(&'a self) -> DatabaseMethods<'a, C> {
141 DatabaseMethods { hub: self }
142 }
143 pub fn flags(&'a self) -> FlagMethods<'a, C> {
144 FlagMethods { hub: self }
145 }
146 pub fn instances(&'a self) -> InstanceMethods<'a, C> {
147 InstanceMethods { hub: self }
148 }
149 pub fn operations(&'a self) -> OperationMethods<'a, C> {
150 OperationMethods { hub: self }
151 }
152 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
153 ProjectMethods { hub: self }
154 }
155 pub fn ssl_certs(&'a self) -> SslCertMethods<'a, C> {
156 SslCertMethods { hub: self }
157 }
158 pub fn tiers(&'a self) -> TierMethods<'a, C> {
159 TierMethods { hub: self }
160 }
161 pub fn users(&'a self) -> UserMethods<'a, C> {
162 UserMethods { hub: self }
163 }
164
165 /// Set the user-agent header field to use in all requests to the server.
166 /// It defaults to `google-api-rust-client/6.0.0`.
167 ///
168 /// Returns the previously set user-agent.
169 pub fn user_agent(&mut self, agent_name: String) -> String {
170 std::mem::replace(&mut self._user_agent, agent_name)
171 }
172
173 /// Set the base url to use in all requests to the server.
174 /// It defaults to `https://sqladmin.googleapis.com/`.
175 ///
176 /// Returns the previously set base url.
177 pub fn base_url(&mut self, new_base_url: String) -> String {
178 std::mem::replace(&mut self._base_url, new_base_url)
179 }
180
181 /// Set the root url to use in all requests to the server.
182 /// It defaults to `https://sqladmin.googleapis.com/`.
183 ///
184 /// Returns the previously set root url.
185 pub fn root_url(&mut self, new_root_url: String) -> String {
186 std::mem::replace(&mut self._root_url, new_root_url)
187 }
188}
189
190// ############
191// SCHEMAS ###
192// ##########
193/// An entry for an Access Control list.
194///
195/// This type is not used in any activity, and only used as *part* of another schema.
196///
197#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
198#[serde_with::serde_as]
199#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
200pub struct AclEntry {
201 /// The time when this access control entry expires in <a
202 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
203 /// <code>2012-11-15T16:19:00.094Z</code>.
204 #[serde(rename = "expirationTime")]
205 pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
206 /// This is always <code>sql#aclEntry</code>.
207 pub kind: Option<String>,
208 /// Optional. A label to identify this entry.
209 pub name: Option<String>,
210 /// The whitelisted value for the access control list.
211 pub value: Option<String>,
212}
213
214impl common::Part for AclEntry {}
215
216/// An Admin API warning message.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct ApiWarning {
224 /// Code to uniquely identify the warning type.
225 pub code: Option<String>,
226 /// The warning message.
227 pub message: Option<String>,
228}
229
230impl common::Part for ApiWarning {}
231
232/// Database instance backup configuration.
233///
234/// This type is not used in any activity, and only used as *part* of another schema.
235///
236#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
237#[serde_with::serde_as]
238#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
239pub struct BackupConfiguration {
240 /// (MySQL only) Whether binary log is enabled. If backup configuration is
241 /// disabled, binarylog must be disabled as well.
242 #[serde(rename = "binaryLogEnabled")]
243 pub binary_log_enabled: Option<bool>,
244 /// Whether this configuration is enabled.
245 pub enabled: Option<bool>,
246 /// This is always <code>sql#backupConfiguration</code>.
247 pub kind: Option<String>,
248 /// Location of the backup
249 pub location: Option<String>,
250 /// Reserved for future use.
251 #[serde(rename = "pointInTimeRecoveryEnabled")]
252 pub point_in_time_recovery_enabled: Option<bool>,
253 /// Reserved for future use.
254 #[serde(rename = "replicationLogArchivingEnabled")]
255 pub replication_log_archiving_enabled: Option<bool>,
256 /// Start time for the daily backup configuration in UTC timezone in the 24
257 /// hour format - <code>HH:MM</code>.
258 #[serde(rename = "startTime")]
259 pub start_time: Option<String>,
260}
261
262impl common::Part for BackupConfiguration {}
263
264/// A BackupRun resource.
265///
266/// # Activities
267///
268/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
269/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
270///
271/// * [delete backup runs](BackupRunDeleteCall) (none)
272/// * [get backup runs](BackupRunGetCall) (response)
273/// * [insert backup runs](BackupRunInsertCall) (request)
274/// * [list backup runs](BackupRunListCall) (none)
275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
276#[serde_with::serde_as]
277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
278pub struct BackupRun {
279 /// The description of this run, only applicable to on-demand backups.
280 pub description: Option<String>,
281 /// Encryption configuration specific to a backup.
282 /// Applies only to Second Generation instances.
283 #[serde(rename = "diskEncryptionConfiguration")]
284 pub disk_encryption_configuration: Option<DiskEncryptionConfiguration>,
285 /// Encryption status specific to a backup.
286 /// Applies only to Second Generation instances.
287 #[serde(rename = "diskEncryptionStatus")]
288 pub disk_encryption_status: Option<DiskEncryptionStatus>,
289 /// The time the backup operation completed in UTC timezone in <a
290 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
291 /// <code>2012-11-15T16:19:00.094Z</code>.
292 #[serde(rename = "endTime")]
293 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
294 /// The time the run was enqueued in UTC timezone in <a
295 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
296 /// <code>2012-11-15T16:19:00.094Z</code>.
297 #[serde(rename = "enqueuedTime")]
298 pub enqueued_time: Option<chrono::DateTime<chrono::offset::Utc>>,
299 /// Information about why the backup operation failed. This is only present if
300 /// the run has the FAILED status.
301 pub error: Option<OperationError>,
302 /// The identifier for this backup run. Unique only for a specific Cloud SQL
303 /// instance.
304 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
305 pub id: Option<i64>,
306 /// Name of the database instance.
307 pub instance: Option<String>,
308 /// This is always <code>sql#backupRun</code>.
309 pub kind: Option<String>,
310 /// Location of the backups.
311 pub location: Option<String>,
312 /// The URI of this resource.
313 #[serde(rename = "selfLink")]
314 pub self_link: Option<String>,
315 /// The time the backup operation actually started in UTC timezone in <a
316 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
317 /// <code>2012-11-15T16:19:00.094Z</code>.
318 #[serde(rename = "startTime")]
319 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
320 /// The status of this run.
321 pub status: Option<String>,
322 /// The type of this run; can be either "AUTOMATED" or "ON_DEMAND".
323 #[serde(rename = "type")]
324 pub type_: Option<String>,
325 /// The start time of the backup window during which this the backup was
326 /// attempted in <a href="https://tools.ietf.org/html/rfc3339">RFC 3339</a>
327 /// format, for example <code>2012-11-15T16:19:00.094Z</code>.
328 #[serde(rename = "windowStartTime")]
329 pub window_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
330}
331
332impl common::RequestValue for BackupRun {}
333impl common::Resource for BackupRun {}
334impl common::ResponseResult for BackupRun {}
335
336/// Backup run list results.
337///
338/// # Activities
339///
340/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
341/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
342///
343/// * [list backup runs](BackupRunListCall) (response)
344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
345#[serde_with::serde_as]
346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
347pub struct BackupRunsListResponse {
348 /// A list of backup runs in reverse chronological order of the enqueued time.
349 pub items: Option<Vec<BackupRun>>,
350 /// This is always <code>sql#backupRunsList</code>.
351 pub kind: Option<String>,
352 /// The continuation token, used to page through large result sets. Provide
353 /// this value in a subsequent request to return the next page of results.
354 #[serde(rename = "nextPageToken")]
355 pub next_page_token: Option<String>,
356}
357
358impl common::ResponseResult for BackupRunsListResponse {}
359
360/// Binary log coordinates.
361///
362/// This type is not used in any activity, and only used as *part* of another schema.
363///
364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
365#[serde_with::serde_as]
366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
367pub struct BinLogCoordinates {
368 /// Name of the binary log file for a Cloud SQL instance.
369 #[serde(rename = "binLogFileName")]
370 pub bin_log_file_name: Option<String>,
371 /// Position (offset) within the binary log file.
372 #[serde(rename = "binLogPosition")]
373 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
374 pub bin_log_position: Option<i64>,
375 /// This is always <code>sql#binLogCoordinates</code>.
376 pub kind: Option<String>,
377}
378
379impl common::Part for BinLogCoordinates {}
380
381/// Database instance clone context.
382///
383/// This type is not used in any activity, and only used as *part* of another schema.
384///
385#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
386#[serde_with::serde_as]
387#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
388pub struct CloneContext {
389 /// Binary log coordinates, if specified, identify the position up to which the
390 /// source instance should be cloned. If not specified, the source instance is
391 /// cloned up to the most recent binary log coordinates.
392 #[serde(rename = "binLogCoordinates")]
393 pub bin_log_coordinates: Option<BinLogCoordinates>,
394 /// Name of the Cloud SQL instance to be created as a clone.
395 #[serde(rename = "destinationInstanceName")]
396 pub destination_instance_name: Option<String>,
397 /// This is always <code>sql#cloneContext</code>.
398 pub kind: Option<String>,
399 /// Reserved for future use.
400 #[serde(rename = "pitrTimestampMs")]
401 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
402 pub pitr_timestamp_ms: Option<i64>,
403 /// Reserved for future use.
404 #[serde(rename = "pointInTime")]
405 pub point_in_time: Option<chrono::DateTime<chrono::offset::Utc>>,
406}
407
408impl common::Part for CloneContext {}
409
410/// Represents a SQL database on the Cloud SQL instance.
411///
412/// # Activities
413///
414/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
415/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
416///
417/// * [delete databases](DatabaseDeleteCall) (none)
418/// * [get databases](DatabaseGetCall) (response)
419/// * [insert databases](DatabaseInsertCall) (request)
420/// * [list databases](DatabaseListCall) (none)
421/// * [patch databases](DatabasePatchCall) (request)
422/// * [update databases](DatabaseUpdateCall) (request)
423#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
424#[serde_with::serde_as]
425#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
426pub struct Database {
427 /// The MySQL charset value.
428 pub charset: Option<String>,
429 /// The MySQL collation value.
430 pub collation: Option<String>,
431 /// This field is deprecated and will be removed from a future version of the
432 /// API.
433 pub etag: Option<String>,
434 /// The name of the Cloud SQL instance. This does not include the project ID.
435 pub instance: Option<String>,
436 /// This is always <code>sql#database</code>.
437 pub kind: Option<String>,
438 /// The name of the database in the Cloud SQL instance. This does not include
439 /// the project ID or instance name.
440 pub name: Option<String>,
441 /// The project ID of the project containing the Cloud SQL database. The Google
442 /// apps domain is prefixed if applicable.
443 pub project: Option<String>,
444 /// The URI of this resource.
445 #[serde(rename = "selfLink")]
446 pub self_link: Option<String>,
447 /// no description provided
448 #[serde(rename = "sqlserverDatabaseDetails")]
449 pub sqlserver_database_details: Option<SqlServerDatabaseDetails>,
450}
451
452impl common::RequestValue for Database {}
453impl common::Resource for Database {}
454impl common::ResponseResult for Database {}
455
456/// Database flags for Cloud SQL instances.
457///
458/// This type is not used in any activity, and only used as *part* of another schema.
459///
460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
461#[serde_with::serde_as]
462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
463pub struct DatabaseFlags {
464 /// The name of the flag. These flags are passed at instance startup, so
465 /// include both server options and system variables for MySQL. Flags should be
466 /// specified with underscores, not hyphens. For more information, see <a
467 /// href="/sql/docs/mysql/flags">Configuring Database Flags</a> in the Cloud
468 /// SQL documentation.
469 pub name: Option<String>,
470 /// The value of the flag. Booleans should be set to <code>on</code> for true
471 /// and <code>off</code> for false. This field must be omitted if the flag
472 /// doesn't take a value.
473 pub value: Option<String>,
474}
475
476impl common::Part for DatabaseFlags {}
477
478/// A Cloud SQL instance resource.
479///
480/// # Activities
481///
482/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
483/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
484///
485/// * [get instances](InstanceGetCall) (response)
486/// * [insert instances](InstanceInsertCall) (request)
487/// * [patch instances](InstancePatchCall) (request)
488/// * [update instances](InstanceUpdateCall) (request)
489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
490#[serde_with::serde_as]
491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
492pub struct DatabaseInstance {
493 /// <code>FIRST_GEN</code>: First Generation instance. MySQL only. <br
494 /// /><code>SECOND_GEN</code>: Second Generation instance or PostgreSQL
495 /// instance. <br /><code>EXTERNAL</code>: A database server that is not
496 /// managed by Google. <br>This property is read-only; use the
497 /// <code>tier</code> property in the <code>settings</code> object to determine
498 /// the database type and Second or First Generation.
499 #[serde(rename = "backendType")]
500 pub backend_type: Option<String>,
501 /// Connection name of the Cloud SQL instance used in connection strings.
502 #[serde(rename = "connectionName")]
503 pub connection_name: Option<String>,
504 /// The current disk usage of the instance in bytes. This property has been
505 /// deprecated. Users should use the
506 /// "cloudsql.googleapis.com/database/disk/bytes_used" metric in Cloud
507 /// Monitoring API instead. Please see <a
508 /// href="https://groups.google.com/d/msg/google-cloud-sql-announce/I_7-F9EBhT0/BtvFtdFeAgAJ">this
509 /// announcement</a> for details.
510 #[serde(rename = "currentDiskSize")]
511 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
512 pub current_disk_size: Option<i64>,
513 /// The database engine type and version. The <code>databaseVersion</code>
514 /// field can not be changed after instance creation. MySQL Second Generation
515 /// instances: <code>MYSQL_5_7</code> (default) or <code>MYSQL_5_6</code>.
516 /// PostgreSQL instances: <code>POSTGRES_9_6</code> (default) or
517 /// <code>POSTGRES_11 Beta</code> MySQL First Generation
518 /// instances: <code>MYSQL_5_6</code> (default) or <code>MYSQL_5_5</code>
519 #[serde(rename = "databaseVersion")]
520 pub database_version: Option<String>,
521 /// Disk encryption configuration specific to an instance.
522 /// Applies only to Second Generation instances.
523 #[serde(rename = "diskEncryptionConfiguration")]
524 pub disk_encryption_configuration: Option<DiskEncryptionConfiguration>,
525 /// Disk encryption status specific to an instance.
526 /// Applies only to Second Generation instances.
527 #[serde(rename = "diskEncryptionStatus")]
528 pub disk_encryption_status: Option<DiskEncryptionStatus>,
529 /// This field is deprecated and will be removed from a future version of the
530 /// API. Use the <code>settings.settingsVersion</code> field instead.
531 pub etag: Option<String>,
532 /// The name and status of the failover replica. This property is applicable
533 /// only to Second Generation instances.
534 #[serde(rename = "failoverReplica")]
535 pub failover_replica: Option<DatabaseInstanceFailoverReplica>,
536 /// The Compute Engine zone that the instance is currently serving from. This
537 /// value could be different from the zone that was specified when the instance
538 /// was created if the instance has failed over to its secondary zone.
539 #[serde(rename = "gceZone")]
540 pub gce_zone: Option<String>,
541 /// The instance type. This can be one of the following.
542 /// <br><code>CLOUD_SQL_INSTANCE</code>: A Cloud SQL instance that is not
543 /// replicating from a master. <br><code>ON_PREMISES_INSTANCE</code>: An
544 /// instance running on the
545 /// customer's premises. <br><code>READ_REPLICA_INSTANCE</code>: A Cloud SQL
546 /// instance configured as a read-replica.
547 #[serde(rename = "instanceType")]
548 pub instance_type: Option<String>,
549 /// The assigned IP addresses for the instance.
550 #[serde(rename = "ipAddresses")]
551 pub ip_addresses: Option<Vec<IpMapping>>,
552 /// The IPv6 address assigned to the instance. This property is applicable only
553 /// to First Generation instances.
554 #[serde(rename = "ipv6Address")]
555 pub ipv6_address: Option<String>,
556 /// This is always <code>sql#instance</code>.
557 pub kind: Option<String>,
558 /// The name of the instance which will act as master in the replication setup.
559 #[serde(rename = "masterInstanceName")]
560 pub master_instance_name: Option<String>,
561 /// The maximum disk size of the instance in bytes.
562 #[serde(rename = "maxDiskSize")]
563 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
564 pub max_disk_size: Option<i64>,
565 /// Name of the Cloud SQL instance. This does not include the project ID.
566 pub name: Option<String>,
567 /// Configuration specific to on-premises instances.
568 #[serde(rename = "onPremisesConfiguration")]
569 pub on_premises_configuration: Option<OnPremisesConfiguration>,
570 /// The project ID of the project containing the Cloud SQL instance. The Google
571 /// apps domain is prefixed if applicable.
572 pub project: Option<String>,
573 /// The geographical region. Can be <code>us-central</code>
574 /// (<code>FIRST_GEN</code> instances only), <code>us-central1</code>
575 /// (<code>SECOND_GEN</code> instances only), <code>asia-east1</code> or
576 /// <code>europe-west1</code>. Defaults to <code>us-central</code> or
577 /// <code>us-central1</code> depending on the instance type (First Generation
578 /// or Second Generation). The region can not be changed after instance
579 /// creation.
580 pub region: Option<String>,
581 /// Configuration specific to failover replicas and read replicas.
582 #[serde(rename = "replicaConfiguration")]
583 pub replica_configuration: Option<ReplicaConfiguration>,
584 /// The replicas of the instance.
585 #[serde(rename = "replicaNames")]
586 pub replica_names: Option<Vec<String>>,
587 /// Initial root password. Use only on creation.
588 #[serde(rename = "rootPassword")]
589 pub root_password: Option<String>,
590 /// The start time of any upcoming scheduled maintenance for this instance.
591 #[serde(rename = "scheduledMaintenance")]
592 pub scheduled_maintenance: Option<SqlScheduledMaintenance>,
593 /// The URI of this resource.
594 #[serde(rename = "selfLink")]
595 pub self_link: Option<String>,
596 /// SSL configuration.
597 #[serde(rename = "serverCaCert")]
598 pub server_ca_cert: Option<SslCert>,
599 /// The service account email address assigned to the instance. This property
600 /// is applicable only to Second Generation instances.
601 #[serde(rename = "serviceAccountEmailAddress")]
602 pub service_account_email_address: Option<String>,
603 /// The user settings.
604 pub settings: Option<Settings>,
605 /// The current serving state of the Cloud SQL instance. This can be one of the
606 /// following. <br><code>RUNNABLE</code>: The instance is running, or is ready
607 /// to run when accessed. <br><code>SUSPENDED</code>: The instance is not
608 /// available, for example due to problems with billing.
609 /// <br><code>PENDING_CREATE</code>: The instance is being created.
610 /// <br><code>MAINTENANCE</code>: The instance is down for maintenance.
611 /// <br><code>FAILED</code>: The instance creation failed.
612 /// <br><code>UNKNOWN_STATE</code>: The state of the instance is unknown.
613 pub state: Option<String>,
614 /// If the instance state is SUSPENDED, the reason for the suspension.
615 #[serde(rename = "suspensionReason")]
616 pub suspension_reason: Option<Vec<String>>,
617}
618
619impl common::RequestValue for DatabaseInstance {}
620impl common::ResponseResult for DatabaseInstance {}
621
622/// Database list response.
623///
624/// # Activities
625///
626/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
627/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
628///
629/// * [list databases](DatabaseListCall) (response)
630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
631#[serde_with::serde_as]
632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
633pub struct DatabasesListResponse {
634 /// List of database resources in the instance.
635 pub items: Option<Vec<Database>>,
636 /// This is always <code>sql#databasesList</code>.
637 pub kind: Option<String>,
638}
639
640impl common::ResponseResult for DatabasesListResponse {}
641
642/// Read-replica configuration for connecting to the on-premises master.
643///
644/// This type is not used in any activity, and only used as *part* of another schema.
645///
646#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
647#[serde_with::serde_as]
648#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
649pub struct DemoteMasterConfiguration {
650 /// This is always <code>sql#demoteMasterConfiguration</code>.
651 pub kind: Option<String>,
652 /// MySQL specific configuration when replicating from a MySQL on-premises
653 /// master. Replication configuration information such as the username,
654 /// password, certificates, and keys are not stored in the instance metadata.
655 /// The configuration information is used only to set up the replication
656 /// connection and is stored by MySQL in a file named <code>master.info</code>
657 /// in the data directory.
658 #[serde(rename = "mysqlReplicaConfiguration")]
659 pub mysql_replica_configuration: Option<DemoteMasterMySqlReplicaConfiguration>,
660}
661
662impl common::Part for DemoteMasterConfiguration {}
663
664/// Database instance demote master context.
665///
666/// This type is not used in any activity, and only used as *part* of another schema.
667///
668#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
669#[serde_with::serde_as]
670#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
671pub struct DemoteMasterContext {
672 /// This is always <code>sql#demoteMasterContext</code>.
673 pub kind: Option<String>,
674 /// The name of the instance which will act as on-premises master in the
675 /// replication setup.
676 #[serde(rename = "masterInstanceName")]
677 pub master_instance_name: Option<String>,
678 /// Configuration specific to read-replicas replicating from the on-premises
679 /// master.
680 #[serde(rename = "replicaConfiguration")]
681 pub replica_configuration: Option<DemoteMasterConfiguration>,
682 /// Verify GTID consistency for demote operation. Default value:
683 /// <code>True</code>. Second Generation instances only. Setting this flag to
684 /// false enables you to bypass GTID consistency check between on-premises
685 /// master and Cloud SQL instance during the demotion operation but also
686 /// exposes you to the risk of future replication failures. Change the value
687 /// only if you know the reason for the GTID divergence and are confident that
688 /// doing so will not cause any replication issues.
689 #[serde(rename = "verifyGtidConsistency")]
690 pub verify_gtid_consistency: Option<bool>,
691}
692
693impl common::Part for DemoteMasterContext {}
694
695/// Read-replica configuration specific to MySQL databases.
696///
697/// This type is not used in any activity, and only used as *part* of another schema.
698///
699#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
700#[serde_with::serde_as]
701#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
702pub struct DemoteMasterMySqlReplicaConfiguration {
703 /// PEM representation of the trusted CA's x509 certificate.
704 #[serde(rename = "caCertificate")]
705 pub ca_certificate: Option<String>,
706 /// PEM representation of the slave's x509 certificate.
707 #[serde(rename = "clientCertificate")]
708 pub client_certificate: Option<String>,
709 /// PEM representation of the slave's private key. The corresponsing public key
710 /// is encoded in the client's certificate. The format of the slave's private
711 /// key can be either PKCS #1 or PKCS #8.
712 #[serde(rename = "clientKey")]
713 pub client_key: Option<String>,
714 /// This is always <code>sql#demoteMasterMysqlReplicaConfiguration</code>.
715 pub kind: Option<String>,
716 /// The password for the replication connection.
717 pub password: Option<String>,
718 /// The username for the replication connection.
719 pub username: Option<String>,
720}
721
722impl common::Part for DemoteMasterMySqlReplicaConfiguration {}
723
724/// Disk encryption configuration for an instance.
725///
726/// This type is not used in any activity, and only used as *part* of another schema.
727///
728#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
729#[serde_with::serde_as]
730#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
731pub struct DiskEncryptionConfiguration {
732 /// This is always <code>sql#diskEncryptionConfiguration</code>.
733 pub kind: Option<String>,
734 /// Resource name of KMS key for disk encryption
735 #[serde(rename = "kmsKeyName")]
736 pub kms_key_name: Option<String>,
737}
738
739impl common::Part for DiskEncryptionConfiguration {}
740
741/// Disk encryption status for an instance.
742///
743/// This type is not used in any activity, and only used as *part* of another schema.
744///
745#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
746#[serde_with::serde_as]
747#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
748pub struct DiskEncryptionStatus {
749 /// This is always <code>sql#diskEncryptionStatus</code>.
750 pub kind: Option<String>,
751 /// KMS key version used to encrypt the Cloud SQL instance resource
752 #[serde(rename = "kmsKeyVersionName")]
753 pub kms_key_version_name: Option<String>,
754}
755
756impl common::Part for DiskEncryptionStatus {}
757
758/// Database instance export context.
759///
760/// This type is not used in any activity, and only used as *part* of another schema.
761///
762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
763#[serde_with::serde_as]
764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
765pub struct ExportContext {
766 /// Options for exporting data as CSV.
767 #[serde(rename = "csvExportOptions")]
768 pub csv_export_options: Option<ExportContextCsvExportOptions>,
769 /// Databases to be exported. <br /> <b>MySQL instances:</b> If
770 /// <code>fileType</code> is <code>SQL</code> and no database is specified, all
771 /// databases are exported, except for the <code>mysql</code> system database.
772 /// If <code>fileType</code> is <code>CSV</code>, you can specify one database,
773 /// either by using this property or by using the
774 /// <code>csvExportOptions.selectQuery</code> property, which takes precedence
775 /// over this property. <br /> <b>PostgreSQL instances:</b> You must specify
776 /// one database to be exported. If <code>fileType</code> is <code>CSV</code>,
777 /// this database must match the one specified in the
778 /// <code>csvExportOptions.selectQuery</code> property.
779 pub databases: Option<Vec<String>>,
780 /// The file type for the specified uri. <br><code>SQL</code>: The file
781 /// contains SQL statements. <br><code>CSV</code>: The file contains CSV data.
782 #[serde(rename = "fileType")]
783 pub file_type: Option<String>,
784 /// This is always <code>sql#exportContext</code>.
785 pub kind: Option<String>,
786 /// Options for exporting data as SQL statements.
787 #[serde(rename = "sqlExportOptions")]
788 pub sql_export_options: Option<ExportContextSqlExportOptions>,
789 /// The path to the file in Google Cloud Storage where the export will be
790 /// stored. The URI is in the form <code>gs:
791 /// //bucketName/fileName</code>. If the file already exists, the requests
792 /// // succeeds, but the operation fails. If <code>fileType</code> is
793 /// // <code>SQL</code> and the filename ends with .gz, the contents are
794 /// // compressed.
795 pub uri: Option<String>,
796}
797
798impl common::Part for ExportContext {}
799
800/// Database instance failover context.
801///
802/// This type is not used in any activity, and only used as *part* of another schema.
803///
804#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
805#[serde_with::serde_as]
806#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
807pub struct FailoverContext {
808 /// This is always <code>sql#failoverContext</code>.
809 pub kind: Option<String>,
810 /// The current settings version of this instance. Request will be rejected if
811 /// this version doesn't match the current settings version.
812 #[serde(rename = "settingsVersion")]
813 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
814 pub settings_version: Option<i64>,
815}
816
817impl common::Part for FailoverContext {}
818
819/// A flag resource.
820///
821/// # Activities
822///
823/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
824/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
825///
826/// * [list flags](FlagListCall) (none)
827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
828#[serde_with::serde_as]
829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
830pub struct Flag {
831 /// Use this field if only certain integers are accepted. Can be combined
832 /// with min_value and max_value to add additional values.
833 #[serde(rename = "allowedIntValues")]
834 #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
835 pub allowed_int_values: Option<Vec<i64>>,
836 /// For <code>STRING</code> flags, a list of strings that the value can be set
837 /// to.
838 #[serde(rename = "allowedStringValues")]
839 pub allowed_string_values: Option<Vec<String>>,
840 /// The database version this flag applies to. Can be <code>MYSQL_5_5</code>,
841 /// <code>MYSQL_5_6</code>, or <code>MYSQL_5_7</code>. <code>MYSQL_5_7</code>
842 /// is applicable only to Second Generation instances.
843 #[serde(rename = "appliesTo")]
844 pub applies_to: Option<Vec<String>>,
845 /// Whether or not the flag is considered in beta.
846 #[serde(rename = "inBeta")]
847 pub in_beta: Option<bool>,
848 /// This is always <code>sql#flag</code>.
849 pub kind: Option<String>,
850 /// For <code>INTEGER</code> flags, the maximum allowed value.
851 #[serde(rename = "maxValue")]
852 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
853 pub max_value: Option<i64>,
854 /// For <code>INTEGER</code> flags, the minimum allowed value.
855 #[serde(rename = "minValue")]
856 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
857 pub min_value: Option<i64>,
858 /// This is the name of the flag. Flag names always use underscores, not
859 /// hyphens, e.g. <code>max_allowed_packet</code>
860 pub name: Option<String>,
861 /// Indicates whether changing this flag will trigger a database restart. Only
862 /// applicable to Second Generation instances.
863 #[serde(rename = "requiresRestart")]
864 pub requires_restart: Option<bool>,
865 /// The type of the flag. Flags are typed to being <code>BOOLEAN</code>,
866 /// <code>STRING</code>, <code>INTEGER</code> or <code>NONE</code>.
867 /// <code>NONE</code> is used for flags which do not take a value, such as
868 /// <code>skip_grant_tables</code>.
869 #[serde(rename = "type")]
870 pub type_: Option<String>,
871}
872
873impl common::Resource for Flag {}
874
875/// Flags list response.
876///
877/// # Activities
878///
879/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
880/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
881///
882/// * [list flags](FlagListCall) (response)
883#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
884#[serde_with::serde_as]
885#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
886pub struct FlagsListResponse {
887 /// List of flags.
888 pub items: Option<Vec<Flag>>,
889 /// This is always <code>sql#flagsList</code>.
890 pub kind: Option<String>,
891}
892
893impl common::ResponseResult for FlagsListResponse {}
894
895/// Database instance import context.
896///
897/// This type is not used in any activity, and only used as *part* of another schema.
898///
899#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
900#[serde_with::serde_as]
901#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
902pub struct ImportContext {
903 /// Import parameters specific to SQL Server .BAK files
904 #[serde(rename = "bakImportOptions")]
905 pub bak_import_options: Option<ImportContextBakImportOptions>,
906 /// Options for importing data as CSV.
907 #[serde(rename = "csvImportOptions")]
908 pub csv_import_options: Option<ImportContextCsvImportOptions>,
909 /// The target database for the import. If <code>fileType</code> is
910 /// <code>SQL</code>, this field is required only if the import file does not
911 /// specify a database, and is overridden by any database specification in the
912 /// import file. If <code>fileType</code> is <code>CSV</code>, one database
913 /// must be specified.
914 pub database: Option<String>,
915 /// The file type for the specified uri. <br><code>SQL</code>: The file
916 /// contains SQL statements. <br><code>CSV</code>: The file contains CSV data.
917 #[serde(rename = "fileType")]
918 pub file_type: Option<String>,
919 /// The PostgreSQL user for this import operation. PostgreSQL instances only.
920 #[serde(rename = "importUser")]
921 pub import_user: Option<String>,
922 /// This is always <code>sql#importContext</code>.
923 pub kind: Option<String>,
924 /// Path to the import file in Cloud Storage, in the form
925 /// <code>gs:
926 /// //bucketName/fileName</code>. Compressed gzip files (.gz) are supported
927 /// // when <code>fileType</code> is <code>SQL</code>. The instance must have
928 /// // write permissions to the bucket and read access to the file.
929 pub uri: Option<String>,
930}
931
932impl common::Part for ImportContext {}
933
934/// Database instance clone request.
935///
936/// # Activities
937///
938/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
939/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
940///
941/// * [clone instances](InstanceCloneCall) (request)
942#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
943#[serde_with::serde_as]
944#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
945pub struct InstancesCloneRequest {
946 /// Contains details about the clone operation.
947 #[serde(rename = "cloneContext")]
948 pub clone_context: Option<CloneContext>,
949}
950
951impl common::RequestValue for InstancesCloneRequest {}
952
953/// Database demote master request.
954///
955/// # Activities
956///
957/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
958/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
959///
960/// * [demote master instances](InstanceDemoteMasterCall) (request)
961#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
962#[serde_with::serde_as]
963#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
964pub struct InstancesDemoteMasterRequest {
965 /// Contains details about the demoteMaster operation.
966 #[serde(rename = "demoteMasterContext")]
967 pub demote_master_context: Option<DemoteMasterContext>,
968}
969
970impl common::RequestValue for InstancesDemoteMasterRequest {}
971
972/// Database instance export request.
973///
974/// # Activities
975///
976/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
977/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
978///
979/// * [export instances](InstanceExportCall) (request)
980#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
981#[serde_with::serde_as]
982#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
983pub struct InstancesExportRequest {
984 /// Contains details about the export operation.
985 #[serde(rename = "exportContext")]
986 pub export_context: Option<ExportContext>,
987}
988
989impl common::RequestValue for InstancesExportRequest {}
990
991/// Instance failover request.
992///
993/// # Activities
994///
995/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
996/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
997///
998/// * [failover instances](InstanceFailoverCall) (request)
999#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1000#[serde_with::serde_as]
1001#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1002pub struct InstancesFailoverRequest {
1003 /// Failover Context.
1004 #[serde(rename = "failoverContext")]
1005 pub failover_context: Option<FailoverContext>,
1006}
1007
1008impl common::RequestValue for InstancesFailoverRequest {}
1009
1010/// Database instance import request.
1011///
1012/// # Activities
1013///
1014/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1015/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1016///
1017/// * [import instances](InstanceImportCall) (request)
1018#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1019#[serde_with::serde_as]
1020#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1021pub struct InstancesImportRequest {
1022 /// Contains details about the import operation.
1023 #[serde(rename = "importContext")]
1024 pub import_context: Option<ImportContext>,
1025}
1026
1027impl common::RequestValue for InstancesImportRequest {}
1028
1029/// Database instances list response.
1030///
1031/// # Activities
1032///
1033/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1034/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1035///
1036/// * [list instances](InstanceListCall) (response)
1037#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1038#[serde_with::serde_as]
1039#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1040pub struct InstancesListResponse {
1041 /// List of database instance resources.
1042 pub items: Option<Vec<DatabaseInstance>>,
1043 /// This is always <code>sql#instancesList</code>.
1044 pub kind: Option<String>,
1045 /// The continuation token, used to page through large result sets. Provide
1046 /// this value in a subsequent request to return the next page of results.
1047 #[serde(rename = "nextPageToken")]
1048 pub next_page_token: Option<String>,
1049 /// List of warnings that occurred while handling the request.
1050 pub warnings: Option<Vec<ApiWarning>>,
1051}
1052
1053impl common::ResponseResult for InstancesListResponse {}
1054
1055/// Instances ListServerCas response.
1056///
1057/// # Activities
1058///
1059/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1060/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1061///
1062/// * [list server cas instances](InstanceListServerCaCall) (response)
1063#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1064#[serde_with::serde_as]
1065#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1066pub struct InstancesListServerCasResponse {
1067 /// no description provided
1068 #[serde(rename = "activeVersion")]
1069 pub active_version: Option<String>,
1070 /// List of server CA certificates for the instance.
1071 pub certs: Option<Vec<SslCert>>,
1072 /// This is always <code>sql#instancesListServerCas</code>.
1073 pub kind: Option<String>,
1074}
1075
1076impl common::ResponseResult for InstancesListServerCasResponse {}
1077
1078/// Database instance restore backup request.
1079///
1080/// # Activities
1081///
1082/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1083/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1084///
1085/// * [restore backup instances](InstanceRestoreBackupCall) (request)
1086#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1087#[serde_with::serde_as]
1088#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1089pub struct InstancesRestoreBackupRequest {
1090 /// Parameters required to perform the restore backup operation.
1091 #[serde(rename = "restoreBackupContext")]
1092 pub restore_backup_context: Option<RestoreBackupContext>,
1093}
1094
1095impl common::RequestValue for InstancesRestoreBackupRequest {}
1096
1097/// Rotate Server CA request.
1098///
1099/// # Activities
1100///
1101/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1102/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1103///
1104/// * [rotate server ca instances](InstanceRotateServerCaCall) (request)
1105#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1106#[serde_with::serde_as]
1107#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1108pub struct InstancesRotateServerCaRequest {
1109 /// Contains details about the rotate server CA operation.
1110 #[serde(rename = "rotateServerCaContext")]
1111 pub rotate_server_ca_context: Option<RotateServerCaContext>,
1112}
1113
1114impl common::RequestValue for InstancesRotateServerCaRequest {}
1115
1116/// Instance truncate log request.
1117///
1118/// # Activities
1119///
1120/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1121/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1122///
1123/// * [truncate log instances](InstanceTruncateLogCall) (request)
1124#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1125#[serde_with::serde_as]
1126#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1127pub struct InstancesTruncateLogRequest {
1128 /// Contains details about the truncate log operation.
1129 #[serde(rename = "truncateLogContext")]
1130 pub truncate_log_context: Option<TruncateLogContext>,
1131}
1132
1133impl common::RequestValue for InstancesTruncateLogRequest {}
1134
1135/// IP Management configuration.
1136///
1137/// This type is not used in any activity, and only used as *part* of another schema.
1138///
1139#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1140#[serde_with::serde_as]
1141#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1142pub struct IpConfiguration {
1143 /// The list of external networks that are allowed to connect to the instance
1144 /// using the IP. In <a
1145 /// href="http://en.wikipedia.org/wiki/CIDR_notation#CIDR_notation">CIDR
1146 /// notation</a>, also known as 'slash' notation (e.g.
1147 /// <code>192.168.100.0/24</code>).
1148 #[serde(rename = "authorizedNetworks")]
1149 pub authorized_networks: Option<Vec<AclEntry>>,
1150 /// Whether the instance should be assigned an IP address or not.
1151 #[serde(rename = "ipv4Enabled")]
1152 pub ipv4_enabled: Option<bool>,
1153 /// The resource link for the VPC network from which the Cloud SQL instance is
1154 /// accessible for private IP. For example,
1155 /// <code>/projects/myProject/global/networks/default</code>. This setting can
1156 /// be updated, but it cannot be removed after it is set.
1157 #[serde(rename = "privateNetwork")]
1158 pub private_network: Option<String>,
1159 /// Whether SSL connections over IP should be enforced or not.
1160 #[serde(rename = "requireSsl")]
1161 pub require_ssl: Option<bool>,
1162}
1163
1164impl common::Part for IpConfiguration {}
1165
1166/// Database instance IP Mapping.
1167///
1168/// This type is not used in any activity, and only used as *part* of another schema.
1169///
1170#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1171#[serde_with::serde_as]
1172#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1173pub struct IpMapping {
1174 /// The IP address assigned.
1175 #[serde(rename = "ipAddress")]
1176 pub ip_address: Option<String>,
1177 /// The due time for this IP to be retired in <a
1178 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1179 /// <code>2012-11-15T16:19:00.094Z</code>. This field is only available when
1180 /// the IP is scheduled to be retired.
1181 #[serde(rename = "timeToRetire")]
1182 pub time_to_retire: Option<chrono::DateTime<chrono::offset::Utc>>,
1183 /// The type of this IP address. A <code>PRIMARY</code> address is a public
1184 /// address that can accept incoming connections. A <code>PRIVATE</code>
1185 /// address is a private address that can accept incoming connections. An
1186 /// <code>OUTGOING</code> address is the source address of connections
1187 /// originating from the instance, if supported.
1188 #[serde(rename = "type")]
1189 pub type_: Option<String>,
1190}
1191
1192impl common::Part for IpMapping {}
1193
1194/// Preferred location. This specifies where a Cloud SQL instance should
1195/// preferably be located, either in a specific Compute Engine zone, or
1196/// co-located with an App Engine application. Note that if the preferred
1197/// location is not available, the instance will be located as close as possible
1198/// within the region. Only one location may be specified.
1199///
1200/// This type is not used in any activity, and only used as *part* of another schema.
1201///
1202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1203#[serde_with::serde_as]
1204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1205pub struct LocationPreference {
1206 /// The AppEngine application to follow, it must be in the same region as the
1207 /// Cloud SQL instance.
1208 #[serde(rename = "followGaeApplication")]
1209 pub follow_gae_application: Option<String>,
1210 /// This is always <code>sql#locationPreference</code>.
1211 pub kind: Option<String>,
1212 /// The preferred Compute Engine zone (e.g. us-central1-a, us-central1-b,
1213 /// etc.).
1214 pub zone: Option<String>,
1215}
1216
1217impl common::Part for LocationPreference {}
1218
1219/// Maintenance window. This specifies when a v2 Cloud SQL instance should
1220/// preferably be restarted for system maintenance purposes.
1221///
1222/// This type is not used in any activity, and only used as *part* of another schema.
1223///
1224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1225#[serde_with::serde_as]
1226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1227pub struct MaintenanceWindow {
1228 /// day of week (1-7), starting on Monday.
1229 pub day: Option<i32>,
1230 /// hour of day - 0 to 23.
1231 pub hour: Option<i32>,
1232 /// This is always <code>sql#maintenanceWindow</code>.
1233 pub kind: Option<String>,
1234 /// Maintenance timing setting: <code>canary</code> (Earlier) or
1235 /// <code>stable</code> (Later). <br /><a
1236 /// href="/sql/docs/db_path/instance-settings#maintenance-timing-2ndgen">
1237 /// Learn more</a>.
1238 #[serde(rename = "updateTrack")]
1239 pub update_track: Option<String>,
1240}
1241
1242impl common::Part for MaintenanceWindow {}
1243
1244/// Read-replica configuration specific to MySQL databases.
1245///
1246/// This type is not used in any activity, and only used as *part* of another schema.
1247///
1248#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1249#[serde_with::serde_as]
1250#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1251pub struct MySqlReplicaConfiguration {
1252 /// PEM representation of the trusted CA's x509 certificate.
1253 #[serde(rename = "caCertificate")]
1254 pub ca_certificate: Option<String>,
1255 /// PEM representation of the slave's x509 certificate.
1256 #[serde(rename = "clientCertificate")]
1257 pub client_certificate: Option<String>,
1258 /// PEM representation of the slave's private key. The corresponsing public key
1259 /// is encoded in the client's certificate.
1260 #[serde(rename = "clientKey")]
1261 pub client_key: Option<String>,
1262 /// Seconds to wait between connect retries. MySQL's default is 60 seconds.
1263 #[serde(rename = "connectRetryInterval")]
1264 pub connect_retry_interval: Option<i32>,
1265 /// Path to a SQL dump file in Google Cloud Storage from which the slave
1266 /// instance is to be created. The URI is in the form gs:
1267 /// //bucketName/fileName. Compressed gzip files (.gz) are also supported.
1268 /// // Dumps should have the binlog co-ordinates from which replication should
1269 /// // begin. This can be accomplished by setting --master-data to 1 when using
1270 /// // mysqldump.
1271 #[serde(rename = "dumpFilePath")]
1272 pub dump_file_path: Option<String>,
1273 /// This is always <code>sql#mysqlReplicaConfiguration</code>.
1274 pub kind: Option<String>,
1275 /// Interval in milliseconds between replication heartbeats.
1276 #[serde(rename = "masterHeartbeatPeriod")]
1277 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1278 pub master_heartbeat_period: Option<i64>,
1279 /// The password for the replication connection.
1280 pub password: Option<String>,
1281 /// A list of permissible ciphers to use for SSL encryption.
1282 #[serde(rename = "sslCipher")]
1283 pub ssl_cipher: Option<String>,
1284 /// The username for the replication connection.
1285 pub username: Option<String>,
1286 /// Whether or not to check the master's Common Name value in the certificate
1287 /// that it sends during the SSL handshake.
1288 #[serde(rename = "verifyServerCertificate")]
1289 pub verify_server_certificate: Option<bool>,
1290}
1291
1292impl common::Part for MySqlReplicaConfiguration {}
1293
1294/// On-premises instance configuration.
1295///
1296/// This type is not used in any activity, and only used as *part* of another schema.
1297///
1298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1299#[serde_with::serde_as]
1300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1301pub struct OnPremisesConfiguration {
1302 /// PEM representation of the trusted CA's x509 certificate.
1303 #[serde(rename = "caCertificate")]
1304 pub ca_certificate: Option<String>,
1305 /// PEM representation of the slave's x509 certificate.
1306 #[serde(rename = "clientCertificate")]
1307 pub client_certificate: Option<String>,
1308 /// PEM representation of the slave's private key. The corresponsing public key
1309 /// is encoded in the client's certificate.
1310 #[serde(rename = "clientKey")]
1311 pub client_key: Option<String>,
1312 /// The dump file to create the Cloud SQL replica.
1313 #[serde(rename = "dumpFilePath")]
1314 pub dump_file_path: Option<String>,
1315 /// The host and port of the on-premises instance in host:port format
1316 #[serde(rename = "hostPort")]
1317 pub host_port: Option<String>,
1318 /// This is always <code>sql#onPremisesConfiguration</code>.
1319 pub kind: Option<String>,
1320 /// The password for connecting to on-premises instance.
1321 pub password: Option<String>,
1322 /// The username for connecting to on-premises instance.
1323 pub username: Option<String>,
1324}
1325
1326impl common::Part for OnPremisesConfiguration {}
1327
1328/// An Operation resource. For successful operations that return an
1329/// Operation resource, only the fields relevant to the operation are populated
1330/// in the resource.
1331///
1332/// # Activities
1333///
1334/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1335/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1336///
1337/// * [delete backup runs](BackupRunDeleteCall) (response)
1338/// * [insert backup runs](BackupRunInsertCall) (response)
1339/// * [delete databases](DatabaseDeleteCall) (response)
1340/// * [insert databases](DatabaseInsertCall) (response)
1341/// * [patch databases](DatabasePatchCall) (response)
1342/// * [update databases](DatabaseUpdateCall) (response)
1343/// * [add server ca instances](InstanceAddServerCaCall) (response)
1344/// * [clone instances](InstanceCloneCall) (response)
1345/// * [delete instances](InstanceDeleteCall) (response)
1346/// * [demote master instances](InstanceDemoteMasterCall) (response)
1347/// * [export instances](InstanceExportCall) (response)
1348/// * [failover instances](InstanceFailoverCall) (response)
1349/// * [import instances](InstanceImportCall) (response)
1350/// * [insert instances](InstanceInsertCall) (response)
1351/// * [patch instances](InstancePatchCall) (response)
1352/// * [promote replica instances](InstancePromoteReplicaCall) (response)
1353/// * [reset ssl config instances](InstanceResetSslConfigCall) (response)
1354/// * [restart instances](InstanceRestartCall) (response)
1355/// * [restore backup instances](InstanceRestoreBackupCall) (response)
1356/// * [rotate server ca instances](InstanceRotateServerCaCall) (response)
1357/// * [start replica instances](InstanceStartReplicaCall) (response)
1358/// * [stop replica instances](InstanceStopReplicaCall) (response)
1359/// * [truncate log instances](InstanceTruncateLogCall) (response)
1360/// * [update instances](InstanceUpdateCall) (response)
1361/// * [get operations](OperationGetCall) (response)
1362/// * [list operations](OperationListCall) (none)
1363/// * [instances reschedule maintenance projects](ProjectInstanceRescheduleMaintenanceCall) (response)
1364/// * [instances start external sync projects](ProjectInstanceStartExternalSyncCall) (response)
1365/// * [delete ssl certs](SslCertDeleteCall) (response)
1366/// * [delete users](UserDeleteCall) (response)
1367/// * [insert users](UserInsertCall) (response)
1368/// * [update users](UserUpdateCall) (response)
1369#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1370#[serde_with::serde_as]
1371#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1372pub struct Operation {
1373 /// The time this operation finished in UTC timezone in <a
1374 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1375 /// <code>2012-11-15T16:19:00.094Z</code>.
1376 #[serde(rename = "endTime")]
1377 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1378 /// If errors occurred during processing of this operation, this field will be
1379 /// populated.
1380 pub error: Option<OperationErrors>,
1381 /// The context for export operation, if applicable.
1382 #[serde(rename = "exportContext")]
1383 pub export_context: Option<ExportContext>,
1384 /// The context for import operation, if applicable.
1385 #[serde(rename = "importContext")]
1386 pub import_context: Option<ImportContext>,
1387 /// The time this operation was enqueued in UTC timezone in <a
1388 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1389 /// <code>2012-11-15T16:19:00.094Z</code>.
1390 #[serde(rename = "insertTime")]
1391 pub insert_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1392 /// This is always <code>sql#operation</code>.
1393 pub kind: Option<String>,
1394 /// An identifier that uniquely identifies the operation. You can use this
1395 /// identifier to retrieve the Operations resource that has information about
1396 /// the operation.
1397 pub name: Option<String>,
1398 /// The type of the operation. Valid values are <code>CREATE</code>,
1399 /// <code>DELETE</code>, <code>UPDATE</code>, <code>RESTART</code>,
1400 /// <code>IMPORT</code>, <code>EXPORT</code>, <code>BACKUP_VOLUME</code>,
1401 /// <code>RESTORE_VOLUME</code>, <code>CREATE_USER</code>,
1402 /// <code>DELETE_USER</code>, <code>CREATE_DATABASE</code>,
1403 /// <code>DELETE_DATABASE</code> .
1404 #[serde(rename = "operationType")]
1405 pub operation_type: Option<String>,
1406 /// The URI of this resource.
1407 #[serde(rename = "selfLink")]
1408 pub self_link: Option<String>,
1409 /// The time this operation actually started in UTC timezone in <a
1410 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1411 /// <code>2012-11-15T16:19:00.094Z</code>.
1412 #[serde(rename = "startTime")]
1413 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1414 /// The status of an operation. Valid values are <code>PENDING</code>,
1415 /// <code>RUNNING</code>, <code>DONE</code>,
1416 /// <code>SQL_OPERATION_STATUS_UNSPECIFIED</code>.
1417 pub status: Option<String>,
1418 /// Name of the database instance related to this operation.
1419 #[serde(rename = "targetId")]
1420 pub target_id: Option<String>,
1421 /// no description provided
1422 #[serde(rename = "targetLink")]
1423 pub target_link: Option<String>,
1424 /// The project ID of the target instance related to this operation.
1425 #[serde(rename = "targetProject")]
1426 pub target_project: Option<String>,
1427 /// The email address of the user who initiated this operation.
1428 pub user: Option<String>,
1429}
1430
1431impl common::Resource for Operation {}
1432impl common::ResponseResult for Operation {}
1433
1434/// Database instance operation error.
1435///
1436/// This type is not used in any activity, and only used as *part* of another schema.
1437///
1438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1439#[serde_with::serde_as]
1440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1441pub struct OperationError {
1442 /// Identifies the specific error that occurred.
1443 pub code: Option<String>,
1444 /// This is always <code>sql#operationError</code>.
1445 pub kind: Option<String>,
1446 /// Additional information about the error encountered.
1447 pub message: Option<String>,
1448}
1449
1450impl common::Part for OperationError {}
1451
1452/// Database instance operation errors list wrapper.
1453///
1454/// This type is not used in any activity, and only used as *part* of another schema.
1455///
1456#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1457#[serde_with::serde_as]
1458#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1459pub struct OperationErrors {
1460 /// The list of errors encountered while processing this operation.
1461 pub errors: Option<Vec<OperationError>>,
1462 /// This is always <code>sql#operationErrors</code>.
1463 pub kind: Option<String>,
1464}
1465
1466impl common::Part for OperationErrors {}
1467
1468/// Database instance list operations response.
1469///
1470/// # Activities
1471///
1472/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1473/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1474///
1475/// * [list operations](OperationListCall) (response)
1476#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1477#[serde_with::serde_as]
1478#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1479pub struct OperationsListResponse {
1480 /// List of operation resources.
1481 pub items: Option<Vec<Operation>>,
1482 /// This is always <code>sql#operationsList</code>.
1483 pub kind: Option<String>,
1484 /// The continuation token, used to page through large result sets. Provide
1485 /// this value in a subsequent request to return the next page of results.
1486 #[serde(rename = "nextPageToken")]
1487 pub next_page_token: Option<String>,
1488}
1489
1490impl common::ResponseResult for OperationsListResponse {}
1491
1492/// Read-replica configuration for connecting to the master.
1493///
1494/// This type is not used in any activity, and only used as *part* of another schema.
1495///
1496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1497#[serde_with::serde_as]
1498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1499pub struct ReplicaConfiguration {
1500 /// Specifies if the replica is the failover target. If the field is set to
1501 /// <code>true</code> the replica will be designated as a failover replica. In
1502 /// case the master instance fails, the replica instance will be promoted as
1503 /// the new master instance. <p>Only one replica can be specified as failover
1504 /// target, and the replica has to be in different zone with the master
1505 /// instance.
1506 #[serde(rename = "failoverTarget")]
1507 pub failover_target: Option<bool>,
1508 /// This is always <code>sql#replicaConfiguration</code>.
1509 pub kind: Option<String>,
1510 /// MySQL specific configuration when replicating from a MySQL on-premises
1511 /// master. Replication configuration information such as the username,
1512 /// password, certificates, and keys are not stored in the instance metadata.
1513 /// The configuration information is used only to set up the replication
1514 /// connection and is stored by MySQL in a file named <code>master.info</code>
1515 /// in the data directory.
1516 #[serde(rename = "mysqlReplicaConfiguration")]
1517 pub mysql_replica_configuration: Option<MySqlReplicaConfiguration>,
1518}
1519
1520impl common::Part for ReplicaConfiguration {}
1521
1522/// There is no detailed description.
1523///
1524/// This type is not used in any activity, and only used as *part* of another schema.
1525///
1526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1527#[serde_with::serde_as]
1528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1529pub struct Reschedule {
1530 /// Required. The type of the reschedule.
1531 #[serde(rename = "rescheduleType")]
1532 pub reschedule_type: Option<String>,
1533 /// Optional. Timestamp when the maintenance shall be rescheduled to if
1534 /// reschedule_type=SPECIFIC_TIME, in <a
1535 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for
1536 /// example <code>2012-11-15T16:19:00.094Z</code>.
1537 #[serde(rename = "scheduleTime")]
1538 pub schedule_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1539}
1540
1541impl common::Part for Reschedule {}
1542
1543/// Database instance restore from backup context.
1544/// Backup context contains source instance id and project id.
1545///
1546/// This type is not used in any activity, and only used as *part* of another schema.
1547///
1548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1549#[serde_with::serde_as]
1550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1551pub struct RestoreBackupContext {
1552 /// The ID of the backup run to restore from.
1553 #[serde(rename = "backupRunId")]
1554 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1555 pub backup_run_id: Option<i64>,
1556 /// The ID of the instance that the backup was taken from.
1557 #[serde(rename = "instanceId")]
1558 pub instance_id: Option<String>,
1559 /// This is always <code>sql#restoreBackupContext</code>.
1560 pub kind: Option<String>,
1561 /// The full project ID of the source instance.
1562 pub project: Option<String>,
1563}
1564
1565impl common::Part for RestoreBackupContext {}
1566
1567/// Instance rotate server CA context.
1568///
1569/// This type is not used in any activity, and only used as *part* of another schema.
1570///
1571#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1572#[serde_with::serde_as]
1573#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1574pub struct RotateServerCaContext {
1575 /// This is always <code>sql#rotateServerCaContext</code>.
1576 pub kind: Option<String>,
1577 /// The fingerprint of the next version to be rotated to. If left unspecified,
1578 /// will be rotated to the most recently added server CA version.
1579 #[serde(rename = "nextVersion")]
1580 pub next_version: Option<String>,
1581}
1582
1583impl common::Part for RotateServerCaContext {}
1584
1585/// Database instance settings.
1586///
1587/// This type is not used in any activity, and only used as *part* of another schema.
1588///
1589#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1590#[serde_with::serde_as]
1591#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1592pub struct Settings {
1593 /// The activation policy specifies when the instance is activated; it is
1594 /// applicable only when the instance state is <code>RUNNABLE</code>. Valid
1595 /// values: <br><code>ALWAYS</code>: The instance is on, and remains so even in
1596 /// the absence of connection requests. <br><code>NEVER</code>: The instance is
1597 /// off; it is not activated, even if a connection request arrives.
1598 /// <br><code>ON_DEMAND</code>: First Generation instances only. The instance
1599 /// responds to incoming requests, and turns itself off when not in use.
1600 /// Instances with <code>PER_USE</code> pricing turn off after 15 minutes of
1601 /// inactivity. Instances with <code>PER_PACKAGE</code> pricing turn off after
1602 /// 12 hours of inactivity.
1603 #[serde(rename = "activationPolicy")]
1604 pub activation_policy: Option<String>,
1605 /// The App Engine app IDs that can access this instance. First Generation
1606 /// instances only.
1607 #[serde(rename = "authorizedGaeApplications")]
1608 pub authorized_gae_applications: Option<Vec<String>>,
1609 /// Availability type (PostgreSQL and MySQL instances only). Potential values:
1610 /// <br><code>ZONAL</code>: The instance serves data from only one zone.
1611 /// Outages in that zone affect data accessibility. <br><code>REGIONAL</code>:
1612 /// The instance can serve data from more than one zone in a region (it is
1613 /// highly available). <br>For more information, see <a
1614 /// href="https://cloud.google.com/sql/docs/postgres/high-availability">Overview
1615 /// of the High Availability Configuration</a>.
1616 #[serde(rename = "availabilityType")]
1617 pub availability_type: Option<String>,
1618 /// The daily backup configuration for the instance.
1619 #[serde(rename = "backupConfiguration")]
1620 pub backup_configuration: Option<BackupConfiguration>,
1621 /// Configuration specific to read replica instances. Indicates whether
1622 /// database flags for crash-safe replication are enabled. This property is
1623 /// only applicable to First Generation instances.
1624 #[serde(rename = "crashSafeReplicationEnabled")]
1625 pub crash_safe_replication_enabled: Option<bool>,
1626 /// The size of data disk, in GB. The data disk size minimum is 10GB. Not used
1627 /// for First Generation instances.
1628 #[serde(rename = "dataDiskSizeGb")]
1629 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1630 pub data_disk_size_gb: Option<i64>,
1631 /// The type of data disk: <code>PD_SSD</code> (default) or
1632 /// <code>PD_HDD</code>. Not used for First Generation instances.
1633 #[serde(rename = "dataDiskType")]
1634 pub data_disk_type: Option<String>,
1635 /// The database flags passed to the instance at startup.
1636 #[serde(rename = "databaseFlags")]
1637 pub database_flags: Option<Vec<DatabaseFlags>>,
1638 /// Configuration specific to read replica instances. Indicates whether
1639 /// replication is enabled or not.
1640 #[serde(rename = "databaseReplicationEnabled")]
1641 pub database_replication_enabled: Option<bool>,
1642 /// The settings for IP Management. This allows to enable or disable the
1643 /// instance IP and manage which external networks can connect to the instance.
1644 /// The IPv4 address cannot be disabled for Second Generation instances.
1645 #[serde(rename = "ipConfiguration")]
1646 pub ip_configuration: Option<IpConfiguration>,
1647 /// This is always <code>sql#settings</code>.
1648 pub kind: Option<String>,
1649 /// The location preference settings. This allows the instance to be located as
1650 /// near as possible to either an App Engine app or Compute Engine zone for
1651 /// better performance. App Engine co-location is only applicable to First
1652 /// Generation instances.
1653 #[serde(rename = "locationPreference")]
1654 pub location_preference: Option<LocationPreference>,
1655 /// The maintenance window for this instance. This specifies when the instance
1656 /// can be restarted for maintenance purposes. Not used for First Generation
1657 /// instances.
1658 #[serde(rename = "maintenanceWindow")]
1659 pub maintenance_window: Option<MaintenanceWindow>,
1660 /// The pricing plan for this instance. This can be either <code>PER_USE</code>
1661 /// or <code>PACKAGE</code>. Only <code>PER_USE</code> is supported for Second
1662 /// Generation instances.
1663 #[serde(rename = "pricingPlan")]
1664 pub pricing_plan: Option<String>,
1665 /// The type of replication this instance uses. This can be either
1666 /// <code>ASYNCHRONOUS</code> or <code>SYNCHRONOUS</code>. This property is
1667 /// only applicable to First Generation instances.
1668 #[serde(rename = "replicationType")]
1669 pub replication_type: Option<String>,
1670 /// The version of instance settings. This is a required field for update
1671 /// method to make sure concurrent updates are handled properly. During update,
1672 /// use the most recent settingsVersion value for this instance and do not try
1673 /// to update this value.
1674 #[serde(rename = "settingsVersion")]
1675 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1676 pub settings_version: Option<i64>,
1677 /// Configuration to increase storage size automatically. The default value is
1678 /// true. Not used for First Generation instances.
1679 #[serde(rename = "storageAutoResize")]
1680 pub storage_auto_resize: Option<bool>,
1681 /// The maximum size to which storage capacity can be automatically increased.
1682 /// The default value is 0, which specifies that there is no limit. Not used
1683 /// for First Generation instances.
1684 #[serde(rename = "storageAutoResizeLimit")]
1685 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1686 pub storage_auto_resize_limit: Option<i64>,
1687 /// The tier (or machine type) for this instance, for example
1688 /// <code>db-n1-standard-1</code> (MySQL instances) or
1689 /// <code>db-custom-1-3840</code> (PostgreSQL instances). For MySQL instances,
1690 /// this property determines whether the instance is First or Second
1691 /// Generation. For more information, see <a
1692 /// href="/sql/docs/db_path/instance-settings">Instance Settings</a>.
1693 pub tier: Option<String>,
1694 /// User-provided labels, represented as a dictionary where each label is a
1695 /// single key value pair.
1696 #[serde(rename = "userLabels")]
1697 pub user_labels: Option<HashMap<String, String>>,
1698}
1699
1700impl common::Part for Settings {}
1701
1702/// External master migration setting error.
1703///
1704/// This type is not used in any activity, and only used as *part* of another schema.
1705///
1706#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1707#[serde_with::serde_as]
1708#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1709pub struct SqlExternalSyncSettingError {
1710 /// Additional information about the error encountered.
1711 pub detail: Option<String>,
1712 /// This is always <code>sql#migrationSettingError</code>.
1713 pub kind: Option<String>,
1714 /// Identifies the specific error that occurred.
1715 #[serde(rename = "type")]
1716 pub type_: Option<String>,
1717}
1718
1719impl common::Part for SqlExternalSyncSettingError {}
1720
1721/// Reschedule options for maintenance windows.
1722///
1723/// # Activities
1724///
1725/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1726/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1727///
1728/// * [instances reschedule maintenance projects](ProjectInstanceRescheduleMaintenanceCall) (request)
1729#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1730#[serde_with::serde_as]
1731#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1732pub struct SqlInstancesRescheduleMaintenanceRequestBody {
1733 /// Required. The type of the reschedule the user wants.
1734 pub reschedule: Option<Reschedule>,
1735}
1736
1737impl common::RequestValue for SqlInstancesRescheduleMaintenanceRequestBody {}
1738
1739/// Instance verify external sync settings response.
1740///
1741/// # Activities
1742///
1743/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1744/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1745///
1746/// * [instances verify external sync settings projects](ProjectInstanceVerifyExternalSyncSettingCall) (response)
1747#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1748#[serde_with::serde_as]
1749#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1750pub struct SqlInstancesVerifyExternalSyncSettingsResponse {
1751 /// List of migration violations.
1752 pub errors: Option<Vec<SqlExternalSyncSettingError>>,
1753 /// This is always <code>sql#migrationSettingErrorList</code>.
1754 pub kind: Option<String>,
1755}
1756
1757impl common::ResponseResult for SqlInstancesVerifyExternalSyncSettingsResponse {}
1758
1759/// Any scheduled maintenancce for this instance.
1760///
1761/// This type is not used in any activity, and only used as *part* of another schema.
1762///
1763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1764#[serde_with::serde_as]
1765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1766pub struct SqlScheduledMaintenance {
1767 /// no description provided
1768 #[serde(rename = "canDefer")]
1769 pub can_defer: Option<bool>,
1770 /// If the scheduled maintenance can be rescheduled.
1771 #[serde(rename = "canReschedule")]
1772 pub can_reschedule: Option<bool>,
1773 /// The start time of any upcoming scheduled maintenance for this instance.
1774 #[serde(rename = "startTime")]
1775 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1776}
1777
1778impl common::Part for SqlScheduledMaintenance {}
1779
1780/// Represents a Sql Server database on the Cloud SQL instance.
1781///
1782/// This type is not used in any activity, and only used as *part* of another schema.
1783///
1784#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1785#[serde_with::serde_as]
1786#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1787pub struct SqlServerDatabaseDetails {
1788 /// The version of SQL Server with which the database is to be made compatible
1789 #[serde(rename = "compatibilityLevel")]
1790 pub compatibility_level: Option<i32>,
1791 /// The recovery model of a SQL Server database
1792 #[serde(rename = "recoveryModel")]
1793 pub recovery_model: Option<String>,
1794}
1795
1796impl common::Part for SqlServerDatabaseDetails {}
1797
1798/// Represents a Sql Server user on the Cloud SQL instance.
1799///
1800/// This type is not used in any activity, and only used as *part* of another schema.
1801///
1802#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1803#[serde_with::serde_as]
1804#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1805pub struct SqlServerUserDetails {
1806 /// If the user has been disabled
1807 pub disabled: Option<bool>,
1808 /// The server roles for this user
1809 #[serde(rename = "serverRoles")]
1810 pub server_roles: Option<Vec<String>>,
1811}
1812
1813impl common::Part for SqlServerUserDetails {}
1814
1815/// SslCerts Resource
1816///
1817/// # Activities
1818///
1819/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1820/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1821///
1822/// * [create ephemeral ssl certs](SslCertCreateEphemeralCall) (response)
1823/// * [delete ssl certs](SslCertDeleteCall) (none)
1824/// * [get ssl certs](SslCertGetCall) (response)
1825/// * [insert ssl certs](SslCertInsertCall) (none)
1826/// * [list ssl certs](SslCertListCall) (none)
1827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1828#[serde_with::serde_as]
1829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1830pub struct SslCert {
1831 /// PEM representation.
1832 pub cert: Option<String>,
1833 /// Serial number, as extracted from the certificate.
1834 #[serde(rename = "certSerialNumber")]
1835 pub cert_serial_number: Option<String>,
1836 /// User supplied name. Constrained to [a-zA-Z.-_ ]+.
1837 #[serde(rename = "commonName")]
1838 pub common_name: Option<String>,
1839 /// The time when the certificate was created in <a
1840 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1841 /// <code>2012-11-15T16:19:00.094Z</code>
1842 #[serde(rename = "createTime")]
1843 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1844 /// The time when the certificate expires in <a
1845 /// href="https://tools.ietf.org/html/rfc3339">RFC 3339</a> format, for example
1846 /// <code>2012-11-15T16:19:00.094Z</code>.
1847 #[serde(rename = "expirationTime")]
1848 pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1849 /// Name of the database instance.
1850 pub instance: Option<String>,
1851 /// This is always <code>sql#sslCert</code>.
1852 pub kind: Option<String>,
1853 /// The URI of this resource.
1854 #[serde(rename = "selfLink")]
1855 pub self_link: Option<String>,
1856 /// Sha1 Fingerprint.
1857 #[serde(rename = "sha1Fingerprint")]
1858 pub sha1_fingerprint: Option<String>,
1859}
1860
1861impl common::Resource for SslCert {}
1862impl common::ResponseResult for SslCert {}
1863
1864/// SslCertDetail.
1865///
1866/// This type is not used in any activity, and only used as *part* of another schema.
1867///
1868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1869#[serde_with::serde_as]
1870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1871pub struct SslCertDetail {
1872 /// The public information about the cert.
1873 #[serde(rename = "certInfo")]
1874 pub cert_info: Option<SslCert>,
1875 /// The private key for the client cert, in pem format. Keep private in order
1876 /// to protect your security.
1877 #[serde(rename = "certPrivateKey")]
1878 pub cert_private_key: Option<String>,
1879}
1880
1881impl common::Part for SslCertDetail {}
1882
1883/// SslCerts create ephemeral certificate request.
1884///
1885/// # Activities
1886///
1887/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1888/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1889///
1890/// * [create ephemeral ssl certs](SslCertCreateEphemeralCall) (request)
1891#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1892#[serde_with::serde_as]
1893#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1894pub struct SslCertsCreateEphemeralRequest {
1895 /// PEM encoded public key to include in the signed certificate.
1896 pub public_key: Option<String>,
1897}
1898
1899impl common::RequestValue for SslCertsCreateEphemeralRequest {}
1900
1901/// SslCerts insert request.
1902///
1903/// # Activities
1904///
1905/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1906/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1907///
1908/// * [insert ssl certs](SslCertInsertCall) (request)
1909#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1910#[serde_with::serde_as]
1911#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1912pub struct SslCertsInsertRequest {
1913 /// User supplied name. Must be a distinct name from the other certificates
1914 /// for this instance.
1915 #[serde(rename = "commonName")]
1916 pub common_name: Option<String>,
1917}
1918
1919impl common::RequestValue for SslCertsInsertRequest {}
1920
1921/// SslCert insert response.
1922///
1923/// # Activities
1924///
1925/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1926/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1927///
1928/// * [insert ssl certs](SslCertInsertCall) (response)
1929#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1930#[serde_with::serde_as]
1931#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1932pub struct SslCertsInsertResponse {
1933 /// The new client certificate and private key. For First Generation
1934 /// instances, the new certificate does not take effect until the instance is
1935 /// restarted.
1936 #[serde(rename = "clientCert")]
1937 pub client_cert: Option<SslCertDetail>,
1938 /// This is always <code>sql#sslCertsInsert</code>.
1939 pub kind: Option<String>,
1940 /// The operation to track the ssl certs insert request.
1941 pub operation: Option<Operation>,
1942 /// The server Certificate Authority's certificate. If this is missing you can
1943 /// force a new one to be generated by calling resetSslConfig method on
1944 /// instances resource.
1945 #[serde(rename = "serverCaCert")]
1946 pub server_ca_cert: Option<SslCert>,
1947}
1948
1949impl common::ResponseResult for SslCertsInsertResponse {}
1950
1951/// SslCerts list response.
1952///
1953/// # Activities
1954///
1955/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1956/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1957///
1958/// * [list ssl certs](SslCertListCall) (response)
1959#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1960#[serde_with::serde_as]
1961#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1962pub struct SslCertsListResponse {
1963 /// List of client certificates for the instance.
1964 pub items: Option<Vec<SslCert>>,
1965 /// This is always <code>sql#sslCertsList</code>.
1966 pub kind: Option<String>,
1967}
1968
1969impl common::ResponseResult for SslCertsListResponse {}
1970
1971/// A Google Cloud SQL service tier resource.
1972///
1973/// # Activities
1974///
1975/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1976/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1977///
1978/// * [list tiers](TierListCall) (none)
1979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1980#[serde_with::serde_as]
1981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1982pub struct Tier {
1983 /// The maximum disk size of this tier in bytes.
1984 #[serde(rename = "DiskQuota")]
1985 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1986 pub disk_quota: Option<i64>,
1987 /// The maximum RAM usage of this tier in bytes.
1988 #[serde(rename = "RAM")]
1989 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1990 pub ram: Option<i64>,
1991 /// This is always <code>sql#tier</code>.
1992 pub kind: Option<String>,
1993 /// The applicable regions for this tier.
1994 pub region: Option<Vec<String>>,
1995 /// An identifier for the machine type, for example, db-n1-standard-1. For
1996 /// related information, see <a href="/sql/pricing">Pricing</a>.
1997 pub tier: Option<String>,
1998}
1999
2000impl common::Resource for Tier {}
2001
2002/// Tiers list response.
2003///
2004/// # Activities
2005///
2006/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2007/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2008///
2009/// * [list tiers](TierListCall) (response)
2010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2011#[serde_with::serde_as]
2012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2013pub struct TiersListResponse {
2014 /// List of tiers.
2015 pub items: Option<Vec<Tier>>,
2016 /// This is always <code>sql#tiersList</code>.
2017 pub kind: Option<String>,
2018}
2019
2020impl common::ResponseResult for TiersListResponse {}
2021
2022/// Database Instance truncate log context.
2023///
2024/// This type is not used in any activity, and only used as *part* of another schema.
2025///
2026#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2027#[serde_with::serde_as]
2028#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2029pub struct TruncateLogContext {
2030 /// This is always <code>sql#truncateLogContext</code>.
2031 pub kind: Option<String>,
2032 /// The type of log to truncate. Valid values are
2033 /// <code>MYSQL_GENERAL_TABLE</code> and <code>MYSQL_SLOW_TABLE</code>.
2034 #[serde(rename = "logType")]
2035 pub log_type: Option<String>,
2036}
2037
2038impl common::Part for TruncateLogContext {}
2039
2040/// A Cloud SQL user resource.
2041///
2042/// # Activities
2043///
2044/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2045/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2046///
2047/// * [delete users](UserDeleteCall) (none)
2048/// * [insert users](UserInsertCall) (request)
2049/// * [list users](UserListCall) (none)
2050/// * [update users](UserUpdateCall) (request)
2051#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2052#[serde_with::serde_as]
2053#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2054pub struct User {
2055 /// This field is deprecated and will be removed from a future version of the
2056 /// API.
2057 pub etag: Option<String>,
2058 /// The host name from which the user can connect. For <code>insert</code>
2059 /// operations, host defaults to an empty string. For <code>update</code>
2060 /// operations, host is specified as part of the request URL. The host name
2061 /// cannot be updated after insertion.
2062 pub host: Option<String>,
2063 /// The name of the Cloud SQL instance. This does not include the project ID.
2064 /// Can be omitted for <code>update</code> since it is already specified on the
2065 /// URL.
2066 pub instance: Option<String>,
2067 /// This is always <code>sql#user</code>.
2068 pub kind: Option<String>,
2069 /// The name of the user in the Cloud SQL instance. Can be omitted for
2070 /// <code>update</code> since it is already specified in the URL.
2071 pub name: Option<String>,
2072 /// The password for the user.
2073 pub password: Option<String>,
2074 /// The project ID of the project containing the Cloud SQL database. The Google
2075 /// apps domain is prefixed if applicable. Can be omitted for
2076 /// <code>update</code> since it is already specified on the URL.
2077 pub project: Option<String>,
2078 /// no description provided
2079 #[serde(rename = "sqlserverUserDetails")]
2080 pub sqlserver_user_details: Option<SqlServerUserDetails>,
2081}
2082
2083impl common::RequestValue for User {}
2084impl common::Resource for User {}
2085
2086/// User list response.
2087///
2088/// # Activities
2089///
2090/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2091/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2092///
2093/// * [list users](UserListCall) (response)
2094#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2095#[serde_with::serde_as]
2096#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2097pub struct UsersListResponse {
2098 /// List of user resources in the instance.
2099 pub items: Option<Vec<User>>,
2100 /// This is always <code>sql#usersList</code>.
2101 pub kind: Option<String>,
2102 /// An identifier that uniquely identifies the operation. You can use this
2103 /// identifier to retrieve the Operations resource that has information about
2104 /// the operation.
2105 #[serde(rename = "nextPageToken")]
2106 pub next_page_token: Option<String>,
2107}
2108
2109impl common::ResponseResult for UsersListResponse {}
2110
2111/// The name and status of the failover replica. This property is applicable
2112/// only to Second Generation instances.
2113///
2114/// This type is not used in any activity, and only used as *part* of another schema.
2115///
2116#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2117#[serde_with::serde_as]
2118#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2119pub struct DatabaseInstanceFailoverReplica {
2120 /// The availability status of the failover replica. A false status indicates
2121 /// that the failover replica is out of sync. The master can only failover to
2122 /// the failover replica when the status is true.
2123 pub available: Option<bool>,
2124 /// The name of the failover replica. If specified at instance creation, a
2125 /// failover replica is created for the instance. The name
2126 /// doesn't include the project ID. This property is applicable only to
2127 /// Second Generation instances.
2128 pub name: Option<String>,
2129}
2130
2131impl common::NestedType for DatabaseInstanceFailoverReplica {}
2132impl common::Part for DatabaseInstanceFailoverReplica {}
2133
2134/// Options for exporting data as CSV.
2135///
2136/// This type is not used in any activity, and only used as *part* of another schema.
2137///
2138#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2139#[serde_with::serde_as]
2140#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2141pub struct ExportContextCsvExportOptions {
2142 /// The select query used to extract the data.
2143 #[serde(rename = "selectQuery")]
2144 pub select_query: Option<String>,
2145}
2146
2147impl common::NestedType for ExportContextCsvExportOptions {}
2148impl common::Part for ExportContextCsvExportOptions {}
2149
2150/// Options for exporting data as SQL statements.
2151///
2152/// This type is not used in any activity, and only used as *part* of another schema.
2153///
2154#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2155#[serde_with::serde_as]
2156#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2157pub struct ExportContextSqlExportOptions {
2158 /// Options for exporting from MySQL.
2159 #[serde(rename = "mysqlExportOptions")]
2160 pub mysql_export_options: Option<ExportContextSqlExportOptionsMysqlExportOptions>,
2161 /// Export only schemas.
2162 #[serde(rename = "schemaOnly")]
2163 pub schema_only: Option<bool>,
2164 /// Tables to export, or that were exported, from the specified database. If
2165 /// you specify tables, specify one and only one database. For PostgreSQL
2166 /// instances, you can specify only one table.
2167 pub tables: Option<Vec<String>>,
2168}
2169
2170impl common::NestedType for ExportContextSqlExportOptions {}
2171impl common::Part for ExportContextSqlExportOptions {}
2172
2173/// Options for exporting from MySQL.
2174///
2175/// This type is not used in any activity, and only used as *part* of another schema.
2176///
2177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2178#[serde_with::serde_as]
2179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2180pub struct ExportContextSqlExportOptionsMysqlExportOptions {
2181 /// Option to include SQL statement required to set up replication.
2182 /// If set to <code>1</code>, the dump file includes
2183 /// a CHANGE MASTER TO statement with the binary log coordinates.
2184 /// If set to <code>2</code>, the CHANGE MASTER TO statement is written as
2185 /// a SQL comment, and has no effect.
2186 /// All other values are ignored.
2187 #[serde(rename = "masterData")]
2188 pub master_data: Option<i32>,
2189}
2190
2191impl common::NestedType for ExportContextSqlExportOptionsMysqlExportOptions {}
2192impl common::Part for ExportContextSqlExportOptionsMysqlExportOptions {}
2193
2194/// Import parameters specific to SQL Server .BAK files
2195///
2196/// This type is not used in any activity, and only used as *part* of another schema.
2197///
2198#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2199#[serde_with::serde_as]
2200#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2201pub struct ImportContextBakImportOptions {
2202 /// no description provided
2203 #[serde(rename = "encryptionOptions")]
2204 pub encryption_options: Option<ImportContextBakImportOptionsEncryptionOptions>,
2205}
2206
2207impl common::NestedType for ImportContextBakImportOptions {}
2208impl common::Part for ImportContextBakImportOptions {}
2209
2210/// There is no detailed description.
2211///
2212/// This type is not used in any activity, and only used as *part* of another schema.
2213///
2214#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2215#[serde_with::serde_as]
2216#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2217pub struct ImportContextBakImportOptionsEncryptionOptions {
2218 /// Path to the Certificate (.cer) in Cloud Storage, in the form
2219 /// <code>gs://bucketName/fileName</code>. The instance must have
2220 /// write permissions to the bucket and read access to the file.
2221 #[serde(rename = "certPath")]
2222 pub cert_path: Option<String>,
2223 /// Password that encrypts the private key
2224 #[serde(rename = "pvkPassword")]
2225 pub pvk_password: Option<String>,
2226 /// Path to the Certificate Private Key (.pvk) in Cloud Storage, in the
2227 /// form <code>gs://bucketName/fileName</code>. The instance must have
2228 /// write permissions to the bucket and read access to the file.
2229 #[serde(rename = "pvkPath")]
2230 pub pvk_path: Option<String>,
2231}
2232
2233impl common::NestedType for ImportContextBakImportOptionsEncryptionOptions {}
2234impl common::Part for ImportContextBakImportOptionsEncryptionOptions {}
2235
2236/// Options for importing data as CSV.
2237///
2238/// This type is not used in any activity, and only used as *part* of another schema.
2239///
2240#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2241#[serde_with::serde_as]
2242#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2243pub struct ImportContextCsvImportOptions {
2244 /// The columns to which CSV data is imported. If not specified, all columns
2245 /// of the database table are loaded with CSV data.
2246 pub columns: Option<Vec<String>>,
2247 /// The table to which CSV data is imported.
2248 pub table: Option<String>,
2249}
2250
2251impl common::NestedType for ImportContextCsvImportOptions {}
2252impl common::Part for ImportContextCsvImportOptions {}
2253
2254// ###################
2255// MethodBuilders ###
2256// #################
2257
2258/// A builder providing access to all methods supported on *backupRun* resources.
2259/// It is not used directly, but through the [`SQLAdmin`] hub.
2260///
2261/// # Example
2262///
2263/// Instantiate a resource builder
2264///
2265/// ```test_harness,no_run
2266/// extern crate hyper;
2267/// extern crate hyper_rustls;
2268/// extern crate google_sql1_beta4 as sql1_beta4;
2269///
2270/// # async fn dox() {
2271/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2272///
2273/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2274/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2275/// secret,
2276/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2277/// ).build().await.unwrap();
2278///
2279/// let client = hyper_util::client::legacy::Client::builder(
2280/// hyper_util::rt::TokioExecutor::new()
2281/// )
2282/// .build(
2283/// hyper_rustls::HttpsConnectorBuilder::new()
2284/// .with_native_roots()
2285/// .unwrap()
2286/// .https_or_http()
2287/// .enable_http1()
2288/// .build()
2289/// );
2290/// let mut hub = SQLAdmin::new(client, auth);
2291/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2292/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
2293/// // to build up your call.
2294/// let rb = hub.backup_runs();
2295/// # }
2296/// ```
2297pub struct BackupRunMethods<'a, C>
2298where
2299 C: 'a,
2300{
2301 hub: &'a SQLAdmin<C>,
2302}
2303
2304impl<'a, C> common::MethodsBuilder for BackupRunMethods<'a, C> {}
2305
2306impl<'a, C> BackupRunMethods<'a, C> {
2307 /// Create a builder to help you perform the following task:
2308 ///
2309 /// Deletes the backup taken by a backup run.
2310 ///
2311 /// # Arguments
2312 ///
2313 /// * `project` - Project ID of the project that contains the instance.
2314 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2315 /// * `id` - The ID of the Backup Run to delete. To find a Backup Run ID, use the <a
2316 /// href="/sql/docs/db_path/admin-api/rest/v1beta4/backupRuns/list">list</a>
2317 /// method.
2318 pub fn delete(&self, project: &str, instance: &str, id: i64) -> BackupRunDeleteCall<'a, C> {
2319 BackupRunDeleteCall {
2320 hub: self.hub,
2321 _project: project.to_string(),
2322 _instance: instance.to_string(),
2323 _id: id,
2324 _delegate: Default::default(),
2325 _additional_params: Default::default(),
2326 _scopes: Default::default(),
2327 }
2328 }
2329
2330 /// Create a builder to help you perform the following task:
2331 ///
2332 /// Retrieves a resource containing information about a backup run.
2333 ///
2334 /// # Arguments
2335 ///
2336 /// * `project` - Project ID of the project that contains the instance.
2337 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2338 /// * `id` - The ID of this Backup Run.
2339 pub fn get(&self, project: &str, instance: &str, id: i64) -> BackupRunGetCall<'a, C> {
2340 BackupRunGetCall {
2341 hub: self.hub,
2342 _project: project.to_string(),
2343 _instance: instance.to_string(),
2344 _id: id,
2345 _delegate: Default::default(),
2346 _additional_params: Default::default(),
2347 _scopes: Default::default(),
2348 }
2349 }
2350
2351 /// Create a builder to help you perform the following task:
2352 ///
2353 /// Creates a new backup run on demand. This method is applicable only to
2354 /// Second Generation instances.
2355 ///
2356 /// # Arguments
2357 ///
2358 /// * `request` - No description provided.
2359 /// * `project` - Project ID of the project that contains the instance.
2360 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2361 pub fn insert(
2362 &self,
2363 request: BackupRun,
2364 project: &str,
2365 instance: &str,
2366 ) -> BackupRunInsertCall<'a, C> {
2367 BackupRunInsertCall {
2368 hub: self.hub,
2369 _request: request,
2370 _project: project.to_string(),
2371 _instance: instance.to_string(),
2372 _delegate: Default::default(),
2373 _additional_params: Default::default(),
2374 _scopes: Default::default(),
2375 }
2376 }
2377
2378 /// Create a builder to help you perform the following task:
2379 ///
2380 /// Lists all backup runs associated with a given instance and configuration in
2381 /// the reverse chronological order of the backup initiation time.
2382 ///
2383 /// # Arguments
2384 ///
2385 /// * `project` - Project ID of the project that contains the instance.
2386 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2387 pub fn list(&self, project: &str, instance: &str) -> BackupRunListCall<'a, C> {
2388 BackupRunListCall {
2389 hub: self.hub,
2390 _project: project.to_string(),
2391 _instance: instance.to_string(),
2392 _page_token: Default::default(),
2393 _max_results: Default::default(),
2394 _delegate: Default::default(),
2395 _additional_params: Default::default(),
2396 _scopes: Default::default(),
2397 }
2398 }
2399}
2400
2401/// A builder providing access to all methods supported on *database* resources.
2402/// It is not used directly, but through the [`SQLAdmin`] hub.
2403///
2404/// # Example
2405///
2406/// Instantiate a resource builder
2407///
2408/// ```test_harness,no_run
2409/// extern crate hyper;
2410/// extern crate hyper_rustls;
2411/// extern crate google_sql1_beta4 as sql1_beta4;
2412///
2413/// # async fn dox() {
2414/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2415///
2416/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2417/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2418/// secret,
2419/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2420/// ).build().await.unwrap();
2421///
2422/// let client = hyper_util::client::legacy::Client::builder(
2423/// hyper_util::rt::TokioExecutor::new()
2424/// )
2425/// .build(
2426/// hyper_rustls::HttpsConnectorBuilder::new()
2427/// .with_native_roots()
2428/// .unwrap()
2429/// .https_or_http()
2430/// .enable_http1()
2431/// .build()
2432/// );
2433/// let mut hub = SQLAdmin::new(client, auth);
2434/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2435/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
2436/// // to build up your call.
2437/// let rb = hub.databases();
2438/// # }
2439/// ```
2440pub struct DatabaseMethods<'a, C>
2441where
2442 C: 'a,
2443{
2444 hub: &'a SQLAdmin<C>,
2445}
2446
2447impl<'a, C> common::MethodsBuilder for DatabaseMethods<'a, C> {}
2448
2449impl<'a, C> DatabaseMethods<'a, C> {
2450 /// Create a builder to help you perform the following task:
2451 ///
2452 /// Deletes a database from a Cloud SQL instance.
2453 ///
2454 /// # Arguments
2455 ///
2456 /// * `project` - Project ID of the project that contains the instance.
2457 /// * `instance` - Database instance ID. This does not include the project ID.
2458 /// * `database` - Name of the database to be deleted in the instance.
2459 pub fn delete(
2460 &self,
2461 project: &str,
2462 instance: &str,
2463 database: &str,
2464 ) -> DatabaseDeleteCall<'a, C> {
2465 DatabaseDeleteCall {
2466 hub: self.hub,
2467 _project: project.to_string(),
2468 _instance: instance.to_string(),
2469 _database: database.to_string(),
2470 _delegate: Default::default(),
2471 _additional_params: Default::default(),
2472 _scopes: Default::default(),
2473 }
2474 }
2475
2476 /// Create a builder to help you perform the following task:
2477 ///
2478 /// Retrieves a resource containing information about a database inside a Cloud
2479 /// SQL instance.
2480 ///
2481 /// # Arguments
2482 ///
2483 /// * `project` - Project ID of the project that contains the instance.
2484 /// * `instance` - Database instance ID. This does not include the project ID.
2485 /// * `database` - Name of the database in the instance.
2486 pub fn get(&self, project: &str, instance: &str, database: &str) -> DatabaseGetCall<'a, C> {
2487 DatabaseGetCall {
2488 hub: self.hub,
2489 _project: project.to_string(),
2490 _instance: instance.to_string(),
2491 _database: database.to_string(),
2492 _delegate: Default::default(),
2493 _additional_params: Default::default(),
2494 _scopes: Default::default(),
2495 }
2496 }
2497
2498 /// Create a builder to help you perform the following task:
2499 ///
2500 /// Inserts a resource containing information about a database inside a Cloud
2501 /// SQL instance.
2502 ///
2503 /// # Arguments
2504 ///
2505 /// * `request` - No description provided.
2506 /// * `project` - Project ID of the project that contains the instance.
2507 /// * `instance` - Database instance ID. This does not include the project ID.
2508 pub fn insert(
2509 &self,
2510 request: Database,
2511 project: &str,
2512 instance: &str,
2513 ) -> DatabaseInsertCall<'a, C> {
2514 DatabaseInsertCall {
2515 hub: self.hub,
2516 _request: request,
2517 _project: project.to_string(),
2518 _instance: instance.to_string(),
2519 _delegate: Default::default(),
2520 _additional_params: Default::default(),
2521 _scopes: Default::default(),
2522 }
2523 }
2524
2525 /// Create a builder to help you perform the following task:
2526 ///
2527 /// Lists databases in the specified Cloud SQL instance.
2528 ///
2529 /// # Arguments
2530 ///
2531 /// * `project` - Project ID of the project that contains the instance.
2532 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2533 pub fn list(&self, project: &str, instance: &str) -> DatabaseListCall<'a, C> {
2534 DatabaseListCall {
2535 hub: self.hub,
2536 _project: project.to_string(),
2537 _instance: instance.to_string(),
2538 _delegate: Default::default(),
2539 _additional_params: Default::default(),
2540 _scopes: Default::default(),
2541 }
2542 }
2543
2544 /// Create a builder to help you perform the following task:
2545 ///
2546 /// Partially updates a resource containing information about a database inside
2547 /// a Cloud SQL instance. This method supports patch semantics.
2548 ///
2549 /// # Arguments
2550 ///
2551 /// * `request` - No description provided.
2552 /// * `project` - Project ID of the project that contains the instance.
2553 /// * `instance` - Database instance ID. This does not include the project ID.
2554 /// * `database` - Name of the database to be updated in the instance.
2555 pub fn patch(
2556 &self,
2557 request: Database,
2558 project: &str,
2559 instance: &str,
2560 database: &str,
2561 ) -> DatabasePatchCall<'a, C> {
2562 DatabasePatchCall {
2563 hub: self.hub,
2564 _request: request,
2565 _project: project.to_string(),
2566 _instance: instance.to_string(),
2567 _database: database.to_string(),
2568 _delegate: Default::default(),
2569 _additional_params: Default::default(),
2570 _scopes: Default::default(),
2571 }
2572 }
2573
2574 /// Create a builder to help you perform the following task:
2575 ///
2576 /// Updates a resource containing information about a database inside a Cloud
2577 /// SQL instance.
2578 ///
2579 /// # Arguments
2580 ///
2581 /// * `request` - No description provided.
2582 /// * `project` - Project ID of the project that contains the instance.
2583 /// * `instance` - Database instance ID. This does not include the project ID.
2584 /// * `database` - Name of the database to be updated in the instance.
2585 pub fn update(
2586 &self,
2587 request: Database,
2588 project: &str,
2589 instance: &str,
2590 database: &str,
2591 ) -> DatabaseUpdateCall<'a, C> {
2592 DatabaseUpdateCall {
2593 hub: self.hub,
2594 _request: request,
2595 _project: project.to_string(),
2596 _instance: instance.to_string(),
2597 _database: database.to_string(),
2598 _delegate: Default::default(),
2599 _additional_params: Default::default(),
2600 _scopes: Default::default(),
2601 }
2602 }
2603}
2604
2605/// A builder providing access to all methods supported on *flag* resources.
2606/// It is not used directly, but through the [`SQLAdmin`] hub.
2607///
2608/// # Example
2609///
2610/// Instantiate a resource builder
2611///
2612/// ```test_harness,no_run
2613/// extern crate hyper;
2614/// extern crate hyper_rustls;
2615/// extern crate google_sql1_beta4 as sql1_beta4;
2616///
2617/// # async fn dox() {
2618/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2619///
2620/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2621/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2622/// secret,
2623/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2624/// ).build().await.unwrap();
2625///
2626/// let client = hyper_util::client::legacy::Client::builder(
2627/// hyper_util::rt::TokioExecutor::new()
2628/// )
2629/// .build(
2630/// hyper_rustls::HttpsConnectorBuilder::new()
2631/// .with_native_roots()
2632/// .unwrap()
2633/// .https_or_http()
2634/// .enable_http1()
2635/// .build()
2636/// );
2637/// let mut hub = SQLAdmin::new(client, auth);
2638/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2639/// // like `list(...)`
2640/// // to build up your call.
2641/// let rb = hub.flags();
2642/// # }
2643/// ```
2644pub struct FlagMethods<'a, C>
2645where
2646 C: 'a,
2647{
2648 hub: &'a SQLAdmin<C>,
2649}
2650
2651impl<'a, C> common::MethodsBuilder for FlagMethods<'a, C> {}
2652
2653impl<'a, C> FlagMethods<'a, C> {
2654 /// Create a builder to help you perform the following task:
2655 ///
2656 /// List all available database flags for Cloud SQL instances.
2657 pub fn list(&self) -> FlagListCall<'a, C> {
2658 FlagListCall {
2659 hub: self.hub,
2660 _database_version: Default::default(),
2661 _delegate: Default::default(),
2662 _additional_params: Default::default(),
2663 _scopes: Default::default(),
2664 }
2665 }
2666}
2667
2668/// A builder providing access to all methods supported on *instance* resources.
2669/// It is not used directly, but through the [`SQLAdmin`] hub.
2670///
2671/// # Example
2672///
2673/// Instantiate a resource builder
2674///
2675/// ```test_harness,no_run
2676/// extern crate hyper;
2677/// extern crate hyper_rustls;
2678/// extern crate google_sql1_beta4 as sql1_beta4;
2679///
2680/// # async fn dox() {
2681/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2682///
2683/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2684/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2685/// secret,
2686/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2687/// ).build().await.unwrap();
2688///
2689/// let client = hyper_util::client::legacy::Client::builder(
2690/// hyper_util::rt::TokioExecutor::new()
2691/// )
2692/// .build(
2693/// hyper_rustls::HttpsConnectorBuilder::new()
2694/// .with_native_roots()
2695/// .unwrap()
2696/// .https_or_http()
2697/// .enable_http1()
2698/// .build()
2699/// );
2700/// let mut hub = SQLAdmin::new(client, auth);
2701/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2702/// // 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(...)`
2703/// // to build up your call.
2704/// let rb = hub.instances();
2705/// # }
2706/// ```
2707pub struct InstanceMethods<'a, C>
2708where
2709 C: 'a,
2710{
2711 hub: &'a SQLAdmin<C>,
2712}
2713
2714impl<'a, C> common::MethodsBuilder for InstanceMethods<'a, C> {}
2715
2716impl<'a, C> InstanceMethods<'a, C> {
2717 /// Create a builder to help you perform the following task:
2718 ///
2719 /// Add a new trusted Certificate Authority (CA) version for the specified
2720 /// instance. Required to prepare for a certificate rotation. If a CA version
2721 /// was previously added but never used in a certificate rotation, this
2722 /// operation replaces that version. There cannot be more than one CA version
2723 /// waiting to be rotated in.
2724 ///
2725 /// # Arguments
2726 ///
2727 /// * `project` - Project ID of the project that contains the instance.
2728 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2729 pub fn add_server_ca(&self, project: &str, instance: &str) -> InstanceAddServerCaCall<'a, C> {
2730 InstanceAddServerCaCall {
2731 hub: self.hub,
2732 _project: project.to_string(),
2733 _instance: instance.to_string(),
2734 _delegate: Default::default(),
2735 _additional_params: Default::default(),
2736 _scopes: Default::default(),
2737 }
2738 }
2739
2740 /// Create a builder to help you perform the following task:
2741 ///
2742 /// Creates a Cloud SQL instance as a clone of the source instance. Using this
2743 /// operation might cause your instance to restart.
2744 ///
2745 /// # Arguments
2746 ///
2747 /// * `request` - No description provided.
2748 /// * `project` - Project ID of the source as well as the clone Cloud SQL instance.
2749 /// * `instance` - The ID of the Cloud SQL instance to be cloned (source). This does not
2750 /// include the project ID.
2751 pub fn clone(
2752 &self,
2753 request: InstancesCloneRequest,
2754 project: &str,
2755 instance: &str,
2756 ) -> InstanceCloneCall<'a, C> {
2757 InstanceCloneCall {
2758 hub: self.hub,
2759 _request: request,
2760 _project: project.to_string(),
2761 _instance: instance.to_string(),
2762 _delegate: Default::default(),
2763 _additional_params: Default::default(),
2764 _scopes: Default::default(),
2765 }
2766 }
2767
2768 /// Create a builder to help you perform the following task:
2769 ///
2770 /// Deletes a Cloud SQL instance.
2771 ///
2772 /// # Arguments
2773 ///
2774 /// * `project` - Project ID of the project that contains the instance to be deleted.
2775 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2776 pub fn delete(&self, project: &str, instance: &str) -> InstanceDeleteCall<'a, C> {
2777 InstanceDeleteCall {
2778 hub: self.hub,
2779 _project: project.to_string(),
2780 _instance: instance.to_string(),
2781 _delegate: Default::default(),
2782 _additional_params: Default::default(),
2783 _scopes: Default::default(),
2784 }
2785 }
2786
2787 /// Create a builder to help you perform the following task:
2788 ///
2789 /// Demotes the stand-alone instance to be a Cloud SQL read replica for an
2790 /// external database server.
2791 ///
2792 /// # Arguments
2793 ///
2794 /// * `request` - No description provided.
2795 /// * `project` - ID of the project that contains the instance.
2796 /// * `instance` - Cloud SQL instance name.
2797 pub fn demote_master(
2798 &self,
2799 request: InstancesDemoteMasterRequest,
2800 project: &str,
2801 instance: &str,
2802 ) -> InstanceDemoteMasterCall<'a, C> {
2803 InstanceDemoteMasterCall {
2804 hub: self.hub,
2805 _request: request,
2806 _project: project.to_string(),
2807 _instance: instance.to_string(),
2808 _delegate: Default::default(),
2809 _additional_params: Default::default(),
2810 _scopes: Default::default(),
2811 }
2812 }
2813
2814 /// Create a builder to help you perform the following task:
2815 ///
2816 /// Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL
2817 /// dump or CSV file.
2818 ///
2819 /// # Arguments
2820 ///
2821 /// * `request` - No description provided.
2822 /// * `project` - Project ID of the project that contains the instance to be exported.
2823 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2824 pub fn export(
2825 &self,
2826 request: InstancesExportRequest,
2827 project: &str,
2828 instance: &str,
2829 ) -> InstanceExportCall<'a, C> {
2830 InstanceExportCall {
2831 hub: self.hub,
2832 _request: request,
2833 _project: project.to_string(),
2834 _instance: instance.to_string(),
2835 _delegate: Default::default(),
2836 _additional_params: Default::default(),
2837 _scopes: Default::default(),
2838 }
2839 }
2840
2841 /// Create a builder to help you perform the following task:
2842 ///
2843 /// Failover the instance to its failover replica instance. Using this
2844 /// operation might cause your instance to restart.
2845 ///
2846 /// # Arguments
2847 ///
2848 /// * `request` - No description provided.
2849 /// * `project` - ID of the project that contains the read replica.
2850 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2851 pub fn failover(
2852 &self,
2853 request: InstancesFailoverRequest,
2854 project: &str,
2855 instance: &str,
2856 ) -> InstanceFailoverCall<'a, C> {
2857 InstanceFailoverCall {
2858 hub: self.hub,
2859 _request: request,
2860 _project: project.to_string(),
2861 _instance: instance.to_string(),
2862 _delegate: Default::default(),
2863 _additional_params: Default::default(),
2864 _scopes: Default::default(),
2865 }
2866 }
2867
2868 /// Create a builder to help you perform the following task:
2869 ///
2870 /// Retrieves a resource containing information about a Cloud SQL instance.
2871 ///
2872 /// # Arguments
2873 ///
2874 /// * `project` - Project ID of the project that contains the instance.
2875 /// * `instance` - Database instance ID. This does not include the project ID.
2876 pub fn get(&self, project: &str, instance: &str) -> InstanceGetCall<'a, C> {
2877 InstanceGetCall {
2878 hub: self.hub,
2879 _project: project.to_string(),
2880 _instance: instance.to_string(),
2881 _delegate: Default::default(),
2882 _additional_params: Default::default(),
2883 _scopes: Default::default(),
2884 }
2885 }
2886
2887 /// Create a builder to help you perform the following task:
2888 ///
2889 /// Imports data into a Cloud SQL instance from a SQL dump or CSV file in
2890 /// Cloud Storage.
2891 ///
2892 /// # Arguments
2893 ///
2894 /// * `request` - No description provided.
2895 /// * `project` - Project ID of the project that contains the instance.
2896 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2897 pub fn import(
2898 &self,
2899 request: InstancesImportRequest,
2900 project: &str,
2901 instance: &str,
2902 ) -> InstanceImportCall<'a, C> {
2903 InstanceImportCall {
2904 hub: self.hub,
2905 _request: request,
2906 _project: project.to_string(),
2907 _instance: instance.to_string(),
2908 _delegate: Default::default(),
2909 _additional_params: Default::default(),
2910 _scopes: Default::default(),
2911 }
2912 }
2913
2914 /// Create a builder to help you perform the following task:
2915 ///
2916 /// Creates a new Cloud SQL instance.
2917 ///
2918 /// # Arguments
2919 ///
2920 /// * `request` - No description provided.
2921 /// * `project` - Project ID of the project to which the newly created Cloud SQL instances
2922 /// should belong.
2923 pub fn insert(&self, request: DatabaseInstance, project: &str) -> InstanceInsertCall<'a, C> {
2924 InstanceInsertCall {
2925 hub: self.hub,
2926 _request: request,
2927 _project: project.to_string(),
2928 _delegate: Default::default(),
2929 _additional_params: Default::default(),
2930 _scopes: Default::default(),
2931 }
2932 }
2933
2934 /// Create a builder to help you perform the following task:
2935 ///
2936 /// Lists instances under a given project.
2937 ///
2938 /// # Arguments
2939 ///
2940 /// * `project` - Project ID of the project for which to list Cloud SQL instances.
2941 pub fn list(&self, project: &str) -> InstanceListCall<'a, C> {
2942 InstanceListCall {
2943 hub: self.hub,
2944 _project: project.to_string(),
2945 _page_token: Default::default(),
2946 _max_results: Default::default(),
2947 _filter: Default::default(),
2948 _delegate: Default::default(),
2949 _additional_params: Default::default(),
2950 _scopes: Default::default(),
2951 }
2952 }
2953
2954 /// Create a builder to help you perform the following task:
2955 ///
2956 /// Lists all of the trusted Certificate Authorities (CAs) for the specified
2957 /// instance. There can be up to three CAs listed: the CA that was used to sign
2958 /// the certificate that is currently in use, a CA that has been added but not
2959 /// yet used to sign a certificate, and a CA used to sign a certificate that
2960 /// has previously rotated out.
2961 ///
2962 /// # Arguments
2963 ///
2964 /// * `project` - Project ID of the project that contains the instance.
2965 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2966 pub fn list_server_cas(
2967 &self,
2968 project: &str,
2969 instance: &str,
2970 ) -> InstanceListServerCaCall<'a, C> {
2971 InstanceListServerCaCall {
2972 hub: self.hub,
2973 _project: project.to_string(),
2974 _instance: instance.to_string(),
2975 _delegate: Default::default(),
2976 _additional_params: Default::default(),
2977 _scopes: Default::default(),
2978 }
2979 }
2980
2981 /// Create a builder to help you perform the following task:
2982 ///
2983 /// Updates settings of a Cloud SQL instance.
2984 /// This method supports patch semantics.
2985 ///
2986 /// # Arguments
2987 ///
2988 /// * `request` - No description provided.
2989 /// * `project` - Project ID of the project that contains the instance.
2990 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
2991 pub fn patch(
2992 &self,
2993 request: DatabaseInstance,
2994 project: &str,
2995 instance: &str,
2996 ) -> InstancePatchCall<'a, C> {
2997 InstancePatchCall {
2998 hub: self.hub,
2999 _request: request,
3000 _project: project.to_string(),
3001 _instance: instance.to_string(),
3002 _delegate: Default::default(),
3003 _additional_params: Default::default(),
3004 _scopes: Default::default(),
3005 }
3006 }
3007
3008 /// Create a builder to help you perform the following task:
3009 ///
3010 /// Promotes the read replica instance to be a stand-alone Cloud SQL instance.
3011 /// Using this operation might cause your instance to restart.
3012 ///
3013 /// # Arguments
3014 ///
3015 /// * `project` - ID of the project that contains the read replica.
3016 /// * `instance` - Cloud SQL read replica instance name.
3017 pub fn promote_replica(
3018 &self,
3019 project: &str,
3020 instance: &str,
3021 ) -> InstancePromoteReplicaCall<'a, C> {
3022 InstancePromoteReplicaCall {
3023 hub: self.hub,
3024 _project: project.to_string(),
3025 _instance: instance.to_string(),
3026 _delegate: Default::default(),
3027 _additional_params: Default::default(),
3028 _scopes: Default::default(),
3029 }
3030 }
3031
3032 /// Create a builder to help you perform the following task:
3033 ///
3034 /// Deletes all client certificates and generates a new server SSL certificate
3035 /// for the instance.
3036 ///
3037 /// # Arguments
3038 ///
3039 /// * `project` - Project ID of the project that contains the instance.
3040 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3041 pub fn reset_ssl_config(
3042 &self,
3043 project: &str,
3044 instance: &str,
3045 ) -> InstanceResetSslConfigCall<'a, C> {
3046 InstanceResetSslConfigCall {
3047 hub: self.hub,
3048 _project: project.to_string(),
3049 _instance: instance.to_string(),
3050 _delegate: Default::default(),
3051 _additional_params: Default::default(),
3052 _scopes: Default::default(),
3053 }
3054 }
3055
3056 /// Create a builder to help you perform the following task:
3057 ///
3058 /// Restarts a Cloud SQL instance.
3059 ///
3060 /// # Arguments
3061 ///
3062 /// * `project` - Project ID of the project that contains the instance to be restarted.
3063 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3064 pub fn restart(&self, project: &str, instance: &str) -> InstanceRestartCall<'a, C> {
3065 InstanceRestartCall {
3066 hub: self.hub,
3067 _project: project.to_string(),
3068 _instance: instance.to_string(),
3069 _delegate: Default::default(),
3070 _additional_params: Default::default(),
3071 _scopes: Default::default(),
3072 }
3073 }
3074
3075 /// Create a builder to help you perform the following task:
3076 ///
3077 /// Restores a backup of a Cloud SQL instance. Using this operation might cause
3078 /// your instance to restart.
3079 ///
3080 /// # Arguments
3081 ///
3082 /// * `request` - No description provided.
3083 /// * `project` - Project ID of the project that contains the instance.
3084 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3085 pub fn restore_backup(
3086 &self,
3087 request: InstancesRestoreBackupRequest,
3088 project: &str,
3089 instance: &str,
3090 ) -> InstanceRestoreBackupCall<'a, C> {
3091 InstanceRestoreBackupCall {
3092 hub: self.hub,
3093 _request: request,
3094 _project: project.to_string(),
3095 _instance: instance.to_string(),
3096 _delegate: Default::default(),
3097 _additional_params: Default::default(),
3098 _scopes: Default::default(),
3099 }
3100 }
3101
3102 /// Create a builder to help you perform the following task:
3103 ///
3104 /// Rotates the server certificate to one signed by the Certificate Authority
3105 /// (CA) version previously added with the addServerCA method.
3106 ///
3107 /// # Arguments
3108 ///
3109 /// * `request` - No description provided.
3110 /// * `project` - Project ID of the project that contains the instance.
3111 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3112 pub fn rotate_server_ca(
3113 &self,
3114 request: InstancesRotateServerCaRequest,
3115 project: &str,
3116 instance: &str,
3117 ) -> InstanceRotateServerCaCall<'a, C> {
3118 InstanceRotateServerCaCall {
3119 hub: self.hub,
3120 _request: request,
3121 _project: project.to_string(),
3122 _instance: instance.to_string(),
3123 _delegate: Default::default(),
3124 _additional_params: Default::default(),
3125 _scopes: Default::default(),
3126 }
3127 }
3128
3129 /// Create a builder to help you perform the following task:
3130 ///
3131 /// Starts the replication in the read replica instance.
3132 ///
3133 /// # Arguments
3134 ///
3135 /// * `project` - ID of the project that contains the read replica.
3136 /// * `instance` - Cloud SQL read replica instance name.
3137 pub fn start_replica(&self, project: &str, instance: &str) -> InstanceStartReplicaCall<'a, C> {
3138 InstanceStartReplicaCall {
3139 hub: self.hub,
3140 _project: project.to_string(),
3141 _instance: instance.to_string(),
3142 _delegate: Default::default(),
3143 _additional_params: Default::default(),
3144 _scopes: Default::default(),
3145 }
3146 }
3147
3148 /// Create a builder to help you perform the following task:
3149 ///
3150 /// Stops the replication in the read replica instance.
3151 ///
3152 /// # Arguments
3153 ///
3154 /// * `project` - ID of the project that contains the read replica.
3155 /// * `instance` - Cloud SQL read replica instance name.
3156 pub fn stop_replica(&self, project: &str, instance: &str) -> InstanceStopReplicaCall<'a, C> {
3157 InstanceStopReplicaCall {
3158 hub: self.hub,
3159 _project: project.to_string(),
3160 _instance: instance.to_string(),
3161 _delegate: Default::default(),
3162 _additional_params: Default::default(),
3163 _scopes: Default::default(),
3164 }
3165 }
3166
3167 /// Create a builder to help you perform the following task:
3168 ///
3169 /// Truncate MySQL general and slow query log tables
3170 ///
3171 /// # Arguments
3172 ///
3173 /// * `request` - No description provided.
3174 /// * `project` - Project ID of the Cloud SQL project.
3175 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3176 pub fn truncate_log(
3177 &self,
3178 request: InstancesTruncateLogRequest,
3179 project: &str,
3180 instance: &str,
3181 ) -> InstanceTruncateLogCall<'a, C> {
3182 InstanceTruncateLogCall {
3183 hub: self.hub,
3184 _request: request,
3185 _project: project.to_string(),
3186 _instance: instance.to_string(),
3187 _delegate: Default::default(),
3188 _additional_params: Default::default(),
3189 _scopes: Default::default(),
3190 }
3191 }
3192
3193 /// Create a builder to help you perform the following task:
3194 ///
3195 /// Updates settings of a Cloud SQL instance. Using this operation might cause
3196 /// your instance to restart.
3197 ///
3198 /// # Arguments
3199 ///
3200 /// * `request` - No description provided.
3201 /// * `project` - Project ID of the project that contains the instance.
3202 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3203 pub fn update(
3204 &self,
3205 request: DatabaseInstance,
3206 project: &str,
3207 instance: &str,
3208 ) -> InstanceUpdateCall<'a, C> {
3209 InstanceUpdateCall {
3210 hub: self.hub,
3211 _request: request,
3212 _project: project.to_string(),
3213 _instance: instance.to_string(),
3214 _delegate: Default::default(),
3215 _additional_params: Default::default(),
3216 _scopes: Default::default(),
3217 }
3218 }
3219}
3220
3221/// A builder providing access to all methods supported on *operation* resources.
3222/// It is not used directly, but through the [`SQLAdmin`] hub.
3223///
3224/// # Example
3225///
3226/// Instantiate a resource builder
3227///
3228/// ```test_harness,no_run
3229/// extern crate hyper;
3230/// extern crate hyper_rustls;
3231/// extern crate google_sql1_beta4 as sql1_beta4;
3232///
3233/// # async fn dox() {
3234/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3235///
3236/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3237/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3238/// secret,
3239/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3240/// ).build().await.unwrap();
3241///
3242/// let client = hyper_util::client::legacy::Client::builder(
3243/// hyper_util::rt::TokioExecutor::new()
3244/// )
3245/// .build(
3246/// hyper_rustls::HttpsConnectorBuilder::new()
3247/// .with_native_roots()
3248/// .unwrap()
3249/// .https_or_http()
3250/// .enable_http1()
3251/// .build()
3252/// );
3253/// let mut hub = SQLAdmin::new(client, auth);
3254/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3255/// // like `get(...)` and `list(...)`
3256/// // to build up your call.
3257/// let rb = hub.operations();
3258/// # }
3259/// ```
3260pub struct OperationMethods<'a, C>
3261where
3262 C: 'a,
3263{
3264 hub: &'a SQLAdmin<C>,
3265}
3266
3267impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
3268
3269impl<'a, C> OperationMethods<'a, C> {
3270 /// Create a builder to help you perform the following task:
3271 ///
3272 /// Retrieves an instance operation that has been performed on an instance.
3273 ///
3274 /// # Arguments
3275 ///
3276 /// * `project` - Project ID of the project that contains the instance.
3277 /// * `operation` - Instance operation ID.
3278 pub fn get(&self, project: &str, operation: &str) -> OperationGetCall<'a, C> {
3279 OperationGetCall {
3280 hub: self.hub,
3281 _project: project.to_string(),
3282 _operation: operation.to_string(),
3283 _delegate: Default::default(),
3284 _additional_params: Default::default(),
3285 _scopes: Default::default(),
3286 }
3287 }
3288
3289 /// Create a builder to help you perform the following task:
3290 ///
3291 /// Lists all instance operations that have been performed on the given Cloud
3292 /// SQL instance in the reverse chronological order of the start time.
3293 ///
3294 /// # Arguments
3295 ///
3296 /// * `project` - Project ID of the project that contains the instance.
3297 pub fn list(&self, project: &str) -> OperationListCall<'a, C> {
3298 OperationListCall {
3299 hub: self.hub,
3300 _project: project.to_string(),
3301 _page_token: Default::default(),
3302 _max_results: Default::default(),
3303 _instance: Default::default(),
3304 _delegate: Default::default(),
3305 _additional_params: Default::default(),
3306 _scopes: Default::default(),
3307 }
3308 }
3309}
3310
3311/// A builder providing access to all methods supported on *project* resources.
3312/// It is not used directly, but through the [`SQLAdmin`] hub.
3313///
3314/// # Example
3315///
3316/// Instantiate a resource builder
3317///
3318/// ```test_harness,no_run
3319/// extern crate hyper;
3320/// extern crate hyper_rustls;
3321/// extern crate google_sql1_beta4 as sql1_beta4;
3322///
3323/// # async fn dox() {
3324/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3325///
3326/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3327/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3328/// secret,
3329/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3330/// ).build().await.unwrap();
3331///
3332/// let client = hyper_util::client::legacy::Client::builder(
3333/// hyper_util::rt::TokioExecutor::new()
3334/// )
3335/// .build(
3336/// hyper_rustls::HttpsConnectorBuilder::new()
3337/// .with_native_roots()
3338/// .unwrap()
3339/// .https_or_http()
3340/// .enable_http1()
3341/// .build()
3342/// );
3343/// let mut hub = SQLAdmin::new(client, auth);
3344/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3345/// // like `instances_reschedule_maintenance(...)`, `instances_start_external_sync(...)` and `instances_verify_external_sync_settings(...)`
3346/// // to build up your call.
3347/// let rb = hub.projects();
3348/// # }
3349/// ```
3350pub struct ProjectMethods<'a, C>
3351where
3352 C: 'a,
3353{
3354 hub: &'a SQLAdmin<C>,
3355}
3356
3357impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3358
3359impl<'a, C> ProjectMethods<'a, C> {
3360 /// Create a builder to help you perform the following task:
3361 ///
3362 /// Reschedules the maintenance on the given instance.
3363 ///
3364 /// # Arguments
3365 ///
3366 /// * `request` - No description provided.
3367 /// * `project` - ID of the project that contains the instance.
3368 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3369 pub fn instances_reschedule_maintenance(
3370 &self,
3371 request: SqlInstancesRescheduleMaintenanceRequestBody,
3372 project: &str,
3373 instance: &str,
3374 ) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
3375 ProjectInstanceRescheduleMaintenanceCall {
3376 hub: self.hub,
3377 _request: request,
3378 _project: project.to_string(),
3379 _instance: instance.to_string(),
3380 _delegate: Default::default(),
3381 _additional_params: Default::default(),
3382 _scopes: Default::default(),
3383 }
3384 }
3385
3386 /// Create a builder to help you perform the following task:
3387 ///
3388 /// Start External master migration.
3389 ///
3390 /// # Arguments
3391 ///
3392 /// * `project` - ID of the project that contains the first generation instance.
3393 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3394 pub fn instances_start_external_sync(
3395 &self,
3396 project: &str,
3397 instance: &str,
3398 ) -> ProjectInstanceStartExternalSyncCall<'a, C> {
3399 ProjectInstanceStartExternalSyncCall {
3400 hub: self.hub,
3401 _project: project.to_string(),
3402 _instance: instance.to_string(),
3403 _sync_mode: Default::default(),
3404 _delegate: Default::default(),
3405 _additional_params: Default::default(),
3406 _scopes: Default::default(),
3407 }
3408 }
3409
3410 /// Create a builder to help you perform the following task:
3411 ///
3412 /// Verify External master external sync settings.
3413 ///
3414 /// # Arguments
3415 ///
3416 /// * `project` - Project ID of the project that contains the instance.
3417 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3418 pub fn instances_verify_external_sync_settings(
3419 &self,
3420 project: &str,
3421 instance: &str,
3422 ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
3423 ProjectInstanceVerifyExternalSyncSettingCall {
3424 hub: self.hub,
3425 _project: project.to_string(),
3426 _instance: instance.to_string(),
3427 _verify_connection_only: Default::default(),
3428 _sync_mode: Default::default(),
3429 _delegate: Default::default(),
3430 _additional_params: Default::default(),
3431 _scopes: Default::default(),
3432 }
3433 }
3434}
3435
3436/// A builder providing access to all methods supported on *sslCert* resources.
3437/// It is not used directly, but through the [`SQLAdmin`] hub.
3438///
3439/// # Example
3440///
3441/// Instantiate a resource builder
3442///
3443/// ```test_harness,no_run
3444/// extern crate hyper;
3445/// extern crate hyper_rustls;
3446/// extern crate google_sql1_beta4 as sql1_beta4;
3447///
3448/// # async fn dox() {
3449/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3450///
3451/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3452/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3453/// secret,
3454/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3455/// ).build().await.unwrap();
3456///
3457/// let client = hyper_util::client::legacy::Client::builder(
3458/// hyper_util::rt::TokioExecutor::new()
3459/// )
3460/// .build(
3461/// hyper_rustls::HttpsConnectorBuilder::new()
3462/// .with_native_roots()
3463/// .unwrap()
3464/// .https_or_http()
3465/// .enable_http1()
3466/// .build()
3467/// );
3468/// let mut hub = SQLAdmin::new(client, auth);
3469/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3470/// // like `create_ephemeral(...)`, `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
3471/// // to build up your call.
3472/// let rb = hub.ssl_certs();
3473/// # }
3474/// ```
3475pub struct SslCertMethods<'a, C>
3476where
3477 C: 'a,
3478{
3479 hub: &'a SQLAdmin<C>,
3480}
3481
3482impl<'a, C> common::MethodsBuilder for SslCertMethods<'a, C> {}
3483
3484impl<'a, C> SslCertMethods<'a, C> {
3485 /// Create a builder to help you perform the following task:
3486 ///
3487 /// Generates a short-lived X509 certificate containing the provided public key
3488 /// and signed by a private key specific to the target instance. Users may use
3489 /// the certificate to authenticate as themselves when connecting to the
3490 /// database.
3491 ///
3492 /// # Arguments
3493 ///
3494 /// * `request` - No description provided.
3495 /// * `project` - Project ID of the Cloud SQL project.
3496 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3497 pub fn create_ephemeral(
3498 &self,
3499 request: SslCertsCreateEphemeralRequest,
3500 project: &str,
3501 instance: &str,
3502 ) -> SslCertCreateEphemeralCall<'a, C> {
3503 SslCertCreateEphemeralCall {
3504 hub: self.hub,
3505 _request: request,
3506 _project: project.to_string(),
3507 _instance: instance.to_string(),
3508 _delegate: Default::default(),
3509 _additional_params: Default::default(),
3510 _scopes: Default::default(),
3511 }
3512 }
3513
3514 /// Create a builder to help you perform the following task:
3515 ///
3516 /// Deletes the SSL certificate. For First Generation instances, the
3517 /// certificate remains valid until the instance is restarted.
3518 ///
3519 /// # Arguments
3520 ///
3521 /// * `project` - Project ID of the project that contains the instance.
3522 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3523 /// * `sha1Fingerprint` - Sha1 FingerPrint.
3524 pub fn delete(
3525 &self,
3526 project: &str,
3527 instance: &str,
3528 sha1_fingerprint: &str,
3529 ) -> SslCertDeleteCall<'a, C> {
3530 SslCertDeleteCall {
3531 hub: self.hub,
3532 _project: project.to_string(),
3533 _instance: instance.to_string(),
3534 _sha1_fingerprint: sha1_fingerprint.to_string(),
3535 _delegate: Default::default(),
3536 _additional_params: Default::default(),
3537 _scopes: Default::default(),
3538 }
3539 }
3540
3541 /// Create a builder to help you perform the following task:
3542 ///
3543 /// Retrieves a particular SSL certificate. Does not include the private key
3544 /// (required for usage). The private key must be saved from the response to
3545 /// initial creation.
3546 ///
3547 /// # Arguments
3548 ///
3549 /// * `project` - Project ID of the project that contains the instance.
3550 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3551 /// * `sha1Fingerprint` - Sha1 FingerPrint.
3552 pub fn get(
3553 &self,
3554 project: &str,
3555 instance: &str,
3556 sha1_fingerprint: &str,
3557 ) -> SslCertGetCall<'a, C> {
3558 SslCertGetCall {
3559 hub: self.hub,
3560 _project: project.to_string(),
3561 _instance: instance.to_string(),
3562 _sha1_fingerprint: sha1_fingerprint.to_string(),
3563 _delegate: Default::default(),
3564 _additional_params: Default::default(),
3565 _scopes: Default::default(),
3566 }
3567 }
3568
3569 /// Create a builder to help you perform the following task:
3570 ///
3571 /// Creates an SSL certificate and returns it along with the private key and
3572 /// server certificate authority. The new certificate will not be usable until
3573 /// the instance is restarted.
3574 ///
3575 /// # Arguments
3576 ///
3577 /// * `request` - No description provided.
3578 /// * `project` - Project ID of the project that contains the instance.
3579 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3580 pub fn insert(
3581 &self,
3582 request: SslCertsInsertRequest,
3583 project: &str,
3584 instance: &str,
3585 ) -> SslCertInsertCall<'a, C> {
3586 SslCertInsertCall {
3587 hub: self.hub,
3588 _request: request,
3589 _project: project.to_string(),
3590 _instance: instance.to_string(),
3591 _delegate: Default::default(),
3592 _additional_params: Default::default(),
3593 _scopes: Default::default(),
3594 }
3595 }
3596
3597 /// Create a builder to help you perform the following task:
3598 ///
3599 /// Lists all of the current SSL certificates for the instance.
3600 ///
3601 /// # Arguments
3602 ///
3603 /// * `project` - Project ID of the project that contains the instance.
3604 /// * `instance` - Cloud SQL instance ID. This does not include the project ID.
3605 pub fn list(&self, project: &str, instance: &str) -> SslCertListCall<'a, C> {
3606 SslCertListCall {
3607 hub: self.hub,
3608 _project: project.to_string(),
3609 _instance: instance.to_string(),
3610 _delegate: Default::default(),
3611 _additional_params: Default::default(),
3612 _scopes: Default::default(),
3613 }
3614 }
3615}
3616
3617/// A builder providing access to all methods supported on *tier* resources.
3618/// It is not used directly, but through the [`SQLAdmin`] hub.
3619///
3620/// # Example
3621///
3622/// Instantiate a resource builder
3623///
3624/// ```test_harness,no_run
3625/// extern crate hyper;
3626/// extern crate hyper_rustls;
3627/// extern crate google_sql1_beta4 as sql1_beta4;
3628///
3629/// # async fn dox() {
3630/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3631///
3632/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3633/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3634/// secret,
3635/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3636/// ).build().await.unwrap();
3637///
3638/// let client = hyper_util::client::legacy::Client::builder(
3639/// hyper_util::rt::TokioExecutor::new()
3640/// )
3641/// .build(
3642/// hyper_rustls::HttpsConnectorBuilder::new()
3643/// .with_native_roots()
3644/// .unwrap()
3645/// .https_or_http()
3646/// .enable_http1()
3647/// .build()
3648/// );
3649/// let mut hub = SQLAdmin::new(client, auth);
3650/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3651/// // like `list(...)`
3652/// // to build up your call.
3653/// let rb = hub.tiers();
3654/// # }
3655/// ```
3656pub struct TierMethods<'a, C>
3657where
3658 C: 'a,
3659{
3660 hub: &'a SQLAdmin<C>,
3661}
3662
3663impl<'a, C> common::MethodsBuilder for TierMethods<'a, C> {}
3664
3665impl<'a, C> TierMethods<'a, C> {
3666 /// Create a builder to help you perform the following task:
3667 ///
3668 /// Lists all available machine types (tiers) for Cloud SQL, for example,
3669 /// db-n1-standard-1. For related information, see <a
3670 /// href="/sql/pricing">Pricing</a>.
3671 ///
3672 /// # Arguments
3673 ///
3674 /// * `project` - Project ID of the project for which to list tiers.
3675 pub fn list(&self, project: &str) -> TierListCall<'a, C> {
3676 TierListCall {
3677 hub: self.hub,
3678 _project: project.to_string(),
3679 _delegate: Default::default(),
3680 _additional_params: Default::default(),
3681 _scopes: Default::default(),
3682 }
3683 }
3684}
3685
3686/// A builder providing access to all methods supported on *user* resources.
3687/// It is not used directly, but through the [`SQLAdmin`] hub.
3688///
3689/// # Example
3690///
3691/// Instantiate a resource builder
3692///
3693/// ```test_harness,no_run
3694/// extern crate hyper;
3695/// extern crate hyper_rustls;
3696/// extern crate google_sql1_beta4 as sql1_beta4;
3697///
3698/// # async fn dox() {
3699/// use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3700///
3701/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3702/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3703/// secret,
3704/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3705/// ).build().await.unwrap();
3706///
3707/// let client = hyper_util::client::legacy::Client::builder(
3708/// hyper_util::rt::TokioExecutor::new()
3709/// )
3710/// .build(
3711/// hyper_rustls::HttpsConnectorBuilder::new()
3712/// .with_native_roots()
3713/// .unwrap()
3714/// .https_or_http()
3715/// .enable_http1()
3716/// .build()
3717/// );
3718/// let mut hub = SQLAdmin::new(client, auth);
3719/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3720/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)`
3721/// // to build up your call.
3722/// let rb = hub.users();
3723/// # }
3724/// ```
3725pub struct UserMethods<'a, C>
3726where
3727 C: 'a,
3728{
3729 hub: &'a SQLAdmin<C>,
3730}
3731
3732impl<'a, C> common::MethodsBuilder for UserMethods<'a, C> {}
3733
3734impl<'a, C> UserMethods<'a, C> {
3735 /// Create a builder to help you perform the following task:
3736 ///
3737 /// Deletes a user from a Cloud SQL instance.
3738 ///
3739 /// # Arguments
3740 ///
3741 /// * `project` - Project ID of the project that contains the instance.
3742 /// * `instance` - Database instance ID. This does not include the project ID.
3743 pub fn delete(&self, project: &str, instance: &str) -> UserDeleteCall<'a, C> {
3744 UserDeleteCall {
3745 hub: self.hub,
3746 _project: project.to_string(),
3747 _instance: instance.to_string(),
3748 _name: Default::default(),
3749 _host: Default::default(),
3750 _delegate: Default::default(),
3751 _additional_params: Default::default(),
3752 _scopes: Default::default(),
3753 }
3754 }
3755
3756 /// Create a builder to help you perform the following task:
3757 ///
3758 /// Creates a new user in a Cloud SQL instance.
3759 ///
3760 /// # Arguments
3761 ///
3762 /// * `request` - No description provided.
3763 /// * `project` - Project ID of the project that contains the instance.
3764 /// * `instance` - Database instance ID. This does not include the project ID.
3765 pub fn insert(&self, request: User, project: &str, instance: &str) -> UserInsertCall<'a, C> {
3766 UserInsertCall {
3767 hub: self.hub,
3768 _request: request,
3769 _project: project.to_string(),
3770 _instance: instance.to_string(),
3771 _delegate: Default::default(),
3772 _additional_params: Default::default(),
3773 _scopes: Default::default(),
3774 }
3775 }
3776
3777 /// Create a builder to help you perform the following task:
3778 ///
3779 /// Lists users in the specified Cloud SQL instance.
3780 ///
3781 /// # Arguments
3782 ///
3783 /// * `project` - Project ID of the project that contains the instance.
3784 /// * `instance` - Database instance ID. This does not include the project ID.
3785 pub fn list(&self, project: &str, instance: &str) -> UserListCall<'a, C> {
3786 UserListCall {
3787 hub: self.hub,
3788 _project: project.to_string(),
3789 _instance: instance.to_string(),
3790 _delegate: Default::default(),
3791 _additional_params: Default::default(),
3792 _scopes: Default::default(),
3793 }
3794 }
3795
3796 /// Create a builder to help you perform the following task:
3797 ///
3798 /// Updates an existing user in a Cloud SQL instance.
3799 ///
3800 /// # Arguments
3801 ///
3802 /// * `request` - No description provided.
3803 /// * `project` - Project ID of the project that contains the instance.
3804 /// * `instance` - Database instance ID. This does not include the project ID.
3805 pub fn update(&self, request: User, project: &str, instance: &str) -> UserUpdateCall<'a, C> {
3806 UserUpdateCall {
3807 hub: self.hub,
3808 _request: request,
3809 _project: project.to_string(),
3810 _instance: instance.to_string(),
3811 _name: Default::default(),
3812 _host: Default::default(),
3813 _delegate: Default::default(),
3814 _additional_params: Default::default(),
3815 _scopes: Default::default(),
3816 }
3817 }
3818}
3819
3820// ###################
3821// CallBuilders ###
3822// #################
3823
3824/// Deletes the backup taken by a backup run.
3825///
3826/// A builder for the *delete* method supported by a *backupRun* resource.
3827/// It is not used directly, but through a [`BackupRunMethods`] instance.
3828///
3829/// # Example
3830///
3831/// Instantiate a resource method builder
3832///
3833/// ```test_harness,no_run
3834/// # extern crate hyper;
3835/// # extern crate hyper_rustls;
3836/// # extern crate google_sql1_beta4 as sql1_beta4;
3837/// # async fn dox() {
3838/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3839///
3840/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3841/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3842/// # secret,
3843/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3844/// # ).build().await.unwrap();
3845///
3846/// # let client = hyper_util::client::legacy::Client::builder(
3847/// # hyper_util::rt::TokioExecutor::new()
3848/// # )
3849/// # .build(
3850/// # hyper_rustls::HttpsConnectorBuilder::new()
3851/// # .with_native_roots()
3852/// # .unwrap()
3853/// # .https_or_http()
3854/// # .enable_http1()
3855/// # .build()
3856/// # );
3857/// # let mut hub = SQLAdmin::new(client, auth);
3858/// // You can configure optional parameters by calling the respective setters at will, and
3859/// // execute the final call using `doit()`.
3860/// // Values shown here are possibly random and not representative !
3861/// let result = hub.backup_runs().delete("project", "instance", -51)
3862/// .doit().await;
3863/// # }
3864/// ```
3865pub struct BackupRunDeleteCall<'a, C>
3866where
3867 C: 'a,
3868{
3869 hub: &'a SQLAdmin<C>,
3870 _project: String,
3871 _instance: String,
3872 _id: i64,
3873 _delegate: Option<&'a mut dyn common::Delegate>,
3874 _additional_params: HashMap<String, String>,
3875 _scopes: BTreeSet<String>,
3876}
3877
3878impl<'a, C> common::CallBuilder for BackupRunDeleteCall<'a, C> {}
3879
3880impl<'a, C> BackupRunDeleteCall<'a, C>
3881where
3882 C: common::Connector,
3883{
3884 /// Perform the operation you have build so far.
3885 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3886 use std::borrow::Cow;
3887 use std::io::{Read, Seek};
3888
3889 use common::{url::Params, ToParts};
3890 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3891
3892 let mut dd = common::DefaultDelegate;
3893 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3894 dlg.begin(common::MethodInfo {
3895 id: "sql.backupRuns.delete",
3896 http_method: hyper::Method::DELETE,
3897 });
3898
3899 for &field in ["alt", "project", "instance", "id"].iter() {
3900 if self._additional_params.contains_key(field) {
3901 dlg.finished(false);
3902 return Err(common::Error::FieldClash(field));
3903 }
3904 }
3905
3906 let mut params = Params::with_capacity(5 + self._additional_params.len());
3907 params.push("project", self._project);
3908 params.push("instance", self._instance);
3909 params.push("id", self._id.to_string());
3910
3911 params.extend(self._additional_params.iter());
3912
3913 params.push("alt", "json");
3914 let mut url = self.hub._base_url.clone()
3915 + "sql/v1beta4/projects/{project}/instances/{instance}/backupRuns/{id}";
3916 if self._scopes.is_empty() {
3917 self._scopes
3918 .insert(Scope::CloudPlatform.as_ref().to_string());
3919 }
3920
3921 #[allow(clippy::single_element_loop)]
3922 for &(find_this, param_name) in [
3923 ("{project}", "project"),
3924 ("{instance}", "instance"),
3925 ("{id}", "id"),
3926 ]
3927 .iter()
3928 {
3929 url = params.uri_replacement(url, param_name, find_this, false);
3930 }
3931 {
3932 let to_remove = ["id", "instance", "project"];
3933 params.remove_params(&to_remove);
3934 }
3935
3936 let url = params.parse_with_url(&url);
3937
3938 loop {
3939 let token = match self
3940 .hub
3941 .auth
3942 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3943 .await
3944 {
3945 Ok(token) => token,
3946 Err(e) => match dlg.token(e) {
3947 Ok(token) => token,
3948 Err(e) => {
3949 dlg.finished(false);
3950 return Err(common::Error::MissingToken(e));
3951 }
3952 },
3953 };
3954 let mut req_result = {
3955 let client = &self.hub.client;
3956 dlg.pre_request();
3957 let mut req_builder = hyper::Request::builder()
3958 .method(hyper::Method::DELETE)
3959 .uri(url.as_str())
3960 .header(USER_AGENT, self.hub._user_agent.clone());
3961
3962 if let Some(token) = token.as_ref() {
3963 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3964 }
3965
3966 let request = req_builder
3967 .header(CONTENT_LENGTH, 0_u64)
3968 .body(common::to_body::<String>(None));
3969
3970 client.request(request.unwrap()).await
3971 };
3972
3973 match req_result {
3974 Err(err) => {
3975 if let common::Retry::After(d) = dlg.http_error(&err) {
3976 sleep(d).await;
3977 continue;
3978 }
3979 dlg.finished(false);
3980 return Err(common::Error::HttpError(err));
3981 }
3982 Ok(res) => {
3983 let (mut parts, body) = res.into_parts();
3984 let mut body = common::Body::new(body);
3985 if !parts.status.is_success() {
3986 let bytes = common::to_bytes(body).await.unwrap_or_default();
3987 let error = serde_json::from_str(&common::to_string(&bytes));
3988 let response = common::to_response(parts, bytes.into());
3989
3990 if let common::Retry::After(d) =
3991 dlg.http_failure(&response, error.as_ref().ok())
3992 {
3993 sleep(d).await;
3994 continue;
3995 }
3996
3997 dlg.finished(false);
3998
3999 return Err(match error {
4000 Ok(value) => common::Error::BadRequest(value),
4001 _ => common::Error::Failure(response),
4002 });
4003 }
4004 let response = {
4005 let bytes = common::to_bytes(body).await.unwrap_or_default();
4006 let encoded = common::to_string(&bytes);
4007 match serde_json::from_str(&encoded) {
4008 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4009 Err(error) => {
4010 dlg.response_json_decode_error(&encoded, &error);
4011 return Err(common::Error::JsonDecodeError(
4012 encoded.to_string(),
4013 error,
4014 ));
4015 }
4016 }
4017 };
4018
4019 dlg.finished(true);
4020 return Ok(response);
4021 }
4022 }
4023 }
4024 }
4025
4026 /// Project ID of the project that contains the instance.
4027 ///
4028 /// Sets the *project* path property to the given value.
4029 ///
4030 /// Even though the property as already been set when instantiating this call,
4031 /// we provide this method for API completeness.
4032 pub fn project(mut self, new_value: &str) -> BackupRunDeleteCall<'a, C> {
4033 self._project = new_value.to_string();
4034 self
4035 }
4036 /// Cloud SQL instance ID. This does not include the project ID.
4037 ///
4038 /// Sets the *instance* path property to the given value.
4039 ///
4040 /// Even though the property as already been set when instantiating this call,
4041 /// we provide this method for API completeness.
4042 pub fn instance(mut self, new_value: &str) -> BackupRunDeleteCall<'a, C> {
4043 self._instance = new_value.to_string();
4044 self
4045 }
4046 /// The ID of the Backup Run to delete. To find a Backup Run ID, use the <a
4047 /// href="/sql/docs/db_path/admin-api/rest/v1beta4/backupRuns/list">list</a>
4048 /// method.
4049 ///
4050 /// Sets the *id* path property to the given value.
4051 ///
4052 /// Even though the property as already been set when instantiating this call,
4053 /// we provide this method for API completeness.
4054 pub fn id(mut self, new_value: i64) -> BackupRunDeleteCall<'a, C> {
4055 self._id = new_value;
4056 self
4057 }
4058 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4059 /// while executing the actual API request.
4060 ///
4061 /// ````text
4062 /// It should be used to handle progress information, and to implement a certain level of resilience.
4063 /// ````
4064 ///
4065 /// Sets the *delegate* property to the given value.
4066 pub fn delegate(
4067 mut self,
4068 new_value: &'a mut dyn common::Delegate,
4069 ) -> BackupRunDeleteCall<'a, C> {
4070 self._delegate = Some(new_value);
4071 self
4072 }
4073
4074 /// Set any additional parameter of the query string used in the request.
4075 /// It should be used to set parameters which are not yet available through their own
4076 /// setters.
4077 ///
4078 /// Please note that this method must not be used to set any of the known parameters
4079 /// which have their own setter method. If done anyway, the request will fail.
4080 ///
4081 /// # Additional Parameters
4082 ///
4083 /// * *$.xgafv* (query-string) - V1 error format.
4084 /// * *access_token* (query-string) - OAuth access token.
4085 /// * *alt* (query-string) - Data format for response.
4086 /// * *callback* (query-string) - JSONP
4087 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4088 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4089 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4090 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4091 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4092 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4093 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4094 pub fn param<T>(mut self, name: T, value: T) -> BackupRunDeleteCall<'a, C>
4095 where
4096 T: AsRef<str>,
4097 {
4098 self._additional_params
4099 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4100 self
4101 }
4102
4103 /// Identifies the authorization scope for the method you are building.
4104 ///
4105 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4106 /// [`Scope::CloudPlatform`].
4107 ///
4108 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4109 /// tokens for more than one scope.
4110 ///
4111 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4112 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4113 /// sufficient, a read-write scope will do as well.
4114 pub fn add_scope<St>(mut self, scope: St) -> BackupRunDeleteCall<'a, C>
4115 where
4116 St: AsRef<str>,
4117 {
4118 self._scopes.insert(String::from(scope.as_ref()));
4119 self
4120 }
4121 /// Identifies the authorization scope(s) for the method you are building.
4122 ///
4123 /// See [`Self::add_scope()`] for details.
4124 pub fn add_scopes<I, St>(mut self, scopes: I) -> BackupRunDeleteCall<'a, C>
4125 where
4126 I: IntoIterator<Item = St>,
4127 St: AsRef<str>,
4128 {
4129 self._scopes
4130 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4131 self
4132 }
4133
4134 /// Removes all scopes, and no default scope will be used either.
4135 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4136 /// for details).
4137 pub fn clear_scopes(mut self) -> BackupRunDeleteCall<'a, C> {
4138 self._scopes.clear();
4139 self
4140 }
4141}
4142
4143/// Retrieves a resource containing information about a backup run.
4144///
4145/// A builder for the *get* method supported by a *backupRun* resource.
4146/// It is not used directly, but through a [`BackupRunMethods`] instance.
4147///
4148/// # Example
4149///
4150/// Instantiate a resource method builder
4151///
4152/// ```test_harness,no_run
4153/// # extern crate hyper;
4154/// # extern crate hyper_rustls;
4155/// # extern crate google_sql1_beta4 as sql1_beta4;
4156/// # async fn dox() {
4157/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4158///
4159/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4160/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4161/// # secret,
4162/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4163/// # ).build().await.unwrap();
4164///
4165/// # let client = hyper_util::client::legacy::Client::builder(
4166/// # hyper_util::rt::TokioExecutor::new()
4167/// # )
4168/// # .build(
4169/// # hyper_rustls::HttpsConnectorBuilder::new()
4170/// # .with_native_roots()
4171/// # .unwrap()
4172/// # .https_or_http()
4173/// # .enable_http1()
4174/// # .build()
4175/// # );
4176/// # let mut hub = SQLAdmin::new(client, auth);
4177/// // You can configure optional parameters by calling the respective setters at will, and
4178/// // execute the final call using `doit()`.
4179/// // Values shown here are possibly random and not representative !
4180/// let result = hub.backup_runs().get("project", "instance", -4)
4181/// .doit().await;
4182/// # }
4183/// ```
4184pub struct BackupRunGetCall<'a, C>
4185where
4186 C: 'a,
4187{
4188 hub: &'a SQLAdmin<C>,
4189 _project: String,
4190 _instance: String,
4191 _id: i64,
4192 _delegate: Option<&'a mut dyn common::Delegate>,
4193 _additional_params: HashMap<String, String>,
4194 _scopes: BTreeSet<String>,
4195}
4196
4197impl<'a, C> common::CallBuilder for BackupRunGetCall<'a, C> {}
4198
4199impl<'a, C> BackupRunGetCall<'a, C>
4200where
4201 C: common::Connector,
4202{
4203 /// Perform the operation you have build so far.
4204 pub async fn doit(mut self) -> common::Result<(common::Response, BackupRun)> {
4205 use std::borrow::Cow;
4206 use std::io::{Read, Seek};
4207
4208 use common::{url::Params, ToParts};
4209 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4210
4211 let mut dd = common::DefaultDelegate;
4212 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4213 dlg.begin(common::MethodInfo {
4214 id: "sql.backupRuns.get",
4215 http_method: hyper::Method::GET,
4216 });
4217
4218 for &field in ["alt", "project", "instance", "id"].iter() {
4219 if self._additional_params.contains_key(field) {
4220 dlg.finished(false);
4221 return Err(common::Error::FieldClash(field));
4222 }
4223 }
4224
4225 let mut params = Params::with_capacity(5 + self._additional_params.len());
4226 params.push("project", self._project);
4227 params.push("instance", self._instance);
4228 params.push("id", self._id.to_string());
4229
4230 params.extend(self._additional_params.iter());
4231
4232 params.push("alt", "json");
4233 let mut url = self.hub._base_url.clone()
4234 + "sql/v1beta4/projects/{project}/instances/{instance}/backupRuns/{id}";
4235 if self._scopes.is_empty() {
4236 self._scopes
4237 .insert(Scope::CloudPlatform.as_ref().to_string());
4238 }
4239
4240 #[allow(clippy::single_element_loop)]
4241 for &(find_this, param_name) in [
4242 ("{project}", "project"),
4243 ("{instance}", "instance"),
4244 ("{id}", "id"),
4245 ]
4246 .iter()
4247 {
4248 url = params.uri_replacement(url, param_name, find_this, false);
4249 }
4250 {
4251 let to_remove = ["id", "instance", "project"];
4252 params.remove_params(&to_remove);
4253 }
4254
4255 let url = params.parse_with_url(&url);
4256
4257 loop {
4258 let token = match self
4259 .hub
4260 .auth
4261 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4262 .await
4263 {
4264 Ok(token) => token,
4265 Err(e) => match dlg.token(e) {
4266 Ok(token) => token,
4267 Err(e) => {
4268 dlg.finished(false);
4269 return Err(common::Error::MissingToken(e));
4270 }
4271 },
4272 };
4273 let mut req_result = {
4274 let client = &self.hub.client;
4275 dlg.pre_request();
4276 let mut req_builder = hyper::Request::builder()
4277 .method(hyper::Method::GET)
4278 .uri(url.as_str())
4279 .header(USER_AGENT, self.hub._user_agent.clone());
4280
4281 if let Some(token) = token.as_ref() {
4282 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4283 }
4284
4285 let request = req_builder
4286 .header(CONTENT_LENGTH, 0_u64)
4287 .body(common::to_body::<String>(None));
4288
4289 client.request(request.unwrap()).await
4290 };
4291
4292 match req_result {
4293 Err(err) => {
4294 if let common::Retry::After(d) = dlg.http_error(&err) {
4295 sleep(d).await;
4296 continue;
4297 }
4298 dlg.finished(false);
4299 return Err(common::Error::HttpError(err));
4300 }
4301 Ok(res) => {
4302 let (mut parts, body) = res.into_parts();
4303 let mut body = common::Body::new(body);
4304 if !parts.status.is_success() {
4305 let bytes = common::to_bytes(body).await.unwrap_or_default();
4306 let error = serde_json::from_str(&common::to_string(&bytes));
4307 let response = common::to_response(parts, bytes.into());
4308
4309 if let common::Retry::After(d) =
4310 dlg.http_failure(&response, error.as_ref().ok())
4311 {
4312 sleep(d).await;
4313 continue;
4314 }
4315
4316 dlg.finished(false);
4317
4318 return Err(match error {
4319 Ok(value) => common::Error::BadRequest(value),
4320 _ => common::Error::Failure(response),
4321 });
4322 }
4323 let response = {
4324 let bytes = common::to_bytes(body).await.unwrap_or_default();
4325 let encoded = common::to_string(&bytes);
4326 match serde_json::from_str(&encoded) {
4327 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4328 Err(error) => {
4329 dlg.response_json_decode_error(&encoded, &error);
4330 return Err(common::Error::JsonDecodeError(
4331 encoded.to_string(),
4332 error,
4333 ));
4334 }
4335 }
4336 };
4337
4338 dlg.finished(true);
4339 return Ok(response);
4340 }
4341 }
4342 }
4343 }
4344
4345 /// Project ID of the project that contains the instance.
4346 ///
4347 /// Sets the *project* path property to the given value.
4348 ///
4349 /// Even though the property as already been set when instantiating this call,
4350 /// we provide this method for API completeness.
4351 pub fn project(mut self, new_value: &str) -> BackupRunGetCall<'a, C> {
4352 self._project = new_value.to_string();
4353 self
4354 }
4355 /// Cloud SQL instance ID. This does not include the project ID.
4356 ///
4357 /// Sets the *instance* path property to the given value.
4358 ///
4359 /// Even though the property as already been set when instantiating this call,
4360 /// we provide this method for API completeness.
4361 pub fn instance(mut self, new_value: &str) -> BackupRunGetCall<'a, C> {
4362 self._instance = new_value.to_string();
4363 self
4364 }
4365 /// The ID of this Backup Run.
4366 ///
4367 /// Sets the *id* path property to the given value.
4368 ///
4369 /// Even though the property as already been set when instantiating this call,
4370 /// we provide this method for API completeness.
4371 pub fn id(mut self, new_value: i64) -> BackupRunGetCall<'a, C> {
4372 self._id = new_value;
4373 self
4374 }
4375 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4376 /// while executing the actual API request.
4377 ///
4378 /// ````text
4379 /// It should be used to handle progress information, and to implement a certain level of resilience.
4380 /// ````
4381 ///
4382 /// Sets the *delegate* property to the given value.
4383 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BackupRunGetCall<'a, C> {
4384 self._delegate = Some(new_value);
4385 self
4386 }
4387
4388 /// Set any additional parameter of the query string used in the request.
4389 /// It should be used to set parameters which are not yet available through their own
4390 /// setters.
4391 ///
4392 /// Please note that this method must not be used to set any of the known parameters
4393 /// which have their own setter method. If done anyway, the request will fail.
4394 ///
4395 /// # Additional Parameters
4396 ///
4397 /// * *$.xgafv* (query-string) - V1 error format.
4398 /// * *access_token* (query-string) - OAuth access token.
4399 /// * *alt* (query-string) - Data format for response.
4400 /// * *callback* (query-string) - JSONP
4401 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4402 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4403 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4404 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4405 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4406 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4407 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4408 pub fn param<T>(mut self, name: T, value: T) -> BackupRunGetCall<'a, C>
4409 where
4410 T: AsRef<str>,
4411 {
4412 self._additional_params
4413 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4414 self
4415 }
4416
4417 /// Identifies the authorization scope for the method you are building.
4418 ///
4419 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4420 /// [`Scope::CloudPlatform`].
4421 ///
4422 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4423 /// tokens for more than one scope.
4424 ///
4425 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4426 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4427 /// sufficient, a read-write scope will do as well.
4428 pub fn add_scope<St>(mut self, scope: St) -> BackupRunGetCall<'a, C>
4429 where
4430 St: AsRef<str>,
4431 {
4432 self._scopes.insert(String::from(scope.as_ref()));
4433 self
4434 }
4435 /// Identifies the authorization scope(s) for the method you are building.
4436 ///
4437 /// See [`Self::add_scope()`] for details.
4438 pub fn add_scopes<I, St>(mut self, scopes: I) -> BackupRunGetCall<'a, C>
4439 where
4440 I: IntoIterator<Item = St>,
4441 St: AsRef<str>,
4442 {
4443 self._scopes
4444 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4445 self
4446 }
4447
4448 /// Removes all scopes, and no default scope will be used either.
4449 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4450 /// for details).
4451 pub fn clear_scopes(mut self) -> BackupRunGetCall<'a, C> {
4452 self._scopes.clear();
4453 self
4454 }
4455}
4456
4457/// Creates a new backup run on demand. This method is applicable only to
4458/// Second Generation instances.
4459///
4460/// A builder for the *insert* method supported by a *backupRun* resource.
4461/// It is not used directly, but through a [`BackupRunMethods`] instance.
4462///
4463/// # Example
4464///
4465/// Instantiate a resource method builder
4466///
4467/// ```test_harness,no_run
4468/// # extern crate hyper;
4469/// # extern crate hyper_rustls;
4470/// # extern crate google_sql1_beta4 as sql1_beta4;
4471/// use sql1_beta4::api::BackupRun;
4472/// # async fn dox() {
4473/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4474///
4475/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4477/// # secret,
4478/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4479/// # ).build().await.unwrap();
4480///
4481/// # let client = hyper_util::client::legacy::Client::builder(
4482/// # hyper_util::rt::TokioExecutor::new()
4483/// # )
4484/// # .build(
4485/// # hyper_rustls::HttpsConnectorBuilder::new()
4486/// # .with_native_roots()
4487/// # .unwrap()
4488/// # .https_or_http()
4489/// # .enable_http1()
4490/// # .build()
4491/// # );
4492/// # let mut hub = SQLAdmin::new(client, auth);
4493/// // As the method needs a request, you would usually fill it with the desired information
4494/// // into the respective structure. Some of the parts shown here might not be applicable !
4495/// // Values shown here are possibly random and not representative !
4496/// let mut req = BackupRun::default();
4497///
4498/// // You can configure optional parameters by calling the respective setters at will, and
4499/// // execute the final call using `doit()`.
4500/// // Values shown here are possibly random and not representative !
4501/// let result = hub.backup_runs().insert(req, "project", "instance")
4502/// .doit().await;
4503/// # }
4504/// ```
4505pub struct BackupRunInsertCall<'a, C>
4506where
4507 C: 'a,
4508{
4509 hub: &'a SQLAdmin<C>,
4510 _request: BackupRun,
4511 _project: String,
4512 _instance: String,
4513 _delegate: Option<&'a mut dyn common::Delegate>,
4514 _additional_params: HashMap<String, String>,
4515 _scopes: BTreeSet<String>,
4516}
4517
4518impl<'a, C> common::CallBuilder for BackupRunInsertCall<'a, C> {}
4519
4520impl<'a, C> BackupRunInsertCall<'a, C>
4521where
4522 C: common::Connector,
4523{
4524 /// Perform the operation you have build so far.
4525 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4526 use std::borrow::Cow;
4527 use std::io::{Read, Seek};
4528
4529 use common::{url::Params, ToParts};
4530 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4531
4532 let mut dd = common::DefaultDelegate;
4533 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4534 dlg.begin(common::MethodInfo {
4535 id: "sql.backupRuns.insert",
4536 http_method: hyper::Method::POST,
4537 });
4538
4539 for &field in ["alt", "project", "instance"].iter() {
4540 if self._additional_params.contains_key(field) {
4541 dlg.finished(false);
4542 return Err(common::Error::FieldClash(field));
4543 }
4544 }
4545
4546 let mut params = Params::with_capacity(5 + self._additional_params.len());
4547 params.push("project", self._project);
4548 params.push("instance", self._instance);
4549
4550 params.extend(self._additional_params.iter());
4551
4552 params.push("alt", "json");
4553 let mut url = self.hub._base_url.clone()
4554 + "sql/v1beta4/projects/{project}/instances/{instance}/backupRuns";
4555 if self._scopes.is_empty() {
4556 self._scopes
4557 .insert(Scope::CloudPlatform.as_ref().to_string());
4558 }
4559
4560 #[allow(clippy::single_element_loop)]
4561 for &(find_this, param_name) in
4562 [("{project}", "project"), ("{instance}", "instance")].iter()
4563 {
4564 url = params.uri_replacement(url, param_name, find_this, false);
4565 }
4566 {
4567 let to_remove = ["instance", "project"];
4568 params.remove_params(&to_remove);
4569 }
4570
4571 let url = params.parse_with_url(&url);
4572
4573 let mut json_mime_type = mime::APPLICATION_JSON;
4574 let mut request_value_reader = {
4575 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4576 common::remove_json_null_values(&mut value);
4577 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4578 serde_json::to_writer(&mut dst, &value).unwrap();
4579 dst
4580 };
4581 let request_size = request_value_reader
4582 .seek(std::io::SeekFrom::End(0))
4583 .unwrap();
4584 request_value_reader
4585 .seek(std::io::SeekFrom::Start(0))
4586 .unwrap();
4587
4588 loop {
4589 let token = match self
4590 .hub
4591 .auth
4592 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4593 .await
4594 {
4595 Ok(token) => token,
4596 Err(e) => match dlg.token(e) {
4597 Ok(token) => token,
4598 Err(e) => {
4599 dlg.finished(false);
4600 return Err(common::Error::MissingToken(e));
4601 }
4602 },
4603 };
4604 request_value_reader
4605 .seek(std::io::SeekFrom::Start(0))
4606 .unwrap();
4607 let mut req_result = {
4608 let client = &self.hub.client;
4609 dlg.pre_request();
4610 let mut req_builder = hyper::Request::builder()
4611 .method(hyper::Method::POST)
4612 .uri(url.as_str())
4613 .header(USER_AGENT, self.hub._user_agent.clone());
4614
4615 if let Some(token) = token.as_ref() {
4616 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4617 }
4618
4619 let request = req_builder
4620 .header(CONTENT_TYPE, json_mime_type.to_string())
4621 .header(CONTENT_LENGTH, request_size as u64)
4622 .body(common::to_body(
4623 request_value_reader.get_ref().clone().into(),
4624 ));
4625
4626 client.request(request.unwrap()).await
4627 };
4628
4629 match req_result {
4630 Err(err) => {
4631 if let common::Retry::After(d) = dlg.http_error(&err) {
4632 sleep(d).await;
4633 continue;
4634 }
4635 dlg.finished(false);
4636 return Err(common::Error::HttpError(err));
4637 }
4638 Ok(res) => {
4639 let (mut parts, body) = res.into_parts();
4640 let mut body = common::Body::new(body);
4641 if !parts.status.is_success() {
4642 let bytes = common::to_bytes(body).await.unwrap_or_default();
4643 let error = serde_json::from_str(&common::to_string(&bytes));
4644 let response = common::to_response(parts, bytes.into());
4645
4646 if let common::Retry::After(d) =
4647 dlg.http_failure(&response, error.as_ref().ok())
4648 {
4649 sleep(d).await;
4650 continue;
4651 }
4652
4653 dlg.finished(false);
4654
4655 return Err(match error {
4656 Ok(value) => common::Error::BadRequest(value),
4657 _ => common::Error::Failure(response),
4658 });
4659 }
4660 let response = {
4661 let bytes = common::to_bytes(body).await.unwrap_or_default();
4662 let encoded = common::to_string(&bytes);
4663 match serde_json::from_str(&encoded) {
4664 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4665 Err(error) => {
4666 dlg.response_json_decode_error(&encoded, &error);
4667 return Err(common::Error::JsonDecodeError(
4668 encoded.to_string(),
4669 error,
4670 ));
4671 }
4672 }
4673 };
4674
4675 dlg.finished(true);
4676 return Ok(response);
4677 }
4678 }
4679 }
4680 }
4681
4682 ///
4683 /// Sets the *request* property to the given value.
4684 ///
4685 /// Even though the property as already been set when instantiating this call,
4686 /// we provide this method for API completeness.
4687 pub fn request(mut self, new_value: BackupRun) -> BackupRunInsertCall<'a, C> {
4688 self._request = new_value;
4689 self
4690 }
4691 /// Project ID of the project that contains the instance.
4692 ///
4693 /// Sets the *project* path property to the given value.
4694 ///
4695 /// Even though the property as already been set when instantiating this call,
4696 /// we provide this method for API completeness.
4697 pub fn project(mut self, new_value: &str) -> BackupRunInsertCall<'a, C> {
4698 self._project = new_value.to_string();
4699 self
4700 }
4701 /// Cloud SQL instance ID. This does not include the project ID.
4702 ///
4703 /// Sets the *instance* path property to the given value.
4704 ///
4705 /// Even though the property as already been set when instantiating this call,
4706 /// we provide this method for API completeness.
4707 pub fn instance(mut self, new_value: &str) -> BackupRunInsertCall<'a, C> {
4708 self._instance = new_value.to_string();
4709 self
4710 }
4711 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4712 /// while executing the actual API request.
4713 ///
4714 /// ````text
4715 /// It should be used to handle progress information, and to implement a certain level of resilience.
4716 /// ````
4717 ///
4718 /// Sets the *delegate* property to the given value.
4719 pub fn delegate(
4720 mut self,
4721 new_value: &'a mut dyn common::Delegate,
4722 ) -> BackupRunInsertCall<'a, C> {
4723 self._delegate = Some(new_value);
4724 self
4725 }
4726
4727 /// Set any additional parameter of the query string used in the request.
4728 /// It should be used to set parameters which are not yet available through their own
4729 /// setters.
4730 ///
4731 /// Please note that this method must not be used to set any of the known parameters
4732 /// which have their own setter method. If done anyway, the request will fail.
4733 ///
4734 /// # Additional Parameters
4735 ///
4736 /// * *$.xgafv* (query-string) - V1 error format.
4737 /// * *access_token* (query-string) - OAuth access token.
4738 /// * *alt* (query-string) - Data format for response.
4739 /// * *callback* (query-string) - JSONP
4740 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4741 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4742 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4743 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4744 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4745 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4746 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4747 pub fn param<T>(mut self, name: T, value: T) -> BackupRunInsertCall<'a, C>
4748 where
4749 T: AsRef<str>,
4750 {
4751 self._additional_params
4752 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4753 self
4754 }
4755
4756 /// Identifies the authorization scope for the method you are building.
4757 ///
4758 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4759 /// [`Scope::CloudPlatform`].
4760 ///
4761 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4762 /// tokens for more than one scope.
4763 ///
4764 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4765 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4766 /// sufficient, a read-write scope will do as well.
4767 pub fn add_scope<St>(mut self, scope: St) -> BackupRunInsertCall<'a, C>
4768 where
4769 St: AsRef<str>,
4770 {
4771 self._scopes.insert(String::from(scope.as_ref()));
4772 self
4773 }
4774 /// Identifies the authorization scope(s) for the method you are building.
4775 ///
4776 /// See [`Self::add_scope()`] for details.
4777 pub fn add_scopes<I, St>(mut self, scopes: I) -> BackupRunInsertCall<'a, C>
4778 where
4779 I: IntoIterator<Item = St>,
4780 St: AsRef<str>,
4781 {
4782 self._scopes
4783 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4784 self
4785 }
4786
4787 /// Removes all scopes, and no default scope will be used either.
4788 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4789 /// for details).
4790 pub fn clear_scopes(mut self) -> BackupRunInsertCall<'a, C> {
4791 self._scopes.clear();
4792 self
4793 }
4794}
4795
4796/// Lists all backup runs associated with a given instance and configuration in
4797/// the reverse chronological order of the backup initiation time.
4798///
4799/// A builder for the *list* method supported by a *backupRun* resource.
4800/// It is not used directly, but through a [`BackupRunMethods`] instance.
4801///
4802/// # Example
4803///
4804/// Instantiate a resource method builder
4805///
4806/// ```test_harness,no_run
4807/// # extern crate hyper;
4808/// # extern crate hyper_rustls;
4809/// # extern crate google_sql1_beta4 as sql1_beta4;
4810/// # async fn dox() {
4811/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4812///
4813/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4814/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4815/// # secret,
4816/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4817/// # ).build().await.unwrap();
4818///
4819/// # let client = hyper_util::client::legacy::Client::builder(
4820/// # hyper_util::rt::TokioExecutor::new()
4821/// # )
4822/// # .build(
4823/// # hyper_rustls::HttpsConnectorBuilder::new()
4824/// # .with_native_roots()
4825/// # .unwrap()
4826/// # .https_or_http()
4827/// # .enable_http1()
4828/// # .build()
4829/// # );
4830/// # let mut hub = SQLAdmin::new(client, auth);
4831/// // You can configure optional parameters by calling the respective setters at will, and
4832/// // execute the final call using `doit()`.
4833/// // Values shown here are possibly random and not representative !
4834/// let result = hub.backup_runs().list("project", "instance")
4835/// .page_token("duo")
4836/// .max_results(-50)
4837/// .doit().await;
4838/// # }
4839/// ```
4840pub struct BackupRunListCall<'a, C>
4841where
4842 C: 'a,
4843{
4844 hub: &'a SQLAdmin<C>,
4845 _project: String,
4846 _instance: String,
4847 _page_token: Option<String>,
4848 _max_results: Option<i32>,
4849 _delegate: Option<&'a mut dyn common::Delegate>,
4850 _additional_params: HashMap<String, String>,
4851 _scopes: BTreeSet<String>,
4852}
4853
4854impl<'a, C> common::CallBuilder for BackupRunListCall<'a, C> {}
4855
4856impl<'a, C> BackupRunListCall<'a, C>
4857where
4858 C: common::Connector,
4859{
4860 /// Perform the operation you have build so far.
4861 pub async fn doit(mut self) -> common::Result<(common::Response, BackupRunsListResponse)> {
4862 use std::borrow::Cow;
4863 use std::io::{Read, Seek};
4864
4865 use common::{url::Params, ToParts};
4866 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4867
4868 let mut dd = common::DefaultDelegate;
4869 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4870 dlg.begin(common::MethodInfo {
4871 id: "sql.backupRuns.list",
4872 http_method: hyper::Method::GET,
4873 });
4874
4875 for &field in ["alt", "project", "instance", "pageToken", "maxResults"].iter() {
4876 if self._additional_params.contains_key(field) {
4877 dlg.finished(false);
4878 return Err(common::Error::FieldClash(field));
4879 }
4880 }
4881
4882 let mut params = Params::with_capacity(6 + self._additional_params.len());
4883 params.push("project", self._project);
4884 params.push("instance", self._instance);
4885 if let Some(value) = self._page_token.as_ref() {
4886 params.push("pageToken", value);
4887 }
4888 if let Some(value) = self._max_results.as_ref() {
4889 params.push("maxResults", value.to_string());
4890 }
4891
4892 params.extend(self._additional_params.iter());
4893
4894 params.push("alt", "json");
4895 let mut url = self.hub._base_url.clone()
4896 + "sql/v1beta4/projects/{project}/instances/{instance}/backupRuns";
4897 if self._scopes.is_empty() {
4898 self._scopes
4899 .insert(Scope::CloudPlatform.as_ref().to_string());
4900 }
4901
4902 #[allow(clippy::single_element_loop)]
4903 for &(find_this, param_name) in
4904 [("{project}", "project"), ("{instance}", "instance")].iter()
4905 {
4906 url = params.uri_replacement(url, param_name, find_this, false);
4907 }
4908 {
4909 let to_remove = ["instance", "project"];
4910 params.remove_params(&to_remove);
4911 }
4912
4913 let url = params.parse_with_url(&url);
4914
4915 loop {
4916 let token = match self
4917 .hub
4918 .auth
4919 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4920 .await
4921 {
4922 Ok(token) => token,
4923 Err(e) => match dlg.token(e) {
4924 Ok(token) => token,
4925 Err(e) => {
4926 dlg.finished(false);
4927 return Err(common::Error::MissingToken(e));
4928 }
4929 },
4930 };
4931 let mut req_result = {
4932 let client = &self.hub.client;
4933 dlg.pre_request();
4934 let mut req_builder = hyper::Request::builder()
4935 .method(hyper::Method::GET)
4936 .uri(url.as_str())
4937 .header(USER_AGENT, self.hub._user_agent.clone());
4938
4939 if let Some(token) = token.as_ref() {
4940 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4941 }
4942
4943 let request = req_builder
4944 .header(CONTENT_LENGTH, 0_u64)
4945 .body(common::to_body::<String>(None));
4946
4947 client.request(request.unwrap()).await
4948 };
4949
4950 match req_result {
4951 Err(err) => {
4952 if let common::Retry::After(d) = dlg.http_error(&err) {
4953 sleep(d).await;
4954 continue;
4955 }
4956 dlg.finished(false);
4957 return Err(common::Error::HttpError(err));
4958 }
4959 Ok(res) => {
4960 let (mut parts, body) = res.into_parts();
4961 let mut body = common::Body::new(body);
4962 if !parts.status.is_success() {
4963 let bytes = common::to_bytes(body).await.unwrap_or_default();
4964 let error = serde_json::from_str(&common::to_string(&bytes));
4965 let response = common::to_response(parts, bytes.into());
4966
4967 if let common::Retry::After(d) =
4968 dlg.http_failure(&response, error.as_ref().ok())
4969 {
4970 sleep(d).await;
4971 continue;
4972 }
4973
4974 dlg.finished(false);
4975
4976 return Err(match error {
4977 Ok(value) => common::Error::BadRequest(value),
4978 _ => common::Error::Failure(response),
4979 });
4980 }
4981 let response = {
4982 let bytes = common::to_bytes(body).await.unwrap_or_default();
4983 let encoded = common::to_string(&bytes);
4984 match serde_json::from_str(&encoded) {
4985 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4986 Err(error) => {
4987 dlg.response_json_decode_error(&encoded, &error);
4988 return Err(common::Error::JsonDecodeError(
4989 encoded.to_string(),
4990 error,
4991 ));
4992 }
4993 }
4994 };
4995
4996 dlg.finished(true);
4997 return Ok(response);
4998 }
4999 }
5000 }
5001 }
5002
5003 /// Project ID of the project that contains the instance.
5004 ///
5005 /// Sets the *project* path property to the given value.
5006 ///
5007 /// Even though the property as already been set when instantiating this call,
5008 /// we provide this method for API completeness.
5009 pub fn project(mut self, new_value: &str) -> BackupRunListCall<'a, C> {
5010 self._project = new_value.to_string();
5011 self
5012 }
5013 /// Cloud SQL instance ID. This does not include the project ID.
5014 ///
5015 /// Sets the *instance* path property to the given value.
5016 ///
5017 /// Even though the property as already been set when instantiating this call,
5018 /// we provide this method for API completeness.
5019 pub fn instance(mut self, new_value: &str) -> BackupRunListCall<'a, C> {
5020 self._instance = new_value.to_string();
5021 self
5022 }
5023 /// A previously-returned page token representing part of the larger set of
5024 /// results to view.
5025 ///
5026 /// Sets the *page token* query property to the given value.
5027 pub fn page_token(mut self, new_value: &str) -> BackupRunListCall<'a, C> {
5028 self._page_token = Some(new_value.to_string());
5029 self
5030 }
5031 /// Maximum number of backup runs per response.
5032 ///
5033 /// Sets the *max results* query property to the given value.
5034 pub fn max_results(mut self, new_value: i32) -> BackupRunListCall<'a, C> {
5035 self._max_results = Some(new_value);
5036 self
5037 }
5038 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5039 /// while executing the actual API request.
5040 ///
5041 /// ````text
5042 /// It should be used to handle progress information, and to implement a certain level of resilience.
5043 /// ````
5044 ///
5045 /// Sets the *delegate* property to the given value.
5046 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BackupRunListCall<'a, C> {
5047 self._delegate = Some(new_value);
5048 self
5049 }
5050
5051 /// Set any additional parameter of the query string used in the request.
5052 /// It should be used to set parameters which are not yet available through their own
5053 /// setters.
5054 ///
5055 /// Please note that this method must not be used to set any of the known parameters
5056 /// which have their own setter method. If done anyway, the request will fail.
5057 ///
5058 /// # Additional Parameters
5059 ///
5060 /// * *$.xgafv* (query-string) - V1 error format.
5061 /// * *access_token* (query-string) - OAuth access token.
5062 /// * *alt* (query-string) - Data format for response.
5063 /// * *callback* (query-string) - JSONP
5064 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5065 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5066 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5067 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5068 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5069 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5070 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5071 pub fn param<T>(mut self, name: T, value: T) -> BackupRunListCall<'a, C>
5072 where
5073 T: AsRef<str>,
5074 {
5075 self._additional_params
5076 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5077 self
5078 }
5079
5080 /// Identifies the authorization scope for the method you are building.
5081 ///
5082 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5083 /// [`Scope::CloudPlatform`].
5084 ///
5085 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5086 /// tokens for more than one scope.
5087 ///
5088 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5089 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5090 /// sufficient, a read-write scope will do as well.
5091 pub fn add_scope<St>(mut self, scope: St) -> BackupRunListCall<'a, C>
5092 where
5093 St: AsRef<str>,
5094 {
5095 self._scopes.insert(String::from(scope.as_ref()));
5096 self
5097 }
5098 /// Identifies the authorization scope(s) for the method you are building.
5099 ///
5100 /// See [`Self::add_scope()`] for details.
5101 pub fn add_scopes<I, St>(mut self, scopes: I) -> BackupRunListCall<'a, C>
5102 where
5103 I: IntoIterator<Item = St>,
5104 St: AsRef<str>,
5105 {
5106 self._scopes
5107 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5108 self
5109 }
5110
5111 /// Removes all scopes, and no default scope will be used either.
5112 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5113 /// for details).
5114 pub fn clear_scopes(mut self) -> BackupRunListCall<'a, C> {
5115 self._scopes.clear();
5116 self
5117 }
5118}
5119
5120/// Deletes a database from a Cloud SQL instance.
5121///
5122/// A builder for the *delete* method supported by a *database* resource.
5123/// It is not used directly, but through a [`DatabaseMethods`] instance.
5124///
5125/// # Example
5126///
5127/// Instantiate a resource method builder
5128///
5129/// ```test_harness,no_run
5130/// # extern crate hyper;
5131/// # extern crate hyper_rustls;
5132/// # extern crate google_sql1_beta4 as sql1_beta4;
5133/// # async fn dox() {
5134/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5135///
5136/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5137/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5138/// # secret,
5139/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5140/// # ).build().await.unwrap();
5141///
5142/// # let client = hyper_util::client::legacy::Client::builder(
5143/// # hyper_util::rt::TokioExecutor::new()
5144/// # )
5145/// # .build(
5146/// # hyper_rustls::HttpsConnectorBuilder::new()
5147/// # .with_native_roots()
5148/// # .unwrap()
5149/// # .https_or_http()
5150/// # .enable_http1()
5151/// # .build()
5152/// # );
5153/// # let mut hub = SQLAdmin::new(client, auth);
5154/// // You can configure optional parameters by calling the respective setters at will, and
5155/// // execute the final call using `doit()`.
5156/// // Values shown here are possibly random and not representative !
5157/// let result = hub.databases().delete("project", "instance", "database")
5158/// .doit().await;
5159/// # }
5160/// ```
5161pub struct DatabaseDeleteCall<'a, C>
5162where
5163 C: 'a,
5164{
5165 hub: &'a SQLAdmin<C>,
5166 _project: String,
5167 _instance: String,
5168 _database: String,
5169 _delegate: Option<&'a mut dyn common::Delegate>,
5170 _additional_params: HashMap<String, String>,
5171 _scopes: BTreeSet<String>,
5172}
5173
5174impl<'a, C> common::CallBuilder for DatabaseDeleteCall<'a, C> {}
5175
5176impl<'a, C> DatabaseDeleteCall<'a, C>
5177where
5178 C: common::Connector,
5179{
5180 /// Perform the operation you have build so far.
5181 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5182 use std::borrow::Cow;
5183 use std::io::{Read, Seek};
5184
5185 use common::{url::Params, ToParts};
5186 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5187
5188 let mut dd = common::DefaultDelegate;
5189 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5190 dlg.begin(common::MethodInfo {
5191 id: "sql.databases.delete",
5192 http_method: hyper::Method::DELETE,
5193 });
5194
5195 for &field in ["alt", "project", "instance", "database"].iter() {
5196 if self._additional_params.contains_key(field) {
5197 dlg.finished(false);
5198 return Err(common::Error::FieldClash(field));
5199 }
5200 }
5201
5202 let mut params = Params::with_capacity(5 + self._additional_params.len());
5203 params.push("project", self._project);
5204 params.push("instance", self._instance);
5205 params.push("database", self._database);
5206
5207 params.extend(self._additional_params.iter());
5208
5209 params.push("alt", "json");
5210 let mut url = self.hub._base_url.clone()
5211 + "sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}";
5212 if self._scopes.is_empty() {
5213 self._scopes
5214 .insert(Scope::CloudPlatform.as_ref().to_string());
5215 }
5216
5217 #[allow(clippy::single_element_loop)]
5218 for &(find_this, param_name) in [
5219 ("{project}", "project"),
5220 ("{instance}", "instance"),
5221 ("{database}", "database"),
5222 ]
5223 .iter()
5224 {
5225 url = params.uri_replacement(url, param_name, find_this, false);
5226 }
5227 {
5228 let to_remove = ["database", "instance", "project"];
5229 params.remove_params(&to_remove);
5230 }
5231
5232 let url = params.parse_with_url(&url);
5233
5234 loop {
5235 let token = match self
5236 .hub
5237 .auth
5238 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5239 .await
5240 {
5241 Ok(token) => token,
5242 Err(e) => match dlg.token(e) {
5243 Ok(token) => token,
5244 Err(e) => {
5245 dlg.finished(false);
5246 return Err(common::Error::MissingToken(e));
5247 }
5248 },
5249 };
5250 let mut req_result = {
5251 let client = &self.hub.client;
5252 dlg.pre_request();
5253 let mut req_builder = hyper::Request::builder()
5254 .method(hyper::Method::DELETE)
5255 .uri(url.as_str())
5256 .header(USER_AGENT, self.hub._user_agent.clone());
5257
5258 if let Some(token) = token.as_ref() {
5259 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5260 }
5261
5262 let request = req_builder
5263 .header(CONTENT_LENGTH, 0_u64)
5264 .body(common::to_body::<String>(None));
5265
5266 client.request(request.unwrap()).await
5267 };
5268
5269 match req_result {
5270 Err(err) => {
5271 if let common::Retry::After(d) = dlg.http_error(&err) {
5272 sleep(d).await;
5273 continue;
5274 }
5275 dlg.finished(false);
5276 return Err(common::Error::HttpError(err));
5277 }
5278 Ok(res) => {
5279 let (mut parts, body) = res.into_parts();
5280 let mut body = common::Body::new(body);
5281 if !parts.status.is_success() {
5282 let bytes = common::to_bytes(body).await.unwrap_or_default();
5283 let error = serde_json::from_str(&common::to_string(&bytes));
5284 let response = common::to_response(parts, bytes.into());
5285
5286 if let common::Retry::After(d) =
5287 dlg.http_failure(&response, error.as_ref().ok())
5288 {
5289 sleep(d).await;
5290 continue;
5291 }
5292
5293 dlg.finished(false);
5294
5295 return Err(match error {
5296 Ok(value) => common::Error::BadRequest(value),
5297 _ => common::Error::Failure(response),
5298 });
5299 }
5300 let response = {
5301 let bytes = common::to_bytes(body).await.unwrap_or_default();
5302 let encoded = common::to_string(&bytes);
5303 match serde_json::from_str(&encoded) {
5304 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5305 Err(error) => {
5306 dlg.response_json_decode_error(&encoded, &error);
5307 return Err(common::Error::JsonDecodeError(
5308 encoded.to_string(),
5309 error,
5310 ));
5311 }
5312 }
5313 };
5314
5315 dlg.finished(true);
5316 return Ok(response);
5317 }
5318 }
5319 }
5320 }
5321
5322 /// Project ID of the project that contains the instance.
5323 ///
5324 /// Sets the *project* path property to the given value.
5325 ///
5326 /// Even though the property as already been set when instantiating this call,
5327 /// we provide this method for API completeness.
5328 pub fn project(mut self, new_value: &str) -> DatabaseDeleteCall<'a, C> {
5329 self._project = new_value.to_string();
5330 self
5331 }
5332 /// Database instance ID. This does not include the project ID.
5333 ///
5334 /// Sets the *instance* path property to the given value.
5335 ///
5336 /// Even though the property as already been set when instantiating this call,
5337 /// we provide this method for API completeness.
5338 pub fn instance(mut self, new_value: &str) -> DatabaseDeleteCall<'a, C> {
5339 self._instance = new_value.to_string();
5340 self
5341 }
5342 /// Name of the database to be deleted in the instance.
5343 ///
5344 /// Sets the *database* path property to the given value.
5345 ///
5346 /// Even though the property as already been set when instantiating this call,
5347 /// we provide this method for API completeness.
5348 pub fn database(mut self, new_value: &str) -> DatabaseDeleteCall<'a, C> {
5349 self._database = new_value.to_string();
5350 self
5351 }
5352 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5353 /// while executing the actual API request.
5354 ///
5355 /// ````text
5356 /// It should be used to handle progress information, and to implement a certain level of resilience.
5357 /// ````
5358 ///
5359 /// Sets the *delegate* property to the given value.
5360 pub fn delegate(
5361 mut self,
5362 new_value: &'a mut dyn common::Delegate,
5363 ) -> DatabaseDeleteCall<'a, C> {
5364 self._delegate = Some(new_value);
5365 self
5366 }
5367
5368 /// Set any additional parameter of the query string used in the request.
5369 /// It should be used to set parameters which are not yet available through their own
5370 /// setters.
5371 ///
5372 /// Please note that this method must not be used to set any of the known parameters
5373 /// which have their own setter method. If done anyway, the request will fail.
5374 ///
5375 /// # Additional Parameters
5376 ///
5377 /// * *$.xgafv* (query-string) - V1 error format.
5378 /// * *access_token* (query-string) - OAuth access token.
5379 /// * *alt* (query-string) - Data format for response.
5380 /// * *callback* (query-string) - JSONP
5381 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5382 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5383 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5384 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5385 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5386 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5387 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5388 pub fn param<T>(mut self, name: T, value: T) -> DatabaseDeleteCall<'a, C>
5389 where
5390 T: AsRef<str>,
5391 {
5392 self._additional_params
5393 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5394 self
5395 }
5396
5397 /// Identifies the authorization scope for the method you are building.
5398 ///
5399 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5400 /// [`Scope::CloudPlatform`].
5401 ///
5402 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5403 /// tokens for more than one scope.
5404 ///
5405 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5406 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5407 /// sufficient, a read-write scope will do as well.
5408 pub fn add_scope<St>(mut self, scope: St) -> DatabaseDeleteCall<'a, C>
5409 where
5410 St: AsRef<str>,
5411 {
5412 self._scopes.insert(String::from(scope.as_ref()));
5413 self
5414 }
5415 /// Identifies the authorization scope(s) for the method you are building.
5416 ///
5417 /// See [`Self::add_scope()`] for details.
5418 pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseDeleteCall<'a, C>
5419 where
5420 I: IntoIterator<Item = St>,
5421 St: AsRef<str>,
5422 {
5423 self._scopes
5424 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5425 self
5426 }
5427
5428 /// Removes all scopes, and no default scope will be used either.
5429 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5430 /// for details).
5431 pub fn clear_scopes(mut self) -> DatabaseDeleteCall<'a, C> {
5432 self._scopes.clear();
5433 self
5434 }
5435}
5436
5437/// Retrieves a resource containing information about a database inside a Cloud
5438/// SQL instance.
5439///
5440/// A builder for the *get* method supported by a *database* resource.
5441/// It is not used directly, but through a [`DatabaseMethods`] instance.
5442///
5443/// # Example
5444///
5445/// Instantiate a resource method builder
5446///
5447/// ```test_harness,no_run
5448/// # extern crate hyper;
5449/// # extern crate hyper_rustls;
5450/// # extern crate google_sql1_beta4 as sql1_beta4;
5451/// # async fn dox() {
5452/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5453///
5454/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5455/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5456/// # secret,
5457/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5458/// # ).build().await.unwrap();
5459///
5460/// # let client = hyper_util::client::legacy::Client::builder(
5461/// # hyper_util::rt::TokioExecutor::new()
5462/// # )
5463/// # .build(
5464/// # hyper_rustls::HttpsConnectorBuilder::new()
5465/// # .with_native_roots()
5466/// # .unwrap()
5467/// # .https_or_http()
5468/// # .enable_http1()
5469/// # .build()
5470/// # );
5471/// # let mut hub = SQLAdmin::new(client, auth);
5472/// // You can configure optional parameters by calling the respective setters at will, and
5473/// // execute the final call using `doit()`.
5474/// // Values shown here are possibly random and not representative !
5475/// let result = hub.databases().get("project", "instance", "database")
5476/// .doit().await;
5477/// # }
5478/// ```
5479pub struct DatabaseGetCall<'a, C>
5480where
5481 C: 'a,
5482{
5483 hub: &'a SQLAdmin<C>,
5484 _project: String,
5485 _instance: String,
5486 _database: String,
5487 _delegate: Option<&'a mut dyn common::Delegate>,
5488 _additional_params: HashMap<String, String>,
5489 _scopes: BTreeSet<String>,
5490}
5491
5492impl<'a, C> common::CallBuilder for DatabaseGetCall<'a, C> {}
5493
5494impl<'a, C> DatabaseGetCall<'a, C>
5495where
5496 C: common::Connector,
5497{
5498 /// Perform the operation you have build so far.
5499 pub async fn doit(mut self) -> common::Result<(common::Response, Database)> {
5500 use std::borrow::Cow;
5501 use std::io::{Read, Seek};
5502
5503 use common::{url::Params, ToParts};
5504 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5505
5506 let mut dd = common::DefaultDelegate;
5507 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5508 dlg.begin(common::MethodInfo {
5509 id: "sql.databases.get",
5510 http_method: hyper::Method::GET,
5511 });
5512
5513 for &field in ["alt", "project", "instance", "database"].iter() {
5514 if self._additional_params.contains_key(field) {
5515 dlg.finished(false);
5516 return Err(common::Error::FieldClash(field));
5517 }
5518 }
5519
5520 let mut params = Params::with_capacity(5 + self._additional_params.len());
5521 params.push("project", self._project);
5522 params.push("instance", self._instance);
5523 params.push("database", self._database);
5524
5525 params.extend(self._additional_params.iter());
5526
5527 params.push("alt", "json");
5528 let mut url = self.hub._base_url.clone()
5529 + "sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}";
5530 if self._scopes.is_empty() {
5531 self._scopes
5532 .insert(Scope::CloudPlatform.as_ref().to_string());
5533 }
5534
5535 #[allow(clippy::single_element_loop)]
5536 for &(find_this, param_name) in [
5537 ("{project}", "project"),
5538 ("{instance}", "instance"),
5539 ("{database}", "database"),
5540 ]
5541 .iter()
5542 {
5543 url = params.uri_replacement(url, param_name, find_this, false);
5544 }
5545 {
5546 let to_remove = ["database", "instance", "project"];
5547 params.remove_params(&to_remove);
5548 }
5549
5550 let url = params.parse_with_url(&url);
5551
5552 loop {
5553 let token = match self
5554 .hub
5555 .auth
5556 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5557 .await
5558 {
5559 Ok(token) => token,
5560 Err(e) => match dlg.token(e) {
5561 Ok(token) => token,
5562 Err(e) => {
5563 dlg.finished(false);
5564 return Err(common::Error::MissingToken(e));
5565 }
5566 },
5567 };
5568 let mut req_result = {
5569 let client = &self.hub.client;
5570 dlg.pre_request();
5571 let mut req_builder = hyper::Request::builder()
5572 .method(hyper::Method::GET)
5573 .uri(url.as_str())
5574 .header(USER_AGENT, self.hub._user_agent.clone());
5575
5576 if let Some(token) = token.as_ref() {
5577 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5578 }
5579
5580 let request = req_builder
5581 .header(CONTENT_LENGTH, 0_u64)
5582 .body(common::to_body::<String>(None));
5583
5584 client.request(request.unwrap()).await
5585 };
5586
5587 match req_result {
5588 Err(err) => {
5589 if let common::Retry::After(d) = dlg.http_error(&err) {
5590 sleep(d).await;
5591 continue;
5592 }
5593 dlg.finished(false);
5594 return Err(common::Error::HttpError(err));
5595 }
5596 Ok(res) => {
5597 let (mut parts, body) = res.into_parts();
5598 let mut body = common::Body::new(body);
5599 if !parts.status.is_success() {
5600 let bytes = common::to_bytes(body).await.unwrap_or_default();
5601 let error = serde_json::from_str(&common::to_string(&bytes));
5602 let response = common::to_response(parts, bytes.into());
5603
5604 if let common::Retry::After(d) =
5605 dlg.http_failure(&response, error.as_ref().ok())
5606 {
5607 sleep(d).await;
5608 continue;
5609 }
5610
5611 dlg.finished(false);
5612
5613 return Err(match error {
5614 Ok(value) => common::Error::BadRequest(value),
5615 _ => common::Error::Failure(response),
5616 });
5617 }
5618 let response = {
5619 let bytes = common::to_bytes(body).await.unwrap_or_default();
5620 let encoded = common::to_string(&bytes);
5621 match serde_json::from_str(&encoded) {
5622 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5623 Err(error) => {
5624 dlg.response_json_decode_error(&encoded, &error);
5625 return Err(common::Error::JsonDecodeError(
5626 encoded.to_string(),
5627 error,
5628 ));
5629 }
5630 }
5631 };
5632
5633 dlg.finished(true);
5634 return Ok(response);
5635 }
5636 }
5637 }
5638 }
5639
5640 /// Project ID of the project that contains the instance.
5641 ///
5642 /// Sets the *project* path property to the given value.
5643 ///
5644 /// Even though the property as already been set when instantiating this call,
5645 /// we provide this method for API completeness.
5646 pub fn project(mut self, new_value: &str) -> DatabaseGetCall<'a, C> {
5647 self._project = new_value.to_string();
5648 self
5649 }
5650 /// Database instance ID. This does not include the project ID.
5651 ///
5652 /// Sets the *instance* path property to the given value.
5653 ///
5654 /// Even though the property as already been set when instantiating this call,
5655 /// we provide this method for API completeness.
5656 pub fn instance(mut self, new_value: &str) -> DatabaseGetCall<'a, C> {
5657 self._instance = new_value.to_string();
5658 self
5659 }
5660 /// Name of the database in the instance.
5661 ///
5662 /// Sets the *database* path property to the given value.
5663 ///
5664 /// Even though the property as already been set when instantiating this call,
5665 /// we provide this method for API completeness.
5666 pub fn database(mut self, new_value: &str) -> DatabaseGetCall<'a, C> {
5667 self._database = new_value.to_string();
5668 self
5669 }
5670 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5671 /// while executing the actual API request.
5672 ///
5673 /// ````text
5674 /// It should be used to handle progress information, and to implement a certain level of resilience.
5675 /// ````
5676 ///
5677 /// Sets the *delegate* property to the given value.
5678 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DatabaseGetCall<'a, C> {
5679 self._delegate = Some(new_value);
5680 self
5681 }
5682
5683 /// Set any additional parameter of the query string used in the request.
5684 /// It should be used to set parameters which are not yet available through their own
5685 /// setters.
5686 ///
5687 /// Please note that this method must not be used to set any of the known parameters
5688 /// which have their own setter method. If done anyway, the request will fail.
5689 ///
5690 /// # Additional Parameters
5691 ///
5692 /// * *$.xgafv* (query-string) - V1 error format.
5693 /// * *access_token* (query-string) - OAuth access token.
5694 /// * *alt* (query-string) - Data format for response.
5695 /// * *callback* (query-string) - JSONP
5696 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5697 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5698 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5699 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5700 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5701 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5702 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5703 pub fn param<T>(mut self, name: T, value: T) -> DatabaseGetCall<'a, C>
5704 where
5705 T: AsRef<str>,
5706 {
5707 self._additional_params
5708 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5709 self
5710 }
5711
5712 /// Identifies the authorization scope for the method you are building.
5713 ///
5714 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5715 /// [`Scope::CloudPlatform`].
5716 ///
5717 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5718 /// tokens for more than one scope.
5719 ///
5720 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5721 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5722 /// sufficient, a read-write scope will do as well.
5723 pub fn add_scope<St>(mut self, scope: St) -> DatabaseGetCall<'a, C>
5724 where
5725 St: AsRef<str>,
5726 {
5727 self._scopes.insert(String::from(scope.as_ref()));
5728 self
5729 }
5730 /// Identifies the authorization scope(s) for the method you are building.
5731 ///
5732 /// See [`Self::add_scope()`] for details.
5733 pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseGetCall<'a, C>
5734 where
5735 I: IntoIterator<Item = St>,
5736 St: AsRef<str>,
5737 {
5738 self._scopes
5739 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5740 self
5741 }
5742
5743 /// Removes all scopes, and no default scope will be used either.
5744 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5745 /// for details).
5746 pub fn clear_scopes(mut self) -> DatabaseGetCall<'a, C> {
5747 self._scopes.clear();
5748 self
5749 }
5750}
5751
5752/// Inserts a resource containing information about a database inside a Cloud
5753/// SQL instance.
5754///
5755/// A builder for the *insert* method supported by a *database* resource.
5756/// It is not used directly, but through a [`DatabaseMethods`] instance.
5757///
5758/// # Example
5759///
5760/// Instantiate a resource method builder
5761///
5762/// ```test_harness,no_run
5763/// # extern crate hyper;
5764/// # extern crate hyper_rustls;
5765/// # extern crate google_sql1_beta4 as sql1_beta4;
5766/// use sql1_beta4::api::Database;
5767/// # async fn dox() {
5768/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5769///
5770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5771/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5772/// # secret,
5773/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5774/// # ).build().await.unwrap();
5775///
5776/// # let client = hyper_util::client::legacy::Client::builder(
5777/// # hyper_util::rt::TokioExecutor::new()
5778/// # )
5779/// # .build(
5780/// # hyper_rustls::HttpsConnectorBuilder::new()
5781/// # .with_native_roots()
5782/// # .unwrap()
5783/// # .https_or_http()
5784/// # .enable_http1()
5785/// # .build()
5786/// # );
5787/// # let mut hub = SQLAdmin::new(client, auth);
5788/// // As the method needs a request, you would usually fill it with the desired information
5789/// // into the respective structure. Some of the parts shown here might not be applicable !
5790/// // Values shown here are possibly random and not representative !
5791/// let mut req = Database::default();
5792///
5793/// // You can configure optional parameters by calling the respective setters at will, and
5794/// // execute the final call using `doit()`.
5795/// // Values shown here are possibly random and not representative !
5796/// let result = hub.databases().insert(req, "project", "instance")
5797/// .doit().await;
5798/// # }
5799/// ```
5800pub struct DatabaseInsertCall<'a, C>
5801where
5802 C: 'a,
5803{
5804 hub: &'a SQLAdmin<C>,
5805 _request: Database,
5806 _project: String,
5807 _instance: String,
5808 _delegate: Option<&'a mut dyn common::Delegate>,
5809 _additional_params: HashMap<String, String>,
5810 _scopes: BTreeSet<String>,
5811}
5812
5813impl<'a, C> common::CallBuilder for DatabaseInsertCall<'a, C> {}
5814
5815impl<'a, C> DatabaseInsertCall<'a, C>
5816where
5817 C: common::Connector,
5818{
5819 /// Perform the operation you have build so far.
5820 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5821 use std::borrow::Cow;
5822 use std::io::{Read, Seek};
5823
5824 use common::{url::Params, ToParts};
5825 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5826
5827 let mut dd = common::DefaultDelegate;
5828 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5829 dlg.begin(common::MethodInfo {
5830 id: "sql.databases.insert",
5831 http_method: hyper::Method::POST,
5832 });
5833
5834 for &field in ["alt", "project", "instance"].iter() {
5835 if self._additional_params.contains_key(field) {
5836 dlg.finished(false);
5837 return Err(common::Error::FieldClash(field));
5838 }
5839 }
5840
5841 let mut params = Params::with_capacity(5 + self._additional_params.len());
5842 params.push("project", self._project);
5843 params.push("instance", self._instance);
5844
5845 params.extend(self._additional_params.iter());
5846
5847 params.push("alt", "json");
5848 let mut url = self.hub._base_url.clone()
5849 + "sql/v1beta4/projects/{project}/instances/{instance}/databases";
5850 if self._scopes.is_empty() {
5851 self._scopes
5852 .insert(Scope::CloudPlatform.as_ref().to_string());
5853 }
5854
5855 #[allow(clippy::single_element_loop)]
5856 for &(find_this, param_name) in
5857 [("{project}", "project"), ("{instance}", "instance")].iter()
5858 {
5859 url = params.uri_replacement(url, param_name, find_this, false);
5860 }
5861 {
5862 let to_remove = ["instance", "project"];
5863 params.remove_params(&to_remove);
5864 }
5865
5866 let url = params.parse_with_url(&url);
5867
5868 let mut json_mime_type = mime::APPLICATION_JSON;
5869 let mut request_value_reader = {
5870 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5871 common::remove_json_null_values(&mut value);
5872 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5873 serde_json::to_writer(&mut dst, &value).unwrap();
5874 dst
5875 };
5876 let request_size = request_value_reader
5877 .seek(std::io::SeekFrom::End(0))
5878 .unwrap();
5879 request_value_reader
5880 .seek(std::io::SeekFrom::Start(0))
5881 .unwrap();
5882
5883 loop {
5884 let token = match self
5885 .hub
5886 .auth
5887 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5888 .await
5889 {
5890 Ok(token) => token,
5891 Err(e) => match dlg.token(e) {
5892 Ok(token) => token,
5893 Err(e) => {
5894 dlg.finished(false);
5895 return Err(common::Error::MissingToken(e));
5896 }
5897 },
5898 };
5899 request_value_reader
5900 .seek(std::io::SeekFrom::Start(0))
5901 .unwrap();
5902 let mut req_result = {
5903 let client = &self.hub.client;
5904 dlg.pre_request();
5905 let mut req_builder = hyper::Request::builder()
5906 .method(hyper::Method::POST)
5907 .uri(url.as_str())
5908 .header(USER_AGENT, self.hub._user_agent.clone());
5909
5910 if let Some(token) = token.as_ref() {
5911 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5912 }
5913
5914 let request = req_builder
5915 .header(CONTENT_TYPE, json_mime_type.to_string())
5916 .header(CONTENT_LENGTH, request_size as u64)
5917 .body(common::to_body(
5918 request_value_reader.get_ref().clone().into(),
5919 ));
5920
5921 client.request(request.unwrap()).await
5922 };
5923
5924 match req_result {
5925 Err(err) => {
5926 if let common::Retry::After(d) = dlg.http_error(&err) {
5927 sleep(d).await;
5928 continue;
5929 }
5930 dlg.finished(false);
5931 return Err(common::Error::HttpError(err));
5932 }
5933 Ok(res) => {
5934 let (mut parts, body) = res.into_parts();
5935 let mut body = common::Body::new(body);
5936 if !parts.status.is_success() {
5937 let bytes = common::to_bytes(body).await.unwrap_or_default();
5938 let error = serde_json::from_str(&common::to_string(&bytes));
5939 let response = common::to_response(parts, bytes.into());
5940
5941 if let common::Retry::After(d) =
5942 dlg.http_failure(&response, error.as_ref().ok())
5943 {
5944 sleep(d).await;
5945 continue;
5946 }
5947
5948 dlg.finished(false);
5949
5950 return Err(match error {
5951 Ok(value) => common::Error::BadRequest(value),
5952 _ => common::Error::Failure(response),
5953 });
5954 }
5955 let response = {
5956 let bytes = common::to_bytes(body).await.unwrap_or_default();
5957 let encoded = common::to_string(&bytes);
5958 match serde_json::from_str(&encoded) {
5959 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5960 Err(error) => {
5961 dlg.response_json_decode_error(&encoded, &error);
5962 return Err(common::Error::JsonDecodeError(
5963 encoded.to_string(),
5964 error,
5965 ));
5966 }
5967 }
5968 };
5969
5970 dlg.finished(true);
5971 return Ok(response);
5972 }
5973 }
5974 }
5975 }
5976
5977 ///
5978 /// Sets the *request* property to the given value.
5979 ///
5980 /// Even though the property as already been set when instantiating this call,
5981 /// we provide this method for API completeness.
5982 pub fn request(mut self, new_value: Database) -> DatabaseInsertCall<'a, C> {
5983 self._request = new_value;
5984 self
5985 }
5986 /// Project ID of the project that contains the instance.
5987 ///
5988 /// Sets the *project* path property to the given value.
5989 ///
5990 /// Even though the property as already been set when instantiating this call,
5991 /// we provide this method for API completeness.
5992 pub fn project(mut self, new_value: &str) -> DatabaseInsertCall<'a, C> {
5993 self._project = new_value.to_string();
5994 self
5995 }
5996 /// Database instance ID. This does not include the project ID.
5997 ///
5998 /// Sets the *instance* path property to the given value.
5999 ///
6000 /// Even though the property as already been set when instantiating this call,
6001 /// we provide this method for API completeness.
6002 pub fn instance(mut self, new_value: &str) -> DatabaseInsertCall<'a, C> {
6003 self._instance = new_value.to_string();
6004 self
6005 }
6006 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6007 /// while executing the actual API request.
6008 ///
6009 /// ````text
6010 /// It should be used to handle progress information, and to implement a certain level of resilience.
6011 /// ````
6012 ///
6013 /// Sets the *delegate* property to the given value.
6014 pub fn delegate(
6015 mut self,
6016 new_value: &'a mut dyn common::Delegate,
6017 ) -> DatabaseInsertCall<'a, C> {
6018 self._delegate = Some(new_value);
6019 self
6020 }
6021
6022 /// Set any additional parameter of the query string used in the request.
6023 /// It should be used to set parameters which are not yet available through their own
6024 /// setters.
6025 ///
6026 /// Please note that this method must not be used to set any of the known parameters
6027 /// which have their own setter method. If done anyway, the request will fail.
6028 ///
6029 /// # Additional Parameters
6030 ///
6031 /// * *$.xgafv* (query-string) - V1 error format.
6032 /// * *access_token* (query-string) - OAuth access token.
6033 /// * *alt* (query-string) - Data format for response.
6034 /// * *callback* (query-string) - JSONP
6035 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6036 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6037 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6038 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6039 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6040 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6041 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6042 pub fn param<T>(mut self, name: T, value: T) -> DatabaseInsertCall<'a, C>
6043 where
6044 T: AsRef<str>,
6045 {
6046 self._additional_params
6047 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6048 self
6049 }
6050
6051 /// Identifies the authorization scope for the method you are building.
6052 ///
6053 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6054 /// [`Scope::CloudPlatform`].
6055 ///
6056 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6057 /// tokens for more than one scope.
6058 ///
6059 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6060 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6061 /// sufficient, a read-write scope will do as well.
6062 pub fn add_scope<St>(mut self, scope: St) -> DatabaseInsertCall<'a, C>
6063 where
6064 St: AsRef<str>,
6065 {
6066 self._scopes.insert(String::from(scope.as_ref()));
6067 self
6068 }
6069 /// Identifies the authorization scope(s) for the method you are building.
6070 ///
6071 /// See [`Self::add_scope()`] for details.
6072 pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseInsertCall<'a, C>
6073 where
6074 I: IntoIterator<Item = St>,
6075 St: AsRef<str>,
6076 {
6077 self._scopes
6078 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6079 self
6080 }
6081
6082 /// Removes all scopes, and no default scope will be used either.
6083 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6084 /// for details).
6085 pub fn clear_scopes(mut self) -> DatabaseInsertCall<'a, C> {
6086 self._scopes.clear();
6087 self
6088 }
6089}
6090
6091/// Lists databases in the specified Cloud SQL instance.
6092///
6093/// A builder for the *list* method supported by a *database* resource.
6094/// It is not used directly, but through a [`DatabaseMethods`] instance.
6095///
6096/// # Example
6097///
6098/// Instantiate a resource method builder
6099///
6100/// ```test_harness,no_run
6101/// # extern crate hyper;
6102/// # extern crate hyper_rustls;
6103/// # extern crate google_sql1_beta4 as sql1_beta4;
6104/// # async fn dox() {
6105/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6106///
6107/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6108/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6109/// # secret,
6110/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6111/// # ).build().await.unwrap();
6112///
6113/// # let client = hyper_util::client::legacy::Client::builder(
6114/// # hyper_util::rt::TokioExecutor::new()
6115/// # )
6116/// # .build(
6117/// # hyper_rustls::HttpsConnectorBuilder::new()
6118/// # .with_native_roots()
6119/// # .unwrap()
6120/// # .https_or_http()
6121/// # .enable_http1()
6122/// # .build()
6123/// # );
6124/// # let mut hub = SQLAdmin::new(client, auth);
6125/// // You can configure optional parameters by calling the respective setters at will, and
6126/// // execute the final call using `doit()`.
6127/// // Values shown here are possibly random and not representative !
6128/// let result = hub.databases().list("project", "instance")
6129/// .doit().await;
6130/// # }
6131/// ```
6132pub struct DatabaseListCall<'a, C>
6133where
6134 C: 'a,
6135{
6136 hub: &'a SQLAdmin<C>,
6137 _project: String,
6138 _instance: String,
6139 _delegate: Option<&'a mut dyn common::Delegate>,
6140 _additional_params: HashMap<String, String>,
6141 _scopes: BTreeSet<String>,
6142}
6143
6144impl<'a, C> common::CallBuilder for DatabaseListCall<'a, C> {}
6145
6146impl<'a, C> DatabaseListCall<'a, C>
6147where
6148 C: common::Connector,
6149{
6150 /// Perform the operation you have build so far.
6151 pub async fn doit(mut self) -> common::Result<(common::Response, DatabasesListResponse)> {
6152 use std::borrow::Cow;
6153 use std::io::{Read, Seek};
6154
6155 use common::{url::Params, ToParts};
6156 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6157
6158 let mut dd = common::DefaultDelegate;
6159 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6160 dlg.begin(common::MethodInfo {
6161 id: "sql.databases.list",
6162 http_method: hyper::Method::GET,
6163 });
6164
6165 for &field in ["alt", "project", "instance"].iter() {
6166 if self._additional_params.contains_key(field) {
6167 dlg.finished(false);
6168 return Err(common::Error::FieldClash(field));
6169 }
6170 }
6171
6172 let mut params = Params::with_capacity(4 + self._additional_params.len());
6173 params.push("project", self._project);
6174 params.push("instance", self._instance);
6175
6176 params.extend(self._additional_params.iter());
6177
6178 params.push("alt", "json");
6179 let mut url = self.hub._base_url.clone()
6180 + "sql/v1beta4/projects/{project}/instances/{instance}/databases";
6181 if self._scopes.is_empty() {
6182 self._scopes
6183 .insert(Scope::CloudPlatform.as_ref().to_string());
6184 }
6185
6186 #[allow(clippy::single_element_loop)]
6187 for &(find_this, param_name) in
6188 [("{project}", "project"), ("{instance}", "instance")].iter()
6189 {
6190 url = params.uri_replacement(url, param_name, find_this, false);
6191 }
6192 {
6193 let to_remove = ["instance", "project"];
6194 params.remove_params(&to_remove);
6195 }
6196
6197 let url = params.parse_with_url(&url);
6198
6199 loop {
6200 let token = match self
6201 .hub
6202 .auth
6203 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6204 .await
6205 {
6206 Ok(token) => token,
6207 Err(e) => match dlg.token(e) {
6208 Ok(token) => token,
6209 Err(e) => {
6210 dlg.finished(false);
6211 return Err(common::Error::MissingToken(e));
6212 }
6213 },
6214 };
6215 let mut req_result = {
6216 let client = &self.hub.client;
6217 dlg.pre_request();
6218 let mut req_builder = hyper::Request::builder()
6219 .method(hyper::Method::GET)
6220 .uri(url.as_str())
6221 .header(USER_AGENT, self.hub._user_agent.clone());
6222
6223 if let Some(token) = token.as_ref() {
6224 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6225 }
6226
6227 let request = req_builder
6228 .header(CONTENT_LENGTH, 0_u64)
6229 .body(common::to_body::<String>(None));
6230
6231 client.request(request.unwrap()).await
6232 };
6233
6234 match req_result {
6235 Err(err) => {
6236 if let common::Retry::After(d) = dlg.http_error(&err) {
6237 sleep(d).await;
6238 continue;
6239 }
6240 dlg.finished(false);
6241 return Err(common::Error::HttpError(err));
6242 }
6243 Ok(res) => {
6244 let (mut parts, body) = res.into_parts();
6245 let mut body = common::Body::new(body);
6246 if !parts.status.is_success() {
6247 let bytes = common::to_bytes(body).await.unwrap_or_default();
6248 let error = serde_json::from_str(&common::to_string(&bytes));
6249 let response = common::to_response(parts, bytes.into());
6250
6251 if let common::Retry::After(d) =
6252 dlg.http_failure(&response, error.as_ref().ok())
6253 {
6254 sleep(d).await;
6255 continue;
6256 }
6257
6258 dlg.finished(false);
6259
6260 return Err(match error {
6261 Ok(value) => common::Error::BadRequest(value),
6262 _ => common::Error::Failure(response),
6263 });
6264 }
6265 let response = {
6266 let bytes = common::to_bytes(body).await.unwrap_or_default();
6267 let encoded = common::to_string(&bytes);
6268 match serde_json::from_str(&encoded) {
6269 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6270 Err(error) => {
6271 dlg.response_json_decode_error(&encoded, &error);
6272 return Err(common::Error::JsonDecodeError(
6273 encoded.to_string(),
6274 error,
6275 ));
6276 }
6277 }
6278 };
6279
6280 dlg.finished(true);
6281 return Ok(response);
6282 }
6283 }
6284 }
6285 }
6286
6287 /// Project ID of the project that contains the instance.
6288 ///
6289 /// Sets the *project* path property to the given value.
6290 ///
6291 /// Even though the property as already been set when instantiating this call,
6292 /// we provide this method for API completeness.
6293 pub fn project(mut self, new_value: &str) -> DatabaseListCall<'a, C> {
6294 self._project = new_value.to_string();
6295 self
6296 }
6297 /// Cloud SQL instance ID. This does not include the project ID.
6298 ///
6299 /// Sets the *instance* path property to the given value.
6300 ///
6301 /// Even though the property as already been set when instantiating this call,
6302 /// we provide this method for API completeness.
6303 pub fn instance(mut self, new_value: &str) -> DatabaseListCall<'a, C> {
6304 self._instance = new_value.to_string();
6305 self
6306 }
6307 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6308 /// while executing the actual API request.
6309 ///
6310 /// ````text
6311 /// It should be used to handle progress information, and to implement a certain level of resilience.
6312 /// ````
6313 ///
6314 /// Sets the *delegate* property to the given value.
6315 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DatabaseListCall<'a, C> {
6316 self._delegate = Some(new_value);
6317 self
6318 }
6319
6320 /// Set any additional parameter of the query string used in the request.
6321 /// It should be used to set parameters which are not yet available through their own
6322 /// setters.
6323 ///
6324 /// Please note that this method must not be used to set any of the known parameters
6325 /// which have their own setter method. If done anyway, the request will fail.
6326 ///
6327 /// # Additional Parameters
6328 ///
6329 /// * *$.xgafv* (query-string) - V1 error format.
6330 /// * *access_token* (query-string) - OAuth access token.
6331 /// * *alt* (query-string) - Data format for response.
6332 /// * *callback* (query-string) - JSONP
6333 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6334 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6335 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6336 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6337 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6338 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6339 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6340 pub fn param<T>(mut self, name: T, value: T) -> DatabaseListCall<'a, C>
6341 where
6342 T: AsRef<str>,
6343 {
6344 self._additional_params
6345 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6346 self
6347 }
6348
6349 /// Identifies the authorization scope for the method you are building.
6350 ///
6351 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6352 /// [`Scope::CloudPlatform`].
6353 ///
6354 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6355 /// tokens for more than one scope.
6356 ///
6357 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6358 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6359 /// sufficient, a read-write scope will do as well.
6360 pub fn add_scope<St>(mut self, scope: St) -> DatabaseListCall<'a, C>
6361 where
6362 St: AsRef<str>,
6363 {
6364 self._scopes.insert(String::from(scope.as_ref()));
6365 self
6366 }
6367 /// Identifies the authorization scope(s) for the method you are building.
6368 ///
6369 /// See [`Self::add_scope()`] for details.
6370 pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseListCall<'a, C>
6371 where
6372 I: IntoIterator<Item = St>,
6373 St: AsRef<str>,
6374 {
6375 self._scopes
6376 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6377 self
6378 }
6379
6380 /// Removes all scopes, and no default scope will be used either.
6381 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6382 /// for details).
6383 pub fn clear_scopes(mut self) -> DatabaseListCall<'a, C> {
6384 self._scopes.clear();
6385 self
6386 }
6387}
6388
6389/// Partially updates a resource containing information about a database inside
6390/// a Cloud SQL instance. This method supports patch semantics.
6391///
6392/// A builder for the *patch* method supported by a *database* resource.
6393/// It is not used directly, but through a [`DatabaseMethods`] instance.
6394///
6395/// # Example
6396///
6397/// Instantiate a resource method builder
6398///
6399/// ```test_harness,no_run
6400/// # extern crate hyper;
6401/// # extern crate hyper_rustls;
6402/// # extern crate google_sql1_beta4 as sql1_beta4;
6403/// use sql1_beta4::api::Database;
6404/// # async fn dox() {
6405/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6406///
6407/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6408/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6409/// # secret,
6410/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6411/// # ).build().await.unwrap();
6412///
6413/// # let client = hyper_util::client::legacy::Client::builder(
6414/// # hyper_util::rt::TokioExecutor::new()
6415/// # )
6416/// # .build(
6417/// # hyper_rustls::HttpsConnectorBuilder::new()
6418/// # .with_native_roots()
6419/// # .unwrap()
6420/// # .https_or_http()
6421/// # .enable_http1()
6422/// # .build()
6423/// # );
6424/// # let mut hub = SQLAdmin::new(client, auth);
6425/// // As the method needs a request, you would usually fill it with the desired information
6426/// // into the respective structure. Some of the parts shown here might not be applicable !
6427/// // Values shown here are possibly random and not representative !
6428/// let mut req = Database::default();
6429///
6430/// // You can configure optional parameters by calling the respective setters at will, and
6431/// // execute the final call using `doit()`.
6432/// // Values shown here are possibly random and not representative !
6433/// let result = hub.databases().patch(req, "project", "instance", "database")
6434/// .doit().await;
6435/// # }
6436/// ```
6437pub struct DatabasePatchCall<'a, C>
6438where
6439 C: 'a,
6440{
6441 hub: &'a SQLAdmin<C>,
6442 _request: Database,
6443 _project: String,
6444 _instance: String,
6445 _database: String,
6446 _delegate: Option<&'a mut dyn common::Delegate>,
6447 _additional_params: HashMap<String, String>,
6448 _scopes: BTreeSet<String>,
6449}
6450
6451impl<'a, C> common::CallBuilder for DatabasePatchCall<'a, C> {}
6452
6453impl<'a, C> DatabasePatchCall<'a, C>
6454where
6455 C: common::Connector,
6456{
6457 /// Perform the operation you have build so far.
6458 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6459 use std::borrow::Cow;
6460 use std::io::{Read, Seek};
6461
6462 use common::{url::Params, ToParts};
6463 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6464
6465 let mut dd = common::DefaultDelegate;
6466 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6467 dlg.begin(common::MethodInfo {
6468 id: "sql.databases.patch",
6469 http_method: hyper::Method::PATCH,
6470 });
6471
6472 for &field in ["alt", "project", "instance", "database"].iter() {
6473 if self._additional_params.contains_key(field) {
6474 dlg.finished(false);
6475 return Err(common::Error::FieldClash(field));
6476 }
6477 }
6478
6479 let mut params = Params::with_capacity(6 + self._additional_params.len());
6480 params.push("project", self._project);
6481 params.push("instance", self._instance);
6482 params.push("database", self._database);
6483
6484 params.extend(self._additional_params.iter());
6485
6486 params.push("alt", "json");
6487 let mut url = self.hub._base_url.clone()
6488 + "sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}";
6489 if self._scopes.is_empty() {
6490 self._scopes
6491 .insert(Scope::CloudPlatform.as_ref().to_string());
6492 }
6493
6494 #[allow(clippy::single_element_loop)]
6495 for &(find_this, param_name) in [
6496 ("{project}", "project"),
6497 ("{instance}", "instance"),
6498 ("{database}", "database"),
6499 ]
6500 .iter()
6501 {
6502 url = params.uri_replacement(url, param_name, find_this, false);
6503 }
6504 {
6505 let to_remove = ["database", "instance", "project"];
6506 params.remove_params(&to_remove);
6507 }
6508
6509 let url = params.parse_with_url(&url);
6510
6511 let mut json_mime_type = mime::APPLICATION_JSON;
6512 let mut request_value_reader = {
6513 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6514 common::remove_json_null_values(&mut value);
6515 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6516 serde_json::to_writer(&mut dst, &value).unwrap();
6517 dst
6518 };
6519 let request_size = request_value_reader
6520 .seek(std::io::SeekFrom::End(0))
6521 .unwrap();
6522 request_value_reader
6523 .seek(std::io::SeekFrom::Start(0))
6524 .unwrap();
6525
6526 loop {
6527 let token = match self
6528 .hub
6529 .auth
6530 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6531 .await
6532 {
6533 Ok(token) => token,
6534 Err(e) => match dlg.token(e) {
6535 Ok(token) => token,
6536 Err(e) => {
6537 dlg.finished(false);
6538 return Err(common::Error::MissingToken(e));
6539 }
6540 },
6541 };
6542 request_value_reader
6543 .seek(std::io::SeekFrom::Start(0))
6544 .unwrap();
6545 let mut req_result = {
6546 let client = &self.hub.client;
6547 dlg.pre_request();
6548 let mut req_builder = hyper::Request::builder()
6549 .method(hyper::Method::PATCH)
6550 .uri(url.as_str())
6551 .header(USER_AGENT, self.hub._user_agent.clone());
6552
6553 if let Some(token) = token.as_ref() {
6554 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6555 }
6556
6557 let request = req_builder
6558 .header(CONTENT_TYPE, json_mime_type.to_string())
6559 .header(CONTENT_LENGTH, request_size as u64)
6560 .body(common::to_body(
6561 request_value_reader.get_ref().clone().into(),
6562 ));
6563
6564 client.request(request.unwrap()).await
6565 };
6566
6567 match req_result {
6568 Err(err) => {
6569 if let common::Retry::After(d) = dlg.http_error(&err) {
6570 sleep(d).await;
6571 continue;
6572 }
6573 dlg.finished(false);
6574 return Err(common::Error::HttpError(err));
6575 }
6576 Ok(res) => {
6577 let (mut parts, body) = res.into_parts();
6578 let mut body = common::Body::new(body);
6579 if !parts.status.is_success() {
6580 let bytes = common::to_bytes(body).await.unwrap_or_default();
6581 let error = serde_json::from_str(&common::to_string(&bytes));
6582 let response = common::to_response(parts, bytes.into());
6583
6584 if let common::Retry::After(d) =
6585 dlg.http_failure(&response, error.as_ref().ok())
6586 {
6587 sleep(d).await;
6588 continue;
6589 }
6590
6591 dlg.finished(false);
6592
6593 return Err(match error {
6594 Ok(value) => common::Error::BadRequest(value),
6595 _ => common::Error::Failure(response),
6596 });
6597 }
6598 let response = {
6599 let bytes = common::to_bytes(body).await.unwrap_or_default();
6600 let encoded = common::to_string(&bytes);
6601 match serde_json::from_str(&encoded) {
6602 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6603 Err(error) => {
6604 dlg.response_json_decode_error(&encoded, &error);
6605 return Err(common::Error::JsonDecodeError(
6606 encoded.to_string(),
6607 error,
6608 ));
6609 }
6610 }
6611 };
6612
6613 dlg.finished(true);
6614 return Ok(response);
6615 }
6616 }
6617 }
6618 }
6619
6620 ///
6621 /// Sets the *request* property to the given value.
6622 ///
6623 /// Even though the property as already been set when instantiating this call,
6624 /// we provide this method for API completeness.
6625 pub fn request(mut self, new_value: Database) -> DatabasePatchCall<'a, C> {
6626 self._request = new_value;
6627 self
6628 }
6629 /// Project ID of the project that contains the instance.
6630 ///
6631 /// Sets the *project* path property to the given value.
6632 ///
6633 /// Even though the property as already been set when instantiating this call,
6634 /// we provide this method for API completeness.
6635 pub fn project(mut self, new_value: &str) -> DatabasePatchCall<'a, C> {
6636 self._project = new_value.to_string();
6637 self
6638 }
6639 /// Database instance ID. This does not include the project ID.
6640 ///
6641 /// Sets the *instance* path property to the given value.
6642 ///
6643 /// Even though the property as already been set when instantiating this call,
6644 /// we provide this method for API completeness.
6645 pub fn instance(mut self, new_value: &str) -> DatabasePatchCall<'a, C> {
6646 self._instance = new_value.to_string();
6647 self
6648 }
6649 /// Name of the database to be updated in the instance.
6650 ///
6651 /// Sets the *database* path property to the given value.
6652 ///
6653 /// Even though the property as already been set when instantiating this call,
6654 /// we provide this method for API completeness.
6655 pub fn database(mut self, new_value: &str) -> DatabasePatchCall<'a, C> {
6656 self._database = new_value.to_string();
6657 self
6658 }
6659 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6660 /// while executing the actual API request.
6661 ///
6662 /// ````text
6663 /// It should be used to handle progress information, and to implement a certain level of resilience.
6664 /// ````
6665 ///
6666 /// Sets the *delegate* property to the given value.
6667 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DatabasePatchCall<'a, C> {
6668 self._delegate = Some(new_value);
6669 self
6670 }
6671
6672 /// Set any additional parameter of the query string used in the request.
6673 /// It should be used to set parameters which are not yet available through their own
6674 /// setters.
6675 ///
6676 /// Please note that this method must not be used to set any of the known parameters
6677 /// which have their own setter method. If done anyway, the request will fail.
6678 ///
6679 /// # Additional Parameters
6680 ///
6681 /// * *$.xgafv* (query-string) - V1 error format.
6682 /// * *access_token* (query-string) - OAuth access token.
6683 /// * *alt* (query-string) - Data format for response.
6684 /// * *callback* (query-string) - JSONP
6685 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6686 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6687 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6688 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6689 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6690 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6691 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6692 pub fn param<T>(mut self, name: T, value: T) -> DatabasePatchCall<'a, C>
6693 where
6694 T: AsRef<str>,
6695 {
6696 self._additional_params
6697 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6698 self
6699 }
6700
6701 /// Identifies the authorization scope for the method you are building.
6702 ///
6703 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6704 /// [`Scope::CloudPlatform`].
6705 ///
6706 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6707 /// tokens for more than one scope.
6708 ///
6709 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6710 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6711 /// sufficient, a read-write scope will do as well.
6712 pub fn add_scope<St>(mut self, scope: St) -> DatabasePatchCall<'a, C>
6713 where
6714 St: AsRef<str>,
6715 {
6716 self._scopes.insert(String::from(scope.as_ref()));
6717 self
6718 }
6719 /// Identifies the authorization scope(s) for the method you are building.
6720 ///
6721 /// See [`Self::add_scope()`] for details.
6722 pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabasePatchCall<'a, C>
6723 where
6724 I: IntoIterator<Item = St>,
6725 St: AsRef<str>,
6726 {
6727 self._scopes
6728 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6729 self
6730 }
6731
6732 /// Removes all scopes, and no default scope will be used either.
6733 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6734 /// for details).
6735 pub fn clear_scopes(mut self) -> DatabasePatchCall<'a, C> {
6736 self._scopes.clear();
6737 self
6738 }
6739}
6740
6741/// Updates a resource containing information about a database inside a Cloud
6742/// SQL instance.
6743///
6744/// A builder for the *update* method supported by a *database* resource.
6745/// It is not used directly, but through a [`DatabaseMethods`] instance.
6746///
6747/// # Example
6748///
6749/// Instantiate a resource method builder
6750///
6751/// ```test_harness,no_run
6752/// # extern crate hyper;
6753/// # extern crate hyper_rustls;
6754/// # extern crate google_sql1_beta4 as sql1_beta4;
6755/// use sql1_beta4::api::Database;
6756/// # async fn dox() {
6757/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6758///
6759/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6760/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6761/// # secret,
6762/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6763/// # ).build().await.unwrap();
6764///
6765/// # let client = hyper_util::client::legacy::Client::builder(
6766/// # hyper_util::rt::TokioExecutor::new()
6767/// # )
6768/// # .build(
6769/// # hyper_rustls::HttpsConnectorBuilder::new()
6770/// # .with_native_roots()
6771/// # .unwrap()
6772/// # .https_or_http()
6773/// # .enable_http1()
6774/// # .build()
6775/// # );
6776/// # let mut hub = SQLAdmin::new(client, auth);
6777/// // As the method needs a request, you would usually fill it with the desired information
6778/// // into the respective structure. Some of the parts shown here might not be applicable !
6779/// // Values shown here are possibly random and not representative !
6780/// let mut req = Database::default();
6781///
6782/// // You can configure optional parameters by calling the respective setters at will, and
6783/// // execute the final call using `doit()`.
6784/// // Values shown here are possibly random and not representative !
6785/// let result = hub.databases().update(req, "project", "instance", "database")
6786/// .doit().await;
6787/// # }
6788/// ```
6789pub struct DatabaseUpdateCall<'a, C>
6790where
6791 C: 'a,
6792{
6793 hub: &'a SQLAdmin<C>,
6794 _request: Database,
6795 _project: String,
6796 _instance: String,
6797 _database: String,
6798 _delegate: Option<&'a mut dyn common::Delegate>,
6799 _additional_params: HashMap<String, String>,
6800 _scopes: BTreeSet<String>,
6801}
6802
6803impl<'a, C> common::CallBuilder for DatabaseUpdateCall<'a, C> {}
6804
6805impl<'a, C> DatabaseUpdateCall<'a, C>
6806where
6807 C: common::Connector,
6808{
6809 /// Perform the operation you have build so far.
6810 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6811 use std::borrow::Cow;
6812 use std::io::{Read, Seek};
6813
6814 use common::{url::Params, ToParts};
6815 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6816
6817 let mut dd = common::DefaultDelegate;
6818 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6819 dlg.begin(common::MethodInfo {
6820 id: "sql.databases.update",
6821 http_method: hyper::Method::PUT,
6822 });
6823
6824 for &field in ["alt", "project", "instance", "database"].iter() {
6825 if self._additional_params.contains_key(field) {
6826 dlg.finished(false);
6827 return Err(common::Error::FieldClash(field));
6828 }
6829 }
6830
6831 let mut params = Params::with_capacity(6 + self._additional_params.len());
6832 params.push("project", self._project);
6833 params.push("instance", self._instance);
6834 params.push("database", self._database);
6835
6836 params.extend(self._additional_params.iter());
6837
6838 params.push("alt", "json");
6839 let mut url = self.hub._base_url.clone()
6840 + "sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}";
6841 if self._scopes.is_empty() {
6842 self._scopes
6843 .insert(Scope::CloudPlatform.as_ref().to_string());
6844 }
6845
6846 #[allow(clippy::single_element_loop)]
6847 for &(find_this, param_name) in [
6848 ("{project}", "project"),
6849 ("{instance}", "instance"),
6850 ("{database}", "database"),
6851 ]
6852 .iter()
6853 {
6854 url = params.uri_replacement(url, param_name, find_this, false);
6855 }
6856 {
6857 let to_remove = ["database", "instance", "project"];
6858 params.remove_params(&to_remove);
6859 }
6860
6861 let url = params.parse_with_url(&url);
6862
6863 let mut json_mime_type = mime::APPLICATION_JSON;
6864 let mut request_value_reader = {
6865 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6866 common::remove_json_null_values(&mut value);
6867 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6868 serde_json::to_writer(&mut dst, &value).unwrap();
6869 dst
6870 };
6871 let request_size = request_value_reader
6872 .seek(std::io::SeekFrom::End(0))
6873 .unwrap();
6874 request_value_reader
6875 .seek(std::io::SeekFrom::Start(0))
6876 .unwrap();
6877
6878 loop {
6879 let token = match self
6880 .hub
6881 .auth
6882 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6883 .await
6884 {
6885 Ok(token) => token,
6886 Err(e) => match dlg.token(e) {
6887 Ok(token) => token,
6888 Err(e) => {
6889 dlg.finished(false);
6890 return Err(common::Error::MissingToken(e));
6891 }
6892 },
6893 };
6894 request_value_reader
6895 .seek(std::io::SeekFrom::Start(0))
6896 .unwrap();
6897 let mut req_result = {
6898 let client = &self.hub.client;
6899 dlg.pre_request();
6900 let mut req_builder = hyper::Request::builder()
6901 .method(hyper::Method::PUT)
6902 .uri(url.as_str())
6903 .header(USER_AGENT, self.hub._user_agent.clone());
6904
6905 if let Some(token) = token.as_ref() {
6906 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6907 }
6908
6909 let request = req_builder
6910 .header(CONTENT_TYPE, json_mime_type.to_string())
6911 .header(CONTENT_LENGTH, request_size as u64)
6912 .body(common::to_body(
6913 request_value_reader.get_ref().clone().into(),
6914 ));
6915
6916 client.request(request.unwrap()).await
6917 };
6918
6919 match req_result {
6920 Err(err) => {
6921 if let common::Retry::After(d) = dlg.http_error(&err) {
6922 sleep(d).await;
6923 continue;
6924 }
6925 dlg.finished(false);
6926 return Err(common::Error::HttpError(err));
6927 }
6928 Ok(res) => {
6929 let (mut parts, body) = res.into_parts();
6930 let mut body = common::Body::new(body);
6931 if !parts.status.is_success() {
6932 let bytes = common::to_bytes(body).await.unwrap_or_default();
6933 let error = serde_json::from_str(&common::to_string(&bytes));
6934 let response = common::to_response(parts, bytes.into());
6935
6936 if let common::Retry::After(d) =
6937 dlg.http_failure(&response, error.as_ref().ok())
6938 {
6939 sleep(d).await;
6940 continue;
6941 }
6942
6943 dlg.finished(false);
6944
6945 return Err(match error {
6946 Ok(value) => common::Error::BadRequest(value),
6947 _ => common::Error::Failure(response),
6948 });
6949 }
6950 let response = {
6951 let bytes = common::to_bytes(body).await.unwrap_or_default();
6952 let encoded = common::to_string(&bytes);
6953 match serde_json::from_str(&encoded) {
6954 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6955 Err(error) => {
6956 dlg.response_json_decode_error(&encoded, &error);
6957 return Err(common::Error::JsonDecodeError(
6958 encoded.to_string(),
6959 error,
6960 ));
6961 }
6962 }
6963 };
6964
6965 dlg.finished(true);
6966 return Ok(response);
6967 }
6968 }
6969 }
6970 }
6971
6972 ///
6973 /// Sets the *request* property to the given value.
6974 ///
6975 /// Even though the property as already been set when instantiating this call,
6976 /// we provide this method for API completeness.
6977 pub fn request(mut self, new_value: Database) -> DatabaseUpdateCall<'a, C> {
6978 self._request = new_value;
6979 self
6980 }
6981 /// Project ID of the project that contains the instance.
6982 ///
6983 /// Sets the *project* path property to the given value.
6984 ///
6985 /// Even though the property as already been set when instantiating this call,
6986 /// we provide this method for API completeness.
6987 pub fn project(mut self, new_value: &str) -> DatabaseUpdateCall<'a, C> {
6988 self._project = new_value.to_string();
6989 self
6990 }
6991 /// Database instance ID. This does not include the project ID.
6992 ///
6993 /// Sets the *instance* path property to the given value.
6994 ///
6995 /// Even though the property as already been set when instantiating this call,
6996 /// we provide this method for API completeness.
6997 pub fn instance(mut self, new_value: &str) -> DatabaseUpdateCall<'a, C> {
6998 self._instance = new_value.to_string();
6999 self
7000 }
7001 /// Name of the database to be updated in the instance.
7002 ///
7003 /// Sets the *database* path property to the given value.
7004 ///
7005 /// Even though the property as already been set when instantiating this call,
7006 /// we provide this method for API completeness.
7007 pub fn database(mut self, new_value: &str) -> DatabaseUpdateCall<'a, C> {
7008 self._database = new_value.to_string();
7009 self
7010 }
7011 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7012 /// while executing the actual API request.
7013 ///
7014 /// ````text
7015 /// It should be used to handle progress information, and to implement a certain level of resilience.
7016 /// ````
7017 ///
7018 /// Sets the *delegate* property to the given value.
7019 pub fn delegate(
7020 mut self,
7021 new_value: &'a mut dyn common::Delegate,
7022 ) -> DatabaseUpdateCall<'a, C> {
7023 self._delegate = Some(new_value);
7024 self
7025 }
7026
7027 /// Set any additional parameter of the query string used in the request.
7028 /// It should be used to set parameters which are not yet available through their own
7029 /// setters.
7030 ///
7031 /// Please note that this method must not be used to set any of the known parameters
7032 /// which have their own setter method. If done anyway, the request will fail.
7033 ///
7034 /// # Additional Parameters
7035 ///
7036 /// * *$.xgafv* (query-string) - V1 error format.
7037 /// * *access_token* (query-string) - OAuth access token.
7038 /// * *alt* (query-string) - Data format for response.
7039 /// * *callback* (query-string) - JSONP
7040 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7041 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7042 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7043 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7044 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7045 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7046 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7047 pub fn param<T>(mut self, name: T, value: T) -> DatabaseUpdateCall<'a, C>
7048 where
7049 T: AsRef<str>,
7050 {
7051 self._additional_params
7052 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7053 self
7054 }
7055
7056 /// Identifies the authorization scope for the method you are building.
7057 ///
7058 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7059 /// [`Scope::CloudPlatform`].
7060 ///
7061 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7062 /// tokens for more than one scope.
7063 ///
7064 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7065 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7066 /// sufficient, a read-write scope will do as well.
7067 pub fn add_scope<St>(mut self, scope: St) -> DatabaseUpdateCall<'a, C>
7068 where
7069 St: AsRef<str>,
7070 {
7071 self._scopes.insert(String::from(scope.as_ref()));
7072 self
7073 }
7074 /// Identifies the authorization scope(s) for the method you are building.
7075 ///
7076 /// See [`Self::add_scope()`] for details.
7077 pub fn add_scopes<I, St>(mut self, scopes: I) -> DatabaseUpdateCall<'a, C>
7078 where
7079 I: IntoIterator<Item = St>,
7080 St: AsRef<str>,
7081 {
7082 self._scopes
7083 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7084 self
7085 }
7086
7087 /// Removes all scopes, and no default scope will be used either.
7088 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7089 /// for details).
7090 pub fn clear_scopes(mut self) -> DatabaseUpdateCall<'a, C> {
7091 self._scopes.clear();
7092 self
7093 }
7094}
7095
7096/// List all available database flags for Cloud SQL instances.
7097///
7098/// A builder for the *list* method supported by a *flag* resource.
7099/// It is not used directly, but through a [`FlagMethods`] instance.
7100///
7101/// # Example
7102///
7103/// Instantiate a resource method builder
7104///
7105/// ```test_harness,no_run
7106/// # extern crate hyper;
7107/// # extern crate hyper_rustls;
7108/// # extern crate google_sql1_beta4 as sql1_beta4;
7109/// # async fn dox() {
7110/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7111///
7112/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7113/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7114/// # secret,
7115/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7116/// # ).build().await.unwrap();
7117///
7118/// # let client = hyper_util::client::legacy::Client::builder(
7119/// # hyper_util::rt::TokioExecutor::new()
7120/// # )
7121/// # .build(
7122/// # hyper_rustls::HttpsConnectorBuilder::new()
7123/// # .with_native_roots()
7124/// # .unwrap()
7125/// # .https_or_http()
7126/// # .enable_http1()
7127/// # .build()
7128/// # );
7129/// # let mut hub = SQLAdmin::new(client, auth);
7130/// // You can configure optional parameters by calling the respective setters at will, and
7131/// // execute the final call using `doit()`.
7132/// // Values shown here are possibly random and not representative !
7133/// let result = hub.flags().list()
7134/// .database_version("sed")
7135/// .doit().await;
7136/// # }
7137/// ```
7138pub struct FlagListCall<'a, C>
7139where
7140 C: 'a,
7141{
7142 hub: &'a SQLAdmin<C>,
7143 _database_version: Option<String>,
7144 _delegate: Option<&'a mut dyn common::Delegate>,
7145 _additional_params: HashMap<String, String>,
7146 _scopes: BTreeSet<String>,
7147}
7148
7149impl<'a, C> common::CallBuilder for FlagListCall<'a, C> {}
7150
7151impl<'a, C> FlagListCall<'a, C>
7152where
7153 C: common::Connector,
7154{
7155 /// Perform the operation you have build so far.
7156 pub async fn doit(mut self) -> common::Result<(common::Response, FlagsListResponse)> {
7157 use std::borrow::Cow;
7158 use std::io::{Read, Seek};
7159
7160 use common::{url::Params, ToParts};
7161 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7162
7163 let mut dd = common::DefaultDelegate;
7164 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7165 dlg.begin(common::MethodInfo {
7166 id: "sql.flags.list",
7167 http_method: hyper::Method::GET,
7168 });
7169
7170 for &field in ["alt", "databaseVersion"].iter() {
7171 if self._additional_params.contains_key(field) {
7172 dlg.finished(false);
7173 return Err(common::Error::FieldClash(field));
7174 }
7175 }
7176
7177 let mut params = Params::with_capacity(3 + self._additional_params.len());
7178 if let Some(value) = self._database_version.as_ref() {
7179 params.push("databaseVersion", value);
7180 }
7181
7182 params.extend(self._additional_params.iter());
7183
7184 params.push("alt", "json");
7185 let mut url = self.hub._base_url.clone() + "sql/v1beta4/flags";
7186 if self._scopes.is_empty() {
7187 self._scopes
7188 .insert(Scope::CloudPlatform.as_ref().to_string());
7189 }
7190
7191 let url = params.parse_with_url(&url);
7192
7193 loop {
7194 let token = match self
7195 .hub
7196 .auth
7197 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7198 .await
7199 {
7200 Ok(token) => token,
7201 Err(e) => match dlg.token(e) {
7202 Ok(token) => token,
7203 Err(e) => {
7204 dlg.finished(false);
7205 return Err(common::Error::MissingToken(e));
7206 }
7207 },
7208 };
7209 let mut req_result = {
7210 let client = &self.hub.client;
7211 dlg.pre_request();
7212 let mut req_builder = hyper::Request::builder()
7213 .method(hyper::Method::GET)
7214 .uri(url.as_str())
7215 .header(USER_AGENT, self.hub._user_agent.clone());
7216
7217 if let Some(token) = token.as_ref() {
7218 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7219 }
7220
7221 let request = req_builder
7222 .header(CONTENT_LENGTH, 0_u64)
7223 .body(common::to_body::<String>(None));
7224
7225 client.request(request.unwrap()).await
7226 };
7227
7228 match req_result {
7229 Err(err) => {
7230 if let common::Retry::After(d) = dlg.http_error(&err) {
7231 sleep(d).await;
7232 continue;
7233 }
7234 dlg.finished(false);
7235 return Err(common::Error::HttpError(err));
7236 }
7237 Ok(res) => {
7238 let (mut parts, body) = res.into_parts();
7239 let mut body = common::Body::new(body);
7240 if !parts.status.is_success() {
7241 let bytes = common::to_bytes(body).await.unwrap_or_default();
7242 let error = serde_json::from_str(&common::to_string(&bytes));
7243 let response = common::to_response(parts, bytes.into());
7244
7245 if let common::Retry::After(d) =
7246 dlg.http_failure(&response, error.as_ref().ok())
7247 {
7248 sleep(d).await;
7249 continue;
7250 }
7251
7252 dlg.finished(false);
7253
7254 return Err(match error {
7255 Ok(value) => common::Error::BadRequest(value),
7256 _ => common::Error::Failure(response),
7257 });
7258 }
7259 let response = {
7260 let bytes = common::to_bytes(body).await.unwrap_or_default();
7261 let encoded = common::to_string(&bytes);
7262 match serde_json::from_str(&encoded) {
7263 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7264 Err(error) => {
7265 dlg.response_json_decode_error(&encoded, &error);
7266 return Err(common::Error::JsonDecodeError(
7267 encoded.to_string(),
7268 error,
7269 ));
7270 }
7271 }
7272 };
7273
7274 dlg.finished(true);
7275 return Ok(response);
7276 }
7277 }
7278 }
7279 }
7280
7281 /// Database type and version you want to retrieve flags for. By default, this
7282 /// method returns flags for all database types and versions.
7283 ///
7284 /// Sets the *database version* query property to the given value.
7285 pub fn database_version(mut self, new_value: &str) -> FlagListCall<'a, C> {
7286 self._database_version = Some(new_value.to_string());
7287 self
7288 }
7289 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7290 /// while executing the actual API request.
7291 ///
7292 /// ````text
7293 /// It should be used to handle progress information, and to implement a certain level of resilience.
7294 /// ````
7295 ///
7296 /// Sets the *delegate* property to the given value.
7297 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FlagListCall<'a, C> {
7298 self._delegate = Some(new_value);
7299 self
7300 }
7301
7302 /// Set any additional parameter of the query string used in the request.
7303 /// It should be used to set parameters which are not yet available through their own
7304 /// setters.
7305 ///
7306 /// Please note that this method must not be used to set any of the known parameters
7307 /// which have their own setter method. If done anyway, the request will fail.
7308 ///
7309 /// # Additional Parameters
7310 ///
7311 /// * *$.xgafv* (query-string) - V1 error format.
7312 /// * *access_token* (query-string) - OAuth access token.
7313 /// * *alt* (query-string) - Data format for response.
7314 /// * *callback* (query-string) - JSONP
7315 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7316 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7317 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7318 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7319 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7320 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7321 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7322 pub fn param<T>(mut self, name: T, value: T) -> FlagListCall<'a, C>
7323 where
7324 T: AsRef<str>,
7325 {
7326 self._additional_params
7327 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7328 self
7329 }
7330
7331 /// Identifies the authorization scope for the method you are building.
7332 ///
7333 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7334 /// [`Scope::CloudPlatform`].
7335 ///
7336 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7337 /// tokens for more than one scope.
7338 ///
7339 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7340 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7341 /// sufficient, a read-write scope will do as well.
7342 pub fn add_scope<St>(mut self, scope: St) -> FlagListCall<'a, C>
7343 where
7344 St: AsRef<str>,
7345 {
7346 self._scopes.insert(String::from(scope.as_ref()));
7347 self
7348 }
7349 /// Identifies the authorization scope(s) for the method you are building.
7350 ///
7351 /// See [`Self::add_scope()`] for details.
7352 pub fn add_scopes<I, St>(mut self, scopes: I) -> FlagListCall<'a, C>
7353 where
7354 I: IntoIterator<Item = St>,
7355 St: AsRef<str>,
7356 {
7357 self._scopes
7358 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7359 self
7360 }
7361
7362 /// Removes all scopes, and no default scope will be used either.
7363 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7364 /// for details).
7365 pub fn clear_scopes(mut self) -> FlagListCall<'a, C> {
7366 self._scopes.clear();
7367 self
7368 }
7369}
7370
7371/// Add a new trusted Certificate Authority (CA) version for the specified
7372/// instance. Required to prepare for a certificate rotation. If a CA version
7373/// was previously added but never used in a certificate rotation, this
7374/// operation replaces that version. There cannot be more than one CA version
7375/// waiting to be rotated in.
7376///
7377/// A builder for the *addServerCa* method supported by a *instance* resource.
7378/// It is not used directly, but through a [`InstanceMethods`] instance.
7379///
7380/// # Example
7381///
7382/// Instantiate a resource method builder
7383///
7384/// ```test_harness,no_run
7385/// # extern crate hyper;
7386/// # extern crate hyper_rustls;
7387/// # extern crate google_sql1_beta4 as sql1_beta4;
7388/// # async fn dox() {
7389/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7390///
7391/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7392/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7393/// # secret,
7394/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7395/// # ).build().await.unwrap();
7396///
7397/// # let client = hyper_util::client::legacy::Client::builder(
7398/// # hyper_util::rt::TokioExecutor::new()
7399/// # )
7400/// # .build(
7401/// # hyper_rustls::HttpsConnectorBuilder::new()
7402/// # .with_native_roots()
7403/// # .unwrap()
7404/// # .https_or_http()
7405/// # .enable_http1()
7406/// # .build()
7407/// # );
7408/// # let mut hub = SQLAdmin::new(client, auth);
7409/// // You can configure optional parameters by calling the respective setters at will, and
7410/// // execute the final call using `doit()`.
7411/// // Values shown here are possibly random and not representative !
7412/// let result = hub.instances().add_server_ca("project", "instance")
7413/// .doit().await;
7414/// # }
7415/// ```
7416pub struct InstanceAddServerCaCall<'a, C>
7417where
7418 C: 'a,
7419{
7420 hub: &'a SQLAdmin<C>,
7421 _project: String,
7422 _instance: String,
7423 _delegate: Option<&'a mut dyn common::Delegate>,
7424 _additional_params: HashMap<String, String>,
7425 _scopes: BTreeSet<String>,
7426}
7427
7428impl<'a, C> common::CallBuilder for InstanceAddServerCaCall<'a, C> {}
7429
7430impl<'a, C> InstanceAddServerCaCall<'a, C>
7431where
7432 C: common::Connector,
7433{
7434 /// Perform the operation you have build so far.
7435 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7436 use std::borrow::Cow;
7437 use std::io::{Read, Seek};
7438
7439 use common::{url::Params, ToParts};
7440 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7441
7442 let mut dd = common::DefaultDelegate;
7443 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7444 dlg.begin(common::MethodInfo {
7445 id: "sql.instances.addServerCa",
7446 http_method: hyper::Method::POST,
7447 });
7448
7449 for &field in ["alt", "project", "instance"].iter() {
7450 if self._additional_params.contains_key(field) {
7451 dlg.finished(false);
7452 return Err(common::Error::FieldClash(field));
7453 }
7454 }
7455
7456 let mut params = Params::with_capacity(4 + self._additional_params.len());
7457 params.push("project", self._project);
7458 params.push("instance", self._instance);
7459
7460 params.extend(self._additional_params.iter());
7461
7462 params.push("alt", "json");
7463 let mut url = self.hub._base_url.clone()
7464 + "sql/v1beta4/projects/{project}/instances/{instance}/addServerCa";
7465 if self._scopes.is_empty() {
7466 self._scopes
7467 .insert(Scope::CloudPlatform.as_ref().to_string());
7468 }
7469
7470 #[allow(clippy::single_element_loop)]
7471 for &(find_this, param_name) in
7472 [("{project}", "project"), ("{instance}", "instance")].iter()
7473 {
7474 url = params.uri_replacement(url, param_name, find_this, false);
7475 }
7476 {
7477 let to_remove = ["instance", "project"];
7478 params.remove_params(&to_remove);
7479 }
7480
7481 let url = params.parse_with_url(&url);
7482
7483 loop {
7484 let token = match self
7485 .hub
7486 .auth
7487 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7488 .await
7489 {
7490 Ok(token) => token,
7491 Err(e) => match dlg.token(e) {
7492 Ok(token) => token,
7493 Err(e) => {
7494 dlg.finished(false);
7495 return Err(common::Error::MissingToken(e));
7496 }
7497 },
7498 };
7499 let mut req_result = {
7500 let client = &self.hub.client;
7501 dlg.pre_request();
7502 let mut req_builder = hyper::Request::builder()
7503 .method(hyper::Method::POST)
7504 .uri(url.as_str())
7505 .header(USER_AGENT, self.hub._user_agent.clone());
7506
7507 if let Some(token) = token.as_ref() {
7508 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7509 }
7510
7511 let request = req_builder
7512 .header(CONTENT_LENGTH, 0_u64)
7513 .body(common::to_body::<String>(None));
7514
7515 client.request(request.unwrap()).await
7516 };
7517
7518 match req_result {
7519 Err(err) => {
7520 if let common::Retry::After(d) = dlg.http_error(&err) {
7521 sleep(d).await;
7522 continue;
7523 }
7524 dlg.finished(false);
7525 return Err(common::Error::HttpError(err));
7526 }
7527 Ok(res) => {
7528 let (mut parts, body) = res.into_parts();
7529 let mut body = common::Body::new(body);
7530 if !parts.status.is_success() {
7531 let bytes = common::to_bytes(body).await.unwrap_or_default();
7532 let error = serde_json::from_str(&common::to_string(&bytes));
7533 let response = common::to_response(parts, bytes.into());
7534
7535 if let common::Retry::After(d) =
7536 dlg.http_failure(&response, error.as_ref().ok())
7537 {
7538 sleep(d).await;
7539 continue;
7540 }
7541
7542 dlg.finished(false);
7543
7544 return Err(match error {
7545 Ok(value) => common::Error::BadRequest(value),
7546 _ => common::Error::Failure(response),
7547 });
7548 }
7549 let response = {
7550 let bytes = common::to_bytes(body).await.unwrap_or_default();
7551 let encoded = common::to_string(&bytes);
7552 match serde_json::from_str(&encoded) {
7553 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7554 Err(error) => {
7555 dlg.response_json_decode_error(&encoded, &error);
7556 return Err(common::Error::JsonDecodeError(
7557 encoded.to_string(),
7558 error,
7559 ));
7560 }
7561 }
7562 };
7563
7564 dlg.finished(true);
7565 return Ok(response);
7566 }
7567 }
7568 }
7569 }
7570
7571 /// Project ID of the project that contains the instance.
7572 ///
7573 /// Sets the *project* path property to the given value.
7574 ///
7575 /// Even though the property as already been set when instantiating this call,
7576 /// we provide this method for API completeness.
7577 pub fn project(mut self, new_value: &str) -> InstanceAddServerCaCall<'a, C> {
7578 self._project = new_value.to_string();
7579 self
7580 }
7581 /// Cloud SQL instance ID. This does not include the project ID.
7582 ///
7583 /// Sets the *instance* path property to the given value.
7584 ///
7585 /// Even though the property as already been set when instantiating this call,
7586 /// we provide this method for API completeness.
7587 pub fn instance(mut self, new_value: &str) -> InstanceAddServerCaCall<'a, C> {
7588 self._instance = new_value.to_string();
7589 self
7590 }
7591 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7592 /// while executing the actual API request.
7593 ///
7594 /// ````text
7595 /// It should be used to handle progress information, and to implement a certain level of resilience.
7596 /// ````
7597 ///
7598 /// Sets the *delegate* property to the given value.
7599 pub fn delegate(
7600 mut self,
7601 new_value: &'a mut dyn common::Delegate,
7602 ) -> InstanceAddServerCaCall<'a, C> {
7603 self._delegate = Some(new_value);
7604 self
7605 }
7606
7607 /// Set any additional parameter of the query string used in the request.
7608 /// It should be used to set parameters which are not yet available through their own
7609 /// setters.
7610 ///
7611 /// Please note that this method must not be used to set any of the known parameters
7612 /// which have their own setter method. If done anyway, the request will fail.
7613 ///
7614 /// # Additional Parameters
7615 ///
7616 /// * *$.xgafv* (query-string) - V1 error format.
7617 /// * *access_token* (query-string) - OAuth access token.
7618 /// * *alt* (query-string) - Data format for response.
7619 /// * *callback* (query-string) - JSONP
7620 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7621 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7622 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7623 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7624 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7625 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7626 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7627 pub fn param<T>(mut self, name: T, value: T) -> InstanceAddServerCaCall<'a, C>
7628 where
7629 T: AsRef<str>,
7630 {
7631 self._additional_params
7632 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7633 self
7634 }
7635
7636 /// Identifies the authorization scope for the method you are building.
7637 ///
7638 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7639 /// [`Scope::CloudPlatform`].
7640 ///
7641 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7642 /// tokens for more than one scope.
7643 ///
7644 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7645 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7646 /// sufficient, a read-write scope will do as well.
7647 pub fn add_scope<St>(mut self, scope: St) -> InstanceAddServerCaCall<'a, C>
7648 where
7649 St: AsRef<str>,
7650 {
7651 self._scopes.insert(String::from(scope.as_ref()));
7652 self
7653 }
7654 /// Identifies the authorization scope(s) for the method you are building.
7655 ///
7656 /// See [`Self::add_scope()`] for details.
7657 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceAddServerCaCall<'a, C>
7658 where
7659 I: IntoIterator<Item = St>,
7660 St: AsRef<str>,
7661 {
7662 self._scopes
7663 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7664 self
7665 }
7666
7667 /// Removes all scopes, and no default scope will be used either.
7668 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7669 /// for details).
7670 pub fn clear_scopes(mut self) -> InstanceAddServerCaCall<'a, C> {
7671 self._scopes.clear();
7672 self
7673 }
7674}
7675
7676/// Creates a Cloud SQL instance as a clone of the source instance. Using this
7677/// operation might cause your instance to restart.
7678///
7679/// A builder for the *clone* method supported by a *instance* resource.
7680/// It is not used directly, but through a [`InstanceMethods`] instance.
7681///
7682/// # Example
7683///
7684/// Instantiate a resource method builder
7685///
7686/// ```test_harness,no_run
7687/// # extern crate hyper;
7688/// # extern crate hyper_rustls;
7689/// # extern crate google_sql1_beta4 as sql1_beta4;
7690/// use sql1_beta4::api::InstancesCloneRequest;
7691/// # async fn dox() {
7692/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7693///
7694/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7695/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7696/// # secret,
7697/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7698/// # ).build().await.unwrap();
7699///
7700/// # let client = hyper_util::client::legacy::Client::builder(
7701/// # hyper_util::rt::TokioExecutor::new()
7702/// # )
7703/// # .build(
7704/// # hyper_rustls::HttpsConnectorBuilder::new()
7705/// # .with_native_roots()
7706/// # .unwrap()
7707/// # .https_or_http()
7708/// # .enable_http1()
7709/// # .build()
7710/// # );
7711/// # let mut hub = SQLAdmin::new(client, auth);
7712/// // As the method needs a request, you would usually fill it with the desired information
7713/// // into the respective structure. Some of the parts shown here might not be applicable !
7714/// // Values shown here are possibly random and not representative !
7715/// let mut req = InstancesCloneRequest::default();
7716///
7717/// // You can configure optional parameters by calling the respective setters at will, and
7718/// // execute the final call using `doit()`.
7719/// // Values shown here are possibly random and not representative !
7720/// let result = hub.instances().clone(req, "project", "instance")
7721/// .doit().await;
7722/// # }
7723/// ```
7724pub struct InstanceCloneCall<'a, C>
7725where
7726 C: 'a,
7727{
7728 hub: &'a SQLAdmin<C>,
7729 _request: InstancesCloneRequest,
7730 _project: String,
7731 _instance: String,
7732 _delegate: Option<&'a mut dyn common::Delegate>,
7733 _additional_params: HashMap<String, String>,
7734 _scopes: BTreeSet<String>,
7735}
7736
7737impl<'a, C> common::CallBuilder for InstanceCloneCall<'a, C> {}
7738
7739impl<'a, C> InstanceCloneCall<'a, C>
7740where
7741 C: common::Connector,
7742{
7743 /// Perform the operation you have build so far.
7744 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7745 use std::borrow::Cow;
7746 use std::io::{Read, Seek};
7747
7748 use common::{url::Params, ToParts};
7749 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7750
7751 let mut dd = common::DefaultDelegate;
7752 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7753 dlg.begin(common::MethodInfo {
7754 id: "sql.instances.clone",
7755 http_method: hyper::Method::POST,
7756 });
7757
7758 for &field in ["alt", "project", "instance"].iter() {
7759 if self._additional_params.contains_key(field) {
7760 dlg.finished(false);
7761 return Err(common::Error::FieldClash(field));
7762 }
7763 }
7764
7765 let mut params = Params::with_capacity(5 + self._additional_params.len());
7766 params.push("project", self._project);
7767 params.push("instance", self._instance);
7768
7769 params.extend(self._additional_params.iter());
7770
7771 params.push("alt", "json");
7772 let mut url = self.hub._base_url.clone()
7773 + "sql/v1beta4/projects/{project}/instances/{instance}/clone";
7774 if self._scopes.is_empty() {
7775 self._scopes
7776 .insert(Scope::CloudPlatform.as_ref().to_string());
7777 }
7778
7779 #[allow(clippy::single_element_loop)]
7780 for &(find_this, param_name) in
7781 [("{project}", "project"), ("{instance}", "instance")].iter()
7782 {
7783 url = params.uri_replacement(url, param_name, find_this, false);
7784 }
7785 {
7786 let to_remove = ["instance", "project"];
7787 params.remove_params(&to_remove);
7788 }
7789
7790 let url = params.parse_with_url(&url);
7791
7792 let mut json_mime_type = mime::APPLICATION_JSON;
7793 let mut request_value_reader = {
7794 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7795 common::remove_json_null_values(&mut value);
7796 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7797 serde_json::to_writer(&mut dst, &value).unwrap();
7798 dst
7799 };
7800 let request_size = request_value_reader
7801 .seek(std::io::SeekFrom::End(0))
7802 .unwrap();
7803 request_value_reader
7804 .seek(std::io::SeekFrom::Start(0))
7805 .unwrap();
7806
7807 loop {
7808 let token = match self
7809 .hub
7810 .auth
7811 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7812 .await
7813 {
7814 Ok(token) => token,
7815 Err(e) => match dlg.token(e) {
7816 Ok(token) => token,
7817 Err(e) => {
7818 dlg.finished(false);
7819 return Err(common::Error::MissingToken(e));
7820 }
7821 },
7822 };
7823 request_value_reader
7824 .seek(std::io::SeekFrom::Start(0))
7825 .unwrap();
7826 let mut req_result = {
7827 let client = &self.hub.client;
7828 dlg.pre_request();
7829 let mut req_builder = hyper::Request::builder()
7830 .method(hyper::Method::POST)
7831 .uri(url.as_str())
7832 .header(USER_AGENT, self.hub._user_agent.clone());
7833
7834 if let Some(token) = token.as_ref() {
7835 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7836 }
7837
7838 let request = req_builder
7839 .header(CONTENT_TYPE, json_mime_type.to_string())
7840 .header(CONTENT_LENGTH, request_size as u64)
7841 .body(common::to_body(
7842 request_value_reader.get_ref().clone().into(),
7843 ));
7844
7845 client.request(request.unwrap()).await
7846 };
7847
7848 match req_result {
7849 Err(err) => {
7850 if let common::Retry::After(d) = dlg.http_error(&err) {
7851 sleep(d).await;
7852 continue;
7853 }
7854 dlg.finished(false);
7855 return Err(common::Error::HttpError(err));
7856 }
7857 Ok(res) => {
7858 let (mut parts, body) = res.into_parts();
7859 let mut body = common::Body::new(body);
7860 if !parts.status.is_success() {
7861 let bytes = common::to_bytes(body).await.unwrap_or_default();
7862 let error = serde_json::from_str(&common::to_string(&bytes));
7863 let response = common::to_response(parts, bytes.into());
7864
7865 if let common::Retry::After(d) =
7866 dlg.http_failure(&response, error.as_ref().ok())
7867 {
7868 sleep(d).await;
7869 continue;
7870 }
7871
7872 dlg.finished(false);
7873
7874 return Err(match error {
7875 Ok(value) => common::Error::BadRequest(value),
7876 _ => common::Error::Failure(response),
7877 });
7878 }
7879 let response = {
7880 let bytes = common::to_bytes(body).await.unwrap_or_default();
7881 let encoded = common::to_string(&bytes);
7882 match serde_json::from_str(&encoded) {
7883 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7884 Err(error) => {
7885 dlg.response_json_decode_error(&encoded, &error);
7886 return Err(common::Error::JsonDecodeError(
7887 encoded.to_string(),
7888 error,
7889 ));
7890 }
7891 }
7892 };
7893
7894 dlg.finished(true);
7895 return Ok(response);
7896 }
7897 }
7898 }
7899 }
7900
7901 ///
7902 /// Sets the *request* property to the given value.
7903 ///
7904 /// Even though the property as already been set when instantiating this call,
7905 /// we provide this method for API completeness.
7906 pub fn request(mut self, new_value: InstancesCloneRequest) -> InstanceCloneCall<'a, C> {
7907 self._request = new_value;
7908 self
7909 }
7910 /// Project ID of the source as well as the clone Cloud SQL instance.
7911 ///
7912 /// Sets the *project* path property to the given value.
7913 ///
7914 /// Even though the property as already been set when instantiating this call,
7915 /// we provide this method for API completeness.
7916 pub fn project(mut self, new_value: &str) -> InstanceCloneCall<'a, C> {
7917 self._project = new_value.to_string();
7918 self
7919 }
7920 /// The ID of the Cloud SQL instance to be cloned (source). This does not
7921 /// include the project ID.
7922 ///
7923 /// Sets the *instance* path property to the given value.
7924 ///
7925 /// Even though the property as already been set when instantiating this call,
7926 /// we provide this method for API completeness.
7927 pub fn instance(mut self, new_value: &str) -> InstanceCloneCall<'a, C> {
7928 self._instance = new_value.to_string();
7929 self
7930 }
7931 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7932 /// while executing the actual API request.
7933 ///
7934 /// ````text
7935 /// It should be used to handle progress information, and to implement a certain level of resilience.
7936 /// ````
7937 ///
7938 /// Sets the *delegate* property to the given value.
7939 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InstanceCloneCall<'a, C> {
7940 self._delegate = Some(new_value);
7941 self
7942 }
7943
7944 /// Set any additional parameter of the query string used in the request.
7945 /// It should be used to set parameters which are not yet available through their own
7946 /// setters.
7947 ///
7948 /// Please note that this method must not be used to set any of the known parameters
7949 /// which have their own setter method. If done anyway, the request will fail.
7950 ///
7951 /// # Additional Parameters
7952 ///
7953 /// * *$.xgafv* (query-string) - V1 error format.
7954 /// * *access_token* (query-string) - OAuth access token.
7955 /// * *alt* (query-string) - Data format for response.
7956 /// * *callback* (query-string) - JSONP
7957 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7958 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7959 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7960 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7961 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7962 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7963 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7964 pub fn param<T>(mut self, name: T, value: T) -> InstanceCloneCall<'a, C>
7965 where
7966 T: AsRef<str>,
7967 {
7968 self._additional_params
7969 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7970 self
7971 }
7972
7973 /// Identifies the authorization scope for the method you are building.
7974 ///
7975 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7976 /// [`Scope::CloudPlatform`].
7977 ///
7978 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7979 /// tokens for more than one scope.
7980 ///
7981 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7982 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7983 /// sufficient, a read-write scope will do as well.
7984 pub fn add_scope<St>(mut self, scope: St) -> InstanceCloneCall<'a, C>
7985 where
7986 St: AsRef<str>,
7987 {
7988 self._scopes.insert(String::from(scope.as_ref()));
7989 self
7990 }
7991 /// Identifies the authorization scope(s) for the method you are building.
7992 ///
7993 /// See [`Self::add_scope()`] for details.
7994 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceCloneCall<'a, C>
7995 where
7996 I: IntoIterator<Item = St>,
7997 St: AsRef<str>,
7998 {
7999 self._scopes
8000 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8001 self
8002 }
8003
8004 /// Removes all scopes, and no default scope will be used either.
8005 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8006 /// for details).
8007 pub fn clear_scopes(mut self) -> InstanceCloneCall<'a, C> {
8008 self._scopes.clear();
8009 self
8010 }
8011}
8012
8013/// Deletes a Cloud SQL instance.
8014///
8015/// A builder for the *delete* method supported by a *instance* resource.
8016/// It is not used directly, but through a [`InstanceMethods`] instance.
8017///
8018/// # Example
8019///
8020/// Instantiate a resource method builder
8021///
8022/// ```test_harness,no_run
8023/// # extern crate hyper;
8024/// # extern crate hyper_rustls;
8025/// # extern crate google_sql1_beta4 as sql1_beta4;
8026/// # async fn dox() {
8027/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8028///
8029/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8030/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8031/// # secret,
8032/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8033/// # ).build().await.unwrap();
8034///
8035/// # let client = hyper_util::client::legacy::Client::builder(
8036/// # hyper_util::rt::TokioExecutor::new()
8037/// # )
8038/// # .build(
8039/// # hyper_rustls::HttpsConnectorBuilder::new()
8040/// # .with_native_roots()
8041/// # .unwrap()
8042/// # .https_or_http()
8043/// # .enable_http1()
8044/// # .build()
8045/// # );
8046/// # let mut hub = SQLAdmin::new(client, auth);
8047/// // You can configure optional parameters by calling the respective setters at will, and
8048/// // execute the final call using `doit()`.
8049/// // Values shown here are possibly random and not representative !
8050/// let result = hub.instances().delete("project", "instance")
8051/// .doit().await;
8052/// # }
8053/// ```
8054pub struct InstanceDeleteCall<'a, C>
8055where
8056 C: 'a,
8057{
8058 hub: &'a SQLAdmin<C>,
8059 _project: String,
8060 _instance: String,
8061 _delegate: Option<&'a mut dyn common::Delegate>,
8062 _additional_params: HashMap<String, String>,
8063 _scopes: BTreeSet<String>,
8064}
8065
8066impl<'a, C> common::CallBuilder for InstanceDeleteCall<'a, C> {}
8067
8068impl<'a, C> InstanceDeleteCall<'a, C>
8069where
8070 C: common::Connector,
8071{
8072 /// Perform the operation you have build so far.
8073 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8074 use std::borrow::Cow;
8075 use std::io::{Read, Seek};
8076
8077 use common::{url::Params, ToParts};
8078 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8079
8080 let mut dd = common::DefaultDelegate;
8081 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8082 dlg.begin(common::MethodInfo {
8083 id: "sql.instances.delete",
8084 http_method: hyper::Method::DELETE,
8085 });
8086
8087 for &field in ["alt", "project", "instance"].iter() {
8088 if self._additional_params.contains_key(field) {
8089 dlg.finished(false);
8090 return Err(common::Error::FieldClash(field));
8091 }
8092 }
8093
8094 let mut params = Params::with_capacity(4 + self._additional_params.len());
8095 params.push("project", self._project);
8096 params.push("instance", self._instance);
8097
8098 params.extend(self._additional_params.iter());
8099
8100 params.push("alt", "json");
8101 let mut url =
8102 self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances/{instance}";
8103 if self._scopes.is_empty() {
8104 self._scopes
8105 .insert(Scope::CloudPlatform.as_ref().to_string());
8106 }
8107
8108 #[allow(clippy::single_element_loop)]
8109 for &(find_this, param_name) in
8110 [("{project}", "project"), ("{instance}", "instance")].iter()
8111 {
8112 url = params.uri_replacement(url, param_name, find_this, false);
8113 }
8114 {
8115 let to_remove = ["instance", "project"];
8116 params.remove_params(&to_remove);
8117 }
8118
8119 let url = params.parse_with_url(&url);
8120
8121 loop {
8122 let token = match self
8123 .hub
8124 .auth
8125 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8126 .await
8127 {
8128 Ok(token) => token,
8129 Err(e) => match dlg.token(e) {
8130 Ok(token) => token,
8131 Err(e) => {
8132 dlg.finished(false);
8133 return Err(common::Error::MissingToken(e));
8134 }
8135 },
8136 };
8137 let mut req_result = {
8138 let client = &self.hub.client;
8139 dlg.pre_request();
8140 let mut req_builder = hyper::Request::builder()
8141 .method(hyper::Method::DELETE)
8142 .uri(url.as_str())
8143 .header(USER_AGENT, self.hub._user_agent.clone());
8144
8145 if let Some(token) = token.as_ref() {
8146 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8147 }
8148
8149 let request = req_builder
8150 .header(CONTENT_LENGTH, 0_u64)
8151 .body(common::to_body::<String>(None));
8152
8153 client.request(request.unwrap()).await
8154 };
8155
8156 match req_result {
8157 Err(err) => {
8158 if let common::Retry::After(d) = dlg.http_error(&err) {
8159 sleep(d).await;
8160 continue;
8161 }
8162 dlg.finished(false);
8163 return Err(common::Error::HttpError(err));
8164 }
8165 Ok(res) => {
8166 let (mut parts, body) = res.into_parts();
8167 let mut body = common::Body::new(body);
8168 if !parts.status.is_success() {
8169 let bytes = common::to_bytes(body).await.unwrap_or_default();
8170 let error = serde_json::from_str(&common::to_string(&bytes));
8171 let response = common::to_response(parts, bytes.into());
8172
8173 if let common::Retry::After(d) =
8174 dlg.http_failure(&response, error.as_ref().ok())
8175 {
8176 sleep(d).await;
8177 continue;
8178 }
8179
8180 dlg.finished(false);
8181
8182 return Err(match error {
8183 Ok(value) => common::Error::BadRequest(value),
8184 _ => common::Error::Failure(response),
8185 });
8186 }
8187 let response = {
8188 let bytes = common::to_bytes(body).await.unwrap_or_default();
8189 let encoded = common::to_string(&bytes);
8190 match serde_json::from_str(&encoded) {
8191 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8192 Err(error) => {
8193 dlg.response_json_decode_error(&encoded, &error);
8194 return Err(common::Error::JsonDecodeError(
8195 encoded.to_string(),
8196 error,
8197 ));
8198 }
8199 }
8200 };
8201
8202 dlg.finished(true);
8203 return Ok(response);
8204 }
8205 }
8206 }
8207 }
8208
8209 /// Project ID of the project that contains the instance to be deleted.
8210 ///
8211 /// Sets the *project* path property to the given value.
8212 ///
8213 /// Even though the property as already been set when instantiating this call,
8214 /// we provide this method for API completeness.
8215 pub fn project(mut self, new_value: &str) -> InstanceDeleteCall<'a, C> {
8216 self._project = new_value.to_string();
8217 self
8218 }
8219 /// Cloud SQL instance ID. This does not include the project ID.
8220 ///
8221 /// Sets the *instance* path property to the given value.
8222 ///
8223 /// Even though the property as already been set when instantiating this call,
8224 /// we provide this method for API completeness.
8225 pub fn instance(mut self, new_value: &str) -> InstanceDeleteCall<'a, C> {
8226 self._instance = new_value.to_string();
8227 self
8228 }
8229 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8230 /// while executing the actual API request.
8231 ///
8232 /// ````text
8233 /// It should be used to handle progress information, and to implement a certain level of resilience.
8234 /// ````
8235 ///
8236 /// Sets the *delegate* property to the given value.
8237 pub fn delegate(
8238 mut self,
8239 new_value: &'a mut dyn common::Delegate,
8240 ) -> InstanceDeleteCall<'a, C> {
8241 self._delegate = Some(new_value);
8242 self
8243 }
8244
8245 /// Set any additional parameter of the query string used in the request.
8246 /// It should be used to set parameters which are not yet available through their own
8247 /// setters.
8248 ///
8249 /// Please note that this method must not be used to set any of the known parameters
8250 /// which have their own setter method. If done anyway, the request will fail.
8251 ///
8252 /// # Additional Parameters
8253 ///
8254 /// * *$.xgafv* (query-string) - V1 error format.
8255 /// * *access_token* (query-string) - OAuth access token.
8256 /// * *alt* (query-string) - Data format for response.
8257 /// * *callback* (query-string) - JSONP
8258 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8259 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8260 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8261 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8262 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8263 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8264 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8265 pub fn param<T>(mut self, name: T, value: T) -> InstanceDeleteCall<'a, C>
8266 where
8267 T: AsRef<str>,
8268 {
8269 self._additional_params
8270 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8271 self
8272 }
8273
8274 /// Identifies the authorization scope for the method you are building.
8275 ///
8276 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8277 /// [`Scope::CloudPlatform`].
8278 ///
8279 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8280 /// tokens for more than one scope.
8281 ///
8282 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8283 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8284 /// sufficient, a read-write scope will do as well.
8285 pub fn add_scope<St>(mut self, scope: St) -> InstanceDeleteCall<'a, C>
8286 where
8287 St: AsRef<str>,
8288 {
8289 self._scopes.insert(String::from(scope.as_ref()));
8290 self
8291 }
8292 /// Identifies the authorization scope(s) for the method you are building.
8293 ///
8294 /// See [`Self::add_scope()`] for details.
8295 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceDeleteCall<'a, C>
8296 where
8297 I: IntoIterator<Item = St>,
8298 St: AsRef<str>,
8299 {
8300 self._scopes
8301 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8302 self
8303 }
8304
8305 /// Removes all scopes, and no default scope will be used either.
8306 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8307 /// for details).
8308 pub fn clear_scopes(mut self) -> InstanceDeleteCall<'a, C> {
8309 self._scopes.clear();
8310 self
8311 }
8312}
8313
8314/// Demotes the stand-alone instance to be a Cloud SQL read replica for an
8315/// external database server.
8316///
8317/// A builder for the *demoteMaster* method supported by a *instance* resource.
8318/// It is not used directly, but through a [`InstanceMethods`] instance.
8319///
8320/// # Example
8321///
8322/// Instantiate a resource method builder
8323///
8324/// ```test_harness,no_run
8325/// # extern crate hyper;
8326/// # extern crate hyper_rustls;
8327/// # extern crate google_sql1_beta4 as sql1_beta4;
8328/// use sql1_beta4::api::InstancesDemoteMasterRequest;
8329/// # async fn dox() {
8330/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8331///
8332/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8333/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8334/// # secret,
8335/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8336/// # ).build().await.unwrap();
8337///
8338/// # let client = hyper_util::client::legacy::Client::builder(
8339/// # hyper_util::rt::TokioExecutor::new()
8340/// # )
8341/// # .build(
8342/// # hyper_rustls::HttpsConnectorBuilder::new()
8343/// # .with_native_roots()
8344/// # .unwrap()
8345/// # .https_or_http()
8346/// # .enable_http1()
8347/// # .build()
8348/// # );
8349/// # let mut hub = SQLAdmin::new(client, auth);
8350/// // As the method needs a request, you would usually fill it with the desired information
8351/// // into the respective structure. Some of the parts shown here might not be applicable !
8352/// // Values shown here are possibly random and not representative !
8353/// let mut req = InstancesDemoteMasterRequest::default();
8354///
8355/// // You can configure optional parameters by calling the respective setters at will, and
8356/// // execute the final call using `doit()`.
8357/// // Values shown here are possibly random and not representative !
8358/// let result = hub.instances().demote_master(req, "project", "instance")
8359/// .doit().await;
8360/// # }
8361/// ```
8362pub struct InstanceDemoteMasterCall<'a, C>
8363where
8364 C: 'a,
8365{
8366 hub: &'a SQLAdmin<C>,
8367 _request: InstancesDemoteMasterRequest,
8368 _project: String,
8369 _instance: String,
8370 _delegate: Option<&'a mut dyn common::Delegate>,
8371 _additional_params: HashMap<String, String>,
8372 _scopes: BTreeSet<String>,
8373}
8374
8375impl<'a, C> common::CallBuilder for InstanceDemoteMasterCall<'a, C> {}
8376
8377impl<'a, C> InstanceDemoteMasterCall<'a, C>
8378where
8379 C: common::Connector,
8380{
8381 /// Perform the operation you have build so far.
8382 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8383 use std::borrow::Cow;
8384 use std::io::{Read, Seek};
8385
8386 use common::{url::Params, ToParts};
8387 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8388
8389 let mut dd = common::DefaultDelegate;
8390 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8391 dlg.begin(common::MethodInfo {
8392 id: "sql.instances.demoteMaster",
8393 http_method: hyper::Method::POST,
8394 });
8395
8396 for &field in ["alt", "project", "instance"].iter() {
8397 if self._additional_params.contains_key(field) {
8398 dlg.finished(false);
8399 return Err(common::Error::FieldClash(field));
8400 }
8401 }
8402
8403 let mut params = Params::with_capacity(5 + self._additional_params.len());
8404 params.push("project", self._project);
8405 params.push("instance", self._instance);
8406
8407 params.extend(self._additional_params.iter());
8408
8409 params.push("alt", "json");
8410 let mut url = self.hub._base_url.clone()
8411 + "sql/v1beta4/projects/{project}/instances/{instance}/demoteMaster";
8412 if self._scopes.is_empty() {
8413 self._scopes
8414 .insert(Scope::CloudPlatform.as_ref().to_string());
8415 }
8416
8417 #[allow(clippy::single_element_loop)]
8418 for &(find_this, param_name) in
8419 [("{project}", "project"), ("{instance}", "instance")].iter()
8420 {
8421 url = params.uri_replacement(url, param_name, find_this, false);
8422 }
8423 {
8424 let to_remove = ["instance", "project"];
8425 params.remove_params(&to_remove);
8426 }
8427
8428 let url = params.parse_with_url(&url);
8429
8430 let mut json_mime_type = mime::APPLICATION_JSON;
8431 let mut request_value_reader = {
8432 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8433 common::remove_json_null_values(&mut value);
8434 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8435 serde_json::to_writer(&mut dst, &value).unwrap();
8436 dst
8437 };
8438 let request_size = request_value_reader
8439 .seek(std::io::SeekFrom::End(0))
8440 .unwrap();
8441 request_value_reader
8442 .seek(std::io::SeekFrom::Start(0))
8443 .unwrap();
8444
8445 loop {
8446 let token = match self
8447 .hub
8448 .auth
8449 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8450 .await
8451 {
8452 Ok(token) => token,
8453 Err(e) => match dlg.token(e) {
8454 Ok(token) => token,
8455 Err(e) => {
8456 dlg.finished(false);
8457 return Err(common::Error::MissingToken(e));
8458 }
8459 },
8460 };
8461 request_value_reader
8462 .seek(std::io::SeekFrom::Start(0))
8463 .unwrap();
8464 let mut req_result = {
8465 let client = &self.hub.client;
8466 dlg.pre_request();
8467 let mut req_builder = hyper::Request::builder()
8468 .method(hyper::Method::POST)
8469 .uri(url.as_str())
8470 .header(USER_AGENT, self.hub._user_agent.clone());
8471
8472 if let Some(token) = token.as_ref() {
8473 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8474 }
8475
8476 let request = req_builder
8477 .header(CONTENT_TYPE, json_mime_type.to_string())
8478 .header(CONTENT_LENGTH, request_size as u64)
8479 .body(common::to_body(
8480 request_value_reader.get_ref().clone().into(),
8481 ));
8482
8483 client.request(request.unwrap()).await
8484 };
8485
8486 match req_result {
8487 Err(err) => {
8488 if let common::Retry::After(d) = dlg.http_error(&err) {
8489 sleep(d).await;
8490 continue;
8491 }
8492 dlg.finished(false);
8493 return Err(common::Error::HttpError(err));
8494 }
8495 Ok(res) => {
8496 let (mut parts, body) = res.into_parts();
8497 let mut body = common::Body::new(body);
8498 if !parts.status.is_success() {
8499 let bytes = common::to_bytes(body).await.unwrap_or_default();
8500 let error = serde_json::from_str(&common::to_string(&bytes));
8501 let response = common::to_response(parts, bytes.into());
8502
8503 if let common::Retry::After(d) =
8504 dlg.http_failure(&response, error.as_ref().ok())
8505 {
8506 sleep(d).await;
8507 continue;
8508 }
8509
8510 dlg.finished(false);
8511
8512 return Err(match error {
8513 Ok(value) => common::Error::BadRequest(value),
8514 _ => common::Error::Failure(response),
8515 });
8516 }
8517 let response = {
8518 let bytes = common::to_bytes(body).await.unwrap_or_default();
8519 let encoded = common::to_string(&bytes);
8520 match serde_json::from_str(&encoded) {
8521 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8522 Err(error) => {
8523 dlg.response_json_decode_error(&encoded, &error);
8524 return Err(common::Error::JsonDecodeError(
8525 encoded.to_string(),
8526 error,
8527 ));
8528 }
8529 }
8530 };
8531
8532 dlg.finished(true);
8533 return Ok(response);
8534 }
8535 }
8536 }
8537 }
8538
8539 ///
8540 /// Sets the *request* property to the given value.
8541 ///
8542 /// Even though the property as already been set when instantiating this call,
8543 /// we provide this method for API completeness.
8544 pub fn request(
8545 mut self,
8546 new_value: InstancesDemoteMasterRequest,
8547 ) -> InstanceDemoteMasterCall<'a, C> {
8548 self._request = new_value;
8549 self
8550 }
8551 /// ID of the project that contains the instance.
8552 ///
8553 /// Sets the *project* path property to the given value.
8554 ///
8555 /// Even though the property as already been set when instantiating this call,
8556 /// we provide this method for API completeness.
8557 pub fn project(mut self, new_value: &str) -> InstanceDemoteMasterCall<'a, C> {
8558 self._project = new_value.to_string();
8559 self
8560 }
8561 /// Cloud SQL instance name.
8562 ///
8563 /// Sets the *instance* path property to the given value.
8564 ///
8565 /// Even though the property as already been set when instantiating this call,
8566 /// we provide this method for API completeness.
8567 pub fn instance(mut self, new_value: &str) -> InstanceDemoteMasterCall<'a, C> {
8568 self._instance = new_value.to_string();
8569 self
8570 }
8571 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8572 /// while executing the actual API request.
8573 ///
8574 /// ````text
8575 /// It should be used to handle progress information, and to implement a certain level of resilience.
8576 /// ````
8577 ///
8578 /// Sets the *delegate* property to the given value.
8579 pub fn delegate(
8580 mut self,
8581 new_value: &'a mut dyn common::Delegate,
8582 ) -> InstanceDemoteMasterCall<'a, C> {
8583 self._delegate = Some(new_value);
8584 self
8585 }
8586
8587 /// Set any additional parameter of the query string used in the request.
8588 /// It should be used to set parameters which are not yet available through their own
8589 /// setters.
8590 ///
8591 /// Please note that this method must not be used to set any of the known parameters
8592 /// which have their own setter method. If done anyway, the request will fail.
8593 ///
8594 /// # Additional Parameters
8595 ///
8596 /// * *$.xgafv* (query-string) - V1 error format.
8597 /// * *access_token* (query-string) - OAuth access token.
8598 /// * *alt* (query-string) - Data format for response.
8599 /// * *callback* (query-string) - JSONP
8600 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8601 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8602 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8603 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8604 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8605 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8606 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8607 pub fn param<T>(mut self, name: T, value: T) -> InstanceDemoteMasterCall<'a, C>
8608 where
8609 T: AsRef<str>,
8610 {
8611 self._additional_params
8612 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8613 self
8614 }
8615
8616 /// Identifies the authorization scope for the method you are building.
8617 ///
8618 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8619 /// [`Scope::CloudPlatform`].
8620 ///
8621 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8622 /// tokens for more than one scope.
8623 ///
8624 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8625 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8626 /// sufficient, a read-write scope will do as well.
8627 pub fn add_scope<St>(mut self, scope: St) -> InstanceDemoteMasterCall<'a, C>
8628 where
8629 St: AsRef<str>,
8630 {
8631 self._scopes.insert(String::from(scope.as_ref()));
8632 self
8633 }
8634 /// Identifies the authorization scope(s) for the method you are building.
8635 ///
8636 /// See [`Self::add_scope()`] for details.
8637 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceDemoteMasterCall<'a, C>
8638 where
8639 I: IntoIterator<Item = St>,
8640 St: AsRef<str>,
8641 {
8642 self._scopes
8643 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8644 self
8645 }
8646
8647 /// Removes all scopes, and no default scope will be used either.
8648 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8649 /// for details).
8650 pub fn clear_scopes(mut self) -> InstanceDemoteMasterCall<'a, C> {
8651 self._scopes.clear();
8652 self
8653 }
8654}
8655
8656/// Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL
8657/// dump or CSV file.
8658///
8659/// A builder for the *export* method supported by a *instance* resource.
8660/// It is not used directly, but through a [`InstanceMethods`] instance.
8661///
8662/// # Example
8663///
8664/// Instantiate a resource method builder
8665///
8666/// ```test_harness,no_run
8667/// # extern crate hyper;
8668/// # extern crate hyper_rustls;
8669/// # extern crate google_sql1_beta4 as sql1_beta4;
8670/// use sql1_beta4::api::InstancesExportRequest;
8671/// # async fn dox() {
8672/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8673///
8674/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8675/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8676/// # secret,
8677/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8678/// # ).build().await.unwrap();
8679///
8680/// # let client = hyper_util::client::legacy::Client::builder(
8681/// # hyper_util::rt::TokioExecutor::new()
8682/// # )
8683/// # .build(
8684/// # hyper_rustls::HttpsConnectorBuilder::new()
8685/// # .with_native_roots()
8686/// # .unwrap()
8687/// # .https_or_http()
8688/// # .enable_http1()
8689/// # .build()
8690/// # );
8691/// # let mut hub = SQLAdmin::new(client, auth);
8692/// // As the method needs a request, you would usually fill it with the desired information
8693/// // into the respective structure. Some of the parts shown here might not be applicable !
8694/// // Values shown here are possibly random and not representative !
8695/// let mut req = InstancesExportRequest::default();
8696///
8697/// // You can configure optional parameters by calling the respective setters at will, and
8698/// // execute the final call using `doit()`.
8699/// // Values shown here are possibly random and not representative !
8700/// let result = hub.instances().export(req, "project", "instance")
8701/// .doit().await;
8702/// # }
8703/// ```
8704pub struct InstanceExportCall<'a, C>
8705where
8706 C: 'a,
8707{
8708 hub: &'a SQLAdmin<C>,
8709 _request: InstancesExportRequest,
8710 _project: String,
8711 _instance: String,
8712 _delegate: Option<&'a mut dyn common::Delegate>,
8713 _additional_params: HashMap<String, String>,
8714 _scopes: BTreeSet<String>,
8715}
8716
8717impl<'a, C> common::CallBuilder for InstanceExportCall<'a, C> {}
8718
8719impl<'a, C> InstanceExportCall<'a, C>
8720where
8721 C: common::Connector,
8722{
8723 /// Perform the operation you have build so far.
8724 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8725 use std::borrow::Cow;
8726 use std::io::{Read, Seek};
8727
8728 use common::{url::Params, ToParts};
8729 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8730
8731 let mut dd = common::DefaultDelegate;
8732 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8733 dlg.begin(common::MethodInfo {
8734 id: "sql.instances.export",
8735 http_method: hyper::Method::POST,
8736 });
8737
8738 for &field in ["alt", "project", "instance"].iter() {
8739 if self._additional_params.contains_key(field) {
8740 dlg.finished(false);
8741 return Err(common::Error::FieldClash(field));
8742 }
8743 }
8744
8745 let mut params = Params::with_capacity(5 + self._additional_params.len());
8746 params.push("project", self._project);
8747 params.push("instance", self._instance);
8748
8749 params.extend(self._additional_params.iter());
8750
8751 params.push("alt", "json");
8752 let mut url = self.hub._base_url.clone()
8753 + "sql/v1beta4/projects/{project}/instances/{instance}/export";
8754 if self._scopes.is_empty() {
8755 self._scopes
8756 .insert(Scope::CloudPlatform.as_ref().to_string());
8757 }
8758
8759 #[allow(clippy::single_element_loop)]
8760 for &(find_this, param_name) in
8761 [("{project}", "project"), ("{instance}", "instance")].iter()
8762 {
8763 url = params.uri_replacement(url, param_name, find_this, false);
8764 }
8765 {
8766 let to_remove = ["instance", "project"];
8767 params.remove_params(&to_remove);
8768 }
8769
8770 let url = params.parse_with_url(&url);
8771
8772 let mut json_mime_type = mime::APPLICATION_JSON;
8773 let mut request_value_reader = {
8774 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8775 common::remove_json_null_values(&mut value);
8776 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8777 serde_json::to_writer(&mut dst, &value).unwrap();
8778 dst
8779 };
8780 let request_size = request_value_reader
8781 .seek(std::io::SeekFrom::End(0))
8782 .unwrap();
8783 request_value_reader
8784 .seek(std::io::SeekFrom::Start(0))
8785 .unwrap();
8786
8787 loop {
8788 let token = match self
8789 .hub
8790 .auth
8791 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8792 .await
8793 {
8794 Ok(token) => token,
8795 Err(e) => match dlg.token(e) {
8796 Ok(token) => token,
8797 Err(e) => {
8798 dlg.finished(false);
8799 return Err(common::Error::MissingToken(e));
8800 }
8801 },
8802 };
8803 request_value_reader
8804 .seek(std::io::SeekFrom::Start(0))
8805 .unwrap();
8806 let mut req_result = {
8807 let client = &self.hub.client;
8808 dlg.pre_request();
8809 let mut req_builder = hyper::Request::builder()
8810 .method(hyper::Method::POST)
8811 .uri(url.as_str())
8812 .header(USER_AGENT, self.hub._user_agent.clone());
8813
8814 if let Some(token) = token.as_ref() {
8815 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8816 }
8817
8818 let request = req_builder
8819 .header(CONTENT_TYPE, json_mime_type.to_string())
8820 .header(CONTENT_LENGTH, request_size as u64)
8821 .body(common::to_body(
8822 request_value_reader.get_ref().clone().into(),
8823 ));
8824
8825 client.request(request.unwrap()).await
8826 };
8827
8828 match req_result {
8829 Err(err) => {
8830 if let common::Retry::After(d) = dlg.http_error(&err) {
8831 sleep(d).await;
8832 continue;
8833 }
8834 dlg.finished(false);
8835 return Err(common::Error::HttpError(err));
8836 }
8837 Ok(res) => {
8838 let (mut parts, body) = res.into_parts();
8839 let mut body = common::Body::new(body);
8840 if !parts.status.is_success() {
8841 let bytes = common::to_bytes(body).await.unwrap_or_default();
8842 let error = serde_json::from_str(&common::to_string(&bytes));
8843 let response = common::to_response(parts, bytes.into());
8844
8845 if let common::Retry::After(d) =
8846 dlg.http_failure(&response, error.as_ref().ok())
8847 {
8848 sleep(d).await;
8849 continue;
8850 }
8851
8852 dlg.finished(false);
8853
8854 return Err(match error {
8855 Ok(value) => common::Error::BadRequest(value),
8856 _ => common::Error::Failure(response),
8857 });
8858 }
8859 let response = {
8860 let bytes = common::to_bytes(body).await.unwrap_or_default();
8861 let encoded = common::to_string(&bytes);
8862 match serde_json::from_str(&encoded) {
8863 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8864 Err(error) => {
8865 dlg.response_json_decode_error(&encoded, &error);
8866 return Err(common::Error::JsonDecodeError(
8867 encoded.to_string(),
8868 error,
8869 ));
8870 }
8871 }
8872 };
8873
8874 dlg.finished(true);
8875 return Ok(response);
8876 }
8877 }
8878 }
8879 }
8880
8881 ///
8882 /// Sets the *request* property to the given value.
8883 ///
8884 /// Even though the property as already been set when instantiating this call,
8885 /// we provide this method for API completeness.
8886 pub fn request(mut self, new_value: InstancesExportRequest) -> InstanceExportCall<'a, C> {
8887 self._request = new_value;
8888 self
8889 }
8890 /// Project ID of the project that contains the instance to be exported.
8891 ///
8892 /// Sets the *project* path property to the given value.
8893 ///
8894 /// Even though the property as already been set when instantiating this call,
8895 /// we provide this method for API completeness.
8896 pub fn project(mut self, new_value: &str) -> InstanceExportCall<'a, C> {
8897 self._project = new_value.to_string();
8898 self
8899 }
8900 /// Cloud SQL instance ID. This does not include the project ID.
8901 ///
8902 /// Sets the *instance* path property to the given value.
8903 ///
8904 /// Even though the property as already been set when instantiating this call,
8905 /// we provide this method for API completeness.
8906 pub fn instance(mut self, new_value: &str) -> InstanceExportCall<'a, C> {
8907 self._instance = new_value.to_string();
8908 self
8909 }
8910 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8911 /// while executing the actual API request.
8912 ///
8913 /// ````text
8914 /// It should be used to handle progress information, and to implement a certain level of resilience.
8915 /// ````
8916 ///
8917 /// Sets the *delegate* property to the given value.
8918 pub fn delegate(
8919 mut self,
8920 new_value: &'a mut dyn common::Delegate,
8921 ) -> InstanceExportCall<'a, C> {
8922 self._delegate = Some(new_value);
8923 self
8924 }
8925
8926 /// Set any additional parameter of the query string used in the request.
8927 /// It should be used to set parameters which are not yet available through their own
8928 /// setters.
8929 ///
8930 /// Please note that this method must not be used to set any of the known parameters
8931 /// which have their own setter method. If done anyway, the request will fail.
8932 ///
8933 /// # Additional Parameters
8934 ///
8935 /// * *$.xgafv* (query-string) - V1 error format.
8936 /// * *access_token* (query-string) - OAuth access token.
8937 /// * *alt* (query-string) - Data format for response.
8938 /// * *callback* (query-string) - JSONP
8939 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8940 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8941 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8942 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8943 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8944 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8945 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8946 pub fn param<T>(mut self, name: T, value: T) -> InstanceExportCall<'a, C>
8947 where
8948 T: AsRef<str>,
8949 {
8950 self._additional_params
8951 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8952 self
8953 }
8954
8955 /// Identifies the authorization scope for the method you are building.
8956 ///
8957 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8958 /// [`Scope::CloudPlatform`].
8959 ///
8960 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8961 /// tokens for more than one scope.
8962 ///
8963 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8964 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8965 /// sufficient, a read-write scope will do as well.
8966 pub fn add_scope<St>(mut self, scope: St) -> InstanceExportCall<'a, C>
8967 where
8968 St: AsRef<str>,
8969 {
8970 self._scopes.insert(String::from(scope.as_ref()));
8971 self
8972 }
8973 /// Identifies the authorization scope(s) for the method you are building.
8974 ///
8975 /// See [`Self::add_scope()`] for details.
8976 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceExportCall<'a, C>
8977 where
8978 I: IntoIterator<Item = St>,
8979 St: AsRef<str>,
8980 {
8981 self._scopes
8982 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8983 self
8984 }
8985
8986 /// Removes all scopes, and no default scope will be used either.
8987 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8988 /// for details).
8989 pub fn clear_scopes(mut self) -> InstanceExportCall<'a, C> {
8990 self._scopes.clear();
8991 self
8992 }
8993}
8994
8995/// Failover the instance to its failover replica instance. Using this
8996/// operation might cause your instance to restart.
8997///
8998/// A builder for the *failover* method supported by a *instance* resource.
8999/// It is not used directly, but through a [`InstanceMethods`] instance.
9000///
9001/// # Example
9002///
9003/// Instantiate a resource method builder
9004///
9005/// ```test_harness,no_run
9006/// # extern crate hyper;
9007/// # extern crate hyper_rustls;
9008/// # extern crate google_sql1_beta4 as sql1_beta4;
9009/// use sql1_beta4::api::InstancesFailoverRequest;
9010/// # async fn dox() {
9011/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9012///
9013/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9014/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9015/// # secret,
9016/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9017/// # ).build().await.unwrap();
9018///
9019/// # let client = hyper_util::client::legacy::Client::builder(
9020/// # hyper_util::rt::TokioExecutor::new()
9021/// # )
9022/// # .build(
9023/// # hyper_rustls::HttpsConnectorBuilder::new()
9024/// # .with_native_roots()
9025/// # .unwrap()
9026/// # .https_or_http()
9027/// # .enable_http1()
9028/// # .build()
9029/// # );
9030/// # let mut hub = SQLAdmin::new(client, auth);
9031/// // As the method needs a request, you would usually fill it with the desired information
9032/// // into the respective structure. Some of the parts shown here might not be applicable !
9033/// // Values shown here are possibly random and not representative !
9034/// let mut req = InstancesFailoverRequest::default();
9035///
9036/// // You can configure optional parameters by calling the respective setters at will, and
9037/// // execute the final call using `doit()`.
9038/// // Values shown here are possibly random and not representative !
9039/// let result = hub.instances().failover(req, "project", "instance")
9040/// .doit().await;
9041/// # }
9042/// ```
9043pub struct InstanceFailoverCall<'a, C>
9044where
9045 C: 'a,
9046{
9047 hub: &'a SQLAdmin<C>,
9048 _request: InstancesFailoverRequest,
9049 _project: String,
9050 _instance: String,
9051 _delegate: Option<&'a mut dyn common::Delegate>,
9052 _additional_params: HashMap<String, String>,
9053 _scopes: BTreeSet<String>,
9054}
9055
9056impl<'a, C> common::CallBuilder for InstanceFailoverCall<'a, C> {}
9057
9058impl<'a, C> InstanceFailoverCall<'a, C>
9059where
9060 C: common::Connector,
9061{
9062 /// Perform the operation you have build so far.
9063 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9064 use std::borrow::Cow;
9065 use std::io::{Read, Seek};
9066
9067 use common::{url::Params, ToParts};
9068 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9069
9070 let mut dd = common::DefaultDelegate;
9071 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9072 dlg.begin(common::MethodInfo {
9073 id: "sql.instances.failover",
9074 http_method: hyper::Method::POST,
9075 });
9076
9077 for &field in ["alt", "project", "instance"].iter() {
9078 if self._additional_params.contains_key(field) {
9079 dlg.finished(false);
9080 return Err(common::Error::FieldClash(field));
9081 }
9082 }
9083
9084 let mut params = Params::with_capacity(5 + self._additional_params.len());
9085 params.push("project", self._project);
9086 params.push("instance", self._instance);
9087
9088 params.extend(self._additional_params.iter());
9089
9090 params.push("alt", "json");
9091 let mut url = self.hub._base_url.clone()
9092 + "sql/v1beta4/projects/{project}/instances/{instance}/failover";
9093 if self._scopes.is_empty() {
9094 self._scopes
9095 .insert(Scope::CloudPlatform.as_ref().to_string());
9096 }
9097
9098 #[allow(clippy::single_element_loop)]
9099 for &(find_this, param_name) in
9100 [("{project}", "project"), ("{instance}", "instance")].iter()
9101 {
9102 url = params.uri_replacement(url, param_name, find_this, false);
9103 }
9104 {
9105 let to_remove = ["instance", "project"];
9106 params.remove_params(&to_remove);
9107 }
9108
9109 let url = params.parse_with_url(&url);
9110
9111 let mut json_mime_type = mime::APPLICATION_JSON;
9112 let mut request_value_reader = {
9113 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9114 common::remove_json_null_values(&mut value);
9115 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9116 serde_json::to_writer(&mut dst, &value).unwrap();
9117 dst
9118 };
9119 let request_size = request_value_reader
9120 .seek(std::io::SeekFrom::End(0))
9121 .unwrap();
9122 request_value_reader
9123 .seek(std::io::SeekFrom::Start(0))
9124 .unwrap();
9125
9126 loop {
9127 let token = match self
9128 .hub
9129 .auth
9130 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9131 .await
9132 {
9133 Ok(token) => token,
9134 Err(e) => match dlg.token(e) {
9135 Ok(token) => token,
9136 Err(e) => {
9137 dlg.finished(false);
9138 return Err(common::Error::MissingToken(e));
9139 }
9140 },
9141 };
9142 request_value_reader
9143 .seek(std::io::SeekFrom::Start(0))
9144 .unwrap();
9145 let mut req_result = {
9146 let client = &self.hub.client;
9147 dlg.pre_request();
9148 let mut req_builder = hyper::Request::builder()
9149 .method(hyper::Method::POST)
9150 .uri(url.as_str())
9151 .header(USER_AGENT, self.hub._user_agent.clone());
9152
9153 if let Some(token) = token.as_ref() {
9154 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9155 }
9156
9157 let request = req_builder
9158 .header(CONTENT_TYPE, json_mime_type.to_string())
9159 .header(CONTENT_LENGTH, request_size as u64)
9160 .body(common::to_body(
9161 request_value_reader.get_ref().clone().into(),
9162 ));
9163
9164 client.request(request.unwrap()).await
9165 };
9166
9167 match req_result {
9168 Err(err) => {
9169 if let common::Retry::After(d) = dlg.http_error(&err) {
9170 sleep(d).await;
9171 continue;
9172 }
9173 dlg.finished(false);
9174 return Err(common::Error::HttpError(err));
9175 }
9176 Ok(res) => {
9177 let (mut parts, body) = res.into_parts();
9178 let mut body = common::Body::new(body);
9179 if !parts.status.is_success() {
9180 let bytes = common::to_bytes(body).await.unwrap_or_default();
9181 let error = serde_json::from_str(&common::to_string(&bytes));
9182 let response = common::to_response(parts, bytes.into());
9183
9184 if let common::Retry::After(d) =
9185 dlg.http_failure(&response, error.as_ref().ok())
9186 {
9187 sleep(d).await;
9188 continue;
9189 }
9190
9191 dlg.finished(false);
9192
9193 return Err(match error {
9194 Ok(value) => common::Error::BadRequest(value),
9195 _ => common::Error::Failure(response),
9196 });
9197 }
9198 let response = {
9199 let bytes = common::to_bytes(body).await.unwrap_or_default();
9200 let encoded = common::to_string(&bytes);
9201 match serde_json::from_str(&encoded) {
9202 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9203 Err(error) => {
9204 dlg.response_json_decode_error(&encoded, &error);
9205 return Err(common::Error::JsonDecodeError(
9206 encoded.to_string(),
9207 error,
9208 ));
9209 }
9210 }
9211 };
9212
9213 dlg.finished(true);
9214 return Ok(response);
9215 }
9216 }
9217 }
9218 }
9219
9220 ///
9221 /// Sets the *request* property to the given value.
9222 ///
9223 /// Even though the property as already been set when instantiating this call,
9224 /// we provide this method for API completeness.
9225 pub fn request(mut self, new_value: InstancesFailoverRequest) -> InstanceFailoverCall<'a, C> {
9226 self._request = new_value;
9227 self
9228 }
9229 /// ID of the project that contains the read replica.
9230 ///
9231 /// Sets the *project* path property to the given value.
9232 ///
9233 /// Even though the property as already been set when instantiating this call,
9234 /// we provide this method for API completeness.
9235 pub fn project(mut self, new_value: &str) -> InstanceFailoverCall<'a, C> {
9236 self._project = new_value.to_string();
9237 self
9238 }
9239 /// Cloud SQL instance ID. This does not include the project ID.
9240 ///
9241 /// Sets the *instance* path property to the given value.
9242 ///
9243 /// Even though the property as already been set when instantiating this call,
9244 /// we provide this method for API completeness.
9245 pub fn instance(mut self, new_value: &str) -> InstanceFailoverCall<'a, C> {
9246 self._instance = new_value.to_string();
9247 self
9248 }
9249 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9250 /// while executing the actual API request.
9251 ///
9252 /// ````text
9253 /// It should be used to handle progress information, and to implement a certain level of resilience.
9254 /// ````
9255 ///
9256 /// Sets the *delegate* property to the given value.
9257 pub fn delegate(
9258 mut self,
9259 new_value: &'a mut dyn common::Delegate,
9260 ) -> InstanceFailoverCall<'a, C> {
9261 self._delegate = Some(new_value);
9262 self
9263 }
9264
9265 /// Set any additional parameter of the query string used in the request.
9266 /// It should be used to set parameters which are not yet available through their own
9267 /// setters.
9268 ///
9269 /// Please note that this method must not be used to set any of the known parameters
9270 /// which have their own setter method. If done anyway, the request will fail.
9271 ///
9272 /// # Additional Parameters
9273 ///
9274 /// * *$.xgafv* (query-string) - V1 error format.
9275 /// * *access_token* (query-string) - OAuth access token.
9276 /// * *alt* (query-string) - Data format for response.
9277 /// * *callback* (query-string) - JSONP
9278 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9279 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9280 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9281 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9282 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9283 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9284 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9285 pub fn param<T>(mut self, name: T, value: T) -> InstanceFailoverCall<'a, C>
9286 where
9287 T: AsRef<str>,
9288 {
9289 self._additional_params
9290 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9291 self
9292 }
9293
9294 /// Identifies the authorization scope for the method you are building.
9295 ///
9296 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9297 /// [`Scope::CloudPlatform`].
9298 ///
9299 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9300 /// tokens for more than one scope.
9301 ///
9302 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9303 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9304 /// sufficient, a read-write scope will do as well.
9305 pub fn add_scope<St>(mut self, scope: St) -> InstanceFailoverCall<'a, C>
9306 where
9307 St: AsRef<str>,
9308 {
9309 self._scopes.insert(String::from(scope.as_ref()));
9310 self
9311 }
9312 /// Identifies the authorization scope(s) for the method you are building.
9313 ///
9314 /// See [`Self::add_scope()`] for details.
9315 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceFailoverCall<'a, C>
9316 where
9317 I: IntoIterator<Item = St>,
9318 St: AsRef<str>,
9319 {
9320 self._scopes
9321 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9322 self
9323 }
9324
9325 /// Removes all scopes, and no default scope will be used either.
9326 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9327 /// for details).
9328 pub fn clear_scopes(mut self) -> InstanceFailoverCall<'a, C> {
9329 self._scopes.clear();
9330 self
9331 }
9332}
9333
9334/// Retrieves a resource containing information about a Cloud SQL instance.
9335///
9336/// A builder for the *get* method supported by a *instance* resource.
9337/// It is not used directly, but through a [`InstanceMethods`] instance.
9338///
9339/// # Example
9340///
9341/// Instantiate a resource method builder
9342///
9343/// ```test_harness,no_run
9344/// # extern crate hyper;
9345/// # extern crate hyper_rustls;
9346/// # extern crate google_sql1_beta4 as sql1_beta4;
9347/// # async fn dox() {
9348/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9349///
9350/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9351/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9352/// # secret,
9353/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9354/// # ).build().await.unwrap();
9355///
9356/// # let client = hyper_util::client::legacy::Client::builder(
9357/// # hyper_util::rt::TokioExecutor::new()
9358/// # )
9359/// # .build(
9360/// # hyper_rustls::HttpsConnectorBuilder::new()
9361/// # .with_native_roots()
9362/// # .unwrap()
9363/// # .https_or_http()
9364/// # .enable_http1()
9365/// # .build()
9366/// # );
9367/// # let mut hub = SQLAdmin::new(client, auth);
9368/// // You can configure optional parameters by calling the respective setters at will, and
9369/// // execute the final call using `doit()`.
9370/// // Values shown here are possibly random and not representative !
9371/// let result = hub.instances().get("project", "instance")
9372/// .doit().await;
9373/// # }
9374/// ```
9375pub struct InstanceGetCall<'a, C>
9376where
9377 C: 'a,
9378{
9379 hub: &'a SQLAdmin<C>,
9380 _project: String,
9381 _instance: String,
9382 _delegate: Option<&'a mut dyn common::Delegate>,
9383 _additional_params: HashMap<String, String>,
9384 _scopes: BTreeSet<String>,
9385}
9386
9387impl<'a, C> common::CallBuilder for InstanceGetCall<'a, C> {}
9388
9389impl<'a, C> InstanceGetCall<'a, C>
9390where
9391 C: common::Connector,
9392{
9393 /// Perform the operation you have build so far.
9394 pub async fn doit(mut self) -> common::Result<(common::Response, DatabaseInstance)> {
9395 use std::borrow::Cow;
9396 use std::io::{Read, Seek};
9397
9398 use common::{url::Params, ToParts};
9399 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9400
9401 let mut dd = common::DefaultDelegate;
9402 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9403 dlg.begin(common::MethodInfo {
9404 id: "sql.instances.get",
9405 http_method: hyper::Method::GET,
9406 });
9407
9408 for &field in ["alt", "project", "instance"].iter() {
9409 if self._additional_params.contains_key(field) {
9410 dlg.finished(false);
9411 return Err(common::Error::FieldClash(field));
9412 }
9413 }
9414
9415 let mut params = Params::with_capacity(4 + self._additional_params.len());
9416 params.push("project", self._project);
9417 params.push("instance", self._instance);
9418
9419 params.extend(self._additional_params.iter());
9420
9421 params.push("alt", "json");
9422 let mut url =
9423 self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances/{instance}";
9424 if self._scopes.is_empty() {
9425 self._scopes
9426 .insert(Scope::CloudPlatform.as_ref().to_string());
9427 }
9428
9429 #[allow(clippy::single_element_loop)]
9430 for &(find_this, param_name) in
9431 [("{project}", "project"), ("{instance}", "instance")].iter()
9432 {
9433 url = params.uri_replacement(url, param_name, find_this, false);
9434 }
9435 {
9436 let to_remove = ["instance", "project"];
9437 params.remove_params(&to_remove);
9438 }
9439
9440 let url = params.parse_with_url(&url);
9441
9442 loop {
9443 let token = match self
9444 .hub
9445 .auth
9446 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9447 .await
9448 {
9449 Ok(token) => token,
9450 Err(e) => match dlg.token(e) {
9451 Ok(token) => token,
9452 Err(e) => {
9453 dlg.finished(false);
9454 return Err(common::Error::MissingToken(e));
9455 }
9456 },
9457 };
9458 let mut req_result = {
9459 let client = &self.hub.client;
9460 dlg.pre_request();
9461 let mut req_builder = hyper::Request::builder()
9462 .method(hyper::Method::GET)
9463 .uri(url.as_str())
9464 .header(USER_AGENT, self.hub._user_agent.clone());
9465
9466 if let Some(token) = token.as_ref() {
9467 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9468 }
9469
9470 let request = req_builder
9471 .header(CONTENT_LENGTH, 0_u64)
9472 .body(common::to_body::<String>(None));
9473
9474 client.request(request.unwrap()).await
9475 };
9476
9477 match req_result {
9478 Err(err) => {
9479 if let common::Retry::After(d) = dlg.http_error(&err) {
9480 sleep(d).await;
9481 continue;
9482 }
9483 dlg.finished(false);
9484 return Err(common::Error::HttpError(err));
9485 }
9486 Ok(res) => {
9487 let (mut parts, body) = res.into_parts();
9488 let mut body = common::Body::new(body);
9489 if !parts.status.is_success() {
9490 let bytes = common::to_bytes(body).await.unwrap_or_default();
9491 let error = serde_json::from_str(&common::to_string(&bytes));
9492 let response = common::to_response(parts, bytes.into());
9493
9494 if let common::Retry::After(d) =
9495 dlg.http_failure(&response, error.as_ref().ok())
9496 {
9497 sleep(d).await;
9498 continue;
9499 }
9500
9501 dlg.finished(false);
9502
9503 return Err(match error {
9504 Ok(value) => common::Error::BadRequest(value),
9505 _ => common::Error::Failure(response),
9506 });
9507 }
9508 let response = {
9509 let bytes = common::to_bytes(body).await.unwrap_or_default();
9510 let encoded = common::to_string(&bytes);
9511 match serde_json::from_str(&encoded) {
9512 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9513 Err(error) => {
9514 dlg.response_json_decode_error(&encoded, &error);
9515 return Err(common::Error::JsonDecodeError(
9516 encoded.to_string(),
9517 error,
9518 ));
9519 }
9520 }
9521 };
9522
9523 dlg.finished(true);
9524 return Ok(response);
9525 }
9526 }
9527 }
9528 }
9529
9530 /// Project ID of the project that contains the instance.
9531 ///
9532 /// Sets the *project* path property to the given value.
9533 ///
9534 /// Even though the property as already been set when instantiating this call,
9535 /// we provide this method for API completeness.
9536 pub fn project(mut self, new_value: &str) -> InstanceGetCall<'a, C> {
9537 self._project = new_value.to_string();
9538 self
9539 }
9540 /// Database instance ID. This does not include the project ID.
9541 ///
9542 /// Sets the *instance* path property to the given value.
9543 ///
9544 /// Even though the property as already been set when instantiating this call,
9545 /// we provide this method for API completeness.
9546 pub fn instance(mut self, new_value: &str) -> InstanceGetCall<'a, C> {
9547 self._instance = new_value.to_string();
9548 self
9549 }
9550 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9551 /// while executing the actual API request.
9552 ///
9553 /// ````text
9554 /// It should be used to handle progress information, and to implement a certain level of resilience.
9555 /// ````
9556 ///
9557 /// Sets the *delegate* property to the given value.
9558 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InstanceGetCall<'a, C> {
9559 self._delegate = Some(new_value);
9560 self
9561 }
9562
9563 /// Set any additional parameter of the query string used in the request.
9564 /// It should be used to set parameters which are not yet available through their own
9565 /// setters.
9566 ///
9567 /// Please note that this method must not be used to set any of the known parameters
9568 /// which have their own setter method. If done anyway, the request will fail.
9569 ///
9570 /// # Additional Parameters
9571 ///
9572 /// * *$.xgafv* (query-string) - V1 error format.
9573 /// * *access_token* (query-string) - OAuth access token.
9574 /// * *alt* (query-string) - Data format for response.
9575 /// * *callback* (query-string) - JSONP
9576 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9577 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9578 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9579 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9580 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9581 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9582 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9583 pub fn param<T>(mut self, name: T, value: T) -> InstanceGetCall<'a, C>
9584 where
9585 T: AsRef<str>,
9586 {
9587 self._additional_params
9588 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9589 self
9590 }
9591
9592 /// Identifies the authorization scope for the method you are building.
9593 ///
9594 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9595 /// [`Scope::CloudPlatform`].
9596 ///
9597 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9598 /// tokens for more than one scope.
9599 ///
9600 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9601 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9602 /// sufficient, a read-write scope will do as well.
9603 pub fn add_scope<St>(mut self, scope: St) -> InstanceGetCall<'a, C>
9604 where
9605 St: AsRef<str>,
9606 {
9607 self._scopes.insert(String::from(scope.as_ref()));
9608 self
9609 }
9610 /// Identifies the authorization scope(s) for the method you are building.
9611 ///
9612 /// See [`Self::add_scope()`] for details.
9613 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGetCall<'a, C>
9614 where
9615 I: IntoIterator<Item = St>,
9616 St: AsRef<str>,
9617 {
9618 self._scopes
9619 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9620 self
9621 }
9622
9623 /// Removes all scopes, and no default scope will be used either.
9624 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9625 /// for details).
9626 pub fn clear_scopes(mut self) -> InstanceGetCall<'a, C> {
9627 self._scopes.clear();
9628 self
9629 }
9630}
9631
9632/// Imports data into a Cloud SQL instance from a SQL dump or CSV file in
9633/// Cloud Storage.
9634///
9635/// A builder for the *import* method supported by a *instance* resource.
9636/// It is not used directly, but through a [`InstanceMethods`] instance.
9637///
9638/// # Example
9639///
9640/// Instantiate a resource method builder
9641///
9642/// ```test_harness,no_run
9643/// # extern crate hyper;
9644/// # extern crate hyper_rustls;
9645/// # extern crate google_sql1_beta4 as sql1_beta4;
9646/// use sql1_beta4::api::InstancesImportRequest;
9647/// # async fn dox() {
9648/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9649///
9650/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9651/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9652/// # secret,
9653/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9654/// # ).build().await.unwrap();
9655///
9656/// # let client = hyper_util::client::legacy::Client::builder(
9657/// # hyper_util::rt::TokioExecutor::new()
9658/// # )
9659/// # .build(
9660/// # hyper_rustls::HttpsConnectorBuilder::new()
9661/// # .with_native_roots()
9662/// # .unwrap()
9663/// # .https_or_http()
9664/// # .enable_http1()
9665/// # .build()
9666/// # );
9667/// # let mut hub = SQLAdmin::new(client, auth);
9668/// // As the method needs a request, you would usually fill it with the desired information
9669/// // into the respective structure. Some of the parts shown here might not be applicable !
9670/// // Values shown here are possibly random and not representative !
9671/// let mut req = InstancesImportRequest::default();
9672///
9673/// // You can configure optional parameters by calling the respective setters at will, and
9674/// // execute the final call using `doit()`.
9675/// // Values shown here are possibly random and not representative !
9676/// let result = hub.instances().import(req, "project", "instance")
9677/// .doit().await;
9678/// # }
9679/// ```
9680pub struct InstanceImportCall<'a, C>
9681where
9682 C: 'a,
9683{
9684 hub: &'a SQLAdmin<C>,
9685 _request: InstancesImportRequest,
9686 _project: String,
9687 _instance: String,
9688 _delegate: Option<&'a mut dyn common::Delegate>,
9689 _additional_params: HashMap<String, String>,
9690 _scopes: BTreeSet<String>,
9691}
9692
9693impl<'a, C> common::CallBuilder for InstanceImportCall<'a, C> {}
9694
9695impl<'a, C> InstanceImportCall<'a, C>
9696where
9697 C: common::Connector,
9698{
9699 /// Perform the operation you have build so far.
9700 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9701 use std::borrow::Cow;
9702 use std::io::{Read, Seek};
9703
9704 use common::{url::Params, ToParts};
9705 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9706
9707 let mut dd = common::DefaultDelegate;
9708 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9709 dlg.begin(common::MethodInfo {
9710 id: "sql.instances.import",
9711 http_method: hyper::Method::POST,
9712 });
9713
9714 for &field in ["alt", "project", "instance"].iter() {
9715 if self._additional_params.contains_key(field) {
9716 dlg.finished(false);
9717 return Err(common::Error::FieldClash(field));
9718 }
9719 }
9720
9721 let mut params = Params::with_capacity(5 + self._additional_params.len());
9722 params.push("project", self._project);
9723 params.push("instance", self._instance);
9724
9725 params.extend(self._additional_params.iter());
9726
9727 params.push("alt", "json");
9728 let mut url = self.hub._base_url.clone()
9729 + "sql/v1beta4/projects/{project}/instances/{instance}/import";
9730 if self._scopes.is_empty() {
9731 self._scopes
9732 .insert(Scope::CloudPlatform.as_ref().to_string());
9733 }
9734
9735 #[allow(clippy::single_element_loop)]
9736 for &(find_this, param_name) in
9737 [("{project}", "project"), ("{instance}", "instance")].iter()
9738 {
9739 url = params.uri_replacement(url, param_name, find_this, false);
9740 }
9741 {
9742 let to_remove = ["instance", "project"];
9743 params.remove_params(&to_remove);
9744 }
9745
9746 let url = params.parse_with_url(&url);
9747
9748 let mut json_mime_type = mime::APPLICATION_JSON;
9749 let mut request_value_reader = {
9750 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9751 common::remove_json_null_values(&mut value);
9752 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9753 serde_json::to_writer(&mut dst, &value).unwrap();
9754 dst
9755 };
9756 let request_size = request_value_reader
9757 .seek(std::io::SeekFrom::End(0))
9758 .unwrap();
9759 request_value_reader
9760 .seek(std::io::SeekFrom::Start(0))
9761 .unwrap();
9762
9763 loop {
9764 let token = match self
9765 .hub
9766 .auth
9767 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9768 .await
9769 {
9770 Ok(token) => token,
9771 Err(e) => match dlg.token(e) {
9772 Ok(token) => token,
9773 Err(e) => {
9774 dlg.finished(false);
9775 return Err(common::Error::MissingToken(e));
9776 }
9777 },
9778 };
9779 request_value_reader
9780 .seek(std::io::SeekFrom::Start(0))
9781 .unwrap();
9782 let mut req_result = {
9783 let client = &self.hub.client;
9784 dlg.pre_request();
9785 let mut req_builder = hyper::Request::builder()
9786 .method(hyper::Method::POST)
9787 .uri(url.as_str())
9788 .header(USER_AGENT, self.hub._user_agent.clone());
9789
9790 if let Some(token) = token.as_ref() {
9791 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9792 }
9793
9794 let request = req_builder
9795 .header(CONTENT_TYPE, json_mime_type.to_string())
9796 .header(CONTENT_LENGTH, request_size as u64)
9797 .body(common::to_body(
9798 request_value_reader.get_ref().clone().into(),
9799 ));
9800
9801 client.request(request.unwrap()).await
9802 };
9803
9804 match req_result {
9805 Err(err) => {
9806 if let common::Retry::After(d) = dlg.http_error(&err) {
9807 sleep(d).await;
9808 continue;
9809 }
9810 dlg.finished(false);
9811 return Err(common::Error::HttpError(err));
9812 }
9813 Ok(res) => {
9814 let (mut parts, body) = res.into_parts();
9815 let mut body = common::Body::new(body);
9816 if !parts.status.is_success() {
9817 let bytes = common::to_bytes(body).await.unwrap_or_default();
9818 let error = serde_json::from_str(&common::to_string(&bytes));
9819 let response = common::to_response(parts, bytes.into());
9820
9821 if let common::Retry::After(d) =
9822 dlg.http_failure(&response, error.as_ref().ok())
9823 {
9824 sleep(d).await;
9825 continue;
9826 }
9827
9828 dlg.finished(false);
9829
9830 return Err(match error {
9831 Ok(value) => common::Error::BadRequest(value),
9832 _ => common::Error::Failure(response),
9833 });
9834 }
9835 let response = {
9836 let bytes = common::to_bytes(body).await.unwrap_or_default();
9837 let encoded = common::to_string(&bytes);
9838 match serde_json::from_str(&encoded) {
9839 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9840 Err(error) => {
9841 dlg.response_json_decode_error(&encoded, &error);
9842 return Err(common::Error::JsonDecodeError(
9843 encoded.to_string(),
9844 error,
9845 ));
9846 }
9847 }
9848 };
9849
9850 dlg.finished(true);
9851 return Ok(response);
9852 }
9853 }
9854 }
9855 }
9856
9857 ///
9858 /// Sets the *request* property to the given value.
9859 ///
9860 /// Even though the property as already been set when instantiating this call,
9861 /// we provide this method for API completeness.
9862 pub fn request(mut self, new_value: InstancesImportRequest) -> InstanceImportCall<'a, C> {
9863 self._request = new_value;
9864 self
9865 }
9866 /// Project ID of the project that contains the instance.
9867 ///
9868 /// Sets the *project* path property to the given value.
9869 ///
9870 /// Even though the property as already been set when instantiating this call,
9871 /// we provide this method for API completeness.
9872 pub fn project(mut self, new_value: &str) -> InstanceImportCall<'a, C> {
9873 self._project = new_value.to_string();
9874 self
9875 }
9876 /// Cloud SQL instance ID. This does not include the project ID.
9877 ///
9878 /// Sets the *instance* path property to the given value.
9879 ///
9880 /// Even though the property as already been set when instantiating this call,
9881 /// we provide this method for API completeness.
9882 pub fn instance(mut self, new_value: &str) -> InstanceImportCall<'a, C> {
9883 self._instance = new_value.to_string();
9884 self
9885 }
9886 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9887 /// while executing the actual API request.
9888 ///
9889 /// ````text
9890 /// It should be used to handle progress information, and to implement a certain level of resilience.
9891 /// ````
9892 ///
9893 /// Sets the *delegate* property to the given value.
9894 pub fn delegate(
9895 mut self,
9896 new_value: &'a mut dyn common::Delegate,
9897 ) -> InstanceImportCall<'a, C> {
9898 self._delegate = Some(new_value);
9899 self
9900 }
9901
9902 /// Set any additional parameter of the query string used in the request.
9903 /// It should be used to set parameters which are not yet available through their own
9904 /// setters.
9905 ///
9906 /// Please note that this method must not be used to set any of the known parameters
9907 /// which have their own setter method. If done anyway, the request will fail.
9908 ///
9909 /// # Additional Parameters
9910 ///
9911 /// * *$.xgafv* (query-string) - V1 error format.
9912 /// * *access_token* (query-string) - OAuth access token.
9913 /// * *alt* (query-string) - Data format for response.
9914 /// * *callback* (query-string) - JSONP
9915 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9916 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9917 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9918 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9919 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9920 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9921 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9922 pub fn param<T>(mut self, name: T, value: T) -> InstanceImportCall<'a, C>
9923 where
9924 T: AsRef<str>,
9925 {
9926 self._additional_params
9927 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9928 self
9929 }
9930
9931 /// Identifies the authorization scope for the method you are building.
9932 ///
9933 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9934 /// [`Scope::CloudPlatform`].
9935 ///
9936 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9937 /// tokens for more than one scope.
9938 ///
9939 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9940 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9941 /// sufficient, a read-write scope will do as well.
9942 pub fn add_scope<St>(mut self, scope: St) -> InstanceImportCall<'a, C>
9943 where
9944 St: AsRef<str>,
9945 {
9946 self._scopes.insert(String::from(scope.as_ref()));
9947 self
9948 }
9949 /// Identifies the authorization scope(s) for the method you are building.
9950 ///
9951 /// See [`Self::add_scope()`] for details.
9952 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceImportCall<'a, C>
9953 where
9954 I: IntoIterator<Item = St>,
9955 St: AsRef<str>,
9956 {
9957 self._scopes
9958 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9959 self
9960 }
9961
9962 /// Removes all scopes, and no default scope will be used either.
9963 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9964 /// for details).
9965 pub fn clear_scopes(mut self) -> InstanceImportCall<'a, C> {
9966 self._scopes.clear();
9967 self
9968 }
9969}
9970
9971/// Creates a new Cloud SQL instance.
9972///
9973/// A builder for the *insert* method supported by a *instance* resource.
9974/// It is not used directly, but through a [`InstanceMethods`] instance.
9975///
9976/// # Example
9977///
9978/// Instantiate a resource method builder
9979///
9980/// ```test_harness,no_run
9981/// # extern crate hyper;
9982/// # extern crate hyper_rustls;
9983/// # extern crate google_sql1_beta4 as sql1_beta4;
9984/// use sql1_beta4::api::DatabaseInstance;
9985/// # async fn dox() {
9986/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9987///
9988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9989/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9990/// # secret,
9991/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9992/// # ).build().await.unwrap();
9993///
9994/// # let client = hyper_util::client::legacy::Client::builder(
9995/// # hyper_util::rt::TokioExecutor::new()
9996/// # )
9997/// # .build(
9998/// # hyper_rustls::HttpsConnectorBuilder::new()
9999/// # .with_native_roots()
10000/// # .unwrap()
10001/// # .https_or_http()
10002/// # .enable_http1()
10003/// # .build()
10004/// # );
10005/// # let mut hub = SQLAdmin::new(client, auth);
10006/// // As the method needs a request, you would usually fill it with the desired information
10007/// // into the respective structure. Some of the parts shown here might not be applicable !
10008/// // Values shown here are possibly random and not representative !
10009/// let mut req = DatabaseInstance::default();
10010///
10011/// // You can configure optional parameters by calling the respective setters at will, and
10012/// // execute the final call using `doit()`.
10013/// // Values shown here are possibly random and not representative !
10014/// let result = hub.instances().insert(req, "project")
10015/// .doit().await;
10016/// # }
10017/// ```
10018pub struct InstanceInsertCall<'a, C>
10019where
10020 C: 'a,
10021{
10022 hub: &'a SQLAdmin<C>,
10023 _request: DatabaseInstance,
10024 _project: String,
10025 _delegate: Option<&'a mut dyn common::Delegate>,
10026 _additional_params: HashMap<String, String>,
10027 _scopes: BTreeSet<String>,
10028}
10029
10030impl<'a, C> common::CallBuilder for InstanceInsertCall<'a, C> {}
10031
10032impl<'a, C> InstanceInsertCall<'a, C>
10033where
10034 C: common::Connector,
10035{
10036 /// Perform the operation you have build so far.
10037 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10038 use std::borrow::Cow;
10039 use std::io::{Read, Seek};
10040
10041 use common::{url::Params, ToParts};
10042 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10043
10044 let mut dd = common::DefaultDelegate;
10045 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10046 dlg.begin(common::MethodInfo {
10047 id: "sql.instances.insert",
10048 http_method: hyper::Method::POST,
10049 });
10050
10051 for &field in ["alt", "project"].iter() {
10052 if self._additional_params.contains_key(field) {
10053 dlg.finished(false);
10054 return Err(common::Error::FieldClash(field));
10055 }
10056 }
10057
10058 let mut params = Params::with_capacity(4 + self._additional_params.len());
10059 params.push("project", self._project);
10060
10061 params.extend(self._additional_params.iter());
10062
10063 params.push("alt", "json");
10064 let mut url = self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances";
10065 if self._scopes.is_empty() {
10066 self._scopes
10067 .insert(Scope::CloudPlatform.as_ref().to_string());
10068 }
10069
10070 #[allow(clippy::single_element_loop)]
10071 for &(find_this, param_name) in [("{project}", "project")].iter() {
10072 url = params.uri_replacement(url, param_name, find_this, false);
10073 }
10074 {
10075 let to_remove = ["project"];
10076 params.remove_params(&to_remove);
10077 }
10078
10079 let url = params.parse_with_url(&url);
10080
10081 let mut json_mime_type = mime::APPLICATION_JSON;
10082 let mut request_value_reader = {
10083 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10084 common::remove_json_null_values(&mut value);
10085 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10086 serde_json::to_writer(&mut dst, &value).unwrap();
10087 dst
10088 };
10089 let request_size = request_value_reader
10090 .seek(std::io::SeekFrom::End(0))
10091 .unwrap();
10092 request_value_reader
10093 .seek(std::io::SeekFrom::Start(0))
10094 .unwrap();
10095
10096 loop {
10097 let token = match self
10098 .hub
10099 .auth
10100 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10101 .await
10102 {
10103 Ok(token) => token,
10104 Err(e) => match dlg.token(e) {
10105 Ok(token) => token,
10106 Err(e) => {
10107 dlg.finished(false);
10108 return Err(common::Error::MissingToken(e));
10109 }
10110 },
10111 };
10112 request_value_reader
10113 .seek(std::io::SeekFrom::Start(0))
10114 .unwrap();
10115 let mut req_result = {
10116 let client = &self.hub.client;
10117 dlg.pre_request();
10118 let mut req_builder = hyper::Request::builder()
10119 .method(hyper::Method::POST)
10120 .uri(url.as_str())
10121 .header(USER_AGENT, self.hub._user_agent.clone());
10122
10123 if let Some(token) = token.as_ref() {
10124 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10125 }
10126
10127 let request = req_builder
10128 .header(CONTENT_TYPE, json_mime_type.to_string())
10129 .header(CONTENT_LENGTH, request_size as u64)
10130 .body(common::to_body(
10131 request_value_reader.get_ref().clone().into(),
10132 ));
10133
10134 client.request(request.unwrap()).await
10135 };
10136
10137 match req_result {
10138 Err(err) => {
10139 if let common::Retry::After(d) = dlg.http_error(&err) {
10140 sleep(d).await;
10141 continue;
10142 }
10143 dlg.finished(false);
10144 return Err(common::Error::HttpError(err));
10145 }
10146 Ok(res) => {
10147 let (mut parts, body) = res.into_parts();
10148 let mut body = common::Body::new(body);
10149 if !parts.status.is_success() {
10150 let bytes = common::to_bytes(body).await.unwrap_or_default();
10151 let error = serde_json::from_str(&common::to_string(&bytes));
10152 let response = common::to_response(parts, bytes.into());
10153
10154 if let common::Retry::After(d) =
10155 dlg.http_failure(&response, error.as_ref().ok())
10156 {
10157 sleep(d).await;
10158 continue;
10159 }
10160
10161 dlg.finished(false);
10162
10163 return Err(match error {
10164 Ok(value) => common::Error::BadRequest(value),
10165 _ => common::Error::Failure(response),
10166 });
10167 }
10168 let response = {
10169 let bytes = common::to_bytes(body).await.unwrap_or_default();
10170 let encoded = common::to_string(&bytes);
10171 match serde_json::from_str(&encoded) {
10172 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10173 Err(error) => {
10174 dlg.response_json_decode_error(&encoded, &error);
10175 return Err(common::Error::JsonDecodeError(
10176 encoded.to_string(),
10177 error,
10178 ));
10179 }
10180 }
10181 };
10182
10183 dlg.finished(true);
10184 return Ok(response);
10185 }
10186 }
10187 }
10188 }
10189
10190 ///
10191 /// Sets the *request* property to the given value.
10192 ///
10193 /// Even though the property as already been set when instantiating this call,
10194 /// we provide this method for API completeness.
10195 pub fn request(mut self, new_value: DatabaseInstance) -> InstanceInsertCall<'a, C> {
10196 self._request = new_value;
10197 self
10198 }
10199 /// Project ID of the project to which the newly created Cloud SQL instances
10200 /// should belong.
10201 ///
10202 /// Sets the *project* path property to the given value.
10203 ///
10204 /// Even though the property as already been set when instantiating this call,
10205 /// we provide this method for API completeness.
10206 pub fn project(mut self, new_value: &str) -> InstanceInsertCall<'a, C> {
10207 self._project = new_value.to_string();
10208 self
10209 }
10210 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10211 /// while executing the actual API request.
10212 ///
10213 /// ````text
10214 /// It should be used to handle progress information, and to implement a certain level of resilience.
10215 /// ````
10216 ///
10217 /// Sets the *delegate* property to the given value.
10218 pub fn delegate(
10219 mut self,
10220 new_value: &'a mut dyn common::Delegate,
10221 ) -> InstanceInsertCall<'a, C> {
10222 self._delegate = Some(new_value);
10223 self
10224 }
10225
10226 /// Set any additional parameter of the query string used in the request.
10227 /// It should be used to set parameters which are not yet available through their own
10228 /// setters.
10229 ///
10230 /// Please note that this method must not be used to set any of the known parameters
10231 /// which have their own setter method. If done anyway, the request will fail.
10232 ///
10233 /// # Additional Parameters
10234 ///
10235 /// * *$.xgafv* (query-string) - V1 error format.
10236 /// * *access_token* (query-string) - OAuth access token.
10237 /// * *alt* (query-string) - Data format for response.
10238 /// * *callback* (query-string) - JSONP
10239 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10240 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10241 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10242 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10243 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10244 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10245 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10246 pub fn param<T>(mut self, name: T, value: T) -> InstanceInsertCall<'a, C>
10247 where
10248 T: AsRef<str>,
10249 {
10250 self._additional_params
10251 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10252 self
10253 }
10254
10255 /// Identifies the authorization scope for the method you are building.
10256 ///
10257 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10258 /// [`Scope::CloudPlatform`].
10259 ///
10260 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10261 /// tokens for more than one scope.
10262 ///
10263 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10264 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10265 /// sufficient, a read-write scope will do as well.
10266 pub fn add_scope<St>(mut self, scope: St) -> InstanceInsertCall<'a, C>
10267 where
10268 St: AsRef<str>,
10269 {
10270 self._scopes.insert(String::from(scope.as_ref()));
10271 self
10272 }
10273 /// Identifies the authorization scope(s) for the method you are building.
10274 ///
10275 /// See [`Self::add_scope()`] for details.
10276 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceInsertCall<'a, C>
10277 where
10278 I: IntoIterator<Item = St>,
10279 St: AsRef<str>,
10280 {
10281 self._scopes
10282 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10283 self
10284 }
10285
10286 /// Removes all scopes, and no default scope will be used either.
10287 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10288 /// for details).
10289 pub fn clear_scopes(mut self) -> InstanceInsertCall<'a, C> {
10290 self._scopes.clear();
10291 self
10292 }
10293}
10294
10295/// Lists instances under a given project.
10296///
10297/// A builder for the *list* method supported by a *instance* resource.
10298/// It is not used directly, but through a [`InstanceMethods`] instance.
10299///
10300/// # Example
10301///
10302/// Instantiate a resource method builder
10303///
10304/// ```test_harness,no_run
10305/// # extern crate hyper;
10306/// # extern crate hyper_rustls;
10307/// # extern crate google_sql1_beta4 as sql1_beta4;
10308/// # async fn dox() {
10309/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10310///
10311/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10312/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10313/// # secret,
10314/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10315/// # ).build().await.unwrap();
10316///
10317/// # let client = hyper_util::client::legacy::Client::builder(
10318/// # hyper_util::rt::TokioExecutor::new()
10319/// # )
10320/// # .build(
10321/// # hyper_rustls::HttpsConnectorBuilder::new()
10322/// # .with_native_roots()
10323/// # .unwrap()
10324/// # .https_or_http()
10325/// # .enable_http1()
10326/// # .build()
10327/// # );
10328/// # let mut hub = SQLAdmin::new(client, auth);
10329/// // You can configure optional parameters by calling the respective setters at will, and
10330/// // execute the final call using `doit()`.
10331/// // Values shown here are possibly random and not representative !
10332/// let result = hub.instances().list("project")
10333/// .page_token("et")
10334/// .max_results(79)
10335/// .filter("sadipscing")
10336/// .doit().await;
10337/// # }
10338/// ```
10339pub struct InstanceListCall<'a, C>
10340where
10341 C: 'a,
10342{
10343 hub: &'a SQLAdmin<C>,
10344 _project: String,
10345 _page_token: Option<String>,
10346 _max_results: Option<u32>,
10347 _filter: Option<String>,
10348 _delegate: Option<&'a mut dyn common::Delegate>,
10349 _additional_params: HashMap<String, String>,
10350 _scopes: BTreeSet<String>,
10351}
10352
10353impl<'a, C> common::CallBuilder for InstanceListCall<'a, C> {}
10354
10355impl<'a, C> InstanceListCall<'a, C>
10356where
10357 C: common::Connector,
10358{
10359 /// Perform the operation you have build so far.
10360 pub async fn doit(mut self) -> common::Result<(common::Response, InstancesListResponse)> {
10361 use std::borrow::Cow;
10362 use std::io::{Read, Seek};
10363
10364 use common::{url::Params, ToParts};
10365 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10366
10367 let mut dd = common::DefaultDelegate;
10368 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10369 dlg.begin(common::MethodInfo {
10370 id: "sql.instances.list",
10371 http_method: hyper::Method::GET,
10372 });
10373
10374 for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() {
10375 if self._additional_params.contains_key(field) {
10376 dlg.finished(false);
10377 return Err(common::Error::FieldClash(field));
10378 }
10379 }
10380
10381 let mut params = Params::with_capacity(6 + self._additional_params.len());
10382 params.push("project", self._project);
10383 if let Some(value) = self._page_token.as_ref() {
10384 params.push("pageToken", value);
10385 }
10386 if let Some(value) = self._max_results.as_ref() {
10387 params.push("maxResults", value.to_string());
10388 }
10389 if let Some(value) = self._filter.as_ref() {
10390 params.push("filter", value);
10391 }
10392
10393 params.extend(self._additional_params.iter());
10394
10395 params.push("alt", "json");
10396 let mut url = self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances";
10397 if self._scopes.is_empty() {
10398 self._scopes
10399 .insert(Scope::CloudPlatform.as_ref().to_string());
10400 }
10401
10402 #[allow(clippy::single_element_loop)]
10403 for &(find_this, param_name) in [("{project}", "project")].iter() {
10404 url = params.uri_replacement(url, param_name, find_this, false);
10405 }
10406 {
10407 let to_remove = ["project"];
10408 params.remove_params(&to_remove);
10409 }
10410
10411 let url = params.parse_with_url(&url);
10412
10413 loop {
10414 let token = match self
10415 .hub
10416 .auth
10417 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10418 .await
10419 {
10420 Ok(token) => token,
10421 Err(e) => match dlg.token(e) {
10422 Ok(token) => token,
10423 Err(e) => {
10424 dlg.finished(false);
10425 return Err(common::Error::MissingToken(e));
10426 }
10427 },
10428 };
10429 let mut req_result = {
10430 let client = &self.hub.client;
10431 dlg.pre_request();
10432 let mut req_builder = hyper::Request::builder()
10433 .method(hyper::Method::GET)
10434 .uri(url.as_str())
10435 .header(USER_AGENT, self.hub._user_agent.clone());
10436
10437 if let Some(token) = token.as_ref() {
10438 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10439 }
10440
10441 let request = req_builder
10442 .header(CONTENT_LENGTH, 0_u64)
10443 .body(common::to_body::<String>(None));
10444
10445 client.request(request.unwrap()).await
10446 };
10447
10448 match req_result {
10449 Err(err) => {
10450 if let common::Retry::After(d) = dlg.http_error(&err) {
10451 sleep(d).await;
10452 continue;
10453 }
10454 dlg.finished(false);
10455 return Err(common::Error::HttpError(err));
10456 }
10457 Ok(res) => {
10458 let (mut parts, body) = res.into_parts();
10459 let mut body = common::Body::new(body);
10460 if !parts.status.is_success() {
10461 let bytes = common::to_bytes(body).await.unwrap_or_default();
10462 let error = serde_json::from_str(&common::to_string(&bytes));
10463 let response = common::to_response(parts, bytes.into());
10464
10465 if let common::Retry::After(d) =
10466 dlg.http_failure(&response, error.as_ref().ok())
10467 {
10468 sleep(d).await;
10469 continue;
10470 }
10471
10472 dlg.finished(false);
10473
10474 return Err(match error {
10475 Ok(value) => common::Error::BadRequest(value),
10476 _ => common::Error::Failure(response),
10477 });
10478 }
10479 let response = {
10480 let bytes = common::to_bytes(body).await.unwrap_or_default();
10481 let encoded = common::to_string(&bytes);
10482 match serde_json::from_str(&encoded) {
10483 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10484 Err(error) => {
10485 dlg.response_json_decode_error(&encoded, &error);
10486 return Err(common::Error::JsonDecodeError(
10487 encoded.to_string(),
10488 error,
10489 ));
10490 }
10491 }
10492 };
10493
10494 dlg.finished(true);
10495 return Ok(response);
10496 }
10497 }
10498 }
10499 }
10500
10501 /// Project ID of the project for which to list Cloud SQL instances.
10502 ///
10503 /// Sets the *project* path property to the given value.
10504 ///
10505 /// Even though the property as already been set when instantiating this call,
10506 /// we provide this method for API completeness.
10507 pub fn project(mut self, new_value: &str) -> InstanceListCall<'a, C> {
10508 self._project = new_value.to_string();
10509 self
10510 }
10511 /// A previously-returned page token representing part of the larger set of
10512 /// results to view.
10513 ///
10514 /// Sets the *page token* query property to the given value.
10515 pub fn page_token(mut self, new_value: &str) -> InstanceListCall<'a, C> {
10516 self._page_token = Some(new_value.to_string());
10517 self
10518 }
10519 /// The maximum number of results to return per response.
10520 ///
10521 /// Sets the *max results* query property to the given value.
10522 pub fn max_results(mut self, new_value: u32) -> InstanceListCall<'a, C> {
10523 self._max_results = Some(new_value);
10524 self
10525 }
10526 /// A filter expression that filters resources listed in the response.
10527 /// The expression is in the form of field:value. For example,
10528 /// 'instanceType:CLOUD_SQL_INSTANCE'. Fields can be nested as needed as per
10529 /// their JSON representation, such as 'settings.userLabels.auto_start:true'.
10530 ///
10531 /// Multiple filter queries are space-separated. For example.
10532 /// 'state:RUNNABLE instanceType:CLOUD_SQL_INSTANCE'. By default, each
10533 /// expression is an AND expression. However, you can include AND and OR
10534 /// expressions explicitly.
10535 ///
10536 /// Sets the *filter* query property to the given value.
10537 pub fn filter(mut self, new_value: &str) -> InstanceListCall<'a, C> {
10538 self._filter = Some(new_value.to_string());
10539 self
10540 }
10541 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10542 /// while executing the actual API request.
10543 ///
10544 /// ````text
10545 /// It should be used to handle progress information, and to implement a certain level of resilience.
10546 /// ````
10547 ///
10548 /// Sets the *delegate* property to the given value.
10549 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InstanceListCall<'a, C> {
10550 self._delegate = Some(new_value);
10551 self
10552 }
10553
10554 /// Set any additional parameter of the query string used in the request.
10555 /// It should be used to set parameters which are not yet available through their own
10556 /// setters.
10557 ///
10558 /// Please note that this method must not be used to set any of the known parameters
10559 /// which have their own setter method. If done anyway, the request will fail.
10560 ///
10561 /// # Additional Parameters
10562 ///
10563 /// * *$.xgafv* (query-string) - V1 error format.
10564 /// * *access_token* (query-string) - OAuth access token.
10565 /// * *alt* (query-string) - Data format for response.
10566 /// * *callback* (query-string) - JSONP
10567 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10568 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10569 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10570 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10571 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10572 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10573 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10574 pub fn param<T>(mut self, name: T, value: T) -> InstanceListCall<'a, C>
10575 where
10576 T: AsRef<str>,
10577 {
10578 self._additional_params
10579 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10580 self
10581 }
10582
10583 /// Identifies the authorization scope for the method you are building.
10584 ///
10585 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10586 /// [`Scope::CloudPlatform`].
10587 ///
10588 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10589 /// tokens for more than one scope.
10590 ///
10591 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10592 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10593 /// sufficient, a read-write scope will do as well.
10594 pub fn add_scope<St>(mut self, scope: St) -> InstanceListCall<'a, C>
10595 where
10596 St: AsRef<str>,
10597 {
10598 self._scopes.insert(String::from(scope.as_ref()));
10599 self
10600 }
10601 /// Identifies the authorization scope(s) for the method you are building.
10602 ///
10603 /// See [`Self::add_scope()`] for details.
10604 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceListCall<'a, C>
10605 where
10606 I: IntoIterator<Item = St>,
10607 St: AsRef<str>,
10608 {
10609 self._scopes
10610 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10611 self
10612 }
10613
10614 /// Removes all scopes, and no default scope will be used either.
10615 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10616 /// for details).
10617 pub fn clear_scopes(mut self) -> InstanceListCall<'a, C> {
10618 self._scopes.clear();
10619 self
10620 }
10621}
10622
10623/// Lists all of the trusted Certificate Authorities (CAs) for the specified
10624/// instance. There can be up to three CAs listed: the CA that was used to sign
10625/// the certificate that is currently in use, a CA that has been added but not
10626/// yet used to sign a certificate, and a CA used to sign a certificate that
10627/// has previously rotated out.
10628///
10629/// A builder for the *listServerCas* method supported by a *instance* resource.
10630/// It is not used directly, but through a [`InstanceMethods`] instance.
10631///
10632/// # Example
10633///
10634/// Instantiate a resource method builder
10635///
10636/// ```test_harness,no_run
10637/// # extern crate hyper;
10638/// # extern crate hyper_rustls;
10639/// # extern crate google_sql1_beta4 as sql1_beta4;
10640/// # async fn dox() {
10641/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10642///
10643/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10644/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10645/// # secret,
10646/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10647/// # ).build().await.unwrap();
10648///
10649/// # let client = hyper_util::client::legacy::Client::builder(
10650/// # hyper_util::rt::TokioExecutor::new()
10651/// # )
10652/// # .build(
10653/// # hyper_rustls::HttpsConnectorBuilder::new()
10654/// # .with_native_roots()
10655/// # .unwrap()
10656/// # .https_or_http()
10657/// # .enable_http1()
10658/// # .build()
10659/// # );
10660/// # let mut hub = SQLAdmin::new(client, auth);
10661/// // You can configure optional parameters by calling the respective setters at will, and
10662/// // execute the final call using `doit()`.
10663/// // Values shown here are possibly random and not representative !
10664/// let result = hub.instances().list_server_cas("project", "instance")
10665/// .doit().await;
10666/// # }
10667/// ```
10668pub struct InstanceListServerCaCall<'a, C>
10669where
10670 C: 'a,
10671{
10672 hub: &'a SQLAdmin<C>,
10673 _project: String,
10674 _instance: String,
10675 _delegate: Option<&'a mut dyn common::Delegate>,
10676 _additional_params: HashMap<String, String>,
10677 _scopes: BTreeSet<String>,
10678}
10679
10680impl<'a, C> common::CallBuilder for InstanceListServerCaCall<'a, C> {}
10681
10682impl<'a, C> InstanceListServerCaCall<'a, C>
10683where
10684 C: common::Connector,
10685{
10686 /// Perform the operation you have build so far.
10687 pub async fn doit(
10688 mut self,
10689 ) -> common::Result<(common::Response, InstancesListServerCasResponse)> {
10690 use std::borrow::Cow;
10691 use std::io::{Read, Seek};
10692
10693 use common::{url::Params, ToParts};
10694 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10695
10696 let mut dd = common::DefaultDelegate;
10697 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10698 dlg.begin(common::MethodInfo {
10699 id: "sql.instances.listServerCas",
10700 http_method: hyper::Method::GET,
10701 });
10702
10703 for &field in ["alt", "project", "instance"].iter() {
10704 if self._additional_params.contains_key(field) {
10705 dlg.finished(false);
10706 return Err(common::Error::FieldClash(field));
10707 }
10708 }
10709
10710 let mut params = Params::with_capacity(4 + self._additional_params.len());
10711 params.push("project", self._project);
10712 params.push("instance", self._instance);
10713
10714 params.extend(self._additional_params.iter());
10715
10716 params.push("alt", "json");
10717 let mut url = self.hub._base_url.clone()
10718 + "sql/v1beta4/projects/{project}/instances/{instance}/listServerCas";
10719 if self._scopes.is_empty() {
10720 self._scopes
10721 .insert(Scope::CloudPlatform.as_ref().to_string());
10722 }
10723
10724 #[allow(clippy::single_element_loop)]
10725 for &(find_this, param_name) in
10726 [("{project}", "project"), ("{instance}", "instance")].iter()
10727 {
10728 url = params.uri_replacement(url, param_name, find_this, false);
10729 }
10730 {
10731 let to_remove = ["instance", "project"];
10732 params.remove_params(&to_remove);
10733 }
10734
10735 let url = params.parse_with_url(&url);
10736
10737 loop {
10738 let token = match self
10739 .hub
10740 .auth
10741 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10742 .await
10743 {
10744 Ok(token) => token,
10745 Err(e) => match dlg.token(e) {
10746 Ok(token) => token,
10747 Err(e) => {
10748 dlg.finished(false);
10749 return Err(common::Error::MissingToken(e));
10750 }
10751 },
10752 };
10753 let mut req_result = {
10754 let client = &self.hub.client;
10755 dlg.pre_request();
10756 let mut req_builder = hyper::Request::builder()
10757 .method(hyper::Method::GET)
10758 .uri(url.as_str())
10759 .header(USER_AGENT, self.hub._user_agent.clone());
10760
10761 if let Some(token) = token.as_ref() {
10762 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10763 }
10764
10765 let request = req_builder
10766 .header(CONTENT_LENGTH, 0_u64)
10767 .body(common::to_body::<String>(None));
10768
10769 client.request(request.unwrap()).await
10770 };
10771
10772 match req_result {
10773 Err(err) => {
10774 if let common::Retry::After(d) = dlg.http_error(&err) {
10775 sleep(d).await;
10776 continue;
10777 }
10778 dlg.finished(false);
10779 return Err(common::Error::HttpError(err));
10780 }
10781 Ok(res) => {
10782 let (mut parts, body) = res.into_parts();
10783 let mut body = common::Body::new(body);
10784 if !parts.status.is_success() {
10785 let bytes = common::to_bytes(body).await.unwrap_or_default();
10786 let error = serde_json::from_str(&common::to_string(&bytes));
10787 let response = common::to_response(parts, bytes.into());
10788
10789 if let common::Retry::After(d) =
10790 dlg.http_failure(&response, error.as_ref().ok())
10791 {
10792 sleep(d).await;
10793 continue;
10794 }
10795
10796 dlg.finished(false);
10797
10798 return Err(match error {
10799 Ok(value) => common::Error::BadRequest(value),
10800 _ => common::Error::Failure(response),
10801 });
10802 }
10803 let response = {
10804 let bytes = common::to_bytes(body).await.unwrap_or_default();
10805 let encoded = common::to_string(&bytes);
10806 match serde_json::from_str(&encoded) {
10807 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10808 Err(error) => {
10809 dlg.response_json_decode_error(&encoded, &error);
10810 return Err(common::Error::JsonDecodeError(
10811 encoded.to_string(),
10812 error,
10813 ));
10814 }
10815 }
10816 };
10817
10818 dlg.finished(true);
10819 return Ok(response);
10820 }
10821 }
10822 }
10823 }
10824
10825 /// Project ID of the project that contains the instance.
10826 ///
10827 /// Sets the *project* path property to the given value.
10828 ///
10829 /// Even though the property as already been set when instantiating this call,
10830 /// we provide this method for API completeness.
10831 pub fn project(mut self, new_value: &str) -> InstanceListServerCaCall<'a, C> {
10832 self._project = new_value.to_string();
10833 self
10834 }
10835 /// Cloud SQL instance ID. This does not include the project ID.
10836 ///
10837 /// Sets the *instance* path property to the given value.
10838 ///
10839 /// Even though the property as already been set when instantiating this call,
10840 /// we provide this method for API completeness.
10841 pub fn instance(mut self, new_value: &str) -> InstanceListServerCaCall<'a, C> {
10842 self._instance = new_value.to_string();
10843 self
10844 }
10845 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10846 /// while executing the actual API request.
10847 ///
10848 /// ````text
10849 /// It should be used to handle progress information, and to implement a certain level of resilience.
10850 /// ````
10851 ///
10852 /// Sets the *delegate* property to the given value.
10853 pub fn delegate(
10854 mut self,
10855 new_value: &'a mut dyn common::Delegate,
10856 ) -> InstanceListServerCaCall<'a, C> {
10857 self._delegate = Some(new_value);
10858 self
10859 }
10860
10861 /// Set any additional parameter of the query string used in the request.
10862 /// It should be used to set parameters which are not yet available through their own
10863 /// setters.
10864 ///
10865 /// Please note that this method must not be used to set any of the known parameters
10866 /// which have their own setter method. If done anyway, the request will fail.
10867 ///
10868 /// # Additional Parameters
10869 ///
10870 /// * *$.xgafv* (query-string) - V1 error format.
10871 /// * *access_token* (query-string) - OAuth access token.
10872 /// * *alt* (query-string) - Data format for response.
10873 /// * *callback* (query-string) - JSONP
10874 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10875 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10876 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10877 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10878 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10879 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10880 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10881 pub fn param<T>(mut self, name: T, value: T) -> InstanceListServerCaCall<'a, C>
10882 where
10883 T: AsRef<str>,
10884 {
10885 self._additional_params
10886 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10887 self
10888 }
10889
10890 /// Identifies the authorization scope for the method you are building.
10891 ///
10892 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10893 /// [`Scope::CloudPlatform`].
10894 ///
10895 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10896 /// tokens for more than one scope.
10897 ///
10898 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10899 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10900 /// sufficient, a read-write scope will do as well.
10901 pub fn add_scope<St>(mut self, scope: St) -> InstanceListServerCaCall<'a, C>
10902 where
10903 St: AsRef<str>,
10904 {
10905 self._scopes.insert(String::from(scope.as_ref()));
10906 self
10907 }
10908 /// Identifies the authorization scope(s) for the method you are building.
10909 ///
10910 /// See [`Self::add_scope()`] for details.
10911 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceListServerCaCall<'a, C>
10912 where
10913 I: IntoIterator<Item = St>,
10914 St: AsRef<str>,
10915 {
10916 self._scopes
10917 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10918 self
10919 }
10920
10921 /// Removes all scopes, and no default scope will be used either.
10922 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10923 /// for details).
10924 pub fn clear_scopes(mut self) -> InstanceListServerCaCall<'a, C> {
10925 self._scopes.clear();
10926 self
10927 }
10928}
10929
10930/// Updates settings of a Cloud SQL instance.
10931/// This method supports patch semantics.
10932///
10933/// A builder for the *patch* method supported by a *instance* resource.
10934/// It is not used directly, but through a [`InstanceMethods`] instance.
10935///
10936/// # Example
10937///
10938/// Instantiate a resource method builder
10939///
10940/// ```test_harness,no_run
10941/// # extern crate hyper;
10942/// # extern crate hyper_rustls;
10943/// # extern crate google_sql1_beta4 as sql1_beta4;
10944/// use sql1_beta4::api::DatabaseInstance;
10945/// # async fn dox() {
10946/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10947///
10948/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10949/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10950/// # secret,
10951/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10952/// # ).build().await.unwrap();
10953///
10954/// # let client = hyper_util::client::legacy::Client::builder(
10955/// # hyper_util::rt::TokioExecutor::new()
10956/// # )
10957/// # .build(
10958/// # hyper_rustls::HttpsConnectorBuilder::new()
10959/// # .with_native_roots()
10960/// # .unwrap()
10961/// # .https_or_http()
10962/// # .enable_http1()
10963/// # .build()
10964/// # );
10965/// # let mut hub = SQLAdmin::new(client, auth);
10966/// // As the method needs a request, you would usually fill it with the desired information
10967/// // into the respective structure. Some of the parts shown here might not be applicable !
10968/// // Values shown here are possibly random and not representative !
10969/// let mut req = DatabaseInstance::default();
10970///
10971/// // You can configure optional parameters by calling the respective setters at will, and
10972/// // execute the final call using `doit()`.
10973/// // Values shown here are possibly random and not representative !
10974/// let result = hub.instances().patch(req, "project", "instance")
10975/// .doit().await;
10976/// # }
10977/// ```
10978pub struct InstancePatchCall<'a, C>
10979where
10980 C: 'a,
10981{
10982 hub: &'a SQLAdmin<C>,
10983 _request: DatabaseInstance,
10984 _project: String,
10985 _instance: String,
10986 _delegate: Option<&'a mut dyn common::Delegate>,
10987 _additional_params: HashMap<String, String>,
10988 _scopes: BTreeSet<String>,
10989}
10990
10991impl<'a, C> common::CallBuilder for InstancePatchCall<'a, C> {}
10992
10993impl<'a, C> InstancePatchCall<'a, C>
10994where
10995 C: common::Connector,
10996{
10997 /// Perform the operation you have build so far.
10998 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10999 use std::borrow::Cow;
11000 use std::io::{Read, Seek};
11001
11002 use common::{url::Params, ToParts};
11003 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11004
11005 let mut dd = common::DefaultDelegate;
11006 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11007 dlg.begin(common::MethodInfo {
11008 id: "sql.instances.patch",
11009 http_method: hyper::Method::PATCH,
11010 });
11011
11012 for &field in ["alt", "project", "instance"].iter() {
11013 if self._additional_params.contains_key(field) {
11014 dlg.finished(false);
11015 return Err(common::Error::FieldClash(field));
11016 }
11017 }
11018
11019 let mut params = Params::with_capacity(5 + self._additional_params.len());
11020 params.push("project", self._project);
11021 params.push("instance", self._instance);
11022
11023 params.extend(self._additional_params.iter());
11024
11025 params.push("alt", "json");
11026 let mut url =
11027 self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances/{instance}";
11028 if self._scopes.is_empty() {
11029 self._scopes
11030 .insert(Scope::CloudPlatform.as_ref().to_string());
11031 }
11032
11033 #[allow(clippy::single_element_loop)]
11034 for &(find_this, param_name) in
11035 [("{project}", "project"), ("{instance}", "instance")].iter()
11036 {
11037 url = params.uri_replacement(url, param_name, find_this, false);
11038 }
11039 {
11040 let to_remove = ["instance", "project"];
11041 params.remove_params(&to_remove);
11042 }
11043
11044 let url = params.parse_with_url(&url);
11045
11046 let mut json_mime_type = mime::APPLICATION_JSON;
11047 let mut request_value_reader = {
11048 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11049 common::remove_json_null_values(&mut value);
11050 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11051 serde_json::to_writer(&mut dst, &value).unwrap();
11052 dst
11053 };
11054 let request_size = request_value_reader
11055 .seek(std::io::SeekFrom::End(0))
11056 .unwrap();
11057 request_value_reader
11058 .seek(std::io::SeekFrom::Start(0))
11059 .unwrap();
11060
11061 loop {
11062 let token = match self
11063 .hub
11064 .auth
11065 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11066 .await
11067 {
11068 Ok(token) => token,
11069 Err(e) => match dlg.token(e) {
11070 Ok(token) => token,
11071 Err(e) => {
11072 dlg.finished(false);
11073 return Err(common::Error::MissingToken(e));
11074 }
11075 },
11076 };
11077 request_value_reader
11078 .seek(std::io::SeekFrom::Start(0))
11079 .unwrap();
11080 let mut req_result = {
11081 let client = &self.hub.client;
11082 dlg.pre_request();
11083 let mut req_builder = hyper::Request::builder()
11084 .method(hyper::Method::PATCH)
11085 .uri(url.as_str())
11086 .header(USER_AGENT, self.hub._user_agent.clone());
11087
11088 if let Some(token) = token.as_ref() {
11089 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11090 }
11091
11092 let request = req_builder
11093 .header(CONTENT_TYPE, json_mime_type.to_string())
11094 .header(CONTENT_LENGTH, request_size as u64)
11095 .body(common::to_body(
11096 request_value_reader.get_ref().clone().into(),
11097 ));
11098
11099 client.request(request.unwrap()).await
11100 };
11101
11102 match req_result {
11103 Err(err) => {
11104 if let common::Retry::After(d) = dlg.http_error(&err) {
11105 sleep(d).await;
11106 continue;
11107 }
11108 dlg.finished(false);
11109 return Err(common::Error::HttpError(err));
11110 }
11111 Ok(res) => {
11112 let (mut parts, body) = res.into_parts();
11113 let mut body = common::Body::new(body);
11114 if !parts.status.is_success() {
11115 let bytes = common::to_bytes(body).await.unwrap_or_default();
11116 let error = serde_json::from_str(&common::to_string(&bytes));
11117 let response = common::to_response(parts, bytes.into());
11118
11119 if let common::Retry::After(d) =
11120 dlg.http_failure(&response, error.as_ref().ok())
11121 {
11122 sleep(d).await;
11123 continue;
11124 }
11125
11126 dlg.finished(false);
11127
11128 return Err(match error {
11129 Ok(value) => common::Error::BadRequest(value),
11130 _ => common::Error::Failure(response),
11131 });
11132 }
11133 let response = {
11134 let bytes = common::to_bytes(body).await.unwrap_or_default();
11135 let encoded = common::to_string(&bytes);
11136 match serde_json::from_str(&encoded) {
11137 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11138 Err(error) => {
11139 dlg.response_json_decode_error(&encoded, &error);
11140 return Err(common::Error::JsonDecodeError(
11141 encoded.to_string(),
11142 error,
11143 ));
11144 }
11145 }
11146 };
11147
11148 dlg.finished(true);
11149 return Ok(response);
11150 }
11151 }
11152 }
11153 }
11154
11155 ///
11156 /// Sets the *request* property to the given value.
11157 ///
11158 /// Even though the property as already been set when instantiating this call,
11159 /// we provide this method for API completeness.
11160 pub fn request(mut self, new_value: DatabaseInstance) -> InstancePatchCall<'a, C> {
11161 self._request = new_value;
11162 self
11163 }
11164 /// Project ID of the project that contains the instance.
11165 ///
11166 /// Sets the *project* path property to the given value.
11167 ///
11168 /// Even though the property as already been set when instantiating this call,
11169 /// we provide this method for API completeness.
11170 pub fn project(mut self, new_value: &str) -> InstancePatchCall<'a, C> {
11171 self._project = new_value.to_string();
11172 self
11173 }
11174 /// Cloud SQL instance ID. This does not include the project ID.
11175 ///
11176 /// Sets the *instance* path property to the given value.
11177 ///
11178 /// Even though the property as already been set when instantiating this call,
11179 /// we provide this method for API completeness.
11180 pub fn instance(mut self, new_value: &str) -> InstancePatchCall<'a, C> {
11181 self._instance = new_value.to_string();
11182 self
11183 }
11184 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11185 /// while executing the actual API request.
11186 ///
11187 /// ````text
11188 /// It should be used to handle progress information, and to implement a certain level of resilience.
11189 /// ````
11190 ///
11191 /// Sets the *delegate* property to the given value.
11192 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InstancePatchCall<'a, C> {
11193 self._delegate = Some(new_value);
11194 self
11195 }
11196
11197 /// Set any additional parameter of the query string used in the request.
11198 /// It should be used to set parameters which are not yet available through their own
11199 /// setters.
11200 ///
11201 /// Please note that this method must not be used to set any of the known parameters
11202 /// which have their own setter method. If done anyway, the request will fail.
11203 ///
11204 /// # Additional Parameters
11205 ///
11206 /// * *$.xgafv* (query-string) - V1 error format.
11207 /// * *access_token* (query-string) - OAuth access token.
11208 /// * *alt* (query-string) - Data format for response.
11209 /// * *callback* (query-string) - JSONP
11210 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11211 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11212 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11213 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11214 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11215 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11216 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11217 pub fn param<T>(mut self, name: T, value: T) -> InstancePatchCall<'a, C>
11218 where
11219 T: AsRef<str>,
11220 {
11221 self._additional_params
11222 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11223 self
11224 }
11225
11226 /// Identifies the authorization scope for the method you are building.
11227 ///
11228 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11229 /// [`Scope::CloudPlatform`].
11230 ///
11231 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11232 /// tokens for more than one scope.
11233 ///
11234 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11235 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11236 /// sufficient, a read-write scope will do as well.
11237 pub fn add_scope<St>(mut self, scope: St) -> InstancePatchCall<'a, C>
11238 where
11239 St: AsRef<str>,
11240 {
11241 self._scopes.insert(String::from(scope.as_ref()));
11242 self
11243 }
11244 /// Identifies the authorization scope(s) for the method you are building.
11245 ///
11246 /// See [`Self::add_scope()`] for details.
11247 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstancePatchCall<'a, C>
11248 where
11249 I: IntoIterator<Item = St>,
11250 St: AsRef<str>,
11251 {
11252 self._scopes
11253 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11254 self
11255 }
11256
11257 /// Removes all scopes, and no default scope will be used either.
11258 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11259 /// for details).
11260 pub fn clear_scopes(mut self) -> InstancePatchCall<'a, C> {
11261 self._scopes.clear();
11262 self
11263 }
11264}
11265
11266/// Promotes the read replica instance to be a stand-alone Cloud SQL instance.
11267/// Using this operation might cause your instance to restart.
11268///
11269/// A builder for the *promoteReplica* method supported by a *instance* resource.
11270/// It is not used directly, but through a [`InstanceMethods`] instance.
11271///
11272/// # Example
11273///
11274/// Instantiate a resource method builder
11275///
11276/// ```test_harness,no_run
11277/// # extern crate hyper;
11278/// # extern crate hyper_rustls;
11279/// # extern crate google_sql1_beta4 as sql1_beta4;
11280/// # async fn dox() {
11281/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11282///
11283/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11284/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11285/// # secret,
11286/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11287/// # ).build().await.unwrap();
11288///
11289/// # let client = hyper_util::client::legacy::Client::builder(
11290/// # hyper_util::rt::TokioExecutor::new()
11291/// # )
11292/// # .build(
11293/// # hyper_rustls::HttpsConnectorBuilder::new()
11294/// # .with_native_roots()
11295/// # .unwrap()
11296/// # .https_or_http()
11297/// # .enable_http1()
11298/// # .build()
11299/// # );
11300/// # let mut hub = SQLAdmin::new(client, auth);
11301/// // You can configure optional parameters by calling the respective setters at will, and
11302/// // execute the final call using `doit()`.
11303/// // Values shown here are possibly random and not representative !
11304/// let result = hub.instances().promote_replica("project", "instance")
11305/// .doit().await;
11306/// # }
11307/// ```
11308pub struct InstancePromoteReplicaCall<'a, C>
11309where
11310 C: 'a,
11311{
11312 hub: &'a SQLAdmin<C>,
11313 _project: String,
11314 _instance: String,
11315 _delegate: Option<&'a mut dyn common::Delegate>,
11316 _additional_params: HashMap<String, String>,
11317 _scopes: BTreeSet<String>,
11318}
11319
11320impl<'a, C> common::CallBuilder for InstancePromoteReplicaCall<'a, C> {}
11321
11322impl<'a, C> InstancePromoteReplicaCall<'a, C>
11323where
11324 C: common::Connector,
11325{
11326 /// Perform the operation you have build so far.
11327 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11328 use std::borrow::Cow;
11329 use std::io::{Read, Seek};
11330
11331 use common::{url::Params, ToParts};
11332 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11333
11334 let mut dd = common::DefaultDelegate;
11335 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11336 dlg.begin(common::MethodInfo {
11337 id: "sql.instances.promoteReplica",
11338 http_method: hyper::Method::POST,
11339 });
11340
11341 for &field in ["alt", "project", "instance"].iter() {
11342 if self._additional_params.contains_key(field) {
11343 dlg.finished(false);
11344 return Err(common::Error::FieldClash(field));
11345 }
11346 }
11347
11348 let mut params = Params::with_capacity(4 + self._additional_params.len());
11349 params.push("project", self._project);
11350 params.push("instance", self._instance);
11351
11352 params.extend(self._additional_params.iter());
11353
11354 params.push("alt", "json");
11355 let mut url = self.hub._base_url.clone()
11356 + "sql/v1beta4/projects/{project}/instances/{instance}/promoteReplica";
11357 if self._scopes.is_empty() {
11358 self._scopes
11359 .insert(Scope::CloudPlatform.as_ref().to_string());
11360 }
11361
11362 #[allow(clippy::single_element_loop)]
11363 for &(find_this, param_name) in
11364 [("{project}", "project"), ("{instance}", "instance")].iter()
11365 {
11366 url = params.uri_replacement(url, param_name, find_this, false);
11367 }
11368 {
11369 let to_remove = ["instance", "project"];
11370 params.remove_params(&to_remove);
11371 }
11372
11373 let url = params.parse_with_url(&url);
11374
11375 loop {
11376 let token = match self
11377 .hub
11378 .auth
11379 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11380 .await
11381 {
11382 Ok(token) => token,
11383 Err(e) => match dlg.token(e) {
11384 Ok(token) => token,
11385 Err(e) => {
11386 dlg.finished(false);
11387 return Err(common::Error::MissingToken(e));
11388 }
11389 },
11390 };
11391 let mut req_result = {
11392 let client = &self.hub.client;
11393 dlg.pre_request();
11394 let mut req_builder = hyper::Request::builder()
11395 .method(hyper::Method::POST)
11396 .uri(url.as_str())
11397 .header(USER_AGENT, self.hub._user_agent.clone());
11398
11399 if let Some(token) = token.as_ref() {
11400 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11401 }
11402
11403 let request = req_builder
11404 .header(CONTENT_LENGTH, 0_u64)
11405 .body(common::to_body::<String>(None));
11406
11407 client.request(request.unwrap()).await
11408 };
11409
11410 match req_result {
11411 Err(err) => {
11412 if let common::Retry::After(d) = dlg.http_error(&err) {
11413 sleep(d).await;
11414 continue;
11415 }
11416 dlg.finished(false);
11417 return Err(common::Error::HttpError(err));
11418 }
11419 Ok(res) => {
11420 let (mut parts, body) = res.into_parts();
11421 let mut body = common::Body::new(body);
11422 if !parts.status.is_success() {
11423 let bytes = common::to_bytes(body).await.unwrap_or_default();
11424 let error = serde_json::from_str(&common::to_string(&bytes));
11425 let response = common::to_response(parts, bytes.into());
11426
11427 if let common::Retry::After(d) =
11428 dlg.http_failure(&response, error.as_ref().ok())
11429 {
11430 sleep(d).await;
11431 continue;
11432 }
11433
11434 dlg.finished(false);
11435
11436 return Err(match error {
11437 Ok(value) => common::Error::BadRequest(value),
11438 _ => common::Error::Failure(response),
11439 });
11440 }
11441 let response = {
11442 let bytes = common::to_bytes(body).await.unwrap_or_default();
11443 let encoded = common::to_string(&bytes);
11444 match serde_json::from_str(&encoded) {
11445 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11446 Err(error) => {
11447 dlg.response_json_decode_error(&encoded, &error);
11448 return Err(common::Error::JsonDecodeError(
11449 encoded.to_string(),
11450 error,
11451 ));
11452 }
11453 }
11454 };
11455
11456 dlg.finished(true);
11457 return Ok(response);
11458 }
11459 }
11460 }
11461 }
11462
11463 /// ID of the project that contains the read replica.
11464 ///
11465 /// Sets the *project* path property to the given value.
11466 ///
11467 /// Even though the property as already been set when instantiating this call,
11468 /// we provide this method for API completeness.
11469 pub fn project(mut self, new_value: &str) -> InstancePromoteReplicaCall<'a, C> {
11470 self._project = new_value.to_string();
11471 self
11472 }
11473 /// Cloud SQL read replica instance name.
11474 ///
11475 /// Sets the *instance* path property to the given value.
11476 ///
11477 /// Even though the property as already been set when instantiating this call,
11478 /// we provide this method for API completeness.
11479 pub fn instance(mut self, new_value: &str) -> InstancePromoteReplicaCall<'a, C> {
11480 self._instance = new_value.to_string();
11481 self
11482 }
11483 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11484 /// while executing the actual API request.
11485 ///
11486 /// ````text
11487 /// It should be used to handle progress information, and to implement a certain level of resilience.
11488 /// ````
11489 ///
11490 /// Sets the *delegate* property to the given value.
11491 pub fn delegate(
11492 mut self,
11493 new_value: &'a mut dyn common::Delegate,
11494 ) -> InstancePromoteReplicaCall<'a, C> {
11495 self._delegate = Some(new_value);
11496 self
11497 }
11498
11499 /// Set any additional parameter of the query string used in the request.
11500 /// It should be used to set parameters which are not yet available through their own
11501 /// setters.
11502 ///
11503 /// Please note that this method must not be used to set any of the known parameters
11504 /// which have their own setter method. If done anyway, the request will fail.
11505 ///
11506 /// # Additional Parameters
11507 ///
11508 /// * *$.xgafv* (query-string) - V1 error format.
11509 /// * *access_token* (query-string) - OAuth access token.
11510 /// * *alt* (query-string) - Data format for response.
11511 /// * *callback* (query-string) - JSONP
11512 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11513 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11514 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11515 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11516 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11517 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11518 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11519 pub fn param<T>(mut self, name: T, value: T) -> InstancePromoteReplicaCall<'a, C>
11520 where
11521 T: AsRef<str>,
11522 {
11523 self._additional_params
11524 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11525 self
11526 }
11527
11528 /// Identifies the authorization scope for the method you are building.
11529 ///
11530 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11531 /// [`Scope::CloudPlatform`].
11532 ///
11533 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11534 /// tokens for more than one scope.
11535 ///
11536 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11537 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11538 /// sufficient, a read-write scope will do as well.
11539 pub fn add_scope<St>(mut self, scope: St) -> InstancePromoteReplicaCall<'a, C>
11540 where
11541 St: AsRef<str>,
11542 {
11543 self._scopes.insert(String::from(scope.as_ref()));
11544 self
11545 }
11546 /// Identifies the authorization scope(s) for the method you are building.
11547 ///
11548 /// See [`Self::add_scope()`] for details.
11549 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstancePromoteReplicaCall<'a, C>
11550 where
11551 I: IntoIterator<Item = St>,
11552 St: AsRef<str>,
11553 {
11554 self._scopes
11555 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11556 self
11557 }
11558
11559 /// Removes all scopes, and no default scope will be used either.
11560 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11561 /// for details).
11562 pub fn clear_scopes(mut self) -> InstancePromoteReplicaCall<'a, C> {
11563 self._scopes.clear();
11564 self
11565 }
11566}
11567
11568/// Deletes all client certificates and generates a new server SSL certificate
11569/// for the instance.
11570///
11571/// A builder for the *resetSslConfig* method supported by a *instance* resource.
11572/// It is not used directly, but through a [`InstanceMethods`] instance.
11573///
11574/// # Example
11575///
11576/// Instantiate a resource method builder
11577///
11578/// ```test_harness,no_run
11579/// # extern crate hyper;
11580/// # extern crate hyper_rustls;
11581/// # extern crate google_sql1_beta4 as sql1_beta4;
11582/// # async fn dox() {
11583/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11584///
11585/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11586/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11587/// # secret,
11588/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11589/// # ).build().await.unwrap();
11590///
11591/// # let client = hyper_util::client::legacy::Client::builder(
11592/// # hyper_util::rt::TokioExecutor::new()
11593/// # )
11594/// # .build(
11595/// # hyper_rustls::HttpsConnectorBuilder::new()
11596/// # .with_native_roots()
11597/// # .unwrap()
11598/// # .https_or_http()
11599/// # .enable_http1()
11600/// # .build()
11601/// # );
11602/// # let mut hub = SQLAdmin::new(client, auth);
11603/// // You can configure optional parameters by calling the respective setters at will, and
11604/// // execute the final call using `doit()`.
11605/// // Values shown here are possibly random and not representative !
11606/// let result = hub.instances().reset_ssl_config("project", "instance")
11607/// .doit().await;
11608/// # }
11609/// ```
11610pub struct InstanceResetSslConfigCall<'a, C>
11611where
11612 C: 'a,
11613{
11614 hub: &'a SQLAdmin<C>,
11615 _project: String,
11616 _instance: String,
11617 _delegate: Option<&'a mut dyn common::Delegate>,
11618 _additional_params: HashMap<String, String>,
11619 _scopes: BTreeSet<String>,
11620}
11621
11622impl<'a, C> common::CallBuilder for InstanceResetSslConfigCall<'a, C> {}
11623
11624impl<'a, C> InstanceResetSslConfigCall<'a, C>
11625where
11626 C: common::Connector,
11627{
11628 /// Perform the operation you have build so far.
11629 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11630 use std::borrow::Cow;
11631 use std::io::{Read, Seek};
11632
11633 use common::{url::Params, ToParts};
11634 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11635
11636 let mut dd = common::DefaultDelegate;
11637 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11638 dlg.begin(common::MethodInfo {
11639 id: "sql.instances.resetSslConfig",
11640 http_method: hyper::Method::POST,
11641 });
11642
11643 for &field in ["alt", "project", "instance"].iter() {
11644 if self._additional_params.contains_key(field) {
11645 dlg.finished(false);
11646 return Err(common::Error::FieldClash(field));
11647 }
11648 }
11649
11650 let mut params = Params::with_capacity(4 + self._additional_params.len());
11651 params.push("project", self._project);
11652 params.push("instance", self._instance);
11653
11654 params.extend(self._additional_params.iter());
11655
11656 params.push("alt", "json");
11657 let mut url = self.hub._base_url.clone()
11658 + "sql/v1beta4/projects/{project}/instances/{instance}/resetSslConfig";
11659 if self._scopes.is_empty() {
11660 self._scopes
11661 .insert(Scope::CloudPlatform.as_ref().to_string());
11662 }
11663
11664 #[allow(clippy::single_element_loop)]
11665 for &(find_this, param_name) in
11666 [("{project}", "project"), ("{instance}", "instance")].iter()
11667 {
11668 url = params.uri_replacement(url, param_name, find_this, false);
11669 }
11670 {
11671 let to_remove = ["instance", "project"];
11672 params.remove_params(&to_remove);
11673 }
11674
11675 let url = params.parse_with_url(&url);
11676
11677 loop {
11678 let token = match self
11679 .hub
11680 .auth
11681 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11682 .await
11683 {
11684 Ok(token) => token,
11685 Err(e) => match dlg.token(e) {
11686 Ok(token) => token,
11687 Err(e) => {
11688 dlg.finished(false);
11689 return Err(common::Error::MissingToken(e));
11690 }
11691 },
11692 };
11693 let mut req_result = {
11694 let client = &self.hub.client;
11695 dlg.pre_request();
11696 let mut req_builder = hyper::Request::builder()
11697 .method(hyper::Method::POST)
11698 .uri(url.as_str())
11699 .header(USER_AGENT, self.hub._user_agent.clone());
11700
11701 if let Some(token) = token.as_ref() {
11702 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11703 }
11704
11705 let request = req_builder
11706 .header(CONTENT_LENGTH, 0_u64)
11707 .body(common::to_body::<String>(None));
11708
11709 client.request(request.unwrap()).await
11710 };
11711
11712 match req_result {
11713 Err(err) => {
11714 if let common::Retry::After(d) = dlg.http_error(&err) {
11715 sleep(d).await;
11716 continue;
11717 }
11718 dlg.finished(false);
11719 return Err(common::Error::HttpError(err));
11720 }
11721 Ok(res) => {
11722 let (mut parts, body) = res.into_parts();
11723 let mut body = common::Body::new(body);
11724 if !parts.status.is_success() {
11725 let bytes = common::to_bytes(body).await.unwrap_or_default();
11726 let error = serde_json::from_str(&common::to_string(&bytes));
11727 let response = common::to_response(parts, bytes.into());
11728
11729 if let common::Retry::After(d) =
11730 dlg.http_failure(&response, error.as_ref().ok())
11731 {
11732 sleep(d).await;
11733 continue;
11734 }
11735
11736 dlg.finished(false);
11737
11738 return Err(match error {
11739 Ok(value) => common::Error::BadRequest(value),
11740 _ => common::Error::Failure(response),
11741 });
11742 }
11743 let response = {
11744 let bytes = common::to_bytes(body).await.unwrap_or_default();
11745 let encoded = common::to_string(&bytes);
11746 match serde_json::from_str(&encoded) {
11747 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11748 Err(error) => {
11749 dlg.response_json_decode_error(&encoded, &error);
11750 return Err(common::Error::JsonDecodeError(
11751 encoded.to_string(),
11752 error,
11753 ));
11754 }
11755 }
11756 };
11757
11758 dlg.finished(true);
11759 return Ok(response);
11760 }
11761 }
11762 }
11763 }
11764
11765 /// Project ID of the project that contains the instance.
11766 ///
11767 /// Sets the *project* path property to the given value.
11768 ///
11769 /// Even though the property as already been set when instantiating this call,
11770 /// we provide this method for API completeness.
11771 pub fn project(mut self, new_value: &str) -> InstanceResetSslConfigCall<'a, C> {
11772 self._project = new_value.to_string();
11773 self
11774 }
11775 /// Cloud SQL instance ID. This does not include the project ID.
11776 ///
11777 /// Sets the *instance* path property to the given value.
11778 ///
11779 /// Even though the property as already been set when instantiating this call,
11780 /// we provide this method for API completeness.
11781 pub fn instance(mut self, new_value: &str) -> InstanceResetSslConfigCall<'a, C> {
11782 self._instance = new_value.to_string();
11783 self
11784 }
11785 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11786 /// while executing the actual API request.
11787 ///
11788 /// ````text
11789 /// It should be used to handle progress information, and to implement a certain level of resilience.
11790 /// ````
11791 ///
11792 /// Sets the *delegate* property to the given value.
11793 pub fn delegate(
11794 mut self,
11795 new_value: &'a mut dyn common::Delegate,
11796 ) -> InstanceResetSslConfigCall<'a, C> {
11797 self._delegate = Some(new_value);
11798 self
11799 }
11800
11801 /// Set any additional parameter of the query string used in the request.
11802 /// It should be used to set parameters which are not yet available through their own
11803 /// setters.
11804 ///
11805 /// Please note that this method must not be used to set any of the known parameters
11806 /// which have their own setter method. If done anyway, the request will fail.
11807 ///
11808 /// # Additional Parameters
11809 ///
11810 /// * *$.xgafv* (query-string) - V1 error format.
11811 /// * *access_token* (query-string) - OAuth access token.
11812 /// * *alt* (query-string) - Data format for response.
11813 /// * *callback* (query-string) - JSONP
11814 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11815 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11816 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11817 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11818 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11819 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11820 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11821 pub fn param<T>(mut self, name: T, value: T) -> InstanceResetSslConfigCall<'a, C>
11822 where
11823 T: AsRef<str>,
11824 {
11825 self._additional_params
11826 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11827 self
11828 }
11829
11830 /// Identifies the authorization scope for the method you are building.
11831 ///
11832 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11833 /// [`Scope::CloudPlatform`].
11834 ///
11835 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11836 /// tokens for more than one scope.
11837 ///
11838 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11839 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11840 /// sufficient, a read-write scope will do as well.
11841 pub fn add_scope<St>(mut self, scope: St) -> InstanceResetSslConfigCall<'a, C>
11842 where
11843 St: AsRef<str>,
11844 {
11845 self._scopes.insert(String::from(scope.as_ref()));
11846 self
11847 }
11848 /// Identifies the authorization scope(s) for the method you are building.
11849 ///
11850 /// See [`Self::add_scope()`] for details.
11851 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceResetSslConfigCall<'a, C>
11852 where
11853 I: IntoIterator<Item = St>,
11854 St: AsRef<str>,
11855 {
11856 self._scopes
11857 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11858 self
11859 }
11860
11861 /// Removes all scopes, and no default scope will be used either.
11862 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11863 /// for details).
11864 pub fn clear_scopes(mut self) -> InstanceResetSslConfigCall<'a, C> {
11865 self._scopes.clear();
11866 self
11867 }
11868}
11869
11870/// Restarts a Cloud SQL instance.
11871///
11872/// A builder for the *restart* method supported by a *instance* resource.
11873/// It is not used directly, but through a [`InstanceMethods`] instance.
11874///
11875/// # Example
11876///
11877/// Instantiate a resource method builder
11878///
11879/// ```test_harness,no_run
11880/// # extern crate hyper;
11881/// # extern crate hyper_rustls;
11882/// # extern crate google_sql1_beta4 as sql1_beta4;
11883/// # async fn dox() {
11884/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11885///
11886/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11887/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11888/// # secret,
11889/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11890/// # ).build().await.unwrap();
11891///
11892/// # let client = hyper_util::client::legacy::Client::builder(
11893/// # hyper_util::rt::TokioExecutor::new()
11894/// # )
11895/// # .build(
11896/// # hyper_rustls::HttpsConnectorBuilder::new()
11897/// # .with_native_roots()
11898/// # .unwrap()
11899/// # .https_or_http()
11900/// # .enable_http1()
11901/// # .build()
11902/// # );
11903/// # let mut hub = SQLAdmin::new(client, auth);
11904/// // You can configure optional parameters by calling the respective setters at will, and
11905/// // execute the final call using `doit()`.
11906/// // Values shown here are possibly random and not representative !
11907/// let result = hub.instances().restart("project", "instance")
11908/// .doit().await;
11909/// # }
11910/// ```
11911pub struct InstanceRestartCall<'a, C>
11912where
11913 C: 'a,
11914{
11915 hub: &'a SQLAdmin<C>,
11916 _project: String,
11917 _instance: String,
11918 _delegate: Option<&'a mut dyn common::Delegate>,
11919 _additional_params: HashMap<String, String>,
11920 _scopes: BTreeSet<String>,
11921}
11922
11923impl<'a, C> common::CallBuilder for InstanceRestartCall<'a, C> {}
11924
11925impl<'a, C> InstanceRestartCall<'a, C>
11926where
11927 C: common::Connector,
11928{
11929 /// Perform the operation you have build so far.
11930 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11931 use std::borrow::Cow;
11932 use std::io::{Read, Seek};
11933
11934 use common::{url::Params, ToParts};
11935 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11936
11937 let mut dd = common::DefaultDelegate;
11938 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11939 dlg.begin(common::MethodInfo {
11940 id: "sql.instances.restart",
11941 http_method: hyper::Method::POST,
11942 });
11943
11944 for &field in ["alt", "project", "instance"].iter() {
11945 if self._additional_params.contains_key(field) {
11946 dlg.finished(false);
11947 return Err(common::Error::FieldClash(field));
11948 }
11949 }
11950
11951 let mut params = Params::with_capacity(4 + self._additional_params.len());
11952 params.push("project", self._project);
11953 params.push("instance", self._instance);
11954
11955 params.extend(self._additional_params.iter());
11956
11957 params.push("alt", "json");
11958 let mut url = self.hub._base_url.clone()
11959 + "sql/v1beta4/projects/{project}/instances/{instance}/restart";
11960 if self._scopes.is_empty() {
11961 self._scopes
11962 .insert(Scope::CloudPlatform.as_ref().to_string());
11963 }
11964
11965 #[allow(clippy::single_element_loop)]
11966 for &(find_this, param_name) in
11967 [("{project}", "project"), ("{instance}", "instance")].iter()
11968 {
11969 url = params.uri_replacement(url, param_name, find_this, false);
11970 }
11971 {
11972 let to_remove = ["instance", "project"];
11973 params.remove_params(&to_remove);
11974 }
11975
11976 let url = params.parse_with_url(&url);
11977
11978 loop {
11979 let token = match self
11980 .hub
11981 .auth
11982 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11983 .await
11984 {
11985 Ok(token) => token,
11986 Err(e) => match dlg.token(e) {
11987 Ok(token) => token,
11988 Err(e) => {
11989 dlg.finished(false);
11990 return Err(common::Error::MissingToken(e));
11991 }
11992 },
11993 };
11994 let mut req_result = {
11995 let client = &self.hub.client;
11996 dlg.pre_request();
11997 let mut req_builder = hyper::Request::builder()
11998 .method(hyper::Method::POST)
11999 .uri(url.as_str())
12000 .header(USER_AGENT, self.hub._user_agent.clone());
12001
12002 if let Some(token) = token.as_ref() {
12003 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12004 }
12005
12006 let request = req_builder
12007 .header(CONTENT_LENGTH, 0_u64)
12008 .body(common::to_body::<String>(None));
12009
12010 client.request(request.unwrap()).await
12011 };
12012
12013 match req_result {
12014 Err(err) => {
12015 if let common::Retry::After(d) = dlg.http_error(&err) {
12016 sleep(d).await;
12017 continue;
12018 }
12019 dlg.finished(false);
12020 return Err(common::Error::HttpError(err));
12021 }
12022 Ok(res) => {
12023 let (mut parts, body) = res.into_parts();
12024 let mut body = common::Body::new(body);
12025 if !parts.status.is_success() {
12026 let bytes = common::to_bytes(body).await.unwrap_or_default();
12027 let error = serde_json::from_str(&common::to_string(&bytes));
12028 let response = common::to_response(parts, bytes.into());
12029
12030 if let common::Retry::After(d) =
12031 dlg.http_failure(&response, error.as_ref().ok())
12032 {
12033 sleep(d).await;
12034 continue;
12035 }
12036
12037 dlg.finished(false);
12038
12039 return Err(match error {
12040 Ok(value) => common::Error::BadRequest(value),
12041 _ => common::Error::Failure(response),
12042 });
12043 }
12044 let response = {
12045 let bytes = common::to_bytes(body).await.unwrap_or_default();
12046 let encoded = common::to_string(&bytes);
12047 match serde_json::from_str(&encoded) {
12048 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12049 Err(error) => {
12050 dlg.response_json_decode_error(&encoded, &error);
12051 return Err(common::Error::JsonDecodeError(
12052 encoded.to_string(),
12053 error,
12054 ));
12055 }
12056 }
12057 };
12058
12059 dlg.finished(true);
12060 return Ok(response);
12061 }
12062 }
12063 }
12064 }
12065
12066 /// Project ID of the project that contains the instance to be restarted.
12067 ///
12068 /// Sets the *project* path property to the given value.
12069 ///
12070 /// Even though the property as already been set when instantiating this call,
12071 /// we provide this method for API completeness.
12072 pub fn project(mut self, new_value: &str) -> InstanceRestartCall<'a, C> {
12073 self._project = new_value.to_string();
12074 self
12075 }
12076 /// Cloud SQL instance ID. This does not include the project ID.
12077 ///
12078 /// Sets the *instance* path property to the given value.
12079 ///
12080 /// Even though the property as already been set when instantiating this call,
12081 /// we provide this method for API completeness.
12082 pub fn instance(mut self, new_value: &str) -> InstanceRestartCall<'a, C> {
12083 self._instance = new_value.to_string();
12084 self
12085 }
12086 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12087 /// while executing the actual API request.
12088 ///
12089 /// ````text
12090 /// It should be used to handle progress information, and to implement a certain level of resilience.
12091 /// ````
12092 ///
12093 /// Sets the *delegate* property to the given value.
12094 pub fn delegate(
12095 mut self,
12096 new_value: &'a mut dyn common::Delegate,
12097 ) -> InstanceRestartCall<'a, C> {
12098 self._delegate = Some(new_value);
12099 self
12100 }
12101
12102 /// Set any additional parameter of the query string used in the request.
12103 /// It should be used to set parameters which are not yet available through their own
12104 /// setters.
12105 ///
12106 /// Please note that this method must not be used to set any of the known parameters
12107 /// which have their own setter method. If done anyway, the request will fail.
12108 ///
12109 /// # Additional Parameters
12110 ///
12111 /// * *$.xgafv* (query-string) - V1 error format.
12112 /// * *access_token* (query-string) - OAuth access token.
12113 /// * *alt* (query-string) - Data format for response.
12114 /// * *callback* (query-string) - JSONP
12115 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12116 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12117 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12118 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12119 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12120 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12121 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12122 pub fn param<T>(mut self, name: T, value: T) -> InstanceRestartCall<'a, C>
12123 where
12124 T: AsRef<str>,
12125 {
12126 self._additional_params
12127 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12128 self
12129 }
12130
12131 /// Identifies the authorization scope for the method you are building.
12132 ///
12133 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12134 /// [`Scope::CloudPlatform`].
12135 ///
12136 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12137 /// tokens for more than one scope.
12138 ///
12139 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12140 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12141 /// sufficient, a read-write scope will do as well.
12142 pub fn add_scope<St>(mut self, scope: St) -> InstanceRestartCall<'a, C>
12143 where
12144 St: AsRef<str>,
12145 {
12146 self._scopes.insert(String::from(scope.as_ref()));
12147 self
12148 }
12149 /// Identifies the authorization scope(s) for the method you are building.
12150 ///
12151 /// See [`Self::add_scope()`] for details.
12152 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceRestartCall<'a, C>
12153 where
12154 I: IntoIterator<Item = St>,
12155 St: AsRef<str>,
12156 {
12157 self._scopes
12158 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12159 self
12160 }
12161
12162 /// Removes all scopes, and no default scope will be used either.
12163 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12164 /// for details).
12165 pub fn clear_scopes(mut self) -> InstanceRestartCall<'a, C> {
12166 self._scopes.clear();
12167 self
12168 }
12169}
12170
12171/// Restores a backup of a Cloud SQL instance. Using this operation might cause
12172/// your instance to restart.
12173///
12174/// A builder for the *restoreBackup* method supported by a *instance* resource.
12175/// It is not used directly, but through a [`InstanceMethods`] instance.
12176///
12177/// # Example
12178///
12179/// Instantiate a resource method builder
12180///
12181/// ```test_harness,no_run
12182/// # extern crate hyper;
12183/// # extern crate hyper_rustls;
12184/// # extern crate google_sql1_beta4 as sql1_beta4;
12185/// use sql1_beta4::api::InstancesRestoreBackupRequest;
12186/// # async fn dox() {
12187/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12188///
12189/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12190/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12191/// # secret,
12192/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12193/// # ).build().await.unwrap();
12194///
12195/// # let client = hyper_util::client::legacy::Client::builder(
12196/// # hyper_util::rt::TokioExecutor::new()
12197/// # )
12198/// # .build(
12199/// # hyper_rustls::HttpsConnectorBuilder::new()
12200/// # .with_native_roots()
12201/// # .unwrap()
12202/// # .https_or_http()
12203/// # .enable_http1()
12204/// # .build()
12205/// # );
12206/// # let mut hub = SQLAdmin::new(client, auth);
12207/// // As the method needs a request, you would usually fill it with the desired information
12208/// // into the respective structure. Some of the parts shown here might not be applicable !
12209/// // Values shown here are possibly random and not representative !
12210/// let mut req = InstancesRestoreBackupRequest::default();
12211///
12212/// // You can configure optional parameters by calling the respective setters at will, and
12213/// // execute the final call using `doit()`.
12214/// // Values shown here are possibly random and not representative !
12215/// let result = hub.instances().restore_backup(req, "project", "instance")
12216/// .doit().await;
12217/// # }
12218/// ```
12219pub struct InstanceRestoreBackupCall<'a, C>
12220where
12221 C: 'a,
12222{
12223 hub: &'a SQLAdmin<C>,
12224 _request: InstancesRestoreBackupRequest,
12225 _project: String,
12226 _instance: String,
12227 _delegate: Option<&'a mut dyn common::Delegate>,
12228 _additional_params: HashMap<String, String>,
12229 _scopes: BTreeSet<String>,
12230}
12231
12232impl<'a, C> common::CallBuilder for InstanceRestoreBackupCall<'a, C> {}
12233
12234impl<'a, C> InstanceRestoreBackupCall<'a, C>
12235where
12236 C: common::Connector,
12237{
12238 /// Perform the operation you have build so far.
12239 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12240 use std::borrow::Cow;
12241 use std::io::{Read, Seek};
12242
12243 use common::{url::Params, ToParts};
12244 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12245
12246 let mut dd = common::DefaultDelegate;
12247 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12248 dlg.begin(common::MethodInfo {
12249 id: "sql.instances.restoreBackup",
12250 http_method: hyper::Method::POST,
12251 });
12252
12253 for &field in ["alt", "project", "instance"].iter() {
12254 if self._additional_params.contains_key(field) {
12255 dlg.finished(false);
12256 return Err(common::Error::FieldClash(field));
12257 }
12258 }
12259
12260 let mut params = Params::with_capacity(5 + self._additional_params.len());
12261 params.push("project", self._project);
12262 params.push("instance", self._instance);
12263
12264 params.extend(self._additional_params.iter());
12265
12266 params.push("alt", "json");
12267 let mut url = self.hub._base_url.clone()
12268 + "sql/v1beta4/projects/{project}/instances/{instance}/restoreBackup";
12269 if self._scopes.is_empty() {
12270 self._scopes
12271 .insert(Scope::CloudPlatform.as_ref().to_string());
12272 }
12273
12274 #[allow(clippy::single_element_loop)]
12275 for &(find_this, param_name) in
12276 [("{project}", "project"), ("{instance}", "instance")].iter()
12277 {
12278 url = params.uri_replacement(url, param_name, find_this, false);
12279 }
12280 {
12281 let to_remove = ["instance", "project"];
12282 params.remove_params(&to_remove);
12283 }
12284
12285 let url = params.parse_with_url(&url);
12286
12287 let mut json_mime_type = mime::APPLICATION_JSON;
12288 let mut request_value_reader = {
12289 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12290 common::remove_json_null_values(&mut value);
12291 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12292 serde_json::to_writer(&mut dst, &value).unwrap();
12293 dst
12294 };
12295 let request_size = request_value_reader
12296 .seek(std::io::SeekFrom::End(0))
12297 .unwrap();
12298 request_value_reader
12299 .seek(std::io::SeekFrom::Start(0))
12300 .unwrap();
12301
12302 loop {
12303 let token = match self
12304 .hub
12305 .auth
12306 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12307 .await
12308 {
12309 Ok(token) => token,
12310 Err(e) => match dlg.token(e) {
12311 Ok(token) => token,
12312 Err(e) => {
12313 dlg.finished(false);
12314 return Err(common::Error::MissingToken(e));
12315 }
12316 },
12317 };
12318 request_value_reader
12319 .seek(std::io::SeekFrom::Start(0))
12320 .unwrap();
12321 let mut req_result = {
12322 let client = &self.hub.client;
12323 dlg.pre_request();
12324 let mut req_builder = hyper::Request::builder()
12325 .method(hyper::Method::POST)
12326 .uri(url.as_str())
12327 .header(USER_AGENT, self.hub._user_agent.clone());
12328
12329 if let Some(token) = token.as_ref() {
12330 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12331 }
12332
12333 let request = req_builder
12334 .header(CONTENT_TYPE, json_mime_type.to_string())
12335 .header(CONTENT_LENGTH, request_size as u64)
12336 .body(common::to_body(
12337 request_value_reader.get_ref().clone().into(),
12338 ));
12339
12340 client.request(request.unwrap()).await
12341 };
12342
12343 match req_result {
12344 Err(err) => {
12345 if let common::Retry::After(d) = dlg.http_error(&err) {
12346 sleep(d).await;
12347 continue;
12348 }
12349 dlg.finished(false);
12350 return Err(common::Error::HttpError(err));
12351 }
12352 Ok(res) => {
12353 let (mut parts, body) = res.into_parts();
12354 let mut body = common::Body::new(body);
12355 if !parts.status.is_success() {
12356 let bytes = common::to_bytes(body).await.unwrap_or_default();
12357 let error = serde_json::from_str(&common::to_string(&bytes));
12358 let response = common::to_response(parts, bytes.into());
12359
12360 if let common::Retry::After(d) =
12361 dlg.http_failure(&response, error.as_ref().ok())
12362 {
12363 sleep(d).await;
12364 continue;
12365 }
12366
12367 dlg.finished(false);
12368
12369 return Err(match error {
12370 Ok(value) => common::Error::BadRequest(value),
12371 _ => common::Error::Failure(response),
12372 });
12373 }
12374 let response = {
12375 let bytes = common::to_bytes(body).await.unwrap_or_default();
12376 let encoded = common::to_string(&bytes);
12377 match serde_json::from_str(&encoded) {
12378 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12379 Err(error) => {
12380 dlg.response_json_decode_error(&encoded, &error);
12381 return Err(common::Error::JsonDecodeError(
12382 encoded.to_string(),
12383 error,
12384 ));
12385 }
12386 }
12387 };
12388
12389 dlg.finished(true);
12390 return Ok(response);
12391 }
12392 }
12393 }
12394 }
12395
12396 ///
12397 /// Sets the *request* property to the given value.
12398 ///
12399 /// Even though the property as already been set when instantiating this call,
12400 /// we provide this method for API completeness.
12401 pub fn request(
12402 mut self,
12403 new_value: InstancesRestoreBackupRequest,
12404 ) -> InstanceRestoreBackupCall<'a, C> {
12405 self._request = new_value;
12406 self
12407 }
12408 /// Project ID of the project that contains the instance.
12409 ///
12410 /// Sets the *project* path property to the given value.
12411 ///
12412 /// Even though the property as already been set when instantiating this call,
12413 /// we provide this method for API completeness.
12414 pub fn project(mut self, new_value: &str) -> InstanceRestoreBackupCall<'a, C> {
12415 self._project = new_value.to_string();
12416 self
12417 }
12418 /// Cloud SQL instance ID. This does not include the project ID.
12419 ///
12420 /// Sets the *instance* path property to the given value.
12421 ///
12422 /// Even though the property as already been set when instantiating this call,
12423 /// we provide this method for API completeness.
12424 pub fn instance(mut self, new_value: &str) -> InstanceRestoreBackupCall<'a, C> {
12425 self._instance = new_value.to_string();
12426 self
12427 }
12428 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12429 /// while executing the actual API request.
12430 ///
12431 /// ````text
12432 /// It should be used to handle progress information, and to implement a certain level of resilience.
12433 /// ````
12434 ///
12435 /// Sets the *delegate* property to the given value.
12436 pub fn delegate(
12437 mut self,
12438 new_value: &'a mut dyn common::Delegate,
12439 ) -> InstanceRestoreBackupCall<'a, C> {
12440 self._delegate = Some(new_value);
12441 self
12442 }
12443
12444 /// Set any additional parameter of the query string used in the request.
12445 /// It should be used to set parameters which are not yet available through their own
12446 /// setters.
12447 ///
12448 /// Please note that this method must not be used to set any of the known parameters
12449 /// which have their own setter method. If done anyway, the request will fail.
12450 ///
12451 /// # Additional Parameters
12452 ///
12453 /// * *$.xgafv* (query-string) - V1 error format.
12454 /// * *access_token* (query-string) - OAuth access token.
12455 /// * *alt* (query-string) - Data format for response.
12456 /// * *callback* (query-string) - JSONP
12457 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12458 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12459 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12460 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12461 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12462 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12463 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12464 pub fn param<T>(mut self, name: T, value: T) -> InstanceRestoreBackupCall<'a, C>
12465 where
12466 T: AsRef<str>,
12467 {
12468 self._additional_params
12469 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12470 self
12471 }
12472
12473 /// Identifies the authorization scope for the method you are building.
12474 ///
12475 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12476 /// [`Scope::CloudPlatform`].
12477 ///
12478 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12479 /// tokens for more than one scope.
12480 ///
12481 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12482 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12483 /// sufficient, a read-write scope will do as well.
12484 pub fn add_scope<St>(mut self, scope: St) -> InstanceRestoreBackupCall<'a, C>
12485 where
12486 St: AsRef<str>,
12487 {
12488 self._scopes.insert(String::from(scope.as_ref()));
12489 self
12490 }
12491 /// Identifies the authorization scope(s) for the method you are building.
12492 ///
12493 /// See [`Self::add_scope()`] for details.
12494 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceRestoreBackupCall<'a, C>
12495 where
12496 I: IntoIterator<Item = St>,
12497 St: AsRef<str>,
12498 {
12499 self._scopes
12500 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12501 self
12502 }
12503
12504 /// Removes all scopes, and no default scope will be used either.
12505 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12506 /// for details).
12507 pub fn clear_scopes(mut self) -> InstanceRestoreBackupCall<'a, C> {
12508 self._scopes.clear();
12509 self
12510 }
12511}
12512
12513/// Rotates the server certificate to one signed by the Certificate Authority
12514/// (CA) version previously added with the addServerCA method.
12515///
12516/// A builder for the *rotateServerCa* method supported by a *instance* resource.
12517/// It is not used directly, but through a [`InstanceMethods`] instance.
12518///
12519/// # Example
12520///
12521/// Instantiate a resource method builder
12522///
12523/// ```test_harness,no_run
12524/// # extern crate hyper;
12525/// # extern crate hyper_rustls;
12526/// # extern crate google_sql1_beta4 as sql1_beta4;
12527/// use sql1_beta4::api::InstancesRotateServerCaRequest;
12528/// # async fn dox() {
12529/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12530///
12531/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12532/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12533/// # secret,
12534/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12535/// # ).build().await.unwrap();
12536///
12537/// # let client = hyper_util::client::legacy::Client::builder(
12538/// # hyper_util::rt::TokioExecutor::new()
12539/// # )
12540/// # .build(
12541/// # hyper_rustls::HttpsConnectorBuilder::new()
12542/// # .with_native_roots()
12543/// # .unwrap()
12544/// # .https_or_http()
12545/// # .enable_http1()
12546/// # .build()
12547/// # );
12548/// # let mut hub = SQLAdmin::new(client, auth);
12549/// // As the method needs a request, you would usually fill it with the desired information
12550/// // into the respective structure. Some of the parts shown here might not be applicable !
12551/// // Values shown here are possibly random and not representative !
12552/// let mut req = InstancesRotateServerCaRequest::default();
12553///
12554/// // You can configure optional parameters by calling the respective setters at will, and
12555/// // execute the final call using `doit()`.
12556/// // Values shown here are possibly random and not representative !
12557/// let result = hub.instances().rotate_server_ca(req, "project", "instance")
12558/// .doit().await;
12559/// # }
12560/// ```
12561pub struct InstanceRotateServerCaCall<'a, C>
12562where
12563 C: 'a,
12564{
12565 hub: &'a SQLAdmin<C>,
12566 _request: InstancesRotateServerCaRequest,
12567 _project: String,
12568 _instance: String,
12569 _delegate: Option<&'a mut dyn common::Delegate>,
12570 _additional_params: HashMap<String, String>,
12571 _scopes: BTreeSet<String>,
12572}
12573
12574impl<'a, C> common::CallBuilder for InstanceRotateServerCaCall<'a, C> {}
12575
12576impl<'a, C> InstanceRotateServerCaCall<'a, C>
12577where
12578 C: common::Connector,
12579{
12580 /// Perform the operation you have build so far.
12581 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12582 use std::borrow::Cow;
12583 use std::io::{Read, Seek};
12584
12585 use common::{url::Params, ToParts};
12586 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12587
12588 let mut dd = common::DefaultDelegate;
12589 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12590 dlg.begin(common::MethodInfo {
12591 id: "sql.instances.rotateServerCa",
12592 http_method: hyper::Method::POST,
12593 });
12594
12595 for &field in ["alt", "project", "instance"].iter() {
12596 if self._additional_params.contains_key(field) {
12597 dlg.finished(false);
12598 return Err(common::Error::FieldClash(field));
12599 }
12600 }
12601
12602 let mut params = Params::with_capacity(5 + self._additional_params.len());
12603 params.push("project", self._project);
12604 params.push("instance", self._instance);
12605
12606 params.extend(self._additional_params.iter());
12607
12608 params.push("alt", "json");
12609 let mut url = self.hub._base_url.clone()
12610 + "sql/v1beta4/projects/{project}/instances/{instance}/rotateServerCa";
12611 if self._scopes.is_empty() {
12612 self._scopes
12613 .insert(Scope::CloudPlatform.as_ref().to_string());
12614 }
12615
12616 #[allow(clippy::single_element_loop)]
12617 for &(find_this, param_name) in
12618 [("{project}", "project"), ("{instance}", "instance")].iter()
12619 {
12620 url = params.uri_replacement(url, param_name, find_this, false);
12621 }
12622 {
12623 let to_remove = ["instance", "project"];
12624 params.remove_params(&to_remove);
12625 }
12626
12627 let url = params.parse_with_url(&url);
12628
12629 let mut json_mime_type = mime::APPLICATION_JSON;
12630 let mut request_value_reader = {
12631 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12632 common::remove_json_null_values(&mut value);
12633 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12634 serde_json::to_writer(&mut dst, &value).unwrap();
12635 dst
12636 };
12637 let request_size = request_value_reader
12638 .seek(std::io::SeekFrom::End(0))
12639 .unwrap();
12640 request_value_reader
12641 .seek(std::io::SeekFrom::Start(0))
12642 .unwrap();
12643
12644 loop {
12645 let token = match self
12646 .hub
12647 .auth
12648 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12649 .await
12650 {
12651 Ok(token) => token,
12652 Err(e) => match dlg.token(e) {
12653 Ok(token) => token,
12654 Err(e) => {
12655 dlg.finished(false);
12656 return Err(common::Error::MissingToken(e));
12657 }
12658 },
12659 };
12660 request_value_reader
12661 .seek(std::io::SeekFrom::Start(0))
12662 .unwrap();
12663 let mut req_result = {
12664 let client = &self.hub.client;
12665 dlg.pre_request();
12666 let mut req_builder = hyper::Request::builder()
12667 .method(hyper::Method::POST)
12668 .uri(url.as_str())
12669 .header(USER_AGENT, self.hub._user_agent.clone());
12670
12671 if let Some(token) = token.as_ref() {
12672 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12673 }
12674
12675 let request = req_builder
12676 .header(CONTENT_TYPE, json_mime_type.to_string())
12677 .header(CONTENT_LENGTH, request_size as u64)
12678 .body(common::to_body(
12679 request_value_reader.get_ref().clone().into(),
12680 ));
12681
12682 client.request(request.unwrap()).await
12683 };
12684
12685 match req_result {
12686 Err(err) => {
12687 if let common::Retry::After(d) = dlg.http_error(&err) {
12688 sleep(d).await;
12689 continue;
12690 }
12691 dlg.finished(false);
12692 return Err(common::Error::HttpError(err));
12693 }
12694 Ok(res) => {
12695 let (mut parts, body) = res.into_parts();
12696 let mut body = common::Body::new(body);
12697 if !parts.status.is_success() {
12698 let bytes = common::to_bytes(body).await.unwrap_or_default();
12699 let error = serde_json::from_str(&common::to_string(&bytes));
12700 let response = common::to_response(parts, bytes.into());
12701
12702 if let common::Retry::After(d) =
12703 dlg.http_failure(&response, error.as_ref().ok())
12704 {
12705 sleep(d).await;
12706 continue;
12707 }
12708
12709 dlg.finished(false);
12710
12711 return Err(match error {
12712 Ok(value) => common::Error::BadRequest(value),
12713 _ => common::Error::Failure(response),
12714 });
12715 }
12716 let response = {
12717 let bytes = common::to_bytes(body).await.unwrap_or_default();
12718 let encoded = common::to_string(&bytes);
12719 match serde_json::from_str(&encoded) {
12720 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12721 Err(error) => {
12722 dlg.response_json_decode_error(&encoded, &error);
12723 return Err(common::Error::JsonDecodeError(
12724 encoded.to_string(),
12725 error,
12726 ));
12727 }
12728 }
12729 };
12730
12731 dlg.finished(true);
12732 return Ok(response);
12733 }
12734 }
12735 }
12736 }
12737
12738 ///
12739 /// Sets the *request* property to the given value.
12740 ///
12741 /// Even though the property as already been set when instantiating this call,
12742 /// we provide this method for API completeness.
12743 pub fn request(
12744 mut self,
12745 new_value: InstancesRotateServerCaRequest,
12746 ) -> InstanceRotateServerCaCall<'a, C> {
12747 self._request = new_value;
12748 self
12749 }
12750 /// Project ID of the project that contains the instance.
12751 ///
12752 /// Sets the *project* path property to the given value.
12753 ///
12754 /// Even though the property as already been set when instantiating this call,
12755 /// we provide this method for API completeness.
12756 pub fn project(mut self, new_value: &str) -> InstanceRotateServerCaCall<'a, C> {
12757 self._project = new_value.to_string();
12758 self
12759 }
12760 /// Cloud SQL instance ID. This does not include the project ID.
12761 ///
12762 /// Sets the *instance* path property to the given value.
12763 ///
12764 /// Even though the property as already been set when instantiating this call,
12765 /// we provide this method for API completeness.
12766 pub fn instance(mut self, new_value: &str) -> InstanceRotateServerCaCall<'a, C> {
12767 self._instance = new_value.to_string();
12768 self
12769 }
12770 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12771 /// while executing the actual API request.
12772 ///
12773 /// ````text
12774 /// It should be used to handle progress information, and to implement a certain level of resilience.
12775 /// ````
12776 ///
12777 /// Sets the *delegate* property to the given value.
12778 pub fn delegate(
12779 mut self,
12780 new_value: &'a mut dyn common::Delegate,
12781 ) -> InstanceRotateServerCaCall<'a, C> {
12782 self._delegate = Some(new_value);
12783 self
12784 }
12785
12786 /// Set any additional parameter of the query string used in the request.
12787 /// It should be used to set parameters which are not yet available through their own
12788 /// setters.
12789 ///
12790 /// Please note that this method must not be used to set any of the known parameters
12791 /// which have their own setter method. If done anyway, the request will fail.
12792 ///
12793 /// # Additional Parameters
12794 ///
12795 /// * *$.xgafv* (query-string) - V1 error format.
12796 /// * *access_token* (query-string) - OAuth access token.
12797 /// * *alt* (query-string) - Data format for response.
12798 /// * *callback* (query-string) - JSONP
12799 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12800 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12801 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12802 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12803 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12804 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12805 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12806 pub fn param<T>(mut self, name: T, value: T) -> InstanceRotateServerCaCall<'a, C>
12807 where
12808 T: AsRef<str>,
12809 {
12810 self._additional_params
12811 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12812 self
12813 }
12814
12815 /// Identifies the authorization scope for the method you are building.
12816 ///
12817 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12818 /// [`Scope::CloudPlatform`].
12819 ///
12820 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12821 /// tokens for more than one scope.
12822 ///
12823 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12824 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12825 /// sufficient, a read-write scope will do as well.
12826 pub fn add_scope<St>(mut self, scope: St) -> InstanceRotateServerCaCall<'a, C>
12827 where
12828 St: AsRef<str>,
12829 {
12830 self._scopes.insert(String::from(scope.as_ref()));
12831 self
12832 }
12833 /// Identifies the authorization scope(s) for the method you are building.
12834 ///
12835 /// See [`Self::add_scope()`] for details.
12836 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceRotateServerCaCall<'a, C>
12837 where
12838 I: IntoIterator<Item = St>,
12839 St: AsRef<str>,
12840 {
12841 self._scopes
12842 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12843 self
12844 }
12845
12846 /// Removes all scopes, and no default scope will be used either.
12847 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12848 /// for details).
12849 pub fn clear_scopes(mut self) -> InstanceRotateServerCaCall<'a, C> {
12850 self._scopes.clear();
12851 self
12852 }
12853}
12854
12855/// Starts the replication in the read replica instance.
12856///
12857/// A builder for the *startReplica* method supported by a *instance* resource.
12858/// It is not used directly, but through a [`InstanceMethods`] instance.
12859///
12860/// # Example
12861///
12862/// Instantiate a resource method builder
12863///
12864/// ```test_harness,no_run
12865/// # extern crate hyper;
12866/// # extern crate hyper_rustls;
12867/// # extern crate google_sql1_beta4 as sql1_beta4;
12868/// # async fn dox() {
12869/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12870///
12871/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12873/// # secret,
12874/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12875/// # ).build().await.unwrap();
12876///
12877/// # let client = hyper_util::client::legacy::Client::builder(
12878/// # hyper_util::rt::TokioExecutor::new()
12879/// # )
12880/// # .build(
12881/// # hyper_rustls::HttpsConnectorBuilder::new()
12882/// # .with_native_roots()
12883/// # .unwrap()
12884/// # .https_or_http()
12885/// # .enable_http1()
12886/// # .build()
12887/// # );
12888/// # let mut hub = SQLAdmin::new(client, auth);
12889/// // You can configure optional parameters by calling the respective setters at will, and
12890/// // execute the final call using `doit()`.
12891/// // Values shown here are possibly random and not representative !
12892/// let result = hub.instances().start_replica("project", "instance")
12893/// .doit().await;
12894/// # }
12895/// ```
12896pub struct InstanceStartReplicaCall<'a, C>
12897where
12898 C: 'a,
12899{
12900 hub: &'a SQLAdmin<C>,
12901 _project: String,
12902 _instance: String,
12903 _delegate: Option<&'a mut dyn common::Delegate>,
12904 _additional_params: HashMap<String, String>,
12905 _scopes: BTreeSet<String>,
12906}
12907
12908impl<'a, C> common::CallBuilder for InstanceStartReplicaCall<'a, C> {}
12909
12910impl<'a, C> InstanceStartReplicaCall<'a, C>
12911where
12912 C: common::Connector,
12913{
12914 /// Perform the operation you have build so far.
12915 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12916 use std::borrow::Cow;
12917 use std::io::{Read, Seek};
12918
12919 use common::{url::Params, ToParts};
12920 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12921
12922 let mut dd = common::DefaultDelegate;
12923 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12924 dlg.begin(common::MethodInfo {
12925 id: "sql.instances.startReplica",
12926 http_method: hyper::Method::POST,
12927 });
12928
12929 for &field in ["alt", "project", "instance"].iter() {
12930 if self._additional_params.contains_key(field) {
12931 dlg.finished(false);
12932 return Err(common::Error::FieldClash(field));
12933 }
12934 }
12935
12936 let mut params = Params::with_capacity(4 + self._additional_params.len());
12937 params.push("project", self._project);
12938 params.push("instance", self._instance);
12939
12940 params.extend(self._additional_params.iter());
12941
12942 params.push("alt", "json");
12943 let mut url = self.hub._base_url.clone()
12944 + "sql/v1beta4/projects/{project}/instances/{instance}/startReplica";
12945 if self._scopes.is_empty() {
12946 self._scopes
12947 .insert(Scope::CloudPlatform.as_ref().to_string());
12948 }
12949
12950 #[allow(clippy::single_element_loop)]
12951 for &(find_this, param_name) in
12952 [("{project}", "project"), ("{instance}", "instance")].iter()
12953 {
12954 url = params.uri_replacement(url, param_name, find_this, false);
12955 }
12956 {
12957 let to_remove = ["instance", "project"];
12958 params.remove_params(&to_remove);
12959 }
12960
12961 let url = params.parse_with_url(&url);
12962
12963 loop {
12964 let token = match self
12965 .hub
12966 .auth
12967 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12968 .await
12969 {
12970 Ok(token) => token,
12971 Err(e) => match dlg.token(e) {
12972 Ok(token) => token,
12973 Err(e) => {
12974 dlg.finished(false);
12975 return Err(common::Error::MissingToken(e));
12976 }
12977 },
12978 };
12979 let mut req_result = {
12980 let client = &self.hub.client;
12981 dlg.pre_request();
12982 let mut req_builder = hyper::Request::builder()
12983 .method(hyper::Method::POST)
12984 .uri(url.as_str())
12985 .header(USER_AGENT, self.hub._user_agent.clone());
12986
12987 if let Some(token) = token.as_ref() {
12988 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12989 }
12990
12991 let request = req_builder
12992 .header(CONTENT_LENGTH, 0_u64)
12993 .body(common::to_body::<String>(None));
12994
12995 client.request(request.unwrap()).await
12996 };
12997
12998 match req_result {
12999 Err(err) => {
13000 if let common::Retry::After(d) = dlg.http_error(&err) {
13001 sleep(d).await;
13002 continue;
13003 }
13004 dlg.finished(false);
13005 return Err(common::Error::HttpError(err));
13006 }
13007 Ok(res) => {
13008 let (mut parts, body) = res.into_parts();
13009 let mut body = common::Body::new(body);
13010 if !parts.status.is_success() {
13011 let bytes = common::to_bytes(body).await.unwrap_or_default();
13012 let error = serde_json::from_str(&common::to_string(&bytes));
13013 let response = common::to_response(parts, bytes.into());
13014
13015 if let common::Retry::After(d) =
13016 dlg.http_failure(&response, error.as_ref().ok())
13017 {
13018 sleep(d).await;
13019 continue;
13020 }
13021
13022 dlg.finished(false);
13023
13024 return Err(match error {
13025 Ok(value) => common::Error::BadRequest(value),
13026 _ => common::Error::Failure(response),
13027 });
13028 }
13029 let response = {
13030 let bytes = common::to_bytes(body).await.unwrap_or_default();
13031 let encoded = common::to_string(&bytes);
13032 match serde_json::from_str(&encoded) {
13033 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13034 Err(error) => {
13035 dlg.response_json_decode_error(&encoded, &error);
13036 return Err(common::Error::JsonDecodeError(
13037 encoded.to_string(),
13038 error,
13039 ));
13040 }
13041 }
13042 };
13043
13044 dlg.finished(true);
13045 return Ok(response);
13046 }
13047 }
13048 }
13049 }
13050
13051 /// ID of the project that contains the read replica.
13052 ///
13053 /// Sets the *project* path property to the given value.
13054 ///
13055 /// Even though the property as already been set when instantiating this call,
13056 /// we provide this method for API completeness.
13057 pub fn project(mut self, new_value: &str) -> InstanceStartReplicaCall<'a, C> {
13058 self._project = new_value.to_string();
13059 self
13060 }
13061 /// Cloud SQL read replica instance name.
13062 ///
13063 /// Sets the *instance* path property to the given value.
13064 ///
13065 /// Even though the property as already been set when instantiating this call,
13066 /// we provide this method for API completeness.
13067 pub fn instance(mut self, new_value: &str) -> InstanceStartReplicaCall<'a, C> {
13068 self._instance = new_value.to_string();
13069 self
13070 }
13071 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13072 /// while executing the actual API request.
13073 ///
13074 /// ````text
13075 /// It should be used to handle progress information, and to implement a certain level of resilience.
13076 /// ````
13077 ///
13078 /// Sets the *delegate* property to the given value.
13079 pub fn delegate(
13080 mut self,
13081 new_value: &'a mut dyn common::Delegate,
13082 ) -> InstanceStartReplicaCall<'a, C> {
13083 self._delegate = Some(new_value);
13084 self
13085 }
13086
13087 /// Set any additional parameter of the query string used in the request.
13088 /// It should be used to set parameters which are not yet available through their own
13089 /// setters.
13090 ///
13091 /// Please note that this method must not be used to set any of the known parameters
13092 /// which have their own setter method. If done anyway, the request will fail.
13093 ///
13094 /// # Additional Parameters
13095 ///
13096 /// * *$.xgafv* (query-string) - V1 error format.
13097 /// * *access_token* (query-string) - OAuth access token.
13098 /// * *alt* (query-string) - Data format for response.
13099 /// * *callback* (query-string) - JSONP
13100 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13101 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13102 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13103 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13104 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13105 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13106 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13107 pub fn param<T>(mut self, name: T, value: T) -> InstanceStartReplicaCall<'a, C>
13108 where
13109 T: AsRef<str>,
13110 {
13111 self._additional_params
13112 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13113 self
13114 }
13115
13116 /// Identifies the authorization scope for the method you are building.
13117 ///
13118 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13119 /// [`Scope::CloudPlatform`].
13120 ///
13121 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13122 /// tokens for more than one scope.
13123 ///
13124 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13125 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13126 /// sufficient, a read-write scope will do as well.
13127 pub fn add_scope<St>(mut self, scope: St) -> InstanceStartReplicaCall<'a, C>
13128 where
13129 St: AsRef<str>,
13130 {
13131 self._scopes.insert(String::from(scope.as_ref()));
13132 self
13133 }
13134 /// Identifies the authorization scope(s) for the method you are building.
13135 ///
13136 /// See [`Self::add_scope()`] for details.
13137 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceStartReplicaCall<'a, C>
13138 where
13139 I: IntoIterator<Item = St>,
13140 St: AsRef<str>,
13141 {
13142 self._scopes
13143 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13144 self
13145 }
13146
13147 /// Removes all scopes, and no default scope will be used either.
13148 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13149 /// for details).
13150 pub fn clear_scopes(mut self) -> InstanceStartReplicaCall<'a, C> {
13151 self._scopes.clear();
13152 self
13153 }
13154}
13155
13156/// Stops the replication in the read replica instance.
13157///
13158/// A builder for the *stopReplica* method supported by a *instance* resource.
13159/// It is not used directly, but through a [`InstanceMethods`] instance.
13160///
13161/// # Example
13162///
13163/// Instantiate a resource method builder
13164///
13165/// ```test_harness,no_run
13166/// # extern crate hyper;
13167/// # extern crate hyper_rustls;
13168/// # extern crate google_sql1_beta4 as sql1_beta4;
13169/// # async fn dox() {
13170/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13171///
13172/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13173/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13174/// # secret,
13175/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13176/// # ).build().await.unwrap();
13177///
13178/// # let client = hyper_util::client::legacy::Client::builder(
13179/// # hyper_util::rt::TokioExecutor::new()
13180/// # )
13181/// # .build(
13182/// # hyper_rustls::HttpsConnectorBuilder::new()
13183/// # .with_native_roots()
13184/// # .unwrap()
13185/// # .https_or_http()
13186/// # .enable_http1()
13187/// # .build()
13188/// # );
13189/// # let mut hub = SQLAdmin::new(client, auth);
13190/// // You can configure optional parameters by calling the respective setters at will, and
13191/// // execute the final call using `doit()`.
13192/// // Values shown here are possibly random and not representative !
13193/// let result = hub.instances().stop_replica("project", "instance")
13194/// .doit().await;
13195/// # }
13196/// ```
13197pub struct InstanceStopReplicaCall<'a, C>
13198where
13199 C: 'a,
13200{
13201 hub: &'a SQLAdmin<C>,
13202 _project: String,
13203 _instance: String,
13204 _delegate: Option<&'a mut dyn common::Delegate>,
13205 _additional_params: HashMap<String, String>,
13206 _scopes: BTreeSet<String>,
13207}
13208
13209impl<'a, C> common::CallBuilder for InstanceStopReplicaCall<'a, C> {}
13210
13211impl<'a, C> InstanceStopReplicaCall<'a, C>
13212where
13213 C: common::Connector,
13214{
13215 /// Perform the operation you have build so far.
13216 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13217 use std::borrow::Cow;
13218 use std::io::{Read, Seek};
13219
13220 use common::{url::Params, ToParts};
13221 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13222
13223 let mut dd = common::DefaultDelegate;
13224 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13225 dlg.begin(common::MethodInfo {
13226 id: "sql.instances.stopReplica",
13227 http_method: hyper::Method::POST,
13228 });
13229
13230 for &field in ["alt", "project", "instance"].iter() {
13231 if self._additional_params.contains_key(field) {
13232 dlg.finished(false);
13233 return Err(common::Error::FieldClash(field));
13234 }
13235 }
13236
13237 let mut params = Params::with_capacity(4 + self._additional_params.len());
13238 params.push("project", self._project);
13239 params.push("instance", self._instance);
13240
13241 params.extend(self._additional_params.iter());
13242
13243 params.push("alt", "json");
13244 let mut url = self.hub._base_url.clone()
13245 + "sql/v1beta4/projects/{project}/instances/{instance}/stopReplica";
13246 if self._scopes.is_empty() {
13247 self._scopes
13248 .insert(Scope::CloudPlatform.as_ref().to_string());
13249 }
13250
13251 #[allow(clippy::single_element_loop)]
13252 for &(find_this, param_name) in
13253 [("{project}", "project"), ("{instance}", "instance")].iter()
13254 {
13255 url = params.uri_replacement(url, param_name, find_this, false);
13256 }
13257 {
13258 let to_remove = ["instance", "project"];
13259 params.remove_params(&to_remove);
13260 }
13261
13262 let url = params.parse_with_url(&url);
13263
13264 loop {
13265 let token = match self
13266 .hub
13267 .auth
13268 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13269 .await
13270 {
13271 Ok(token) => token,
13272 Err(e) => match dlg.token(e) {
13273 Ok(token) => token,
13274 Err(e) => {
13275 dlg.finished(false);
13276 return Err(common::Error::MissingToken(e));
13277 }
13278 },
13279 };
13280 let mut req_result = {
13281 let client = &self.hub.client;
13282 dlg.pre_request();
13283 let mut req_builder = hyper::Request::builder()
13284 .method(hyper::Method::POST)
13285 .uri(url.as_str())
13286 .header(USER_AGENT, self.hub._user_agent.clone());
13287
13288 if let Some(token) = token.as_ref() {
13289 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13290 }
13291
13292 let request = req_builder
13293 .header(CONTENT_LENGTH, 0_u64)
13294 .body(common::to_body::<String>(None));
13295
13296 client.request(request.unwrap()).await
13297 };
13298
13299 match req_result {
13300 Err(err) => {
13301 if let common::Retry::After(d) = dlg.http_error(&err) {
13302 sleep(d).await;
13303 continue;
13304 }
13305 dlg.finished(false);
13306 return Err(common::Error::HttpError(err));
13307 }
13308 Ok(res) => {
13309 let (mut parts, body) = res.into_parts();
13310 let mut body = common::Body::new(body);
13311 if !parts.status.is_success() {
13312 let bytes = common::to_bytes(body).await.unwrap_or_default();
13313 let error = serde_json::from_str(&common::to_string(&bytes));
13314 let response = common::to_response(parts, bytes.into());
13315
13316 if let common::Retry::After(d) =
13317 dlg.http_failure(&response, error.as_ref().ok())
13318 {
13319 sleep(d).await;
13320 continue;
13321 }
13322
13323 dlg.finished(false);
13324
13325 return Err(match error {
13326 Ok(value) => common::Error::BadRequest(value),
13327 _ => common::Error::Failure(response),
13328 });
13329 }
13330 let response = {
13331 let bytes = common::to_bytes(body).await.unwrap_or_default();
13332 let encoded = common::to_string(&bytes);
13333 match serde_json::from_str(&encoded) {
13334 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13335 Err(error) => {
13336 dlg.response_json_decode_error(&encoded, &error);
13337 return Err(common::Error::JsonDecodeError(
13338 encoded.to_string(),
13339 error,
13340 ));
13341 }
13342 }
13343 };
13344
13345 dlg.finished(true);
13346 return Ok(response);
13347 }
13348 }
13349 }
13350 }
13351
13352 /// ID of the project that contains the read replica.
13353 ///
13354 /// Sets the *project* path property to the given value.
13355 ///
13356 /// Even though the property as already been set when instantiating this call,
13357 /// we provide this method for API completeness.
13358 pub fn project(mut self, new_value: &str) -> InstanceStopReplicaCall<'a, C> {
13359 self._project = new_value.to_string();
13360 self
13361 }
13362 /// Cloud SQL read replica instance name.
13363 ///
13364 /// Sets the *instance* path property to the given value.
13365 ///
13366 /// Even though the property as already been set when instantiating this call,
13367 /// we provide this method for API completeness.
13368 pub fn instance(mut self, new_value: &str) -> InstanceStopReplicaCall<'a, C> {
13369 self._instance = new_value.to_string();
13370 self
13371 }
13372 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13373 /// while executing the actual API request.
13374 ///
13375 /// ````text
13376 /// It should be used to handle progress information, and to implement a certain level of resilience.
13377 /// ````
13378 ///
13379 /// Sets the *delegate* property to the given value.
13380 pub fn delegate(
13381 mut self,
13382 new_value: &'a mut dyn common::Delegate,
13383 ) -> InstanceStopReplicaCall<'a, C> {
13384 self._delegate = Some(new_value);
13385 self
13386 }
13387
13388 /// Set any additional parameter of the query string used in the request.
13389 /// It should be used to set parameters which are not yet available through their own
13390 /// setters.
13391 ///
13392 /// Please note that this method must not be used to set any of the known parameters
13393 /// which have their own setter method. If done anyway, the request will fail.
13394 ///
13395 /// # Additional Parameters
13396 ///
13397 /// * *$.xgafv* (query-string) - V1 error format.
13398 /// * *access_token* (query-string) - OAuth access token.
13399 /// * *alt* (query-string) - Data format for response.
13400 /// * *callback* (query-string) - JSONP
13401 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13402 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13403 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13404 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13405 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13406 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13407 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13408 pub fn param<T>(mut self, name: T, value: T) -> InstanceStopReplicaCall<'a, C>
13409 where
13410 T: AsRef<str>,
13411 {
13412 self._additional_params
13413 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13414 self
13415 }
13416
13417 /// Identifies the authorization scope for the method you are building.
13418 ///
13419 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13420 /// [`Scope::CloudPlatform`].
13421 ///
13422 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13423 /// tokens for more than one scope.
13424 ///
13425 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13426 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13427 /// sufficient, a read-write scope will do as well.
13428 pub fn add_scope<St>(mut self, scope: St) -> InstanceStopReplicaCall<'a, C>
13429 where
13430 St: AsRef<str>,
13431 {
13432 self._scopes.insert(String::from(scope.as_ref()));
13433 self
13434 }
13435 /// Identifies the authorization scope(s) for the method you are building.
13436 ///
13437 /// See [`Self::add_scope()`] for details.
13438 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceStopReplicaCall<'a, C>
13439 where
13440 I: IntoIterator<Item = St>,
13441 St: AsRef<str>,
13442 {
13443 self._scopes
13444 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13445 self
13446 }
13447
13448 /// Removes all scopes, and no default scope will be used either.
13449 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13450 /// for details).
13451 pub fn clear_scopes(mut self) -> InstanceStopReplicaCall<'a, C> {
13452 self._scopes.clear();
13453 self
13454 }
13455}
13456
13457/// Truncate MySQL general and slow query log tables
13458///
13459/// A builder for the *truncateLog* method supported by a *instance* resource.
13460/// It is not used directly, but through a [`InstanceMethods`] instance.
13461///
13462/// # Example
13463///
13464/// Instantiate a resource method builder
13465///
13466/// ```test_harness,no_run
13467/// # extern crate hyper;
13468/// # extern crate hyper_rustls;
13469/// # extern crate google_sql1_beta4 as sql1_beta4;
13470/// use sql1_beta4::api::InstancesTruncateLogRequest;
13471/// # async fn dox() {
13472/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13473///
13474/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13475/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13476/// # secret,
13477/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13478/// # ).build().await.unwrap();
13479///
13480/// # let client = hyper_util::client::legacy::Client::builder(
13481/// # hyper_util::rt::TokioExecutor::new()
13482/// # )
13483/// # .build(
13484/// # hyper_rustls::HttpsConnectorBuilder::new()
13485/// # .with_native_roots()
13486/// # .unwrap()
13487/// # .https_or_http()
13488/// # .enable_http1()
13489/// # .build()
13490/// # );
13491/// # let mut hub = SQLAdmin::new(client, auth);
13492/// // As the method needs a request, you would usually fill it with the desired information
13493/// // into the respective structure. Some of the parts shown here might not be applicable !
13494/// // Values shown here are possibly random and not representative !
13495/// let mut req = InstancesTruncateLogRequest::default();
13496///
13497/// // You can configure optional parameters by calling the respective setters at will, and
13498/// // execute the final call using `doit()`.
13499/// // Values shown here are possibly random and not representative !
13500/// let result = hub.instances().truncate_log(req, "project", "instance")
13501/// .doit().await;
13502/// # }
13503/// ```
13504pub struct InstanceTruncateLogCall<'a, C>
13505where
13506 C: 'a,
13507{
13508 hub: &'a SQLAdmin<C>,
13509 _request: InstancesTruncateLogRequest,
13510 _project: String,
13511 _instance: String,
13512 _delegate: Option<&'a mut dyn common::Delegate>,
13513 _additional_params: HashMap<String, String>,
13514 _scopes: BTreeSet<String>,
13515}
13516
13517impl<'a, C> common::CallBuilder for InstanceTruncateLogCall<'a, C> {}
13518
13519impl<'a, C> InstanceTruncateLogCall<'a, C>
13520where
13521 C: common::Connector,
13522{
13523 /// Perform the operation you have build so far.
13524 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13525 use std::borrow::Cow;
13526 use std::io::{Read, Seek};
13527
13528 use common::{url::Params, ToParts};
13529 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13530
13531 let mut dd = common::DefaultDelegate;
13532 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13533 dlg.begin(common::MethodInfo {
13534 id: "sql.instances.truncateLog",
13535 http_method: hyper::Method::POST,
13536 });
13537
13538 for &field in ["alt", "project", "instance"].iter() {
13539 if self._additional_params.contains_key(field) {
13540 dlg.finished(false);
13541 return Err(common::Error::FieldClash(field));
13542 }
13543 }
13544
13545 let mut params = Params::with_capacity(5 + self._additional_params.len());
13546 params.push("project", self._project);
13547 params.push("instance", self._instance);
13548
13549 params.extend(self._additional_params.iter());
13550
13551 params.push("alt", "json");
13552 let mut url = self.hub._base_url.clone()
13553 + "sql/v1beta4/projects/{project}/instances/{instance}/truncateLog";
13554 if self._scopes.is_empty() {
13555 self._scopes
13556 .insert(Scope::CloudPlatform.as_ref().to_string());
13557 }
13558
13559 #[allow(clippy::single_element_loop)]
13560 for &(find_this, param_name) in
13561 [("{project}", "project"), ("{instance}", "instance")].iter()
13562 {
13563 url = params.uri_replacement(url, param_name, find_this, false);
13564 }
13565 {
13566 let to_remove = ["instance", "project"];
13567 params.remove_params(&to_remove);
13568 }
13569
13570 let url = params.parse_with_url(&url);
13571
13572 let mut json_mime_type = mime::APPLICATION_JSON;
13573 let mut request_value_reader = {
13574 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13575 common::remove_json_null_values(&mut value);
13576 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13577 serde_json::to_writer(&mut dst, &value).unwrap();
13578 dst
13579 };
13580 let request_size = request_value_reader
13581 .seek(std::io::SeekFrom::End(0))
13582 .unwrap();
13583 request_value_reader
13584 .seek(std::io::SeekFrom::Start(0))
13585 .unwrap();
13586
13587 loop {
13588 let token = match self
13589 .hub
13590 .auth
13591 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13592 .await
13593 {
13594 Ok(token) => token,
13595 Err(e) => match dlg.token(e) {
13596 Ok(token) => token,
13597 Err(e) => {
13598 dlg.finished(false);
13599 return Err(common::Error::MissingToken(e));
13600 }
13601 },
13602 };
13603 request_value_reader
13604 .seek(std::io::SeekFrom::Start(0))
13605 .unwrap();
13606 let mut req_result = {
13607 let client = &self.hub.client;
13608 dlg.pre_request();
13609 let mut req_builder = hyper::Request::builder()
13610 .method(hyper::Method::POST)
13611 .uri(url.as_str())
13612 .header(USER_AGENT, self.hub._user_agent.clone());
13613
13614 if let Some(token) = token.as_ref() {
13615 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13616 }
13617
13618 let request = req_builder
13619 .header(CONTENT_TYPE, json_mime_type.to_string())
13620 .header(CONTENT_LENGTH, request_size as u64)
13621 .body(common::to_body(
13622 request_value_reader.get_ref().clone().into(),
13623 ));
13624
13625 client.request(request.unwrap()).await
13626 };
13627
13628 match req_result {
13629 Err(err) => {
13630 if let common::Retry::After(d) = dlg.http_error(&err) {
13631 sleep(d).await;
13632 continue;
13633 }
13634 dlg.finished(false);
13635 return Err(common::Error::HttpError(err));
13636 }
13637 Ok(res) => {
13638 let (mut parts, body) = res.into_parts();
13639 let mut body = common::Body::new(body);
13640 if !parts.status.is_success() {
13641 let bytes = common::to_bytes(body).await.unwrap_or_default();
13642 let error = serde_json::from_str(&common::to_string(&bytes));
13643 let response = common::to_response(parts, bytes.into());
13644
13645 if let common::Retry::After(d) =
13646 dlg.http_failure(&response, error.as_ref().ok())
13647 {
13648 sleep(d).await;
13649 continue;
13650 }
13651
13652 dlg.finished(false);
13653
13654 return Err(match error {
13655 Ok(value) => common::Error::BadRequest(value),
13656 _ => common::Error::Failure(response),
13657 });
13658 }
13659 let response = {
13660 let bytes = common::to_bytes(body).await.unwrap_or_default();
13661 let encoded = common::to_string(&bytes);
13662 match serde_json::from_str(&encoded) {
13663 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13664 Err(error) => {
13665 dlg.response_json_decode_error(&encoded, &error);
13666 return Err(common::Error::JsonDecodeError(
13667 encoded.to_string(),
13668 error,
13669 ));
13670 }
13671 }
13672 };
13673
13674 dlg.finished(true);
13675 return Ok(response);
13676 }
13677 }
13678 }
13679 }
13680
13681 ///
13682 /// Sets the *request* property to the given value.
13683 ///
13684 /// Even though the property as already been set when instantiating this call,
13685 /// we provide this method for API completeness.
13686 pub fn request(
13687 mut self,
13688 new_value: InstancesTruncateLogRequest,
13689 ) -> InstanceTruncateLogCall<'a, C> {
13690 self._request = new_value;
13691 self
13692 }
13693 /// Project ID of the Cloud SQL project.
13694 ///
13695 /// Sets the *project* path property to the given value.
13696 ///
13697 /// Even though the property as already been set when instantiating this call,
13698 /// we provide this method for API completeness.
13699 pub fn project(mut self, new_value: &str) -> InstanceTruncateLogCall<'a, C> {
13700 self._project = new_value.to_string();
13701 self
13702 }
13703 /// Cloud SQL instance ID. This does not include the project ID.
13704 ///
13705 /// Sets the *instance* path property to the given value.
13706 ///
13707 /// Even though the property as already been set when instantiating this call,
13708 /// we provide this method for API completeness.
13709 pub fn instance(mut self, new_value: &str) -> InstanceTruncateLogCall<'a, C> {
13710 self._instance = new_value.to_string();
13711 self
13712 }
13713 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13714 /// while executing the actual API request.
13715 ///
13716 /// ````text
13717 /// It should be used to handle progress information, and to implement a certain level of resilience.
13718 /// ````
13719 ///
13720 /// Sets the *delegate* property to the given value.
13721 pub fn delegate(
13722 mut self,
13723 new_value: &'a mut dyn common::Delegate,
13724 ) -> InstanceTruncateLogCall<'a, C> {
13725 self._delegate = Some(new_value);
13726 self
13727 }
13728
13729 /// Set any additional parameter of the query string used in the request.
13730 /// It should be used to set parameters which are not yet available through their own
13731 /// setters.
13732 ///
13733 /// Please note that this method must not be used to set any of the known parameters
13734 /// which have their own setter method. If done anyway, the request will fail.
13735 ///
13736 /// # Additional Parameters
13737 ///
13738 /// * *$.xgafv* (query-string) - V1 error format.
13739 /// * *access_token* (query-string) - OAuth access token.
13740 /// * *alt* (query-string) - Data format for response.
13741 /// * *callback* (query-string) - JSONP
13742 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13743 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13744 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13745 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13746 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13747 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13748 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13749 pub fn param<T>(mut self, name: T, value: T) -> InstanceTruncateLogCall<'a, C>
13750 where
13751 T: AsRef<str>,
13752 {
13753 self._additional_params
13754 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13755 self
13756 }
13757
13758 /// Identifies the authorization scope for the method you are building.
13759 ///
13760 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13761 /// [`Scope::CloudPlatform`].
13762 ///
13763 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13764 /// tokens for more than one scope.
13765 ///
13766 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13767 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13768 /// sufficient, a read-write scope will do as well.
13769 pub fn add_scope<St>(mut self, scope: St) -> InstanceTruncateLogCall<'a, C>
13770 where
13771 St: AsRef<str>,
13772 {
13773 self._scopes.insert(String::from(scope.as_ref()));
13774 self
13775 }
13776 /// Identifies the authorization scope(s) for the method you are building.
13777 ///
13778 /// See [`Self::add_scope()`] for details.
13779 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceTruncateLogCall<'a, C>
13780 where
13781 I: IntoIterator<Item = St>,
13782 St: AsRef<str>,
13783 {
13784 self._scopes
13785 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13786 self
13787 }
13788
13789 /// Removes all scopes, and no default scope will be used either.
13790 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13791 /// for details).
13792 pub fn clear_scopes(mut self) -> InstanceTruncateLogCall<'a, C> {
13793 self._scopes.clear();
13794 self
13795 }
13796}
13797
13798/// Updates settings of a Cloud SQL instance. Using this operation might cause
13799/// your instance to restart.
13800///
13801/// A builder for the *update* method supported by a *instance* resource.
13802/// It is not used directly, but through a [`InstanceMethods`] instance.
13803///
13804/// # Example
13805///
13806/// Instantiate a resource method builder
13807///
13808/// ```test_harness,no_run
13809/// # extern crate hyper;
13810/// # extern crate hyper_rustls;
13811/// # extern crate google_sql1_beta4 as sql1_beta4;
13812/// use sql1_beta4::api::DatabaseInstance;
13813/// # async fn dox() {
13814/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13815///
13816/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13817/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13818/// # secret,
13819/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13820/// # ).build().await.unwrap();
13821///
13822/// # let client = hyper_util::client::legacy::Client::builder(
13823/// # hyper_util::rt::TokioExecutor::new()
13824/// # )
13825/// # .build(
13826/// # hyper_rustls::HttpsConnectorBuilder::new()
13827/// # .with_native_roots()
13828/// # .unwrap()
13829/// # .https_or_http()
13830/// # .enable_http1()
13831/// # .build()
13832/// # );
13833/// # let mut hub = SQLAdmin::new(client, auth);
13834/// // As the method needs a request, you would usually fill it with the desired information
13835/// // into the respective structure. Some of the parts shown here might not be applicable !
13836/// // Values shown here are possibly random and not representative !
13837/// let mut req = DatabaseInstance::default();
13838///
13839/// // You can configure optional parameters by calling the respective setters at will, and
13840/// // execute the final call using `doit()`.
13841/// // Values shown here are possibly random and not representative !
13842/// let result = hub.instances().update(req, "project", "instance")
13843/// .doit().await;
13844/// # }
13845/// ```
13846pub struct InstanceUpdateCall<'a, C>
13847where
13848 C: 'a,
13849{
13850 hub: &'a SQLAdmin<C>,
13851 _request: DatabaseInstance,
13852 _project: String,
13853 _instance: String,
13854 _delegate: Option<&'a mut dyn common::Delegate>,
13855 _additional_params: HashMap<String, String>,
13856 _scopes: BTreeSet<String>,
13857}
13858
13859impl<'a, C> common::CallBuilder for InstanceUpdateCall<'a, C> {}
13860
13861impl<'a, C> InstanceUpdateCall<'a, C>
13862where
13863 C: common::Connector,
13864{
13865 /// Perform the operation you have build so far.
13866 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13867 use std::borrow::Cow;
13868 use std::io::{Read, Seek};
13869
13870 use common::{url::Params, ToParts};
13871 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13872
13873 let mut dd = common::DefaultDelegate;
13874 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13875 dlg.begin(common::MethodInfo {
13876 id: "sql.instances.update",
13877 http_method: hyper::Method::PUT,
13878 });
13879
13880 for &field in ["alt", "project", "instance"].iter() {
13881 if self._additional_params.contains_key(field) {
13882 dlg.finished(false);
13883 return Err(common::Error::FieldClash(field));
13884 }
13885 }
13886
13887 let mut params = Params::with_capacity(5 + self._additional_params.len());
13888 params.push("project", self._project);
13889 params.push("instance", self._instance);
13890
13891 params.extend(self._additional_params.iter());
13892
13893 params.push("alt", "json");
13894 let mut url =
13895 self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/instances/{instance}";
13896 if self._scopes.is_empty() {
13897 self._scopes
13898 .insert(Scope::CloudPlatform.as_ref().to_string());
13899 }
13900
13901 #[allow(clippy::single_element_loop)]
13902 for &(find_this, param_name) in
13903 [("{project}", "project"), ("{instance}", "instance")].iter()
13904 {
13905 url = params.uri_replacement(url, param_name, find_this, false);
13906 }
13907 {
13908 let to_remove = ["instance", "project"];
13909 params.remove_params(&to_remove);
13910 }
13911
13912 let url = params.parse_with_url(&url);
13913
13914 let mut json_mime_type = mime::APPLICATION_JSON;
13915 let mut request_value_reader = {
13916 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13917 common::remove_json_null_values(&mut value);
13918 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13919 serde_json::to_writer(&mut dst, &value).unwrap();
13920 dst
13921 };
13922 let request_size = request_value_reader
13923 .seek(std::io::SeekFrom::End(0))
13924 .unwrap();
13925 request_value_reader
13926 .seek(std::io::SeekFrom::Start(0))
13927 .unwrap();
13928
13929 loop {
13930 let token = match self
13931 .hub
13932 .auth
13933 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13934 .await
13935 {
13936 Ok(token) => token,
13937 Err(e) => match dlg.token(e) {
13938 Ok(token) => token,
13939 Err(e) => {
13940 dlg.finished(false);
13941 return Err(common::Error::MissingToken(e));
13942 }
13943 },
13944 };
13945 request_value_reader
13946 .seek(std::io::SeekFrom::Start(0))
13947 .unwrap();
13948 let mut req_result = {
13949 let client = &self.hub.client;
13950 dlg.pre_request();
13951 let mut req_builder = hyper::Request::builder()
13952 .method(hyper::Method::PUT)
13953 .uri(url.as_str())
13954 .header(USER_AGENT, self.hub._user_agent.clone());
13955
13956 if let Some(token) = token.as_ref() {
13957 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13958 }
13959
13960 let request = req_builder
13961 .header(CONTENT_TYPE, json_mime_type.to_string())
13962 .header(CONTENT_LENGTH, request_size as u64)
13963 .body(common::to_body(
13964 request_value_reader.get_ref().clone().into(),
13965 ));
13966
13967 client.request(request.unwrap()).await
13968 };
13969
13970 match req_result {
13971 Err(err) => {
13972 if let common::Retry::After(d) = dlg.http_error(&err) {
13973 sleep(d).await;
13974 continue;
13975 }
13976 dlg.finished(false);
13977 return Err(common::Error::HttpError(err));
13978 }
13979 Ok(res) => {
13980 let (mut parts, body) = res.into_parts();
13981 let mut body = common::Body::new(body);
13982 if !parts.status.is_success() {
13983 let bytes = common::to_bytes(body).await.unwrap_or_default();
13984 let error = serde_json::from_str(&common::to_string(&bytes));
13985 let response = common::to_response(parts, bytes.into());
13986
13987 if let common::Retry::After(d) =
13988 dlg.http_failure(&response, error.as_ref().ok())
13989 {
13990 sleep(d).await;
13991 continue;
13992 }
13993
13994 dlg.finished(false);
13995
13996 return Err(match error {
13997 Ok(value) => common::Error::BadRequest(value),
13998 _ => common::Error::Failure(response),
13999 });
14000 }
14001 let response = {
14002 let bytes = common::to_bytes(body).await.unwrap_or_default();
14003 let encoded = common::to_string(&bytes);
14004 match serde_json::from_str(&encoded) {
14005 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14006 Err(error) => {
14007 dlg.response_json_decode_error(&encoded, &error);
14008 return Err(common::Error::JsonDecodeError(
14009 encoded.to_string(),
14010 error,
14011 ));
14012 }
14013 }
14014 };
14015
14016 dlg.finished(true);
14017 return Ok(response);
14018 }
14019 }
14020 }
14021 }
14022
14023 ///
14024 /// Sets the *request* property to the given value.
14025 ///
14026 /// Even though the property as already been set when instantiating this call,
14027 /// we provide this method for API completeness.
14028 pub fn request(mut self, new_value: DatabaseInstance) -> InstanceUpdateCall<'a, C> {
14029 self._request = new_value;
14030 self
14031 }
14032 /// Project ID of the project that contains the instance.
14033 ///
14034 /// Sets the *project* path property to the given value.
14035 ///
14036 /// Even though the property as already been set when instantiating this call,
14037 /// we provide this method for API completeness.
14038 pub fn project(mut self, new_value: &str) -> InstanceUpdateCall<'a, C> {
14039 self._project = new_value.to_string();
14040 self
14041 }
14042 /// Cloud SQL instance ID. This does not include the project ID.
14043 ///
14044 /// Sets the *instance* path property to the given value.
14045 ///
14046 /// Even though the property as already been set when instantiating this call,
14047 /// we provide this method for API completeness.
14048 pub fn instance(mut self, new_value: &str) -> InstanceUpdateCall<'a, C> {
14049 self._instance = new_value.to_string();
14050 self
14051 }
14052 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14053 /// while executing the actual API request.
14054 ///
14055 /// ````text
14056 /// It should be used to handle progress information, and to implement a certain level of resilience.
14057 /// ````
14058 ///
14059 /// Sets the *delegate* property to the given value.
14060 pub fn delegate(
14061 mut self,
14062 new_value: &'a mut dyn common::Delegate,
14063 ) -> InstanceUpdateCall<'a, C> {
14064 self._delegate = Some(new_value);
14065 self
14066 }
14067
14068 /// Set any additional parameter of the query string used in the request.
14069 /// It should be used to set parameters which are not yet available through their own
14070 /// setters.
14071 ///
14072 /// Please note that this method must not be used to set any of the known parameters
14073 /// which have their own setter method. If done anyway, the request will fail.
14074 ///
14075 /// # Additional Parameters
14076 ///
14077 /// * *$.xgafv* (query-string) - V1 error format.
14078 /// * *access_token* (query-string) - OAuth access token.
14079 /// * *alt* (query-string) - Data format for response.
14080 /// * *callback* (query-string) - JSONP
14081 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14082 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14083 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14084 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14085 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14086 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14087 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14088 pub fn param<T>(mut self, name: T, value: T) -> InstanceUpdateCall<'a, C>
14089 where
14090 T: AsRef<str>,
14091 {
14092 self._additional_params
14093 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14094 self
14095 }
14096
14097 /// Identifies the authorization scope for the method you are building.
14098 ///
14099 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14100 /// [`Scope::CloudPlatform`].
14101 ///
14102 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14103 /// tokens for more than one scope.
14104 ///
14105 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14106 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14107 /// sufficient, a read-write scope will do as well.
14108 pub fn add_scope<St>(mut self, scope: St) -> InstanceUpdateCall<'a, C>
14109 where
14110 St: AsRef<str>,
14111 {
14112 self._scopes.insert(String::from(scope.as_ref()));
14113 self
14114 }
14115 /// Identifies the authorization scope(s) for the method you are building.
14116 ///
14117 /// See [`Self::add_scope()`] for details.
14118 pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceUpdateCall<'a, C>
14119 where
14120 I: IntoIterator<Item = St>,
14121 St: AsRef<str>,
14122 {
14123 self._scopes
14124 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14125 self
14126 }
14127
14128 /// Removes all scopes, and no default scope will be used either.
14129 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14130 /// for details).
14131 pub fn clear_scopes(mut self) -> InstanceUpdateCall<'a, C> {
14132 self._scopes.clear();
14133 self
14134 }
14135}
14136
14137/// Retrieves an instance operation that has been performed on an instance.
14138///
14139/// A builder for the *get* method supported by a *operation* resource.
14140/// It is not used directly, but through a [`OperationMethods`] instance.
14141///
14142/// # Example
14143///
14144/// Instantiate a resource method builder
14145///
14146/// ```test_harness,no_run
14147/// # extern crate hyper;
14148/// # extern crate hyper_rustls;
14149/// # extern crate google_sql1_beta4 as sql1_beta4;
14150/// # async fn dox() {
14151/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14152///
14153/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14154/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14155/// # secret,
14156/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14157/// # ).build().await.unwrap();
14158///
14159/// # let client = hyper_util::client::legacy::Client::builder(
14160/// # hyper_util::rt::TokioExecutor::new()
14161/// # )
14162/// # .build(
14163/// # hyper_rustls::HttpsConnectorBuilder::new()
14164/// # .with_native_roots()
14165/// # .unwrap()
14166/// # .https_or_http()
14167/// # .enable_http1()
14168/// # .build()
14169/// # );
14170/// # let mut hub = SQLAdmin::new(client, auth);
14171/// // You can configure optional parameters by calling the respective setters at will, and
14172/// // execute the final call using `doit()`.
14173/// // Values shown here are possibly random and not representative !
14174/// let result = hub.operations().get("project", "operation")
14175/// .doit().await;
14176/// # }
14177/// ```
14178pub struct OperationGetCall<'a, C>
14179where
14180 C: 'a,
14181{
14182 hub: &'a SQLAdmin<C>,
14183 _project: String,
14184 _operation: String,
14185 _delegate: Option<&'a mut dyn common::Delegate>,
14186 _additional_params: HashMap<String, String>,
14187 _scopes: BTreeSet<String>,
14188}
14189
14190impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
14191
14192impl<'a, C> OperationGetCall<'a, C>
14193where
14194 C: common::Connector,
14195{
14196 /// Perform the operation you have build so far.
14197 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14198 use std::borrow::Cow;
14199 use std::io::{Read, Seek};
14200
14201 use common::{url::Params, ToParts};
14202 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14203
14204 let mut dd = common::DefaultDelegate;
14205 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14206 dlg.begin(common::MethodInfo {
14207 id: "sql.operations.get",
14208 http_method: hyper::Method::GET,
14209 });
14210
14211 for &field in ["alt", "project", "operation"].iter() {
14212 if self._additional_params.contains_key(field) {
14213 dlg.finished(false);
14214 return Err(common::Error::FieldClash(field));
14215 }
14216 }
14217
14218 let mut params = Params::with_capacity(4 + self._additional_params.len());
14219 params.push("project", self._project);
14220 params.push("operation", self._operation);
14221
14222 params.extend(self._additional_params.iter());
14223
14224 params.push("alt", "json");
14225 let mut url =
14226 self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/operations/{operation}";
14227 if self._scopes.is_empty() {
14228 self._scopes
14229 .insert(Scope::CloudPlatform.as_ref().to_string());
14230 }
14231
14232 #[allow(clippy::single_element_loop)]
14233 for &(find_this, param_name) in
14234 [("{project}", "project"), ("{operation}", "operation")].iter()
14235 {
14236 url = params.uri_replacement(url, param_name, find_this, false);
14237 }
14238 {
14239 let to_remove = ["operation", "project"];
14240 params.remove_params(&to_remove);
14241 }
14242
14243 let url = params.parse_with_url(&url);
14244
14245 loop {
14246 let token = match self
14247 .hub
14248 .auth
14249 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14250 .await
14251 {
14252 Ok(token) => token,
14253 Err(e) => match dlg.token(e) {
14254 Ok(token) => token,
14255 Err(e) => {
14256 dlg.finished(false);
14257 return Err(common::Error::MissingToken(e));
14258 }
14259 },
14260 };
14261 let mut req_result = {
14262 let client = &self.hub.client;
14263 dlg.pre_request();
14264 let mut req_builder = hyper::Request::builder()
14265 .method(hyper::Method::GET)
14266 .uri(url.as_str())
14267 .header(USER_AGENT, self.hub._user_agent.clone());
14268
14269 if let Some(token) = token.as_ref() {
14270 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14271 }
14272
14273 let request = req_builder
14274 .header(CONTENT_LENGTH, 0_u64)
14275 .body(common::to_body::<String>(None));
14276
14277 client.request(request.unwrap()).await
14278 };
14279
14280 match req_result {
14281 Err(err) => {
14282 if let common::Retry::After(d) = dlg.http_error(&err) {
14283 sleep(d).await;
14284 continue;
14285 }
14286 dlg.finished(false);
14287 return Err(common::Error::HttpError(err));
14288 }
14289 Ok(res) => {
14290 let (mut parts, body) = res.into_parts();
14291 let mut body = common::Body::new(body);
14292 if !parts.status.is_success() {
14293 let bytes = common::to_bytes(body).await.unwrap_or_default();
14294 let error = serde_json::from_str(&common::to_string(&bytes));
14295 let response = common::to_response(parts, bytes.into());
14296
14297 if let common::Retry::After(d) =
14298 dlg.http_failure(&response, error.as_ref().ok())
14299 {
14300 sleep(d).await;
14301 continue;
14302 }
14303
14304 dlg.finished(false);
14305
14306 return Err(match error {
14307 Ok(value) => common::Error::BadRequest(value),
14308 _ => common::Error::Failure(response),
14309 });
14310 }
14311 let response = {
14312 let bytes = common::to_bytes(body).await.unwrap_or_default();
14313 let encoded = common::to_string(&bytes);
14314 match serde_json::from_str(&encoded) {
14315 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14316 Err(error) => {
14317 dlg.response_json_decode_error(&encoded, &error);
14318 return Err(common::Error::JsonDecodeError(
14319 encoded.to_string(),
14320 error,
14321 ));
14322 }
14323 }
14324 };
14325
14326 dlg.finished(true);
14327 return Ok(response);
14328 }
14329 }
14330 }
14331 }
14332
14333 /// Project ID of the project that contains the instance.
14334 ///
14335 /// Sets the *project* path property to the given value.
14336 ///
14337 /// Even though the property as already been set when instantiating this call,
14338 /// we provide this method for API completeness.
14339 pub fn project(mut self, new_value: &str) -> OperationGetCall<'a, C> {
14340 self._project = new_value.to_string();
14341 self
14342 }
14343 /// Instance operation ID.
14344 ///
14345 /// Sets the *operation* path property to the given value.
14346 ///
14347 /// Even though the property as already been set when instantiating this call,
14348 /// we provide this method for API completeness.
14349 pub fn operation(mut self, new_value: &str) -> OperationGetCall<'a, C> {
14350 self._operation = new_value.to_string();
14351 self
14352 }
14353 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14354 /// while executing the actual API request.
14355 ///
14356 /// ````text
14357 /// It should be used to handle progress information, and to implement a certain level of resilience.
14358 /// ````
14359 ///
14360 /// Sets the *delegate* property to the given value.
14361 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
14362 self._delegate = Some(new_value);
14363 self
14364 }
14365
14366 /// Set any additional parameter of the query string used in the request.
14367 /// It should be used to set parameters which are not yet available through their own
14368 /// setters.
14369 ///
14370 /// Please note that this method must not be used to set any of the known parameters
14371 /// which have their own setter method. If done anyway, the request will fail.
14372 ///
14373 /// # Additional Parameters
14374 ///
14375 /// * *$.xgafv* (query-string) - V1 error format.
14376 /// * *access_token* (query-string) - OAuth access token.
14377 /// * *alt* (query-string) - Data format for response.
14378 /// * *callback* (query-string) - JSONP
14379 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14380 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14381 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14382 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14383 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14384 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14385 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14386 pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
14387 where
14388 T: AsRef<str>,
14389 {
14390 self._additional_params
14391 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14392 self
14393 }
14394
14395 /// Identifies the authorization scope for the method you are building.
14396 ///
14397 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14398 /// [`Scope::CloudPlatform`].
14399 ///
14400 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14401 /// tokens for more than one scope.
14402 ///
14403 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14404 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14405 /// sufficient, a read-write scope will do as well.
14406 pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
14407 where
14408 St: AsRef<str>,
14409 {
14410 self._scopes.insert(String::from(scope.as_ref()));
14411 self
14412 }
14413 /// Identifies the authorization scope(s) for the method you are building.
14414 ///
14415 /// See [`Self::add_scope()`] for details.
14416 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
14417 where
14418 I: IntoIterator<Item = St>,
14419 St: AsRef<str>,
14420 {
14421 self._scopes
14422 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14423 self
14424 }
14425
14426 /// Removes all scopes, and no default scope will be used either.
14427 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14428 /// for details).
14429 pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
14430 self._scopes.clear();
14431 self
14432 }
14433}
14434
14435/// Lists all instance operations that have been performed on the given Cloud
14436/// SQL instance in the reverse chronological order of the start time.
14437///
14438/// A builder for the *list* method supported by a *operation* resource.
14439/// It is not used directly, but through a [`OperationMethods`] instance.
14440///
14441/// # Example
14442///
14443/// Instantiate a resource method builder
14444///
14445/// ```test_harness,no_run
14446/// # extern crate hyper;
14447/// # extern crate hyper_rustls;
14448/// # extern crate google_sql1_beta4 as sql1_beta4;
14449/// # async fn dox() {
14450/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14451///
14452/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14453/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14454/// # secret,
14455/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14456/// # ).build().await.unwrap();
14457///
14458/// # let client = hyper_util::client::legacy::Client::builder(
14459/// # hyper_util::rt::TokioExecutor::new()
14460/// # )
14461/// # .build(
14462/// # hyper_rustls::HttpsConnectorBuilder::new()
14463/// # .with_native_roots()
14464/// # .unwrap()
14465/// # .https_or_http()
14466/// # .enable_http1()
14467/// # .build()
14468/// # );
14469/// # let mut hub = SQLAdmin::new(client, auth);
14470/// // You can configure optional parameters by calling the respective setters at will, and
14471/// // execute the final call using `doit()`.
14472/// // Values shown here are possibly random and not representative !
14473/// let result = hub.operations().list("project")
14474/// .page_token("et")
14475/// .max_results(78)
14476/// .instance("voluptua.")
14477/// .doit().await;
14478/// # }
14479/// ```
14480pub struct OperationListCall<'a, C>
14481where
14482 C: 'a,
14483{
14484 hub: &'a SQLAdmin<C>,
14485 _project: String,
14486 _page_token: Option<String>,
14487 _max_results: Option<u32>,
14488 _instance: Option<String>,
14489 _delegate: Option<&'a mut dyn common::Delegate>,
14490 _additional_params: HashMap<String, String>,
14491 _scopes: BTreeSet<String>,
14492}
14493
14494impl<'a, C> common::CallBuilder for OperationListCall<'a, C> {}
14495
14496impl<'a, C> OperationListCall<'a, C>
14497where
14498 C: common::Connector,
14499{
14500 /// Perform the operation you have build so far.
14501 pub async fn doit(mut self) -> common::Result<(common::Response, OperationsListResponse)> {
14502 use std::borrow::Cow;
14503 use std::io::{Read, Seek};
14504
14505 use common::{url::Params, ToParts};
14506 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14507
14508 let mut dd = common::DefaultDelegate;
14509 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14510 dlg.begin(common::MethodInfo {
14511 id: "sql.operations.list",
14512 http_method: hyper::Method::GET,
14513 });
14514
14515 for &field in ["alt", "project", "pageToken", "maxResults", "instance"].iter() {
14516 if self._additional_params.contains_key(field) {
14517 dlg.finished(false);
14518 return Err(common::Error::FieldClash(field));
14519 }
14520 }
14521
14522 let mut params = Params::with_capacity(6 + self._additional_params.len());
14523 params.push("project", self._project);
14524 if let Some(value) = self._page_token.as_ref() {
14525 params.push("pageToken", value);
14526 }
14527 if let Some(value) = self._max_results.as_ref() {
14528 params.push("maxResults", value.to_string());
14529 }
14530 if let Some(value) = self._instance.as_ref() {
14531 params.push("instance", value);
14532 }
14533
14534 params.extend(self._additional_params.iter());
14535
14536 params.push("alt", "json");
14537 let mut url = self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/operations";
14538 if self._scopes.is_empty() {
14539 self._scopes
14540 .insert(Scope::CloudPlatform.as_ref().to_string());
14541 }
14542
14543 #[allow(clippy::single_element_loop)]
14544 for &(find_this, param_name) in [("{project}", "project")].iter() {
14545 url = params.uri_replacement(url, param_name, find_this, false);
14546 }
14547 {
14548 let to_remove = ["project"];
14549 params.remove_params(&to_remove);
14550 }
14551
14552 let url = params.parse_with_url(&url);
14553
14554 loop {
14555 let token = match self
14556 .hub
14557 .auth
14558 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14559 .await
14560 {
14561 Ok(token) => token,
14562 Err(e) => match dlg.token(e) {
14563 Ok(token) => token,
14564 Err(e) => {
14565 dlg.finished(false);
14566 return Err(common::Error::MissingToken(e));
14567 }
14568 },
14569 };
14570 let mut req_result = {
14571 let client = &self.hub.client;
14572 dlg.pre_request();
14573 let mut req_builder = hyper::Request::builder()
14574 .method(hyper::Method::GET)
14575 .uri(url.as_str())
14576 .header(USER_AGENT, self.hub._user_agent.clone());
14577
14578 if let Some(token) = token.as_ref() {
14579 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14580 }
14581
14582 let request = req_builder
14583 .header(CONTENT_LENGTH, 0_u64)
14584 .body(common::to_body::<String>(None));
14585
14586 client.request(request.unwrap()).await
14587 };
14588
14589 match req_result {
14590 Err(err) => {
14591 if let common::Retry::After(d) = dlg.http_error(&err) {
14592 sleep(d).await;
14593 continue;
14594 }
14595 dlg.finished(false);
14596 return Err(common::Error::HttpError(err));
14597 }
14598 Ok(res) => {
14599 let (mut parts, body) = res.into_parts();
14600 let mut body = common::Body::new(body);
14601 if !parts.status.is_success() {
14602 let bytes = common::to_bytes(body).await.unwrap_or_default();
14603 let error = serde_json::from_str(&common::to_string(&bytes));
14604 let response = common::to_response(parts, bytes.into());
14605
14606 if let common::Retry::After(d) =
14607 dlg.http_failure(&response, error.as_ref().ok())
14608 {
14609 sleep(d).await;
14610 continue;
14611 }
14612
14613 dlg.finished(false);
14614
14615 return Err(match error {
14616 Ok(value) => common::Error::BadRequest(value),
14617 _ => common::Error::Failure(response),
14618 });
14619 }
14620 let response = {
14621 let bytes = common::to_bytes(body).await.unwrap_or_default();
14622 let encoded = common::to_string(&bytes);
14623 match serde_json::from_str(&encoded) {
14624 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14625 Err(error) => {
14626 dlg.response_json_decode_error(&encoded, &error);
14627 return Err(common::Error::JsonDecodeError(
14628 encoded.to_string(),
14629 error,
14630 ));
14631 }
14632 }
14633 };
14634
14635 dlg.finished(true);
14636 return Ok(response);
14637 }
14638 }
14639 }
14640 }
14641
14642 /// Project ID of the project that contains the instance.
14643 ///
14644 /// Sets the *project* path property to the given value.
14645 ///
14646 /// Even though the property as already been set when instantiating this call,
14647 /// we provide this method for API completeness.
14648 pub fn project(mut self, new_value: &str) -> OperationListCall<'a, C> {
14649 self._project = new_value.to_string();
14650 self
14651 }
14652 /// A previously-returned page token representing part of the larger set of
14653 /// results to view.
14654 ///
14655 /// Sets the *page token* query property to the given value.
14656 pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C> {
14657 self._page_token = Some(new_value.to_string());
14658 self
14659 }
14660 /// Maximum number of operations per response.
14661 ///
14662 /// Sets the *max results* query property to the given value.
14663 pub fn max_results(mut self, new_value: u32) -> OperationListCall<'a, C> {
14664 self._max_results = Some(new_value);
14665 self
14666 }
14667 /// Cloud SQL instance ID. This does not include the project ID.
14668 ///
14669 /// Sets the *instance* query property to the given value.
14670 pub fn instance(mut self, new_value: &str) -> OperationListCall<'a, C> {
14671 self._instance = Some(new_value.to_string());
14672 self
14673 }
14674 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14675 /// while executing the actual API request.
14676 ///
14677 /// ````text
14678 /// It should be used to handle progress information, and to implement a certain level of resilience.
14679 /// ````
14680 ///
14681 /// Sets the *delegate* property to the given value.
14682 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationListCall<'a, C> {
14683 self._delegate = Some(new_value);
14684 self
14685 }
14686
14687 /// Set any additional parameter of the query string used in the request.
14688 /// It should be used to set parameters which are not yet available through their own
14689 /// setters.
14690 ///
14691 /// Please note that this method must not be used to set any of the known parameters
14692 /// which have their own setter method. If done anyway, the request will fail.
14693 ///
14694 /// # Additional Parameters
14695 ///
14696 /// * *$.xgafv* (query-string) - V1 error format.
14697 /// * *access_token* (query-string) - OAuth access token.
14698 /// * *alt* (query-string) - Data format for response.
14699 /// * *callback* (query-string) - JSONP
14700 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14701 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14702 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14703 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14704 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14705 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14706 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14707 pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C>
14708 where
14709 T: AsRef<str>,
14710 {
14711 self._additional_params
14712 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14713 self
14714 }
14715
14716 /// Identifies the authorization scope for the method you are building.
14717 ///
14718 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14719 /// [`Scope::CloudPlatform`].
14720 ///
14721 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14722 /// tokens for more than one scope.
14723 ///
14724 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14725 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14726 /// sufficient, a read-write scope will do as well.
14727 pub fn add_scope<St>(mut self, scope: St) -> OperationListCall<'a, C>
14728 where
14729 St: AsRef<str>,
14730 {
14731 self._scopes.insert(String::from(scope.as_ref()));
14732 self
14733 }
14734 /// Identifies the authorization scope(s) for the method you are building.
14735 ///
14736 /// See [`Self::add_scope()`] for details.
14737 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationListCall<'a, C>
14738 where
14739 I: IntoIterator<Item = St>,
14740 St: AsRef<str>,
14741 {
14742 self._scopes
14743 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14744 self
14745 }
14746
14747 /// Removes all scopes, and no default scope will be used either.
14748 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14749 /// for details).
14750 pub fn clear_scopes(mut self) -> OperationListCall<'a, C> {
14751 self._scopes.clear();
14752 self
14753 }
14754}
14755
14756/// Reschedules the maintenance on the given instance.
14757///
14758/// A builder for the *instances.rescheduleMaintenance* method supported by a *project* resource.
14759/// It is not used directly, but through a [`ProjectMethods`] instance.
14760///
14761/// # Example
14762///
14763/// Instantiate a resource method builder
14764///
14765/// ```test_harness,no_run
14766/// # extern crate hyper;
14767/// # extern crate hyper_rustls;
14768/// # extern crate google_sql1_beta4 as sql1_beta4;
14769/// use sql1_beta4::api::SqlInstancesRescheduleMaintenanceRequestBody;
14770/// # async fn dox() {
14771/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14772///
14773/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14774/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14775/// # secret,
14776/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14777/// # ).build().await.unwrap();
14778///
14779/// # let client = hyper_util::client::legacy::Client::builder(
14780/// # hyper_util::rt::TokioExecutor::new()
14781/// # )
14782/// # .build(
14783/// # hyper_rustls::HttpsConnectorBuilder::new()
14784/// # .with_native_roots()
14785/// # .unwrap()
14786/// # .https_or_http()
14787/// # .enable_http1()
14788/// # .build()
14789/// # );
14790/// # let mut hub = SQLAdmin::new(client, auth);
14791/// // As the method needs a request, you would usually fill it with the desired information
14792/// // into the respective structure. Some of the parts shown here might not be applicable !
14793/// // Values shown here are possibly random and not representative !
14794/// let mut req = SqlInstancesRescheduleMaintenanceRequestBody::default();
14795///
14796/// // You can configure optional parameters by calling the respective setters at will, and
14797/// // execute the final call using `doit()`.
14798/// // Values shown here are possibly random and not representative !
14799/// let result = hub.projects().instances_reschedule_maintenance(req, "project", "instance")
14800/// .doit().await;
14801/// # }
14802/// ```
14803pub struct ProjectInstanceRescheduleMaintenanceCall<'a, C>
14804where
14805 C: 'a,
14806{
14807 hub: &'a SQLAdmin<C>,
14808 _request: SqlInstancesRescheduleMaintenanceRequestBody,
14809 _project: String,
14810 _instance: String,
14811 _delegate: Option<&'a mut dyn common::Delegate>,
14812 _additional_params: HashMap<String, String>,
14813 _scopes: BTreeSet<String>,
14814}
14815
14816impl<'a, C> common::CallBuilder for ProjectInstanceRescheduleMaintenanceCall<'a, C> {}
14817
14818impl<'a, C> ProjectInstanceRescheduleMaintenanceCall<'a, C>
14819where
14820 C: common::Connector,
14821{
14822 /// Perform the operation you have build so far.
14823 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14824 use std::borrow::Cow;
14825 use std::io::{Read, Seek};
14826
14827 use common::{url::Params, ToParts};
14828 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14829
14830 let mut dd = common::DefaultDelegate;
14831 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14832 dlg.begin(common::MethodInfo {
14833 id: "sql.projects.instances.rescheduleMaintenance",
14834 http_method: hyper::Method::POST,
14835 });
14836
14837 for &field in ["alt", "project", "instance"].iter() {
14838 if self._additional_params.contains_key(field) {
14839 dlg.finished(false);
14840 return Err(common::Error::FieldClash(field));
14841 }
14842 }
14843
14844 let mut params = Params::with_capacity(5 + self._additional_params.len());
14845 params.push("project", self._project);
14846 params.push("instance", self._instance);
14847
14848 params.extend(self._additional_params.iter());
14849
14850 params.push("alt", "json");
14851 let mut url = self.hub._base_url.clone()
14852 + "sql/v1beta4/projects/{project}/instances/{instance}/rescheduleMaintenance";
14853 if self._scopes.is_empty() {
14854 self._scopes
14855 .insert(Scope::CloudPlatform.as_ref().to_string());
14856 }
14857
14858 #[allow(clippy::single_element_loop)]
14859 for &(find_this, param_name) in
14860 [("{project}", "project"), ("{instance}", "instance")].iter()
14861 {
14862 url = params.uri_replacement(url, param_name, find_this, false);
14863 }
14864 {
14865 let to_remove = ["instance", "project"];
14866 params.remove_params(&to_remove);
14867 }
14868
14869 let url = params.parse_with_url(&url);
14870
14871 let mut json_mime_type = mime::APPLICATION_JSON;
14872 let mut request_value_reader = {
14873 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14874 common::remove_json_null_values(&mut value);
14875 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14876 serde_json::to_writer(&mut dst, &value).unwrap();
14877 dst
14878 };
14879 let request_size = request_value_reader
14880 .seek(std::io::SeekFrom::End(0))
14881 .unwrap();
14882 request_value_reader
14883 .seek(std::io::SeekFrom::Start(0))
14884 .unwrap();
14885
14886 loop {
14887 let token = match self
14888 .hub
14889 .auth
14890 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14891 .await
14892 {
14893 Ok(token) => token,
14894 Err(e) => match dlg.token(e) {
14895 Ok(token) => token,
14896 Err(e) => {
14897 dlg.finished(false);
14898 return Err(common::Error::MissingToken(e));
14899 }
14900 },
14901 };
14902 request_value_reader
14903 .seek(std::io::SeekFrom::Start(0))
14904 .unwrap();
14905 let mut req_result = {
14906 let client = &self.hub.client;
14907 dlg.pre_request();
14908 let mut req_builder = hyper::Request::builder()
14909 .method(hyper::Method::POST)
14910 .uri(url.as_str())
14911 .header(USER_AGENT, self.hub._user_agent.clone());
14912
14913 if let Some(token) = token.as_ref() {
14914 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14915 }
14916
14917 let request = req_builder
14918 .header(CONTENT_TYPE, json_mime_type.to_string())
14919 .header(CONTENT_LENGTH, request_size as u64)
14920 .body(common::to_body(
14921 request_value_reader.get_ref().clone().into(),
14922 ));
14923
14924 client.request(request.unwrap()).await
14925 };
14926
14927 match req_result {
14928 Err(err) => {
14929 if let common::Retry::After(d) = dlg.http_error(&err) {
14930 sleep(d).await;
14931 continue;
14932 }
14933 dlg.finished(false);
14934 return Err(common::Error::HttpError(err));
14935 }
14936 Ok(res) => {
14937 let (mut parts, body) = res.into_parts();
14938 let mut body = common::Body::new(body);
14939 if !parts.status.is_success() {
14940 let bytes = common::to_bytes(body).await.unwrap_or_default();
14941 let error = serde_json::from_str(&common::to_string(&bytes));
14942 let response = common::to_response(parts, bytes.into());
14943
14944 if let common::Retry::After(d) =
14945 dlg.http_failure(&response, error.as_ref().ok())
14946 {
14947 sleep(d).await;
14948 continue;
14949 }
14950
14951 dlg.finished(false);
14952
14953 return Err(match error {
14954 Ok(value) => common::Error::BadRequest(value),
14955 _ => common::Error::Failure(response),
14956 });
14957 }
14958 let response = {
14959 let bytes = common::to_bytes(body).await.unwrap_or_default();
14960 let encoded = common::to_string(&bytes);
14961 match serde_json::from_str(&encoded) {
14962 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14963 Err(error) => {
14964 dlg.response_json_decode_error(&encoded, &error);
14965 return Err(common::Error::JsonDecodeError(
14966 encoded.to_string(),
14967 error,
14968 ));
14969 }
14970 }
14971 };
14972
14973 dlg.finished(true);
14974 return Ok(response);
14975 }
14976 }
14977 }
14978 }
14979
14980 ///
14981 /// Sets the *request* property to the given value.
14982 ///
14983 /// Even though the property as already been set when instantiating this call,
14984 /// we provide this method for API completeness.
14985 pub fn request(
14986 mut self,
14987 new_value: SqlInstancesRescheduleMaintenanceRequestBody,
14988 ) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
14989 self._request = new_value;
14990 self
14991 }
14992 /// ID of the project that contains the instance.
14993 ///
14994 /// Sets the *project* path property to the given value.
14995 ///
14996 /// Even though the property as already been set when instantiating this call,
14997 /// we provide this method for API completeness.
14998 pub fn project(mut self, new_value: &str) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
14999 self._project = new_value.to_string();
15000 self
15001 }
15002 /// Cloud SQL instance ID. This does not include the project ID.
15003 ///
15004 /// Sets the *instance* path property to the given value.
15005 ///
15006 /// Even though the property as already been set when instantiating this call,
15007 /// we provide this method for API completeness.
15008 pub fn instance(mut self, new_value: &str) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
15009 self._instance = new_value.to_string();
15010 self
15011 }
15012 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15013 /// while executing the actual API request.
15014 ///
15015 /// ````text
15016 /// It should be used to handle progress information, and to implement a certain level of resilience.
15017 /// ````
15018 ///
15019 /// Sets the *delegate* property to the given value.
15020 pub fn delegate(
15021 mut self,
15022 new_value: &'a mut dyn common::Delegate,
15023 ) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
15024 self._delegate = Some(new_value);
15025 self
15026 }
15027
15028 /// Set any additional parameter of the query string used in the request.
15029 /// It should be used to set parameters which are not yet available through their own
15030 /// setters.
15031 ///
15032 /// Please note that this method must not be used to set any of the known parameters
15033 /// which have their own setter method. If done anyway, the request will fail.
15034 ///
15035 /// # Additional Parameters
15036 ///
15037 /// * *$.xgafv* (query-string) - V1 error format.
15038 /// * *access_token* (query-string) - OAuth access token.
15039 /// * *alt* (query-string) - Data format for response.
15040 /// * *callback* (query-string) - JSONP
15041 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15042 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15043 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15044 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15045 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15046 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15047 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15048 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceRescheduleMaintenanceCall<'a, C>
15049 where
15050 T: AsRef<str>,
15051 {
15052 self._additional_params
15053 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15054 self
15055 }
15056
15057 /// Identifies the authorization scope for the method you are building.
15058 ///
15059 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15060 /// [`Scope::CloudPlatform`].
15061 ///
15062 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15063 /// tokens for more than one scope.
15064 ///
15065 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15066 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15067 /// sufficient, a read-write scope will do as well.
15068 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceRescheduleMaintenanceCall<'a, C>
15069 where
15070 St: AsRef<str>,
15071 {
15072 self._scopes.insert(String::from(scope.as_ref()));
15073 self
15074 }
15075 /// Identifies the authorization scope(s) for the method you are building.
15076 ///
15077 /// See [`Self::add_scope()`] for details.
15078 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceRescheduleMaintenanceCall<'a, C>
15079 where
15080 I: IntoIterator<Item = St>,
15081 St: AsRef<str>,
15082 {
15083 self._scopes
15084 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15085 self
15086 }
15087
15088 /// Removes all scopes, and no default scope will be used either.
15089 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15090 /// for details).
15091 pub fn clear_scopes(mut self) -> ProjectInstanceRescheduleMaintenanceCall<'a, C> {
15092 self._scopes.clear();
15093 self
15094 }
15095}
15096
15097/// Start External master migration.
15098///
15099/// A builder for the *instances.startExternalSync* method supported by a *project* resource.
15100/// It is not used directly, but through a [`ProjectMethods`] instance.
15101///
15102/// # Example
15103///
15104/// Instantiate a resource method builder
15105///
15106/// ```test_harness,no_run
15107/// # extern crate hyper;
15108/// # extern crate hyper_rustls;
15109/// # extern crate google_sql1_beta4 as sql1_beta4;
15110/// # async fn dox() {
15111/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15112///
15113/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15114/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15115/// # secret,
15116/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15117/// # ).build().await.unwrap();
15118///
15119/// # let client = hyper_util::client::legacy::Client::builder(
15120/// # hyper_util::rt::TokioExecutor::new()
15121/// # )
15122/// # .build(
15123/// # hyper_rustls::HttpsConnectorBuilder::new()
15124/// # .with_native_roots()
15125/// # .unwrap()
15126/// # .https_or_http()
15127/// # .enable_http1()
15128/// # .build()
15129/// # );
15130/// # let mut hub = SQLAdmin::new(client, auth);
15131/// // You can configure optional parameters by calling the respective setters at will, and
15132/// // execute the final call using `doit()`.
15133/// // Values shown here are possibly random and not representative !
15134/// let result = hub.projects().instances_start_external_sync("project", "instance")
15135/// .sync_mode("amet.")
15136/// .doit().await;
15137/// # }
15138/// ```
15139pub struct ProjectInstanceStartExternalSyncCall<'a, C>
15140where
15141 C: 'a,
15142{
15143 hub: &'a SQLAdmin<C>,
15144 _project: String,
15145 _instance: String,
15146 _sync_mode: Option<String>,
15147 _delegate: Option<&'a mut dyn common::Delegate>,
15148 _additional_params: HashMap<String, String>,
15149 _scopes: BTreeSet<String>,
15150}
15151
15152impl<'a, C> common::CallBuilder for ProjectInstanceStartExternalSyncCall<'a, C> {}
15153
15154impl<'a, C> ProjectInstanceStartExternalSyncCall<'a, C>
15155where
15156 C: common::Connector,
15157{
15158 /// Perform the operation you have build so far.
15159 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15160 use std::borrow::Cow;
15161 use std::io::{Read, Seek};
15162
15163 use common::{url::Params, ToParts};
15164 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15165
15166 let mut dd = common::DefaultDelegate;
15167 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15168 dlg.begin(common::MethodInfo {
15169 id: "sql.projects.instances.startExternalSync",
15170 http_method: hyper::Method::POST,
15171 });
15172
15173 for &field in ["alt", "project", "instance", "syncMode"].iter() {
15174 if self._additional_params.contains_key(field) {
15175 dlg.finished(false);
15176 return Err(common::Error::FieldClash(field));
15177 }
15178 }
15179
15180 let mut params = Params::with_capacity(5 + self._additional_params.len());
15181 params.push("project", self._project);
15182 params.push("instance", self._instance);
15183 if let Some(value) = self._sync_mode.as_ref() {
15184 params.push("syncMode", value);
15185 }
15186
15187 params.extend(self._additional_params.iter());
15188
15189 params.push("alt", "json");
15190 let mut url = self.hub._base_url.clone()
15191 + "sql/v1beta4/projects/{project}/instances/{instance}/startExternalSync";
15192 if self._scopes.is_empty() {
15193 self._scopes
15194 .insert(Scope::CloudPlatform.as_ref().to_string());
15195 }
15196
15197 #[allow(clippy::single_element_loop)]
15198 for &(find_this, param_name) in
15199 [("{project}", "project"), ("{instance}", "instance")].iter()
15200 {
15201 url = params.uri_replacement(url, param_name, find_this, false);
15202 }
15203 {
15204 let to_remove = ["instance", "project"];
15205 params.remove_params(&to_remove);
15206 }
15207
15208 let url = params.parse_with_url(&url);
15209
15210 loop {
15211 let token = match self
15212 .hub
15213 .auth
15214 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15215 .await
15216 {
15217 Ok(token) => token,
15218 Err(e) => match dlg.token(e) {
15219 Ok(token) => token,
15220 Err(e) => {
15221 dlg.finished(false);
15222 return Err(common::Error::MissingToken(e));
15223 }
15224 },
15225 };
15226 let mut req_result = {
15227 let client = &self.hub.client;
15228 dlg.pre_request();
15229 let mut req_builder = hyper::Request::builder()
15230 .method(hyper::Method::POST)
15231 .uri(url.as_str())
15232 .header(USER_AGENT, self.hub._user_agent.clone());
15233
15234 if let Some(token) = token.as_ref() {
15235 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15236 }
15237
15238 let request = req_builder
15239 .header(CONTENT_LENGTH, 0_u64)
15240 .body(common::to_body::<String>(None));
15241
15242 client.request(request.unwrap()).await
15243 };
15244
15245 match req_result {
15246 Err(err) => {
15247 if let common::Retry::After(d) = dlg.http_error(&err) {
15248 sleep(d).await;
15249 continue;
15250 }
15251 dlg.finished(false);
15252 return Err(common::Error::HttpError(err));
15253 }
15254 Ok(res) => {
15255 let (mut parts, body) = res.into_parts();
15256 let mut body = common::Body::new(body);
15257 if !parts.status.is_success() {
15258 let bytes = common::to_bytes(body).await.unwrap_or_default();
15259 let error = serde_json::from_str(&common::to_string(&bytes));
15260 let response = common::to_response(parts, bytes.into());
15261
15262 if let common::Retry::After(d) =
15263 dlg.http_failure(&response, error.as_ref().ok())
15264 {
15265 sleep(d).await;
15266 continue;
15267 }
15268
15269 dlg.finished(false);
15270
15271 return Err(match error {
15272 Ok(value) => common::Error::BadRequest(value),
15273 _ => common::Error::Failure(response),
15274 });
15275 }
15276 let response = {
15277 let bytes = common::to_bytes(body).await.unwrap_or_default();
15278 let encoded = common::to_string(&bytes);
15279 match serde_json::from_str(&encoded) {
15280 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15281 Err(error) => {
15282 dlg.response_json_decode_error(&encoded, &error);
15283 return Err(common::Error::JsonDecodeError(
15284 encoded.to_string(),
15285 error,
15286 ));
15287 }
15288 }
15289 };
15290
15291 dlg.finished(true);
15292 return Ok(response);
15293 }
15294 }
15295 }
15296 }
15297
15298 /// ID of the project that contains the first generation instance.
15299 ///
15300 /// Sets the *project* path property to the given value.
15301 ///
15302 /// Even though the property as already been set when instantiating this call,
15303 /// we provide this method for API completeness.
15304 pub fn project(mut self, new_value: &str) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15305 self._project = new_value.to_string();
15306 self
15307 }
15308 /// Cloud SQL instance ID. This does not include the project ID.
15309 ///
15310 /// Sets the *instance* path property to the given value.
15311 ///
15312 /// Even though the property as already been set when instantiating this call,
15313 /// we provide this method for API completeness.
15314 pub fn instance(mut self, new_value: &str) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15315 self._instance = new_value.to_string();
15316 self
15317 }
15318 /// External sync mode
15319 ///
15320 /// Sets the *sync mode* query property to the given value.
15321 pub fn sync_mode(mut self, new_value: &str) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15322 self._sync_mode = Some(new_value.to_string());
15323 self
15324 }
15325 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15326 /// while executing the actual API request.
15327 ///
15328 /// ````text
15329 /// It should be used to handle progress information, and to implement a certain level of resilience.
15330 /// ````
15331 ///
15332 /// Sets the *delegate* property to the given value.
15333 pub fn delegate(
15334 mut self,
15335 new_value: &'a mut dyn common::Delegate,
15336 ) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15337 self._delegate = Some(new_value);
15338 self
15339 }
15340
15341 /// Set any additional parameter of the query string used in the request.
15342 /// It should be used to set parameters which are not yet available through their own
15343 /// setters.
15344 ///
15345 /// Please note that this method must not be used to set any of the known parameters
15346 /// which have their own setter method. If done anyway, the request will fail.
15347 ///
15348 /// # Additional Parameters
15349 ///
15350 /// * *$.xgafv* (query-string) - V1 error format.
15351 /// * *access_token* (query-string) - OAuth access token.
15352 /// * *alt* (query-string) - Data format for response.
15353 /// * *callback* (query-string) - JSONP
15354 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15355 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15356 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15357 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15358 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15359 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15360 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15361 pub fn param<T>(mut self, name: T, value: T) -> ProjectInstanceStartExternalSyncCall<'a, C>
15362 where
15363 T: AsRef<str>,
15364 {
15365 self._additional_params
15366 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15367 self
15368 }
15369
15370 /// Identifies the authorization scope for the method you are building.
15371 ///
15372 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15373 /// [`Scope::CloudPlatform`].
15374 ///
15375 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15376 /// tokens for more than one scope.
15377 ///
15378 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15379 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15380 /// sufficient, a read-write scope will do as well.
15381 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceStartExternalSyncCall<'a, C>
15382 where
15383 St: AsRef<str>,
15384 {
15385 self._scopes.insert(String::from(scope.as_ref()));
15386 self
15387 }
15388 /// Identifies the authorization scope(s) for the method you are building.
15389 ///
15390 /// See [`Self::add_scope()`] for details.
15391 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectInstanceStartExternalSyncCall<'a, C>
15392 where
15393 I: IntoIterator<Item = St>,
15394 St: AsRef<str>,
15395 {
15396 self._scopes
15397 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15398 self
15399 }
15400
15401 /// Removes all scopes, and no default scope will be used either.
15402 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15403 /// for details).
15404 pub fn clear_scopes(mut self) -> ProjectInstanceStartExternalSyncCall<'a, C> {
15405 self._scopes.clear();
15406 self
15407 }
15408}
15409
15410/// Verify External master external sync settings.
15411///
15412/// A builder for the *instances.verifyExternalSyncSettings* method supported by a *project* resource.
15413/// It is not used directly, but through a [`ProjectMethods`] instance.
15414///
15415/// # Example
15416///
15417/// Instantiate a resource method builder
15418///
15419/// ```test_harness,no_run
15420/// # extern crate hyper;
15421/// # extern crate hyper_rustls;
15422/// # extern crate google_sql1_beta4 as sql1_beta4;
15423/// # async fn dox() {
15424/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15425///
15426/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15427/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15428/// # secret,
15429/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15430/// # ).build().await.unwrap();
15431///
15432/// # let client = hyper_util::client::legacy::Client::builder(
15433/// # hyper_util::rt::TokioExecutor::new()
15434/// # )
15435/// # .build(
15436/// # hyper_rustls::HttpsConnectorBuilder::new()
15437/// # .with_native_roots()
15438/// # .unwrap()
15439/// # .https_or_http()
15440/// # .enable_http1()
15441/// # .build()
15442/// # );
15443/// # let mut hub = SQLAdmin::new(client, auth);
15444/// // You can configure optional parameters by calling the respective setters at will, and
15445/// // execute the final call using `doit()`.
15446/// // Values shown here are possibly random and not representative !
15447/// let result = hub.projects().instances_verify_external_sync_settings("project", "instance")
15448/// .verify_connection_only(true)
15449/// .sync_mode("no")
15450/// .doit().await;
15451/// # }
15452/// ```
15453pub struct ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
15454where
15455 C: 'a,
15456{
15457 hub: &'a SQLAdmin<C>,
15458 _project: String,
15459 _instance: String,
15460 _verify_connection_only: Option<bool>,
15461 _sync_mode: Option<String>,
15462 _delegate: Option<&'a mut dyn common::Delegate>,
15463 _additional_params: HashMap<String, String>,
15464 _scopes: BTreeSet<String>,
15465}
15466
15467impl<'a, C> common::CallBuilder for ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {}
15468
15469impl<'a, C> ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
15470where
15471 C: common::Connector,
15472{
15473 /// Perform the operation you have build so far.
15474 pub async fn doit(
15475 mut self,
15476 ) -> common::Result<(
15477 common::Response,
15478 SqlInstancesVerifyExternalSyncSettingsResponse,
15479 )> {
15480 use std::borrow::Cow;
15481 use std::io::{Read, Seek};
15482
15483 use common::{url::Params, ToParts};
15484 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15485
15486 let mut dd = common::DefaultDelegate;
15487 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15488 dlg.begin(common::MethodInfo {
15489 id: "sql.projects.instances.verifyExternalSyncSettings",
15490 http_method: hyper::Method::POST,
15491 });
15492
15493 for &field in [
15494 "alt",
15495 "project",
15496 "instance",
15497 "verifyConnectionOnly",
15498 "syncMode",
15499 ]
15500 .iter()
15501 {
15502 if self._additional_params.contains_key(field) {
15503 dlg.finished(false);
15504 return Err(common::Error::FieldClash(field));
15505 }
15506 }
15507
15508 let mut params = Params::with_capacity(6 + self._additional_params.len());
15509 params.push("project", self._project);
15510 params.push("instance", self._instance);
15511 if let Some(value) = self._verify_connection_only.as_ref() {
15512 params.push("verifyConnectionOnly", value.to_string());
15513 }
15514 if let Some(value) = self._sync_mode.as_ref() {
15515 params.push("syncMode", value);
15516 }
15517
15518 params.extend(self._additional_params.iter());
15519
15520 params.push("alt", "json");
15521 let mut url = self.hub._base_url.clone()
15522 + "sql/v1beta4/projects/{project}/instances/{instance}/verifyExternalSyncSettings";
15523 if self._scopes.is_empty() {
15524 self._scopes
15525 .insert(Scope::CloudPlatform.as_ref().to_string());
15526 }
15527
15528 #[allow(clippy::single_element_loop)]
15529 for &(find_this, param_name) in
15530 [("{project}", "project"), ("{instance}", "instance")].iter()
15531 {
15532 url = params.uri_replacement(url, param_name, find_this, false);
15533 }
15534 {
15535 let to_remove = ["instance", "project"];
15536 params.remove_params(&to_remove);
15537 }
15538
15539 let url = params.parse_with_url(&url);
15540
15541 loop {
15542 let token = match self
15543 .hub
15544 .auth
15545 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15546 .await
15547 {
15548 Ok(token) => token,
15549 Err(e) => match dlg.token(e) {
15550 Ok(token) => token,
15551 Err(e) => {
15552 dlg.finished(false);
15553 return Err(common::Error::MissingToken(e));
15554 }
15555 },
15556 };
15557 let mut req_result = {
15558 let client = &self.hub.client;
15559 dlg.pre_request();
15560 let mut req_builder = hyper::Request::builder()
15561 .method(hyper::Method::POST)
15562 .uri(url.as_str())
15563 .header(USER_AGENT, self.hub._user_agent.clone());
15564
15565 if let Some(token) = token.as_ref() {
15566 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15567 }
15568
15569 let request = req_builder
15570 .header(CONTENT_LENGTH, 0_u64)
15571 .body(common::to_body::<String>(None));
15572
15573 client.request(request.unwrap()).await
15574 };
15575
15576 match req_result {
15577 Err(err) => {
15578 if let common::Retry::After(d) = dlg.http_error(&err) {
15579 sleep(d).await;
15580 continue;
15581 }
15582 dlg.finished(false);
15583 return Err(common::Error::HttpError(err));
15584 }
15585 Ok(res) => {
15586 let (mut parts, body) = res.into_parts();
15587 let mut body = common::Body::new(body);
15588 if !parts.status.is_success() {
15589 let bytes = common::to_bytes(body).await.unwrap_or_default();
15590 let error = serde_json::from_str(&common::to_string(&bytes));
15591 let response = common::to_response(parts, bytes.into());
15592
15593 if let common::Retry::After(d) =
15594 dlg.http_failure(&response, error.as_ref().ok())
15595 {
15596 sleep(d).await;
15597 continue;
15598 }
15599
15600 dlg.finished(false);
15601
15602 return Err(match error {
15603 Ok(value) => common::Error::BadRequest(value),
15604 _ => common::Error::Failure(response),
15605 });
15606 }
15607 let response = {
15608 let bytes = common::to_bytes(body).await.unwrap_or_default();
15609 let encoded = common::to_string(&bytes);
15610 match serde_json::from_str(&encoded) {
15611 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15612 Err(error) => {
15613 dlg.response_json_decode_error(&encoded, &error);
15614 return Err(common::Error::JsonDecodeError(
15615 encoded.to_string(),
15616 error,
15617 ));
15618 }
15619 }
15620 };
15621
15622 dlg.finished(true);
15623 return Ok(response);
15624 }
15625 }
15626 }
15627 }
15628
15629 /// Project ID of the project that contains the instance.
15630 ///
15631 /// Sets the *project* path property to the given value.
15632 ///
15633 /// Even though the property as already been set when instantiating this call,
15634 /// we provide this method for API completeness.
15635 pub fn project(
15636 mut self,
15637 new_value: &str,
15638 ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
15639 self._project = new_value.to_string();
15640 self
15641 }
15642 /// Cloud SQL instance ID. This does not include the project ID.
15643 ///
15644 /// Sets the *instance* path property to the given value.
15645 ///
15646 /// Even though the property as already been set when instantiating this call,
15647 /// we provide this method for API completeness.
15648 pub fn instance(
15649 mut self,
15650 new_value: &str,
15651 ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
15652 self._instance = new_value.to_string();
15653 self
15654 }
15655 /// Flag to enable verifying connection only
15656 ///
15657 /// Sets the *verify connection only* query property to the given value.
15658 pub fn verify_connection_only(
15659 mut self,
15660 new_value: bool,
15661 ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
15662 self._verify_connection_only = Some(new_value);
15663 self
15664 }
15665 /// External sync mode
15666 ///
15667 /// Sets the *sync mode* query property to the given value.
15668 pub fn sync_mode(
15669 mut self,
15670 new_value: &str,
15671 ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
15672 self._sync_mode = Some(new_value.to_string());
15673 self
15674 }
15675 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15676 /// while executing the actual API request.
15677 ///
15678 /// ````text
15679 /// It should be used to handle progress information, and to implement a certain level of resilience.
15680 /// ````
15681 ///
15682 /// Sets the *delegate* property to the given value.
15683 pub fn delegate(
15684 mut self,
15685 new_value: &'a mut dyn common::Delegate,
15686 ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
15687 self._delegate = Some(new_value);
15688 self
15689 }
15690
15691 /// Set any additional parameter of the query string used in the request.
15692 /// It should be used to set parameters which are not yet available through their own
15693 /// setters.
15694 ///
15695 /// Please note that this method must not be used to set any of the known parameters
15696 /// which have their own setter method. If done anyway, the request will fail.
15697 ///
15698 /// # Additional Parameters
15699 ///
15700 /// * *$.xgafv* (query-string) - V1 error format.
15701 /// * *access_token* (query-string) - OAuth access token.
15702 /// * *alt* (query-string) - Data format for response.
15703 /// * *callback* (query-string) - JSONP
15704 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15705 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15706 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15707 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15708 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15709 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15710 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15711 pub fn param<T>(
15712 mut self,
15713 name: T,
15714 value: T,
15715 ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
15716 where
15717 T: AsRef<str>,
15718 {
15719 self._additional_params
15720 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15721 self
15722 }
15723
15724 /// Identifies the authorization scope for the method you are building.
15725 ///
15726 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15727 /// [`Scope::CloudPlatform`].
15728 ///
15729 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15730 /// tokens for more than one scope.
15731 ///
15732 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15733 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15734 /// sufficient, a read-write scope will do as well.
15735 pub fn add_scope<St>(mut self, scope: St) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
15736 where
15737 St: AsRef<str>,
15738 {
15739 self._scopes.insert(String::from(scope.as_ref()));
15740 self
15741 }
15742 /// Identifies the authorization scope(s) for the method you are building.
15743 ///
15744 /// See [`Self::add_scope()`] for details.
15745 pub fn add_scopes<I, St>(
15746 mut self,
15747 scopes: I,
15748 ) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C>
15749 where
15750 I: IntoIterator<Item = St>,
15751 St: AsRef<str>,
15752 {
15753 self._scopes
15754 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15755 self
15756 }
15757
15758 /// Removes all scopes, and no default scope will be used either.
15759 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15760 /// for details).
15761 pub fn clear_scopes(mut self) -> ProjectInstanceVerifyExternalSyncSettingCall<'a, C> {
15762 self._scopes.clear();
15763 self
15764 }
15765}
15766
15767/// Generates a short-lived X509 certificate containing the provided public key
15768/// and signed by a private key specific to the target instance. Users may use
15769/// the certificate to authenticate as themselves when connecting to the
15770/// database.
15771///
15772/// A builder for the *createEphemeral* method supported by a *sslCert* resource.
15773/// It is not used directly, but through a [`SslCertMethods`] instance.
15774///
15775/// # Example
15776///
15777/// Instantiate a resource method builder
15778///
15779/// ```test_harness,no_run
15780/// # extern crate hyper;
15781/// # extern crate hyper_rustls;
15782/// # extern crate google_sql1_beta4 as sql1_beta4;
15783/// use sql1_beta4::api::SslCertsCreateEphemeralRequest;
15784/// # async fn dox() {
15785/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15786///
15787/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15788/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15789/// # secret,
15790/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15791/// # ).build().await.unwrap();
15792///
15793/// # let client = hyper_util::client::legacy::Client::builder(
15794/// # hyper_util::rt::TokioExecutor::new()
15795/// # )
15796/// # .build(
15797/// # hyper_rustls::HttpsConnectorBuilder::new()
15798/// # .with_native_roots()
15799/// # .unwrap()
15800/// # .https_or_http()
15801/// # .enable_http1()
15802/// # .build()
15803/// # );
15804/// # let mut hub = SQLAdmin::new(client, auth);
15805/// // As the method needs a request, you would usually fill it with the desired information
15806/// // into the respective structure. Some of the parts shown here might not be applicable !
15807/// // Values shown here are possibly random and not representative !
15808/// let mut req = SslCertsCreateEphemeralRequest::default();
15809///
15810/// // You can configure optional parameters by calling the respective setters at will, and
15811/// // execute the final call using `doit()`.
15812/// // Values shown here are possibly random and not representative !
15813/// let result = hub.ssl_certs().create_ephemeral(req, "project", "instance")
15814/// .doit().await;
15815/// # }
15816/// ```
15817pub struct SslCertCreateEphemeralCall<'a, C>
15818where
15819 C: 'a,
15820{
15821 hub: &'a SQLAdmin<C>,
15822 _request: SslCertsCreateEphemeralRequest,
15823 _project: String,
15824 _instance: String,
15825 _delegate: Option<&'a mut dyn common::Delegate>,
15826 _additional_params: HashMap<String, String>,
15827 _scopes: BTreeSet<String>,
15828}
15829
15830impl<'a, C> common::CallBuilder for SslCertCreateEphemeralCall<'a, C> {}
15831
15832impl<'a, C> SslCertCreateEphemeralCall<'a, C>
15833where
15834 C: common::Connector,
15835{
15836 /// Perform the operation you have build so far.
15837 pub async fn doit(mut self) -> common::Result<(common::Response, SslCert)> {
15838 use std::borrow::Cow;
15839 use std::io::{Read, Seek};
15840
15841 use common::{url::Params, ToParts};
15842 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15843
15844 let mut dd = common::DefaultDelegate;
15845 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15846 dlg.begin(common::MethodInfo {
15847 id: "sql.sslCerts.createEphemeral",
15848 http_method: hyper::Method::POST,
15849 });
15850
15851 for &field in ["alt", "project", "instance"].iter() {
15852 if self._additional_params.contains_key(field) {
15853 dlg.finished(false);
15854 return Err(common::Error::FieldClash(field));
15855 }
15856 }
15857
15858 let mut params = Params::with_capacity(5 + self._additional_params.len());
15859 params.push("project", self._project);
15860 params.push("instance", self._instance);
15861
15862 params.extend(self._additional_params.iter());
15863
15864 params.push("alt", "json");
15865 let mut url = self.hub._base_url.clone()
15866 + "sql/v1beta4/projects/{project}/instances/{instance}/createEphemeral";
15867 if self._scopes.is_empty() {
15868 self._scopes
15869 .insert(Scope::CloudPlatform.as_ref().to_string());
15870 }
15871
15872 #[allow(clippy::single_element_loop)]
15873 for &(find_this, param_name) in
15874 [("{project}", "project"), ("{instance}", "instance")].iter()
15875 {
15876 url = params.uri_replacement(url, param_name, find_this, false);
15877 }
15878 {
15879 let to_remove = ["instance", "project"];
15880 params.remove_params(&to_remove);
15881 }
15882
15883 let url = params.parse_with_url(&url);
15884
15885 let mut json_mime_type = mime::APPLICATION_JSON;
15886 let mut request_value_reader = {
15887 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15888 common::remove_json_null_values(&mut value);
15889 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15890 serde_json::to_writer(&mut dst, &value).unwrap();
15891 dst
15892 };
15893 let request_size = request_value_reader
15894 .seek(std::io::SeekFrom::End(0))
15895 .unwrap();
15896 request_value_reader
15897 .seek(std::io::SeekFrom::Start(0))
15898 .unwrap();
15899
15900 loop {
15901 let token = match self
15902 .hub
15903 .auth
15904 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15905 .await
15906 {
15907 Ok(token) => token,
15908 Err(e) => match dlg.token(e) {
15909 Ok(token) => token,
15910 Err(e) => {
15911 dlg.finished(false);
15912 return Err(common::Error::MissingToken(e));
15913 }
15914 },
15915 };
15916 request_value_reader
15917 .seek(std::io::SeekFrom::Start(0))
15918 .unwrap();
15919 let mut req_result = {
15920 let client = &self.hub.client;
15921 dlg.pre_request();
15922 let mut req_builder = hyper::Request::builder()
15923 .method(hyper::Method::POST)
15924 .uri(url.as_str())
15925 .header(USER_AGENT, self.hub._user_agent.clone());
15926
15927 if let Some(token) = token.as_ref() {
15928 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15929 }
15930
15931 let request = req_builder
15932 .header(CONTENT_TYPE, json_mime_type.to_string())
15933 .header(CONTENT_LENGTH, request_size as u64)
15934 .body(common::to_body(
15935 request_value_reader.get_ref().clone().into(),
15936 ));
15937
15938 client.request(request.unwrap()).await
15939 };
15940
15941 match req_result {
15942 Err(err) => {
15943 if let common::Retry::After(d) = dlg.http_error(&err) {
15944 sleep(d).await;
15945 continue;
15946 }
15947 dlg.finished(false);
15948 return Err(common::Error::HttpError(err));
15949 }
15950 Ok(res) => {
15951 let (mut parts, body) = res.into_parts();
15952 let mut body = common::Body::new(body);
15953 if !parts.status.is_success() {
15954 let bytes = common::to_bytes(body).await.unwrap_or_default();
15955 let error = serde_json::from_str(&common::to_string(&bytes));
15956 let response = common::to_response(parts, bytes.into());
15957
15958 if let common::Retry::After(d) =
15959 dlg.http_failure(&response, error.as_ref().ok())
15960 {
15961 sleep(d).await;
15962 continue;
15963 }
15964
15965 dlg.finished(false);
15966
15967 return Err(match error {
15968 Ok(value) => common::Error::BadRequest(value),
15969 _ => common::Error::Failure(response),
15970 });
15971 }
15972 let response = {
15973 let bytes = common::to_bytes(body).await.unwrap_or_default();
15974 let encoded = common::to_string(&bytes);
15975 match serde_json::from_str(&encoded) {
15976 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15977 Err(error) => {
15978 dlg.response_json_decode_error(&encoded, &error);
15979 return Err(common::Error::JsonDecodeError(
15980 encoded.to_string(),
15981 error,
15982 ));
15983 }
15984 }
15985 };
15986
15987 dlg.finished(true);
15988 return Ok(response);
15989 }
15990 }
15991 }
15992 }
15993
15994 ///
15995 /// Sets the *request* property to the given value.
15996 ///
15997 /// Even though the property as already been set when instantiating this call,
15998 /// we provide this method for API completeness.
15999 pub fn request(
16000 mut self,
16001 new_value: SslCertsCreateEphemeralRequest,
16002 ) -> SslCertCreateEphemeralCall<'a, C> {
16003 self._request = new_value;
16004 self
16005 }
16006 /// Project ID of the Cloud SQL project.
16007 ///
16008 /// Sets the *project* path property to the given value.
16009 ///
16010 /// Even though the property as already been set when instantiating this call,
16011 /// we provide this method for API completeness.
16012 pub fn project(mut self, new_value: &str) -> SslCertCreateEphemeralCall<'a, C> {
16013 self._project = new_value.to_string();
16014 self
16015 }
16016 /// Cloud SQL instance ID. This does not include the project ID.
16017 ///
16018 /// Sets the *instance* path property to the given value.
16019 ///
16020 /// Even though the property as already been set when instantiating this call,
16021 /// we provide this method for API completeness.
16022 pub fn instance(mut self, new_value: &str) -> SslCertCreateEphemeralCall<'a, C> {
16023 self._instance = new_value.to_string();
16024 self
16025 }
16026 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16027 /// while executing the actual API request.
16028 ///
16029 /// ````text
16030 /// It should be used to handle progress information, and to implement a certain level of resilience.
16031 /// ````
16032 ///
16033 /// Sets the *delegate* property to the given value.
16034 pub fn delegate(
16035 mut self,
16036 new_value: &'a mut dyn common::Delegate,
16037 ) -> SslCertCreateEphemeralCall<'a, C> {
16038 self._delegate = Some(new_value);
16039 self
16040 }
16041
16042 /// Set any additional parameter of the query string used in the request.
16043 /// It should be used to set parameters which are not yet available through their own
16044 /// setters.
16045 ///
16046 /// Please note that this method must not be used to set any of the known parameters
16047 /// which have their own setter method. If done anyway, the request will fail.
16048 ///
16049 /// # Additional Parameters
16050 ///
16051 /// * *$.xgafv* (query-string) - V1 error format.
16052 /// * *access_token* (query-string) - OAuth access token.
16053 /// * *alt* (query-string) - Data format for response.
16054 /// * *callback* (query-string) - JSONP
16055 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16056 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16057 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16058 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16059 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16060 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16061 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16062 pub fn param<T>(mut self, name: T, value: T) -> SslCertCreateEphemeralCall<'a, C>
16063 where
16064 T: AsRef<str>,
16065 {
16066 self._additional_params
16067 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16068 self
16069 }
16070
16071 /// Identifies the authorization scope for the method you are building.
16072 ///
16073 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16074 /// [`Scope::CloudPlatform`].
16075 ///
16076 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16077 /// tokens for more than one scope.
16078 ///
16079 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16080 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16081 /// sufficient, a read-write scope will do as well.
16082 pub fn add_scope<St>(mut self, scope: St) -> SslCertCreateEphemeralCall<'a, C>
16083 where
16084 St: AsRef<str>,
16085 {
16086 self._scopes.insert(String::from(scope.as_ref()));
16087 self
16088 }
16089 /// Identifies the authorization scope(s) for the method you are building.
16090 ///
16091 /// See [`Self::add_scope()`] for details.
16092 pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertCreateEphemeralCall<'a, C>
16093 where
16094 I: IntoIterator<Item = St>,
16095 St: AsRef<str>,
16096 {
16097 self._scopes
16098 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16099 self
16100 }
16101
16102 /// Removes all scopes, and no default scope will be used either.
16103 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16104 /// for details).
16105 pub fn clear_scopes(mut self) -> SslCertCreateEphemeralCall<'a, C> {
16106 self._scopes.clear();
16107 self
16108 }
16109}
16110
16111/// Deletes the SSL certificate. For First Generation instances, the
16112/// certificate remains valid until the instance is restarted.
16113///
16114/// A builder for the *delete* method supported by a *sslCert* resource.
16115/// It is not used directly, but through a [`SslCertMethods`] instance.
16116///
16117/// # Example
16118///
16119/// Instantiate a resource method builder
16120///
16121/// ```test_harness,no_run
16122/// # extern crate hyper;
16123/// # extern crate hyper_rustls;
16124/// # extern crate google_sql1_beta4 as sql1_beta4;
16125/// # async fn dox() {
16126/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16127///
16128/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16129/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16130/// # secret,
16131/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16132/// # ).build().await.unwrap();
16133///
16134/// # let client = hyper_util::client::legacy::Client::builder(
16135/// # hyper_util::rt::TokioExecutor::new()
16136/// # )
16137/// # .build(
16138/// # hyper_rustls::HttpsConnectorBuilder::new()
16139/// # .with_native_roots()
16140/// # .unwrap()
16141/// # .https_or_http()
16142/// # .enable_http1()
16143/// # .build()
16144/// # );
16145/// # let mut hub = SQLAdmin::new(client, auth);
16146/// // You can configure optional parameters by calling the respective setters at will, and
16147/// // execute the final call using `doit()`.
16148/// // Values shown here are possibly random and not representative !
16149/// let result = hub.ssl_certs().delete("project", "instance", "sha1Fingerprint")
16150/// .doit().await;
16151/// # }
16152/// ```
16153pub struct SslCertDeleteCall<'a, C>
16154where
16155 C: 'a,
16156{
16157 hub: &'a SQLAdmin<C>,
16158 _project: String,
16159 _instance: String,
16160 _sha1_fingerprint: String,
16161 _delegate: Option<&'a mut dyn common::Delegate>,
16162 _additional_params: HashMap<String, String>,
16163 _scopes: BTreeSet<String>,
16164}
16165
16166impl<'a, C> common::CallBuilder for SslCertDeleteCall<'a, C> {}
16167
16168impl<'a, C> SslCertDeleteCall<'a, C>
16169where
16170 C: common::Connector,
16171{
16172 /// Perform the operation you have build so far.
16173 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16174 use std::borrow::Cow;
16175 use std::io::{Read, Seek};
16176
16177 use common::{url::Params, ToParts};
16178 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16179
16180 let mut dd = common::DefaultDelegate;
16181 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16182 dlg.begin(common::MethodInfo {
16183 id: "sql.sslCerts.delete",
16184 http_method: hyper::Method::DELETE,
16185 });
16186
16187 for &field in ["alt", "project", "instance", "sha1Fingerprint"].iter() {
16188 if self._additional_params.contains_key(field) {
16189 dlg.finished(false);
16190 return Err(common::Error::FieldClash(field));
16191 }
16192 }
16193
16194 let mut params = Params::with_capacity(5 + self._additional_params.len());
16195 params.push("project", self._project);
16196 params.push("instance", self._instance);
16197 params.push("sha1Fingerprint", self._sha1_fingerprint);
16198
16199 params.extend(self._additional_params.iter());
16200
16201 params.push("alt", "json");
16202 let mut url = self.hub._base_url.clone()
16203 + "sql/v1beta4/projects/{project}/instances/{instance}/sslCerts/{sha1Fingerprint}";
16204 if self._scopes.is_empty() {
16205 self._scopes
16206 .insert(Scope::CloudPlatform.as_ref().to_string());
16207 }
16208
16209 #[allow(clippy::single_element_loop)]
16210 for &(find_this, param_name) in [
16211 ("{project}", "project"),
16212 ("{instance}", "instance"),
16213 ("{sha1Fingerprint}", "sha1Fingerprint"),
16214 ]
16215 .iter()
16216 {
16217 url = params.uri_replacement(url, param_name, find_this, false);
16218 }
16219 {
16220 let to_remove = ["sha1Fingerprint", "instance", "project"];
16221 params.remove_params(&to_remove);
16222 }
16223
16224 let url = params.parse_with_url(&url);
16225
16226 loop {
16227 let token = match self
16228 .hub
16229 .auth
16230 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16231 .await
16232 {
16233 Ok(token) => token,
16234 Err(e) => match dlg.token(e) {
16235 Ok(token) => token,
16236 Err(e) => {
16237 dlg.finished(false);
16238 return Err(common::Error::MissingToken(e));
16239 }
16240 },
16241 };
16242 let mut req_result = {
16243 let client = &self.hub.client;
16244 dlg.pre_request();
16245 let mut req_builder = hyper::Request::builder()
16246 .method(hyper::Method::DELETE)
16247 .uri(url.as_str())
16248 .header(USER_AGENT, self.hub._user_agent.clone());
16249
16250 if let Some(token) = token.as_ref() {
16251 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16252 }
16253
16254 let request = req_builder
16255 .header(CONTENT_LENGTH, 0_u64)
16256 .body(common::to_body::<String>(None));
16257
16258 client.request(request.unwrap()).await
16259 };
16260
16261 match req_result {
16262 Err(err) => {
16263 if let common::Retry::After(d) = dlg.http_error(&err) {
16264 sleep(d).await;
16265 continue;
16266 }
16267 dlg.finished(false);
16268 return Err(common::Error::HttpError(err));
16269 }
16270 Ok(res) => {
16271 let (mut parts, body) = res.into_parts();
16272 let mut body = common::Body::new(body);
16273 if !parts.status.is_success() {
16274 let bytes = common::to_bytes(body).await.unwrap_or_default();
16275 let error = serde_json::from_str(&common::to_string(&bytes));
16276 let response = common::to_response(parts, bytes.into());
16277
16278 if let common::Retry::After(d) =
16279 dlg.http_failure(&response, error.as_ref().ok())
16280 {
16281 sleep(d).await;
16282 continue;
16283 }
16284
16285 dlg.finished(false);
16286
16287 return Err(match error {
16288 Ok(value) => common::Error::BadRequest(value),
16289 _ => common::Error::Failure(response),
16290 });
16291 }
16292 let response = {
16293 let bytes = common::to_bytes(body).await.unwrap_or_default();
16294 let encoded = common::to_string(&bytes);
16295 match serde_json::from_str(&encoded) {
16296 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16297 Err(error) => {
16298 dlg.response_json_decode_error(&encoded, &error);
16299 return Err(common::Error::JsonDecodeError(
16300 encoded.to_string(),
16301 error,
16302 ));
16303 }
16304 }
16305 };
16306
16307 dlg.finished(true);
16308 return Ok(response);
16309 }
16310 }
16311 }
16312 }
16313
16314 /// Project ID of the project that contains the instance.
16315 ///
16316 /// Sets the *project* path property to the given value.
16317 ///
16318 /// Even though the property as already been set when instantiating this call,
16319 /// we provide this method for API completeness.
16320 pub fn project(mut self, new_value: &str) -> SslCertDeleteCall<'a, C> {
16321 self._project = new_value.to_string();
16322 self
16323 }
16324 /// Cloud SQL instance ID. This does not include the project ID.
16325 ///
16326 /// Sets the *instance* path property to the given value.
16327 ///
16328 /// Even though the property as already been set when instantiating this call,
16329 /// we provide this method for API completeness.
16330 pub fn instance(mut self, new_value: &str) -> SslCertDeleteCall<'a, C> {
16331 self._instance = new_value.to_string();
16332 self
16333 }
16334 /// Sha1 FingerPrint.
16335 ///
16336 /// Sets the *sha1 fingerprint* path property to the given value.
16337 ///
16338 /// Even though the property as already been set when instantiating this call,
16339 /// we provide this method for API completeness.
16340 pub fn sha1_fingerprint(mut self, new_value: &str) -> SslCertDeleteCall<'a, C> {
16341 self._sha1_fingerprint = new_value.to_string();
16342 self
16343 }
16344 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16345 /// while executing the actual API request.
16346 ///
16347 /// ````text
16348 /// It should be used to handle progress information, and to implement a certain level of resilience.
16349 /// ````
16350 ///
16351 /// Sets the *delegate* property to the given value.
16352 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SslCertDeleteCall<'a, C> {
16353 self._delegate = Some(new_value);
16354 self
16355 }
16356
16357 /// Set any additional parameter of the query string used in the request.
16358 /// It should be used to set parameters which are not yet available through their own
16359 /// setters.
16360 ///
16361 /// Please note that this method must not be used to set any of the known parameters
16362 /// which have their own setter method. If done anyway, the request will fail.
16363 ///
16364 /// # Additional Parameters
16365 ///
16366 /// * *$.xgafv* (query-string) - V1 error format.
16367 /// * *access_token* (query-string) - OAuth access token.
16368 /// * *alt* (query-string) - Data format for response.
16369 /// * *callback* (query-string) - JSONP
16370 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16371 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16372 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16373 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16374 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16375 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16376 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16377 pub fn param<T>(mut self, name: T, value: T) -> SslCertDeleteCall<'a, C>
16378 where
16379 T: AsRef<str>,
16380 {
16381 self._additional_params
16382 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16383 self
16384 }
16385
16386 /// Identifies the authorization scope for the method you are building.
16387 ///
16388 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16389 /// [`Scope::CloudPlatform`].
16390 ///
16391 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16392 /// tokens for more than one scope.
16393 ///
16394 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16395 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16396 /// sufficient, a read-write scope will do as well.
16397 pub fn add_scope<St>(mut self, scope: St) -> SslCertDeleteCall<'a, C>
16398 where
16399 St: AsRef<str>,
16400 {
16401 self._scopes.insert(String::from(scope.as_ref()));
16402 self
16403 }
16404 /// Identifies the authorization scope(s) for the method you are building.
16405 ///
16406 /// See [`Self::add_scope()`] for details.
16407 pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertDeleteCall<'a, C>
16408 where
16409 I: IntoIterator<Item = St>,
16410 St: AsRef<str>,
16411 {
16412 self._scopes
16413 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16414 self
16415 }
16416
16417 /// Removes all scopes, and no default scope will be used either.
16418 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16419 /// for details).
16420 pub fn clear_scopes(mut self) -> SslCertDeleteCall<'a, C> {
16421 self._scopes.clear();
16422 self
16423 }
16424}
16425
16426/// Retrieves a particular SSL certificate. Does not include the private key
16427/// (required for usage). The private key must be saved from the response to
16428/// initial creation.
16429///
16430/// A builder for the *get* method supported by a *sslCert* resource.
16431/// It is not used directly, but through a [`SslCertMethods`] instance.
16432///
16433/// # Example
16434///
16435/// Instantiate a resource method builder
16436///
16437/// ```test_harness,no_run
16438/// # extern crate hyper;
16439/// # extern crate hyper_rustls;
16440/// # extern crate google_sql1_beta4 as sql1_beta4;
16441/// # async fn dox() {
16442/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16443///
16444/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16445/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16446/// # secret,
16447/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16448/// # ).build().await.unwrap();
16449///
16450/// # let client = hyper_util::client::legacy::Client::builder(
16451/// # hyper_util::rt::TokioExecutor::new()
16452/// # )
16453/// # .build(
16454/// # hyper_rustls::HttpsConnectorBuilder::new()
16455/// # .with_native_roots()
16456/// # .unwrap()
16457/// # .https_or_http()
16458/// # .enable_http1()
16459/// # .build()
16460/// # );
16461/// # let mut hub = SQLAdmin::new(client, auth);
16462/// // You can configure optional parameters by calling the respective setters at will, and
16463/// // execute the final call using `doit()`.
16464/// // Values shown here are possibly random and not representative !
16465/// let result = hub.ssl_certs().get("project", "instance", "sha1Fingerprint")
16466/// .doit().await;
16467/// # }
16468/// ```
16469pub struct SslCertGetCall<'a, C>
16470where
16471 C: 'a,
16472{
16473 hub: &'a SQLAdmin<C>,
16474 _project: String,
16475 _instance: String,
16476 _sha1_fingerprint: String,
16477 _delegate: Option<&'a mut dyn common::Delegate>,
16478 _additional_params: HashMap<String, String>,
16479 _scopes: BTreeSet<String>,
16480}
16481
16482impl<'a, C> common::CallBuilder for SslCertGetCall<'a, C> {}
16483
16484impl<'a, C> SslCertGetCall<'a, C>
16485where
16486 C: common::Connector,
16487{
16488 /// Perform the operation you have build so far.
16489 pub async fn doit(mut self) -> common::Result<(common::Response, SslCert)> {
16490 use std::borrow::Cow;
16491 use std::io::{Read, Seek};
16492
16493 use common::{url::Params, ToParts};
16494 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16495
16496 let mut dd = common::DefaultDelegate;
16497 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16498 dlg.begin(common::MethodInfo {
16499 id: "sql.sslCerts.get",
16500 http_method: hyper::Method::GET,
16501 });
16502
16503 for &field in ["alt", "project", "instance", "sha1Fingerprint"].iter() {
16504 if self._additional_params.contains_key(field) {
16505 dlg.finished(false);
16506 return Err(common::Error::FieldClash(field));
16507 }
16508 }
16509
16510 let mut params = Params::with_capacity(5 + self._additional_params.len());
16511 params.push("project", self._project);
16512 params.push("instance", self._instance);
16513 params.push("sha1Fingerprint", self._sha1_fingerprint);
16514
16515 params.extend(self._additional_params.iter());
16516
16517 params.push("alt", "json");
16518 let mut url = self.hub._base_url.clone()
16519 + "sql/v1beta4/projects/{project}/instances/{instance}/sslCerts/{sha1Fingerprint}";
16520 if self._scopes.is_empty() {
16521 self._scopes
16522 .insert(Scope::CloudPlatform.as_ref().to_string());
16523 }
16524
16525 #[allow(clippy::single_element_loop)]
16526 for &(find_this, param_name) in [
16527 ("{project}", "project"),
16528 ("{instance}", "instance"),
16529 ("{sha1Fingerprint}", "sha1Fingerprint"),
16530 ]
16531 .iter()
16532 {
16533 url = params.uri_replacement(url, param_name, find_this, false);
16534 }
16535 {
16536 let to_remove = ["sha1Fingerprint", "instance", "project"];
16537 params.remove_params(&to_remove);
16538 }
16539
16540 let url = params.parse_with_url(&url);
16541
16542 loop {
16543 let token = match self
16544 .hub
16545 .auth
16546 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16547 .await
16548 {
16549 Ok(token) => token,
16550 Err(e) => match dlg.token(e) {
16551 Ok(token) => token,
16552 Err(e) => {
16553 dlg.finished(false);
16554 return Err(common::Error::MissingToken(e));
16555 }
16556 },
16557 };
16558 let mut req_result = {
16559 let client = &self.hub.client;
16560 dlg.pre_request();
16561 let mut req_builder = hyper::Request::builder()
16562 .method(hyper::Method::GET)
16563 .uri(url.as_str())
16564 .header(USER_AGENT, self.hub._user_agent.clone());
16565
16566 if let Some(token) = token.as_ref() {
16567 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16568 }
16569
16570 let request = req_builder
16571 .header(CONTENT_LENGTH, 0_u64)
16572 .body(common::to_body::<String>(None));
16573
16574 client.request(request.unwrap()).await
16575 };
16576
16577 match req_result {
16578 Err(err) => {
16579 if let common::Retry::After(d) = dlg.http_error(&err) {
16580 sleep(d).await;
16581 continue;
16582 }
16583 dlg.finished(false);
16584 return Err(common::Error::HttpError(err));
16585 }
16586 Ok(res) => {
16587 let (mut parts, body) = res.into_parts();
16588 let mut body = common::Body::new(body);
16589 if !parts.status.is_success() {
16590 let bytes = common::to_bytes(body).await.unwrap_or_default();
16591 let error = serde_json::from_str(&common::to_string(&bytes));
16592 let response = common::to_response(parts, bytes.into());
16593
16594 if let common::Retry::After(d) =
16595 dlg.http_failure(&response, error.as_ref().ok())
16596 {
16597 sleep(d).await;
16598 continue;
16599 }
16600
16601 dlg.finished(false);
16602
16603 return Err(match error {
16604 Ok(value) => common::Error::BadRequest(value),
16605 _ => common::Error::Failure(response),
16606 });
16607 }
16608 let response = {
16609 let bytes = common::to_bytes(body).await.unwrap_or_default();
16610 let encoded = common::to_string(&bytes);
16611 match serde_json::from_str(&encoded) {
16612 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16613 Err(error) => {
16614 dlg.response_json_decode_error(&encoded, &error);
16615 return Err(common::Error::JsonDecodeError(
16616 encoded.to_string(),
16617 error,
16618 ));
16619 }
16620 }
16621 };
16622
16623 dlg.finished(true);
16624 return Ok(response);
16625 }
16626 }
16627 }
16628 }
16629
16630 /// Project ID of the project that contains the instance.
16631 ///
16632 /// Sets the *project* path property to the given value.
16633 ///
16634 /// Even though the property as already been set when instantiating this call,
16635 /// we provide this method for API completeness.
16636 pub fn project(mut self, new_value: &str) -> SslCertGetCall<'a, C> {
16637 self._project = new_value.to_string();
16638 self
16639 }
16640 /// Cloud SQL instance ID. This does not include the project ID.
16641 ///
16642 /// Sets the *instance* path property to the given value.
16643 ///
16644 /// Even though the property as already been set when instantiating this call,
16645 /// we provide this method for API completeness.
16646 pub fn instance(mut self, new_value: &str) -> SslCertGetCall<'a, C> {
16647 self._instance = new_value.to_string();
16648 self
16649 }
16650 /// Sha1 FingerPrint.
16651 ///
16652 /// Sets the *sha1 fingerprint* path property to the given value.
16653 ///
16654 /// Even though the property as already been set when instantiating this call,
16655 /// we provide this method for API completeness.
16656 pub fn sha1_fingerprint(mut self, new_value: &str) -> SslCertGetCall<'a, C> {
16657 self._sha1_fingerprint = new_value.to_string();
16658 self
16659 }
16660 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16661 /// while executing the actual API request.
16662 ///
16663 /// ````text
16664 /// It should be used to handle progress information, and to implement a certain level of resilience.
16665 /// ````
16666 ///
16667 /// Sets the *delegate* property to the given value.
16668 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SslCertGetCall<'a, C> {
16669 self._delegate = Some(new_value);
16670 self
16671 }
16672
16673 /// Set any additional parameter of the query string used in the request.
16674 /// It should be used to set parameters which are not yet available through their own
16675 /// setters.
16676 ///
16677 /// Please note that this method must not be used to set any of the known parameters
16678 /// which have their own setter method. If done anyway, the request will fail.
16679 ///
16680 /// # Additional Parameters
16681 ///
16682 /// * *$.xgafv* (query-string) - V1 error format.
16683 /// * *access_token* (query-string) - OAuth access token.
16684 /// * *alt* (query-string) - Data format for response.
16685 /// * *callback* (query-string) - JSONP
16686 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16687 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16688 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16689 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16690 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16691 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16692 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16693 pub fn param<T>(mut self, name: T, value: T) -> SslCertGetCall<'a, C>
16694 where
16695 T: AsRef<str>,
16696 {
16697 self._additional_params
16698 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16699 self
16700 }
16701
16702 /// Identifies the authorization scope for the method you are building.
16703 ///
16704 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16705 /// [`Scope::CloudPlatform`].
16706 ///
16707 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16708 /// tokens for more than one scope.
16709 ///
16710 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16711 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16712 /// sufficient, a read-write scope will do as well.
16713 pub fn add_scope<St>(mut self, scope: St) -> SslCertGetCall<'a, C>
16714 where
16715 St: AsRef<str>,
16716 {
16717 self._scopes.insert(String::from(scope.as_ref()));
16718 self
16719 }
16720 /// Identifies the authorization scope(s) for the method you are building.
16721 ///
16722 /// See [`Self::add_scope()`] for details.
16723 pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertGetCall<'a, C>
16724 where
16725 I: IntoIterator<Item = St>,
16726 St: AsRef<str>,
16727 {
16728 self._scopes
16729 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16730 self
16731 }
16732
16733 /// Removes all scopes, and no default scope will be used either.
16734 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16735 /// for details).
16736 pub fn clear_scopes(mut self) -> SslCertGetCall<'a, C> {
16737 self._scopes.clear();
16738 self
16739 }
16740}
16741
16742/// Creates an SSL certificate and returns it along with the private key and
16743/// server certificate authority. The new certificate will not be usable until
16744/// the instance is restarted.
16745///
16746/// A builder for the *insert* method supported by a *sslCert* resource.
16747/// It is not used directly, but through a [`SslCertMethods`] instance.
16748///
16749/// # Example
16750///
16751/// Instantiate a resource method builder
16752///
16753/// ```test_harness,no_run
16754/// # extern crate hyper;
16755/// # extern crate hyper_rustls;
16756/// # extern crate google_sql1_beta4 as sql1_beta4;
16757/// use sql1_beta4::api::SslCertsInsertRequest;
16758/// # async fn dox() {
16759/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16760///
16761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16762/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16763/// # secret,
16764/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16765/// # ).build().await.unwrap();
16766///
16767/// # let client = hyper_util::client::legacy::Client::builder(
16768/// # hyper_util::rt::TokioExecutor::new()
16769/// # )
16770/// # .build(
16771/// # hyper_rustls::HttpsConnectorBuilder::new()
16772/// # .with_native_roots()
16773/// # .unwrap()
16774/// # .https_or_http()
16775/// # .enable_http1()
16776/// # .build()
16777/// # );
16778/// # let mut hub = SQLAdmin::new(client, auth);
16779/// // As the method needs a request, you would usually fill it with the desired information
16780/// // into the respective structure. Some of the parts shown here might not be applicable !
16781/// // Values shown here are possibly random and not representative !
16782/// let mut req = SslCertsInsertRequest::default();
16783///
16784/// // You can configure optional parameters by calling the respective setters at will, and
16785/// // execute the final call using `doit()`.
16786/// // Values shown here are possibly random and not representative !
16787/// let result = hub.ssl_certs().insert(req, "project", "instance")
16788/// .doit().await;
16789/// # }
16790/// ```
16791pub struct SslCertInsertCall<'a, C>
16792where
16793 C: 'a,
16794{
16795 hub: &'a SQLAdmin<C>,
16796 _request: SslCertsInsertRequest,
16797 _project: String,
16798 _instance: String,
16799 _delegate: Option<&'a mut dyn common::Delegate>,
16800 _additional_params: HashMap<String, String>,
16801 _scopes: BTreeSet<String>,
16802}
16803
16804impl<'a, C> common::CallBuilder for SslCertInsertCall<'a, C> {}
16805
16806impl<'a, C> SslCertInsertCall<'a, C>
16807where
16808 C: common::Connector,
16809{
16810 /// Perform the operation you have build so far.
16811 pub async fn doit(mut self) -> common::Result<(common::Response, SslCertsInsertResponse)> {
16812 use std::borrow::Cow;
16813 use std::io::{Read, Seek};
16814
16815 use common::{url::Params, ToParts};
16816 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16817
16818 let mut dd = common::DefaultDelegate;
16819 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16820 dlg.begin(common::MethodInfo {
16821 id: "sql.sslCerts.insert",
16822 http_method: hyper::Method::POST,
16823 });
16824
16825 for &field in ["alt", "project", "instance"].iter() {
16826 if self._additional_params.contains_key(field) {
16827 dlg.finished(false);
16828 return Err(common::Error::FieldClash(field));
16829 }
16830 }
16831
16832 let mut params = Params::with_capacity(5 + self._additional_params.len());
16833 params.push("project", self._project);
16834 params.push("instance", self._instance);
16835
16836 params.extend(self._additional_params.iter());
16837
16838 params.push("alt", "json");
16839 let mut url = self.hub._base_url.clone()
16840 + "sql/v1beta4/projects/{project}/instances/{instance}/sslCerts";
16841 if self._scopes.is_empty() {
16842 self._scopes
16843 .insert(Scope::CloudPlatform.as_ref().to_string());
16844 }
16845
16846 #[allow(clippy::single_element_loop)]
16847 for &(find_this, param_name) in
16848 [("{project}", "project"), ("{instance}", "instance")].iter()
16849 {
16850 url = params.uri_replacement(url, param_name, find_this, false);
16851 }
16852 {
16853 let to_remove = ["instance", "project"];
16854 params.remove_params(&to_remove);
16855 }
16856
16857 let url = params.parse_with_url(&url);
16858
16859 let mut json_mime_type = mime::APPLICATION_JSON;
16860 let mut request_value_reader = {
16861 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16862 common::remove_json_null_values(&mut value);
16863 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16864 serde_json::to_writer(&mut dst, &value).unwrap();
16865 dst
16866 };
16867 let request_size = request_value_reader
16868 .seek(std::io::SeekFrom::End(0))
16869 .unwrap();
16870 request_value_reader
16871 .seek(std::io::SeekFrom::Start(0))
16872 .unwrap();
16873
16874 loop {
16875 let token = match self
16876 .hub
16877 .auth
16878 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16879 .await
16880 {
16881 Ok(token) => token,
16882 Err(e) => match dlg.token(e) {
16883 Ok(token) => token,
16884 Err(e) => {
16885 dlg.finished(false);
16886 return Err(common::Error::MissingToken(e));
16887 }
16888 },
16889 };
16890 request_value_reader
16891 .seek(std::io::SeekFrom::Start(0))
16892 .unwrap();
16893 let mut req_result = {
16894 let client = &self.hub.client;
16895 dlg.pre_request();
16896 let mut req_builder = hyper::Request::builder()
16897 .method(hyper::Method::POST)
16898 .uri(url.as_str())
16899 .header(USER_AGENT, self.hub._user_agent.clone());
16900
16901 if let Some(token) = token.as_ref() {
16902 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16903 }
16904
16905 let request = req_builder
16906 .header(CONTENT_TYPE, json_mime_type.to_string())
16907 .header(CONTENT_LENGTH, request_size as u64)
16908 .body(common::to_body(
16909 request_value_reader.get_ref().clone().into(),
16910 ));
16911
16912 client.request(request.unwrap()).await
16913 };
16914
16915 match req_result {
16916 Err(err) => {
16917 if let common::Retry::After(d) = dlg.http_error(&err) {
16918 sleep(d).await;
16919 continue;
16920 }
16921 dlg.finished(false);
16922 return Err(common::Error::HttpError(err));
16923 }
16924 Ok(res) => {
16925 let (mut parts, body) = res.into_parts();
16926 let mut body = common::Body::new(body);
16927 if !parts.status.is_success() {
16928 let bytes = common::to_bytes(body).await.unwrap_or_default();
16929 let error = serde_json::from_str(&common::to_string(&bytes));
16930 let response = common::to_response(parts, bytes.into());
16931
16932 if let common::Retry::After(d) =
16933 dlg.http_failure(&response, error.as_ref().ok())
16934 {
16935 sleep(d).await;
16936 continue;
16937 }
16938
16939 dlg.finished(false);
16940
16941 return Err(match error {
16942 Ok(value) => common::Error::BadRequest(value),
16943 _ => common::Error::Failure(response),
16944 });
16945 }
16946 let response = {
16947 let bytes = common::to_bytes(body).await.unwrap_or_default();
16948 let encoded = common::to_string(&bytes);
16949 match serde_json::from_str(&encoded) {
16950 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16951 Err(error) => {
16952 dlg.response_json_decode_error(&encoded, &error);
16953 return Err(common::Error::JsonDecodeError(
16954 encoded.to_string(),
16955 error,
16956 ));
16957 }
16958 }
16959 };
16960
16961 dlg.finished(true);
16962 return Ok(response);
16963 }
16964 }
16965 }
16966 }
16967
16968 ///
16969 /// Sets the *request* property to the given value.
16970 ///
16971 /// Even though the property as already been set when instantiating this call,
16972 /// we provide this method for API completeness.
16973 pub fn request(mut self, new_value: SslCertsInsertRequest) -> SslCertInsertCall<'a, C> {
16974 self._request = new_value;
16975 self
16976 }
16977 /// Project ID of the project that contains the instance.
16978 ///
16979 /// Sets the *project* path property to the given value.
16980 ///
16981 /// Even though the property as already been set when instantiating this call,
16982 /// we provide this method for API completeness.
16983 pub fn project(mut self, new_value: &str) -> SslCertInsertCall<'a, C> {
16984 self._project = new_value.to_string();
16985 self
16986 }
16987 /// Cloud SQL instance ID. This does not include the project ID.
16988 ///
16989 /// Sets the *instance* path property to the given value.
16990 ///
16991 /// Even though the property as already been set when instantiating this call,
16992 /// we provide this method for API completeness.
16993 pub fn instance(mut self, new_value: &str) -> SslCertInsertCall<'a, C> {
16994 self._instance = new_value.to_string();
16995 self
16996 }
16997 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16998 /// while executing the actual API request.
16999 ///
17000 /// ````text
17001 /// It should be used to handle progress information, and to implement a certain level of resilience.
17002 /// ````
17003 ///
17004 /// Sets the *delegate* property to the given value.
17005 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SslCertInsertCall<'a, C> {
17006 self._delegate = Some(new_value);
17007 self
17008 }
17009
17010 /// Set any additional parameter of the query string used in the request.
17011 /// It should be used to set parameters which are not yet available through their own
17012 /// setters.
17013 ///
17014 /// Please note that this method must not be used to set any of the known parameters
17015 /// which have their own setter method. If done anyway, the request will fail.
17016 ///
17017 /// # Additional Parameters
17018 ///
17019 /// * *$.xgafv* (query-string) - V1 error format.
17020 /// * *access_token* (query-string) - OAuth access token.
17021 /// * *alt* (query-string) - Data format for response.
17022 /// * *callback* (query-string) - JSONP
17023 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17024 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17025 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17026 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17027 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17028 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17029 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17030 pub fn param<T>(mut self, name: T, value: T) -> SslCertInsertCall<'a, C>
17031 where
17032 T: AsRef<str>,
17033 {
17034 self._additional_params
17035 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17036 self
17037 }
17038
17039 /// Identifies the authorization scope for the method you are building.
17040 ///
17041 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17042 /// [`Scope::CloudPlatform`].
17043 ///
17044 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17045 /// tokens for more than one scope.
17046 ///
17047 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17048 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17049 /// sufficient, a read-write scope will do as well.
17050 pub fn add_scope<St>(mut self, scope: St) -> SslCertInsertCall<'a, C>
17051 where
17052 St: AsRef<str>,
17053 {
17054 self._scopes.insert(String::from(scope.as_ref()));
17055 self
17056 }
17057 /// Identifies the authorization scope(s) for the method you are building.
17058 ///
17059 /// See [`Self::add_scope()`] for details.
17060 pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertInsertCall<'a, C>
17061 where
17062 I: IntoIterator<Item = St>,
17063 St: AsRef<str>,
17064 {
17065 self._scopes
17066 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17067 self
17068 }
17069
17070 /// Removes all scopes, and no default scope will be used either.
17071 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17072 /// for details).
17073 pub fn clear_scopes(mut self) -> SslCertInsertCall<'a, C> {
17074 self._scopes.clear();
17075 self
17076 }
17077}
17078
17079/// Lists all of the current SSL certificates for the instance.
17080///
17081/// A builder for the *list* method supported by a *sslCert* resource.
17082/// It is not used directly, but through a [`SslCertMethods`] instance.
17083///
17084/// # Example
17085///
17086/// Instantiate a resource method builder
17087///
17088/// ```test_harness,no_run
17089/// # extern crate hyper;
17090/// # extern crate hyper_rustls;
17091/// # extern crate google_sql1_beta4 as sql1_beta4;
17092/// # async fn dox() {
17093/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17094///
17095/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17096/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17097/// # secret,
17098/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17099/// # ).build().await.unwrap();
17100///
17101/// # let client = hyper_util::client::legacy::Client::builder(
17102/// # hyper_util::rt::TokioExecutor::new()
17103/// # )
17104/// # .build(
17105/// # hyper_rustls::HttpsConnectorBuilder::new()
17106/// # .with_native_roots()
17107/// # .unwrap()
17108/// # .https_or_http()
17109/// # .enable_http1()
17110/// # .build()
17111/// # );
17112/// # let mut hub = SQLAdmin::new(client, auth);
17113/// // You can configure optional parameters by calling the respective setters at will, and
17114/// // execute the final call using `doit()`.
17115/// // Values shown here are possibly random and not representative !
17116/// let result = hub.ssl_certs().list("project", "instance")
17117/// .doit().await;
17118/// # }
17119/// ```
17120pub struct SslCertListCall<'a, C>
17121where
17122 C: 'a,
17123{
17124 hub: &'a SQLAdmin<C>,
17125 _project: String,
17126 _instance: String,
17127 _delegate: Option<&'a mut dyn common::Delegate>,
17128 _additional_params: HashMap<String, String>,
17129 _scopes: BTreeSet<String>,
17130}
17131
17132impl<'a, C> common::CallBuilder for SslCertListCall<'a, C> {}
17133
17134impl<'a, C> SslCertListCall<'a, C>
17135where
17136 C: common::Connector,
17137{
17138 /// Perform the operation you have build so far.
17139 pub async fn doit(mut self) -> common::Result<(common::Response, SslCertsListResponse)> {
17140 use std::borrow::Cow;
17141 use std::io::{Read, Seek};
17142
17143 use common::{url::Params, ToParts};
17144 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17145
17146 let mut dd = common::DefaultDelegate;
17147 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17148 dlg.begin(common::MethodInfo {
17149 id: "sql.sslCerts.list",
17150 http_method: hyper::Method::GET,
17151 });
17152
17153 for &field in ["alt", "project", "instance"].iter() {
17154 if self._additional_params.contains_key(field) {
17155 dlg.finished(false);
17156 return Err(common::Error::FieldClash(field));
17157 }
17158 }
17159
17160 let mut params = Params::with_capacity(4 + self._additional_params.len());
17161 params.push("project", self._project);
17162 params.push("instance", self._instance);
17163
17164 params.extend(self._additional_params.iter());
17165
17166 params.push("alt", "json");
17167 let mut url = self.hub._base_url.clone()
17168 + "sql/v1beta4/projects/{project}/instances/{instance}/sslCerts";
17169 if self._scopes.is_empty() {
17170 self._scopes
17171 .insert(Scope::CloudPlatform.as_ref().to_string());
17172 }
17173
17174 #[allow(clippy::single_element_loop)]
17175 for &(find_this, param_name) in
17176 [("{project}", "project"), ("{instance}", "instance")].iter()
17177 {
17178 url = params.uri_replacement(url, param_name, find_this, false);
17179 }
17180 {
17181 let to_remove = ["instance", "project"];
17182 params.remove_params(&to_remove);
17183 }
17184
17185 let url = params.parse_with_url(&url);
17186
17187 loop {
17188 let token = match self
17189 .hub
17190 .auth
17191 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17192 .await
17193 {
17194 Ok(token) => token,
17195 Err(e) => match dlg.token(e) {
17196 Ok(token) => token,
17197 Err(e) => {
17198 dlg.finished(false);
17199 return Err(common::Error::MissingToken(e));
17200 }
17201 },
17202 };
17203 let mut req_result = {
17204 let client = &self.hub.client;
17205 dlg.pre_request();
17206 let mut req_builder = hyper::Request::builder()
17207 .method(hyper::Method::GET)
17208 .uri(url.as_str())
17209 .header(USER_AGENT, self.hub._user_agent.clone());
17210
17211 if let Some(token) = token.as_ref() {
17212 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17213 }
17214
17215 let request = req_builder
17216 .header(CONTENT_LENGTH, 0_u64)
17217 .body(common::to_body::<String>(None));
17218
17219 client.request(request.unwrap()).await
17220 };
17221
17222 match req_result {
17223 Err(err) => {
17224 if let common::Retry::After(d) = dlg.http_error(&err) {
17225 sleep(d).await;
17226 continue;
17227 }
17228 dlg.finished(false);
17229 return Err(common::Error::HttpError(err));
17230 }
17231 Ok(res) => {
17232 let (mut parts, body) = res.into_parts();
17233 let mut body = common::Body::new(body);
17234 if !parts.status.is_success() {
17235 let bytes = common::to_bytes(body).await.unwrap_or_default();
17236 let error = serde_json::from_str(&common::to_string(&bytes));
17237 let response = common::to_response(parts, bytes.into());
17238
17239 if let common::Retry::After(d) =
17240 dlg.http_failure(&response, error.as_ref().ok())
17241 {
17242 sleep(d).await;
17243 continue;
17244 }
17245
17246 dlg.finished(false);
17247
17248 return Err(match error {
17249 Ok(value) => common::Error::BadRequest(value),
17250 _ => common::Error::Failure(response),
17251 });
17252 }
17253 let response = {
17254 let bytes = common::to_bytes(body).await.unwrap_or_default();
17255 let encoded = common::to_string(&bytes);
17256 match serde_json::from_str(&encoded) {
17257 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17258 Err(error) => {
17259 dlg.response_json_decode_error(&encoded, &error);
17260 return Err(common::Error::JsonDecodeError(
17261 encoded.to_string(),
17262 error,
17263 ));
17264 }
17265 }
17266 };
17267
17268 dlg.finished(true);
17269 return Ok(response);
17270 }
17271 }
17272 }
17273 }
17274
17275 /// Project ID of the project that contains the instance.
17276 ///
17277 /// Sets the *project* path property to the given value.
17278 ///
17279 /// Even though the property as already been set when instantiating this call,
17280 /// we provide this method for API completeness.
17281 pub fn project(mut self, new_value: &str) -> SslCertListCall<'a, C> {
17282 self._project = new_value.to_string();
17283 self
17284 }
17285 /// Cloud SQL instance ID. This does not include the project ID.
17286 ///
17287 /// Sets the *instance* path property to the given value.
17288 ///
17289 /// Even though the property as already been set when instantiating this call,
17290 /// we provide this method for API completeness.
17291 pub fn instance(mut self, new_value: &str) -> SslCertListCall<'a, C> {
17292 self._instance = new_value.to_string();
17293 self
17294 }
17295 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17296 /// while executing the actual API request.
17297 ///
17298 /// ````text
17299 /// It should be used to handle progress information, and to implement a certain level of resilience.
17300 /// ````
17301 ///
17302 /// Sets the *delegate* property to the given value.
17303 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SslCertListCall<'a, C> {
17304 self._delegate = Some(new_value);
17305 self
17306 }
17307
17308 /// Set any additional parameter of the query string used in the request.
17309 /// It should be used to set parameters which are not yet available through their own
17310 /// setters.
17311 ///
17312 /// Please note that this method must not be used to set any of the known parameters
17313 /// which have their own setter method. If done anyway, the request will fail.
17314 ///
17315 /// # Additional Parameters
17316 ///
17317 /// * *$.xgafv* (query-string) - V1 error format.
17318 /// * *access_token* (query-string) - OAuth access token.
17319 /// * *alt* (query-string) - Data format for response.
17320 /// * *callback* (query-string) - JSONP
17321 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17322 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17323 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17324 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17325 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17326 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17327 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17328 pub fn param<T>(mut self, name: T, value: T) -> SslCertListCall<'a, C>
17329 where
17330 T: AsRef<str>,
17331 {
17332 self._additional_params
17333 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17334 self
17335 }
17336
17337 /// Identifies the authorization scope for the method you are building.
17338 ///
17339 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17340 /// [`Scope::CloudPlatform`].
17341 ///
17342 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17343 /// tokens for more than one scope.
17344 ///
17345 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17346 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17347 /// sufficient, a read-write scope will do as well.
17348 pub fn add_scope<St>(mut self, scope: St) -> SslCertListCall<'a, C>
17349 where
17350 St: AsRef<str>,
17351 {
17352 self._scopes.insert(String::from(scope.as_ref()));
17353 self
17354 }
17355 /// Identifies the authorization scope(s) for the method you are building.
17356 ///
17357 /// See [`Self::add_scope()`] for details.
17358 pub fn add_scopes<I, St>(mut self, scopes: I) -> SslCertListCall<'a, C>
17359 where
17360 I: IntoIterator<Item = St>,
17361 St: AsRef<str>,
17362 {
17363 self._scopes
17364 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17365 self
17366 }
17367
17368 /// Removes all scopes, and no default scope will be used either.
17369 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17370 /// for details).
17371 pub fn clear_scopes(mut self) -> SslCertListCall<'a, C> {
17372 self._scopes.clear();
17373 self
17374 }
17375}
17376
17377/// Lists all available machine types (tiers) for Cloud SQL, for example,
17378/// db-n1-standard-1. For related information, see <a
17379/// href="/sql/pricing">Pricing</a>.
17380///
17381/// A builder for the *list* method supported by a *tier* resource.
17382/// It is not used directly, but through a [`TierMethods`] instance.
17383///
17384/// # Example
17385///
17386/// Instantiate a resource method builder
17387///
17388/// ```test_harness,no_run
17389/// # extern crate hyper;
17390/// # extern crate hyper_rustls;
17391/// # extern crate google_sql1_beta4 as sql1_beta4;
17392/// # async fn dox() {
17393/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17394///
17395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17396/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17397/// # secret,
17398/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17399/// # ).build().await.unwrap();
17400///
17401/// # let client = hyper_util::client::legacy::Client::builder(
17402/// # hyper_util::rt::TokioExecutor::new()
17403/// # )
17404/// # .build(
17405/// # hyper_rustls::HttpsConnectorBuilder::new()
17406/// # .with_native_roots()
17407/// # .unwrap()
17408/// # .https_or_http()
17409/// # .enable_http1()
17410/// # .build()
17411/// # );
17412/// # let mut hub = SQLAdmin::new(client, auth);
17413/// // You can configure optional parameters by calling the respective setters at will, and
17414/// // execute the final call using `doit()`.
17415/// // Values shown here are possibly random and not representative !
17416/// let result = hub.tiers().list("project")
17417/// .doit().await;
17418/// # }
17419/// ```
17420pub struct TierListCall<'a, C>
17421where
17422 C: 'a,
17423{
17424 hub: &'a SQLAdmin<C>,
17425 _project: String,
17426 _delegate: Option<&'a mut dyn common::Delegate>,
17427 _additional_params: HashMap<String, String>,
17428 _scopes: BTreeSet<String>,
17429}
17430
17431impl<'a, C> common::CallBuilder for TierListCall<'a, C> {}
17432
17433impl<'a, C> TierListCall<'a, C>
17434where
17435 C: common::Connector,
17436{
17437 /// Perform the operation you have build so far.
17438 pub async fn doit(mut self) -> common::Result<(common::Response, TiersListResponse)> {
17439 use std::borrow::Cow;
17440 use std::io::{Read, Seek};
17441
17442 use common::{url::Params, ToParts};
17443 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17444
17445 let mut dd = common::DefaultDelegate;
17446 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17447 dlg.begin(common::MethodInfo {
17448 id: "sql.tiers.list",
17449 http_method: hyper::Method::GET,
17450 });
17451
17452 for &field in ["alt", "project"].iter() {
17453 if self._additional_params.contains_key(field) {
17454 dlg.finished(false);
17455 return Err(common::Error::FieldClash(field));
17456 }
17457 }
17458
17459 let mut params = Params::with_capacity(3 + self._additional_params.len());
17460 params.push("project", self._project);
17461
17462 params.extend(self._additional_params.iter());
17463
17464 params.push("alt", "json");
17465 let mut url = self.hub._base_url.clone() + "sql/v1beta4/projects/{project}/tiers";
17466 if self._scopes.is_empty() {
17467 self._scopes
17468 .insert(Scope::CloudPlatform.as_ref().to_string());
17469 }
17470
17471 #[allow(clippy::single_element_loop)]
17472 for &(find_this, param_name) in [("{project}", "project")].iter() {
17473 url = params.uri_replacement(url, param_name, find_this, false);
17474 }
17475 {
17476 let to_remove = ["project"];
17477 params.remove_params(&to_remove);
17478 }
17479
17480 let url = params.parse_with_url(&url);
17481
17482 loop {
17483 let token = match self
17484 .hub
17485 .auth
17486 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17487 .await
17488 {
17489 Ok(token) => token,
17490 Err(e) => match dlg.token(e) {
17491 Ok(token) => token,
17492 Err(e) => {
17493 dlg.finished(false);
17494 return Err(common::Error::MissingToken(e));
17495 }
17496 },
17497 };
17498 let mut req_result = {
17499 let client = &self.hub.client;
17500 dlg.pre_request();
17501 let mut req_builder = hyper::Request::builder()
17502 .method(hyper::Method::GET)
17503 .uri(url.as_str())
17504 .header(USER_AGENT, self.hub._user_agent.clone());
17505
17506 if let Some(token) = token.as_ref() {
17507 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17508 }
17509
17510 let request = req_builder
17511 .header(CONTENT_LENGTH, 0_u64)
17512 .body(common::to_body::<String>(None));
17513
17514 client.request(request.unwrap()).await
17515 };
17516
17517 match req_result {
17518 Err(err) => {
17519 if let common::Retry::After(d) = dlg.http_error(&err) {
17520 sleep(d).await;
17521 continue;
17522 }
17523 dlg.finished(false);
17524 return Err(common::Error::HttpError(err));
17525 }
17526 Ok(res) => {
17527 let (mut parts, body) = res.into_parts();
17528 let mut body = common::Body::new(body);
17529 if !parts.status.is_success() {
17530 let bytes = common::to_bytes(body).await.unwrap_or_default();
17531 let error = serde_json::from_str(&common::to_string(&bytes));
17532 let response = common::to_response(parts, bytes.into());
17533
17534 if let common::Retry::After(d) =
17535 dlg.http_failure(&response, error.as_ref().ok())
17536 {
17537 sleep(d).await;
17538 continue;
17539 }
17540
17541 dlg.finished(false);
17542
17543 return Err(match error {
17544 Ok(value) => common::Error::BadRequest(value),
17545 _ => common::Error::Failure(response),
17546 });
17547 }
17548 let response = {
17549 let bytes = common::to_bytes(body).await.unwrap_or_default();
17550 let encoded = common::to_string(&bytes);
17551 match serde_json::from_str(&encoded) {
17552 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17553 Err(error) => {
17554 dlg.response_json_decode_error(&encoded, &error);
17555 return Err(common::Error::JsonDecodeError(
17556 encoded.to_string(),
17557 error,
17558 ));
17559 }
17560 }
17561 };
17562
17563 dlg.finished(true);
17564 return Ok(response);
17565 }
17566 }
17567 }
17568 }
17569
17570 /// Project ID of the project for which to list tiers.
17571 ///
17572 /// Sets the *project* path property to the given value.
17573 ///
17574 /// Even though the property as already been set when instantiating this call,
17575 /// we provide this method for API completeness.
17576 pub fn project(mut self, new_value: &str) -> TierListCall<'a, C> {
17577 self._project = new_value.to_string();
17578 self
17579 }
17580 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17581 /// while executing the actual API request.
17582 ///
17583 /// ````text
17584 /// It should be used to handle progress information, and to implement a certain level of resilience.
17585 /// ````
17586 ///
17587 /// Sets the *delegate* property to the given value.
17588 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TierListCall<'a, C> {
17589 self._delegate = Some(new_value);
17590 self
17591 }
17592
17593 /// Set any additional parameter of the query string used in the request.
17594 /// It should be used to set parameters which are not yet available through their own
17595 /// setters.
17596 ///
17597 /// Please note that this method must not be used to set any of the known parameters
17598 /// which have their own setter method. If done anyway, the request will fail.
17599 ///
17600 /// # Additional Parameters
17601 ///
17602 /// * *$.xgafv* (query-string) - V1 error format.
17603 /// * *access_token* (query-string) - OAuth access token.
17604 /// * *alt* (query-string) - Data format for response.
17605 /// * *callback* (query-string) - JSONP
17606 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17607 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17608 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17609 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17610 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17611 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17612 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17613 pub fn param<T>(mut self, name: T, value: T) -> TierListCall<'a, C>
17614 where
17615 T: AsRef<str>,
17616 {
17617 self._additional_params
17618 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17619 self
17620 }
17621
17622 /// Identifies the authorization scope for the method you are building.
17623 ///
17624 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17625 /// [`Scope::CloudPlatform`].
17626 ///
17627 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17628 /// tokens for more than one scope.
17629 ///
17630 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17631 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17632 /// sufficient, a read-write scope will do as well.
17633 pub fn add_scope<St>(mut self, scope: St) -> TierListCall<'a, C>
17634 where
17635 St: AsRef<str>,
17636 {
17637 self._scopes.insert(String::from(scope.as_ref()));
17638 self
17639 }
17640 /// Identifies the authorization scope(s) for the method you are building.
17641 ///
17642 /// See [`Self::add_scope()`] for details.
17643 pub fn add_scopes<I, St>(mut self, scopes: I) -> TierListCall<'a, C>
17644 where
17645 I: IntoIterator<Item = St>,
17646 St: AsRef<str>,
17647 {
17648 self._scopes
17649 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17650 self
17651 }
17652
17653 /// Removes all scopes, and no default scope will be used either.
17654 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17655 /// for details).
17656 pub fn clear_scopes(mut self) -> TierListCall<'a, C> {
17657 self._scopes.clear();
17658 self
17659 }
17660}
17661
17662/// Deletes a user from a Cloud SQL instance.
17663///
17664/// A builder for the *delete* method supported by a *user* resource.
17665/// It is not used directly, but through a [`UserMethods`] instance.
17666///
17667/// # Example
17668///
17669/// Instantiate a resource method builder
17670///
17671/// ```test_harness,no_run
17672/// # extern crate hyper;
17673/// # extern crate hyper_rustls;
17674/// # extern crate google_sql1_beta4 as sql1_beta4;
17675/// # async fn dox() {
17676/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17677///
17678/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17679/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17680/// # secret,
17681/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17682/// # ).build().await.unwrap();
17683///
17684/// # let client = hyper_util::client::legacy::Client::builder(
17685/// # hyper_util::rt::TokioExecutor::new()
17686/// # )
17687/// # .build(
17688/// # hyper_rustls::HttpsConnectorBuilder::new()
17689/// # .with_native_roots()
17690/// # .unwrap()
17691/// # .https_or_http()
17692/// # .enable_http1()
17693/// # .build()
17694/// # );
17695/// # let mut hub = SQLAdmin::new(client, auth);
17696/// // You can configure optional parameters by calling the respective setters at will, and
17697/// // execute the final call using `doit()`.
17698/// // Values shown here are possibly random and not representative !
17699/// let result = hub.users().delete("project", "instance")
17700/// .name("dolores")
17701/// .host("et")
17702/// .doit().await;
17703/// # }
17704/// ```
17705pub struct UserDeleteCall<'a, C>
17706where
17707 C: 'a,
17708{
17709 hub: &'a SQLAdmin<C>,
17710 _project: String,
17711 _instance: String,
17712 _name: Option<String>,
17713 _host: Option<String>,
17714 _delegate: Option<&'a mut dyn common::Delegate>,
17715 _additional_params: HashMap<String, String>,
17716 _scopes: BTreeSet<String>,
17717}
17718
17719impl<'a, C> common::CallBuilder for UserDeleteCall<'a, C> {}
17720
17721impl<'a, C> UserDeleteCall<'a, C>
17722where
17723 C: common::Connector,
17724{
17725 /// Perform the operation you have build so far.
17726 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17727 use std::borrow::Cow;
17728 use std::io::{Read, Seek};
17729
17730 use common::{url::Params, ToParts};
17731 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17732
17733 let mut dd = common::DefaultDelegate;
17734 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17735 dlg.begin(common::MethodInfo {
17736 id: "sql.users.delete",
17737 http_method: hyper::Method::DELETE,
17738 });
17739
17740 for &field in ["alt", "project", "instance", "name", "host"].iter() {
17741 if self._additional_params.contains_key(field) {
17742 dlg.finished(false);
17743 return Err(common::Error::FieldClash(field));
17744 }
17745 }
17746
17747 let mut params = Params::with_capacity(6 + self._additional_params.len());
17748 params.push("project", self._project);
17749 params.push("instance", self._instance);
17750 if let Some(value) = self._name.as_ref() {
17751 params.push("name", value);
17752 }
17753 if let Some(value) = self._host.as_ref() {
17754 params.push("host", value);
17755 }
17756
17757 params.extend(self._additional_params.iter());
17758
17759 params.push("alt", "json");
17760 let mut url = self.hub._base_url.clone()
17761 + "sql/v1beta4/projects/{project}/instances/{instance}/users";
17762 if self._scopes.is_empty() {
17763 self._scopes
17764 .insert(Scope::CloudPlatform.as_ref().to_string());
17765 }
17766
17767 #[allow(clippy::single_element_loop)]
17768 for &(find_this, param_name) in
17769 [("{project}", "project"), ("{instance}", "instance")].iter()
17770 {
17771 url = params.uri_replacement(url, param_name, find_this, false);
17772 }
17773 {
17774 let to_remove = ["instance", "project"];
17775 params.remove_params(&to_remove);
17776 }
17777
17778 let url = params.parse_with_url(&url);
17779
17780 loop {
17781 let token = match self
17782 .hub
17783 .auth
17784 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17785 .await
17786 {
17787 Ok(token) => token,
17788 Err(e) => match dlg.token(e) {
17789 Ok(token) => token,
17790 Err(e) => {
17791 dlg.finished(false);
17792 return Err(common::Error::MissingToken(e));
17793 }
17794 },
17795 };
17796 let mut req_result = {
17797 let client = &self.hub.client;
17798 dlg.pre_request();
17799 let mut req_builder = hyper::Request::builder()
17800 .method(hyper::Method::DELETE)
17801 .uri(url.as_str())
17802 .header(USER_AGENT, self.hub._user_agent.clone());
17803
17804 if let Some(token) = token.as_ref() {
17805 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17806 }
17807
17808 let request = req_builder
17809 .header(CONTENT_LENGTH, 0_u64)
17810 .body(common::to_body::<String>(None));
17811
17812 client.request(request.unwrap()).await
17813 };
17814
17815 match req_result {
17816 Err(err) => {
17817 if let common::Retry::After(d) = dlg.http_error(&err) {
17818 sleep(d).await;
17819 continue;
17820 }
17821 dlg.finished(false);
17822 return Err(common::Error::HttpError(err));
17823 }
17824 Ok(res) => {
17825 let (mut parts, body) = res.into_parts();
17826 let mut body = common::Body::new(body);
17827 if !parts.status.is_success() {
17828 let bytes = common::to_bytes(body).await.unwrap_or_default();
17829 let error = serde_json::from_str(&common::to_string(&bytes));
17830 let response = common::to_response(parts, bytes.into());
17831
17832 if let common::Retry::After(d) =
17833 dlg.http_failure(&response, error.as_ref().ok())
17834 {
17835 sleep(d).await;
17836 continue;
17837 }
17838
17839 dlg.finished(false);
17840
17841 return Err(match error {
17842 Ok(value) => common::Error::BadRequest(value),
17843 _ => common::Error::Failure(response),
17844 });
17845 }
17846 let response = {
17847 let bytes = common::to_bytes(body).await.unwrap_or_default();
17848 let encoded = common::to_string(&bytes);
17849 match serde_json::from_str(&encoded) {
17850 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17851 Err(error) => {
17852 dlg.response_json_decode_error(&encoded, &error);
17853 return Err(common::Error::JsonDecodeError(
17854 encoded.to_string(),
17855 error,
17856 ));
17857 }
17858 }
17859 };
17860
17861 dlg.finished(true);
17862 return Ok(response);
17863 }
17864 }
17865 }
17866 }
17867
17868 /// Project ID of the project that contains the instance.
17869 ///
17870 /// Sets the *project* path property to the given value.
17871 ///
17872 /// Even though the property as already been set when instantiating this call,
17873 /// we provide this method for API completeness.
17874 pub fn project(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
17875 self._project = new_value.to_string();
17876 self
17877 }
17878 /// Database instance ID. This does not include the project ID.
17879 ///
17880 /// Sets the *instance* path property to the given value.
17881 ///
17882 /// Even though the property as already been set when instantiating this call,
17883 /// we provide this method for API completeness.
17884 pub fn instance(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
17885 self._instance = new_value.to_string();
17886 self
17887 }
17888 /// Name of the user in the instance.
17889 ///
17890 /// Sets the *name* query property to the given value.
17891 pub fn name(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
17892 self._name = Some(new_value.to_string());
17893 self
17894 }
17895 /// Host of the user in the instance.
17896 ///
17897 /// Sets the *host* query property to the given value.
17898 pub fn host(mut self, new_value: &str) -> UserDeleteCall<'a, C> {
17899 self._host = Some(new_value.to_string());
17900 self
17901 }
17902 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17903 /// while executing the actual API request.
17904 ///
17905 /// ````text
17906 /// It should be used to handle progress information, and to implement a certain level of resilience.
17907 /// ````
17908 ///
17909 /// Sets the *delegate* property to the given value.
17910 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserDeleteCall<'a, C> {
17911 self._delegate = Some(new_value);
17912 self
17913 }
17914
17915 /// Set any additional parameter of the query string used in the request.
17916 /// It should be used to set parameters which are not yet available through their own
17917 /// setters.
17918 ///
17919 /// Please note that this method must not be used to set any of the known parameters
17920 /// which have their own setter method. If done anyway, the request will fail.
17921 ///
17922 /// # Additional Parameters
17923 ///
17924 /// * *$.xgafv* (query-string) - V1 error format.
17925 /// * *access_token* (query-string) - OAuth access token.
17926 /// * *alt* (query-string) - Data format for response.
17927 /// * *callback* (query-string) - JSONP
17928 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17929 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17930 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17931 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17932 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17933 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17934 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17935 pub fn param<T>(mut self, name: T, value: T) -> UserDeleteCall<'a, C>
17936 where
17937 T: AsRef<str>,
17938 {
17939 self._additional_params
17940 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17941 self
17942 }
17943
17944 /// Identifies the authorization scope for the method you are building.
17945 ///
17946 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17947 /// [`Scope::CloudPlatform`].
17948 ///
17949 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17950 /// tokens for more than one scope.
17951 ///
17952 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17953 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17954 /// sufficient, a read-write scope will do as well.
17955 pub fn add_scope<St>(mut self, scope: St) -> UserDeleteCall<'a, C>
17956 where
17957 St: AsRef<str>,
17958 {
17959 self._scopes.insert(String::from(scope.as_ref()));
17960 self
17961 }
17962 /// Identifies the authorization scope(s) for the method you are building.
17963 ///
17964 /// See [`Self::add_scope()`] for details.
17965 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDeleteCall<'a, C>
17966 where
17967 I: IntoIterator<Item = St>,
17968 St: AsRef<str>,
17969 {
17970 self._scopes
17971 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17972 self
17973 }
17974
17975 /// Removes all scopes, and no default scope will be used either.
17976 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17977 /// for details).
17978 pub fn clear_scopes(mut self) -> UserDeleteCall<'a, C> {
17979 self._scopes.clear();
17980 self
17981 }
17982}
17983
17984/// Creates a new user in a Cloud SQL instance.
17985///
17986/// A builder for the *insert* method supported by a *user* resource.
17987/// It is not used directly, but through a [`UserMethods`] instance.
17988///
17989/// # Example
17990///
17991/// Instantiate a resource method builder
17992///
17993/// ```test_harness,no_run
17994/// # extern crate hyper;
17995/// # extern crate hyper_rustls;
17996/// # extern crate google_sql1_beta4 as sql1_beta4;
17997/// use sql1_beta4::api::User;
17998/// # async fn dox() {
17999/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18000///
18001/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18002/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18003/// # secret,
18004/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18005/// # ).build().await.unwrap();
18006///
18007/// # let client = hyper_util::client::legacy::Client::builder(
18008/// # hyper_util::rt::TokioExecutor::new()
18009/// # )
18010/// # .build(
18011/// # hyper_rustls::HttpsConnectorBuilder::new()
18012/// # .with_native_roots()
18013/// # .unwrap()
18014/// # .https_or_http()
18015/// # .enable_http1()
18016/// # .build()
18017/// # );
18018/// # let mut hub = SQLAdmin::new(client, auth);
18019/// // As the method needs a request, you would usually fill it with the desired information
18020/// // into the respective structure. Some of the parts shown here might not be applicable !
18021/// // Values shown here are possibly random and not representative !
18022/// let mut req = User::default();
18023///
18024/// // You can configure optional parameters by calling the respective setters at will, and
18025/// // execute the final call using `doit()`.
18026/// // Values shown here are possibly random and not representative !
18027/// let result = hub.users().insert(req, "project", "instance")
18028/// .doit().await;
18029/// # }
18030/// ```
18031pub struct UserInsertCall<'a, C>
18032where
18033 C: 'a,
18034{
18035 hub: &'a SQLAdmin<C>,
18036 _request: User,
18037 _project: String,
18038 _instance: String,
18039 _delegate: Option<&'a mut dyn common::Delegate>,
18040 _additional_params: HashMap<String, String>,
18041 _scopes: BTreeSet<String>,
18042}
18043
18044impl<'a, C> common::CallBuilder for UserInsertCall<'a, C> {}
18045
18046impl<'a, C> UserInsertCall<'a, C>
18047where
18048 C: common::Connector,
18049{
18050 /// Perform the operation you have build so far.
18051 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18052 use std::borrow::Cow;
18053 use std::io::{Read, Seek};
18054
18055 use common::{url::Params, ToParts};
18056 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18057
18058 let mut dd = common::DefaultDelegate;
18059 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18060 dlg.begin(common::MethodInfo {
18061 id: "sql.users.insert",
18062 http_method: hyper::Method::POST,
18063 });
18064
18065 for &field in ["alt", "project", "instance"].iter() {
18066 if self._additional_params.contains_key(field) {
18067 dlg.finished(false);
18068 return Err(common::Error::FieldClash(field));
18069 }
18070 }
18071
18072 let mut params = Params::with_capacity(5 + self._additional_params.len());
18073 params.push("project", self._project);
18074 params.push("instance", self._instance);
18075
18076 params.extend(self._additional_params.iter());
18077
18078 params.push("alt", "json");
18079 let mut url = self.hub._base_url.clone()
18080 + "sql/v1beta4/projects/{project}/instances/{instance}/users";
18081 if self._scopes.is_empty() {
18082 self._scopes
18083 .insert(Scope::CloudPlatform.as_ref().to_string());
18084 }
18085
18086 #[allow(clippy::single_element_loop)]
18087 for &(find_this, param_name) in
18088 [("{project}", "project"), ("{instance}", "instance")].iter()
18089 {
18090 url = params.uri_replacement(url, param_name, find_this, false);
18091 }
18092 {
18093 let to_remove = ["instance", "project"];
18094 params.remove_params(&to_remove);
18095 }
18096
18097 let url = params.parse_with_url(&url);
18098
18099 let mut json_mime_type = mime::APPLICATION_JSON;
18100 let mut request_value_reader = {
18101 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18102 common::remove_json_null_values(&mut value);
18103 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18104 serde_json::to_writer(&mut dst, &value).unwrap();
18105 dst
18106 };
18107 let request_size = request_value_reader
18108 .seek(std::io::SeekFrom::End(0))
18109 .unwrap();
18110 request_value_reader
18111 .seek(std::io::SeekFrom::Start(0))
18112 .unwrap();
18113
18114 loop {
18115 let token = match self
18116 .hub
18117 .auth
18118 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18119 .await
18120 {
18121 Ok(token) => token,
18122 Err(e) => match dlg.token(e) {
18123 Ok(token) => token,
18124 Err(e) => {
18125 dlg.finished(false);
18126 return Err(common::Error::MissingToken(e));
18127 }
18128 },
18129 };
18130 request_value_reader
18131 .seek(std::io::SeekFrom::Start(0))
18132 .unwrap();
18133 let mut req_result = {
18134 let client = &self.hub.client;
18135 dlg.pre_request();
18136 let mut req_builder = hyper::Request::builder()
18137 .method(hyper::Method::POST)
18138 .uri(url.as_str())
18139 .header(USER_AGENT, self.hub._user_agent.clone());
18140
18141 if let Some(token) = token.as_ref() {
18142 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18143 }
18144
18145 let request = req_builder
18146 .header(CONTENT_TYPE, json_mime_type.to_string())
18147 .header(CONTENT_LENGTH, request_size as u64)
18148 .body(common::to_body(
18149 request_value_reader.get_ref().clone().into(),
18150 ));
18151
18152 client.request(request.unwrap()).await
18153 };
18154
18155 match req_result {
18156 Err(err) => {
18157 if let common::Retry::After(d) = dlg.http_error(&err) {
18158 sleep(d).await;
18159 continue;
18160 }
18161 dlg.finished(false);
18162 return Err(common::Error::HttpError(err));
18163 }
18164 Ok(res) => {
18165 let (mut parts, body) = res.into_parts();
18166 let mut body = common::Body::new(body);
18167 if !parts.status.is_success() {
18168 let bytes = common::to_bytes(body).await.unwrap_or_default();
18169 let error = serde_json::from_str(&common::to_string(&bytes));
18170 let response = common::to_response(parts, bytes.into());
18171
18172 if let common::Retry::After(d) =
18173 dlg.http_failure(&response, error.as_ref().ok())
18174 {
18175 sleep(d).await;
18176 continue;
18177 }
18178
18179 dlg.finished(false);
18180
18181 return Err(match error {
18182 Ok(value) => common::Error::BadRequest(value),
18183 _ => common::Error::Failure(response),
18184 });
18185 }
18186 let response = {
18187 let bytes = common::to_bytes(body).await.unwrap_or_default();
18188 let encoded = common::to_string(&bytes);
18189 match serde_json::from_str(&encoded) {
18190 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18191 Err(error) => {
18192 dlg.response_json_decode_error(&encoded, &error);
18193 return Err(common::Error::JsonDecodeError(
18194 encoded.to_string(),
18195 error,
18196 ));
18197 }
18198 }
18199 };
18200
18201 dlg.finished(true);
18202 return Ok(response);
18203 }
18204 }
18205 }
18206 }
18207
18208 ///
18209 /// Sets the *request* property to the given value.
18210 ///
18211 /// Even though the property as already been set when instantiating this call,
18212 /// we provide this method for API completeness.
18213 pub fn request(mut self, new_value: User) -> UserInsertCall<'a, C> {
18214 self._request = new_value;
18215 self
18216 }
18217 /// Project ID of the project that contains the instance.
18218 ///
18219 /// Sets the *project* path property to the given value.
18220 ///
18221 /// Even though the property as already been set when instantiating this call,
18222 /// we provide this method for API completeness.
18223 pub fn project(mut self, new_value: &str) -> UserInsertCall<'a, C> {
18224 self._project = new_value.to_string();
18225 self
18226 }
18227 /// Database instance ID. This does not include the project ID.
18228 ///
18229 /// Sets the *instance* path property to the given value.
18230 ///
18231 /// Even though the property as already been set when instantiating this call,
18232 /// we provide this method for API completeness.
18233 pub fn instance(mut self, new_value: &str) -> UserInsertCall<'a, C> {
18234 self._instance = new_value.to_string();
18235 self
18236 }
18237 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18238 /// while executing the actual API request.
18239 ///
18240 /// ````text
18241 /// It should be used to handle progress information, and to implement a certain level of resilience.
18242 /// ````
18243 ///
18244 /// Sets the *delegate* property to the given value.
18245 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserInsertCall<'a, C> {
18246 self._delegate = Some(new_value);
18247 self
18248 }
18249
18250 /// Set any additional parameter of the query string used in the request.
18251 /// It should be used to set parameters which are not yet available through their own
18252 /// setters.
18253 ///
18254 /// Please note that this method must not be used to set any of the known parameters
18255 /// which have their own setter method. If done anyway, the request will fail.
18256 ///
18257 /// # Additional Parameters
18258 ///
18259 /// * *$.xgafv* (query-string) - V1 error format.
18260 /// * *access_token* (query-string) - OAuth access token.
18261 /// * *alt* (query-string) - Data format for response.
18262 /// * *callback* (query-string) - JSONP
18263 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18264 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18265 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18266 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18267 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18268 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18269 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18270 pub fn param<T>(mut self, name: T, value: T) -> UserInsertCall<'a, C>
18271 where
18272 T: AsRef<str>,
18273 {
18274 self._additional_params
18275 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18276 self
18277 }
18278
18279 /// Identifies the authorization scope for the method you are building.
18280 ///
18281 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18282 /// [`Scope::CloudPlatform`].
18283 ///
18284 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18285 /// tokens for more than one scope.
18286 ///
18287 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18288 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18289 /// sufficient, a read-write scope will do as well.
18290 pub fn add_scope<St>(mut self, scope: St) -> UserInsertCall<'a, C>
18291 where
18292 St: AsRef<str>,
18293 {
18294 self._scopes.insert(String::from(scope.as_ref()));
18295 self
18296 }
18297 /// Identifies the authorization scope(s) for the method you are building.
18298 ///
18299 /// See [`Self::add_scope()`] for details.
18300 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserInsertCall<'a, C>
18301 where
18302 I: IntoIterator<Item = St>,
18303 St: AsRef<str>,
18304 {
18305 self._scopes
18306 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18307 self
18308 }
18309
18310 /// Removes all scopes, and no default scope will be used either.
18311 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18312 /// for details).
18313 pub fn clear_scopes(mut self) -> UserInsertCall<'a, C> {
18314 self._scopes.clear();
18315 self
18316 }
18317}
18318
18319/// Lists users in the specified Cloud SQL instance.
18320///
18321/// A builder for the *list* method supported by a *user* resource.
18322/// It is not used directly, but through a [`UserMethods`] instance.
18323///
18324/// # Example
18325///
18326/// Instantiate a resource method builder
18327///
18328/// ```test_harness,no_run
18329/// # extern crate hyper;
18330/// # extern crate hyper_rustls;
18331/// # extern crate google_sql1_beta4 as sql1_beta4;
18332/// # async fn dox() {
18333/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18334///
18335/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18337/// # secret,
18338/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18339/// # ).build().await.unwrap();
18340///
18341/// # let client = hyper_util::client::legacy::Client::builder(
18342/// # hyper_util::rt::TokioExecutor::new()
18343/// # )
18344/// # .build(
18345/// # hyper_rustls::HttpsConnectorBuilder::new()
18346/// # .with_native_roots()
18347/// # .unwrap()
18348/// # .https_or_http()
18349/// # .enable_http1()
18350/// # .build()
18351/// # );
18352/// # let mut hub = SQLAdmin::new(client, auth);
18353/// // You can configure optional parameters by calling the respective setters at will, and
18354/// // execute the final call using `doit()`.
18355/// // Values shown here are possibly random and not representative !
18356/// let result = hub.users().list("project", "instance")
18357/// .doit().await;
18358/// # }
18359/// ```
18360pub struct UserListCall<'a, C>
18361where
18362 C: 'a,
18363{
18364 hub: &'a SQLAdmin<C>,
18365 _project: String,
18366 _instance: String,
18367 _delegate: Option<&'a mut dyn common::Delegate>,
18368 _additional_params: HashMap<String, String>,
18369 _scopes: BTreeSet<String>,
18370}
18371
18372impl<'a, C> common::CallBuilder for UserListCall<'a, C> {}
18373
18374impl<'a, C> UserListCall<'a, C>
18375where
18376 C: common::Connector,
18377{
18378 /// Perform the operation you have build so far.
18379 pub async fn doit(mut self) -> common::Result<(common::Response, UsersListResponse)> {
18380 use std::borrow::Cow;
18381 use std::io::{Read, Seek};
18382
18383 use common::{url::Params, ToParts};
18384 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18385
18386 let mut dd = common::DefaultDelegate;
18387 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18388 dlg.begin(common::MethodInfo {
18389 id: "sql.users.list",
18390 http_method: hyper::Method::GET,
18391 });
18392
18393 for &field in ["alt", "project", "instance"].iter() {
18394 if self._additional_params.contains_key(field) {
18395 dlg.finished(false);
18396 return Err(common::Error::FieldClash(field));
18397 }
18398 }
18399
18400 let mut params = Params::with_capacity(4 + self._additional_params.len());
18401 params.push("project", self._project);
18402 params.push("instance", self._instance);
18403
18404 params.extend(self._additional_params.iter());
18405
18406 params.push("alt", "json");
18407 let mut url = self.hub._base_url.clone()
18408 + "sql/v1beta4/projects/{project}/instances/{instance}/users";
18409 if self._scopes.is_empty() {
18410 self._scopes
18411 .insert(Scope::CloudPlatform.as_ref().to_string());
18412 }
18413
18414 #[allow(clippy::single_element_loop)]
18415 for &(find_this, param_name) in
18416 [("{project}", "project"), ("{instance}", "instance")].iter()
18417 {
18418 url = params.uri_replacement(url, param_name, find_this, false);
18419 }
18420 {
18421 let to_remove = ["instance", "project"];
18422 params.remove_params(&to_remove);
18423 }
18424
18425 let url = params.parse_with_url(&url);
18426
18427 loop {
18428 let token = match self
18429 .hub
18430 .auth
18431 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18432 .await
18433 {
18434 Ok(token) => token,
18435 Err(e) => match dlg.token(e) {
18436 Ok(token) => token,
18437 Err(e) => {
18438 dlg.finished(false);
18439 return Err(common::Error::MissingToken(e));
18440 }
18441 },
18442 };
18443 let mut req_result = {
18444 let client = &self.hub.client;
18445 dlg.pre_request();
18446 let mut req_builder = hyper::Request::builder()
18447 .method(hyper::Method::GET)
18448 .uri(url.as_str())
18449 .header(USER_AGENT, self.hub._user_agent.clone());
18450
18451 if let Some(token) = token.as_ref() {
18452 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18453 }
18454
18455 let request = req_builder
18456 .header(CONTENT_LENGTH, 0_u64)
18457 .body(common::to_body::<String>(None));
18458
18459 client.request(request.unwrap()).await
18460 };
18461
18462 match req_result {
18463 Err(err) => {
18464 if let common::Retry::After(d) = dlg.http_error(&err) {
18465 sleep(d).await;
18466 continue;
18467 }
18468 dlg.finished(false);
18469 return Err(common::Error::HttpError(err));
18470 }
18471 Ok(res) => {
18472 let (mut parts, body) = res.into_parts();
18473 let mut body = common::Body::new(body);
18474 if !parts.status.is_success() {
18475 let bytes = common::to_bytes(body).await.unwrap_or_default();
18476 let error = serde_json::from_str(&common::to_string(&bytes));
18477 let response = common::to_response(parts, bytes.into());
18478
18479 if let common::Retry::After(d) =
18480 dlg.http_failure(&response, error.as_ref().ok())
18481 {
18482 sleep(d).await;
18483 continue;
18484 }
18485
18486 dlg.finished(false);
18487
18488 return Err(match error {
18489 Ok(value) => common::Error::BadRequest(value),
18490 _ => common::Error::Failure(response),
18491 });
18492 }
18493 let response = {
18494 let bytes = common::to_bytes(body).await.unwrap_or_default();
18495 let encoded = common::to_string(&bytes);
18496 match serde_json::from_str(&encoded) {
18497 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18498 Err(error) => {
18499 dlg.response_json_decode_error(&encoded, &error);
18500 return Err(common::Error::JsonDecodeError(
18501 encoded.to_string(),
18502 error,
18503 ));
18504 }
18505 }
18506 };
18507
18508 dlg.finished(true);
18509 return Ok(response);
18510 }
18511 }
18512 }
18513 }
18514
18515 /// Project ID of the project that contains the instance.
18516 ///
18517 /// Sets the *project* path property to the given value.
18518 ///
18519 /// Even though the property as already been set when instantiating this call,
18520 /// we provide this method for API completeness.
18521 pub fn project(mut self, new_value: &str) -> UserListCall<'a, C> {
18522 self._project = new_value.to_string();
18523 self
18524 }
18525 /// Database instance ID. This does not include the project ID.
18526 ///
18527 /// Sets the *instance* path property to the given value.
18528 ///
18529 /// Even though the property as already been set when instantiating this call,
18530 /// we provide this method for API completeness.
18531 pub fn instance(mut self, new_value: &str) -> UserListCall<'a, C> {
18532 self._instance = new_value.to_string();
18533 self
18534 }
18535 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18536 /// while executing the actual API request.
18537 ///
18538 /// ````text
18539 /// It should be used to handle progress information, and to implement a certain level of resilience.
18540 /// ````
18541 ///
18542 /// Sets the *delegate* property to the given value.
18543 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserListCall<'a, C> {
18544 self._delegate = Some(new_value);
18545 self
18546 }
18547
18548 /// Set any additional parameter of the query string used in the request.
18549 /// It should be used to set parameters which are not yet available through their own
18550 /// setters.
18551 ///
18552 /// Please note that this method must not be used to set any of the known parameters
18553 /// which have their own setter method. If done anyway, the request will fail.
18554 ///
18555 /// # Additional Parameters
18556 ///
18557 /// * *$.xgafv* (query-string) - V1 error format.
18558 /// * *access_token* (query-string) - OAuth access token.
18559 /// * *alt* (query-string) - Data format for response.
18560 /// * *callback* (query-string) - JSONP
18561 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18562 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18563 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18564 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18565 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18566 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18567 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18568 pub fn param<T>(mut self, name: T, value: T) -> UserListCall<'a, C>
18569 where
18570 T: AsRef<str>,
18571 {
18572 self._additional_params
18573 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18574 self
18575 }
18576
18577 /// Identifies the authorization scope for the method you are building.
18578 ///
18579 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18580 /// [`Scope::CloudPlatform`].
18581 ///
18582 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18583 /// tokens for more than one scope.
18584 ///
18585 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18586 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18587 /// sufficient, a read-write scope will do as well.
18588 pub fn add_scope<St>(mut self, scope: St) -> UserListCall<'a, C>
18589 where
18590 St: AsRef<str>,
18591 {
18592 self._scopes.insert(String::from(scope.as_ref()));
18593 self
18594 }
18595 /// Identifies the authorization scope(s) for the method you are building.
18596 ///
18597 /// See [`Self::add_scope()`] for details.
18598 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserListCall<'a, C>
18599 where
18600 I: IntoIterator<Item = St>,
18601 St: AsRef<str>,
18602 {
18603 self._scopes
18604 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18605 self
18606 }
18607
18608 /// Removes all scopes, and no default scope will be used either.
18609 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18610 /// for details).
18611 pub fn clear_scopes(mut self) -> UserListCall<'a, C> {
18612 self._scopes.clear();
18613 self
18614 }
18615}
18616
18617/// Updates an existing user in a Cloud SQL instance.
18618///
18619/// A builder for the *update* method supported by a *user* resource.
18620/// It is not used directly, but through a [`UserMethods`] instance.
18621///
18622/// # Example
18623///
18624/// Instantiate a resource method builder
18625///
18626/// ```test_harness,no_run
18627/// # extern crate hyper;
18628/// # extern crate hyper_rustls;
18629/// # extern crate google_sql1_beta4 as sql1_beta4;
18630/// use sql1_beta4::api::User;
18631/// # async fn dox() {
18632/// # use sql1_beta4::{SQLAdmin, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18633///
18634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18635/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18636/// # secret,
18637/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18638/// # ).build().await.unwrap();
18639///
18640/// # let client = hyper_util::client::legacy::Client::builder(
18641/// # hyper_util::rt::TokioExecutor::new()
18642/// # )
18643/// # .build(
18644/// # hyper_rustls::HttpsConnectorBuilder::new()
18645/// # .with_native_roots()
18646/// # .unwrap()
18647/// # .https_or_http()
18648/// # .enable_http1()
18649/// # .build()
18650/// # );
18651/// # let mut hub = SQLAdmin::new(client, auth);
18652/// // As the method needs a request, you would usually fill it with the desired information
18653/// // into the respective structure. Some of the parts shown here might not be applicable !
18654/// // Values shown here are possibly random and not representative !
18655/// let mut req = User::default();
18656///
18657/// // You can configure optional parameters by calling the respective setters at will, and
18658/// // execute the final call using `doit()`.
18659/// // Values shown here are possibly random and not representative !
18660/// let result = hub.users().update(req, "project", "instance")
18661/// .name("nonumy")
18662/// .host("At")
18663/// .doit().await;
18664/// # }
18665/// ```
18666pub struct UserUpdateCall<'a, C>
18667where
18668 C: 'a,
18669{
18670 hub: &'a SQLAdmin<C>,
18671 _request: User,
18672 _project: String,
18673 _instance: String,
18674 _name: Option<String>,
18675 _host: Option<String>,
18676 _delegate: Option<&'a mut dyn common::Delegate>,
18677 _additional_params: HashMap<String, String>,
18678 _scopes: BTreeSet<String>,
18679}
18680
18681impl<'a, C> common::CallBuilder for UserUpdateCall<'a, C> {}
18682
18683impl<'a, C> UserUpdateCall<'a, C>
18684where
18685 C: common::Connector,
18686{
18687 /// Perform the operation you have build so far.
18688 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18689 use std::borrow::Cow;
18690 use std::io::{Read, Seek};
18691
18692 use common::{url::Params, ToParts};
18693 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18694
18695 let mut dd = common::DefaultDelegate;
18696 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18697 dlg.begin(common::MethodInfo {
18698 id: "sql.users.update",
18699 http_method: hyper::Method::PUT,
18700 });
18701
18702 for &field in ["alt", "project", "instance", "name", "host"].iter() {
18703 if self._additional_params.contains_key(field) {
18704 dlg.finished(false);
18705 return Err(common::Error::FieldClash(field));
18706 }
18707 }
18708
18709 let mut params = Params::with_capacity(7 + self._additional_params.len());
18710 params.push("project", self._project);
18711 params.push("instance", self._instance);
18712 if let Some(value) = self._name.as_ref() {
18713 params.push("name", value);
18714 }
18715 if let Some(value) = self._host.as_ref() {
18716 params.push("host", value);
18717 }
18718
18719 params.extend(self._additional_params.iter());
18720
18721 params.push("alt", "json");
18722 let mut url = self.hub._base_url.clone()
18723 + "sql/v1beta4/projects/{project}/instances/{instance}/users";
18724 if self._scopes.is_empty() {
18725 self._scopes
18726 .insert(Scope::CloudPlatform.as_ref().to_string());
18727 }
18728
18729 #[allow(clippy::single_element_loop)]
18730 for &(find_this, param_name) in
18731 [("{project}", "project"), ("{instance}", "instance")].iter()
18732 {
18733 url = params.uri_replacement(url, param_name, find_this, false);
18734 }
18735 {
18736 let to_remove = ["instance", "project"];
18737 params.remove_params(&to_remove);
18738 }
18739
18740 let url = params.parse_with_url(&url);
18741
18742 let mut json_mime_type = mime::APPLICATION_JSON;
18743 let mut request_value_reader = {
18744 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18745 common::remove_json_null_values(&mut value);
18746 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18747 serde_json::to_writer(&mut dst, &value).unwrap();
18748 dst
18749 };
18750 let request_size = request_value_reader
18751 .seek(std::io::SeekFrom::End(0))
18752 .unwrap();
18753 request_value_reader
18754 .seek(std::io::SeekFrom::Start(0))
18755 .unwrap();
18756
18757 loop {
18758 let token = match self
18759 .hub
18760 .auth
18761 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18762 .await
18763 {
18764 Ok(token) => token,
18765 Err(e) => match dlg.token(e) {
18766 Ok(token) => token,
18767 Err(e) => {
18768 dlg.finished(false);
18769 return Err(common::Error::MissingToken(e));
18770 }
18771 },
18772 };
18773 request_value_reader
18774 .seek(std::io::SeekFrom::Start(0))
18775 .unwrap();
18776 let mut req_result = {
18777 let client = &self.hub.client;
18778 dlg.pre_request();
18779 let mut req_builder = hyper::Request::builder()
18780 .method(hyper::Method::PUT)
18781 .uri(url.as_str())
18782 .header(USER_AGENT, self.hub._user_agent.clone());
18783
18784 if let Some(token) = token.as_ref() {
18785 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18786 }
18787
18788 let request = req_builder
18789 .header(CONTENT_TYPE, json_mime_type.to_string())
18790 .header(CONTENT_LENGTH, request_size as u64)
18791 .body(common::to_body(
18792 request_value_reader.get_ref().clone().into(),
18793 ));
18794
18795 client.request(request.unwrap()).await
18796 };
18797
18798 match req_result {
18799 Err(err) => {
18800 if let common::Retry::After(d) = dlg.http_error(&err) {
18801 sleep(d).await;
18802 continue;
18803 }
18804 dlg.finished(false);
18805 return Err(common::Error::HttpError(err));
18806 }
18807 Ok(res) => {
18808 let (mut parts, body) = res.into_parts();
18809 let mut body = common::Body::new(body);
18810 if !parts.status.is_success() {
18811 let bytes = common::to_bytes(body).await.unwrap_or_default();
18812 let error = serde_json::from_str(&common::to_string(&bytes));
18813 let response = common::to_response(parts, bytes.into());
18814
18815 if let common::Retry::After(d) =
18816 dlg.http_failure(&response, error.as_ref().ok())
18817 {
18818 sleep(d).await;
18819 continue;
18820 }
18821
18822 dlg.finished(false);
18823
18824 return Err(match error {
18825 Ok(value) => common::Error::BadRequest(value),
18826 _ => common::Error::Failure(response),
18827 });
18828 }
18829 let response = {
18830 let bytes = common::to_bytes(body).await.unwrap_or_default();
18831 let encoded = common::to_string(&bytes);
18832 match serde_json::from_str(&encoded) {
18833 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18834 Err(error) => {
18835 dlg.response_json_decode_error(&encoded, &error);
18836 return Err(common::Error::JsonDecodeError(
18837 encoded.to_string(),
18838 error,
18839 ));
18840 }
18841 }
18842 };
18843
18844 dlg.finished(true);
18845 return Ok(response);
18846 }
18847 }
18848 }
18849 }
18850
18851 ///
18852 /// Sets the *request* property to the given value.
18853 ///
18854 /// Even though the property as already been set when instantiating this call,
18855 /// we provide this method for API completeness.
18856 pub fn request(mut self, new_value: User) -> UserUpdateCall<'a, C> {
18857 self._request = new_value;
18858 self
18859 }
18860 /// Project ID of the project that contains the instance.
18861 ///
18862 /// Sets the *project* path property to the given value.
18863 ///
18864 /// Even though the property as already been set when instantiating this call,
18865 /// we provide this method for API completeness.
18866 pub fn project(mut self, new_value: &str) -> UserUpdateCall<'a, C> {
18867 self._project = new_value.to_string();
18868 self
18869 }
18870 /// Database instance ID. This does not include the project ID.
18871 ///
18872 /// Sets the *instance* path property to the given value.
18873 ///
18874 /// Even though the property as already been set when instantiating this call,
18875 /// we provide this method for API completeness.
18876 pub fn instance(mut self, new_value: &str) -> UserUpdateCall<'a, C> {
18877 self._instance = new_value.to_string();
18878 self
18879 }
18880 /// Name of the user in the instance.
18881 ///
18882 /// Sets the *name* query property to the given value.
18883 pub fn name(mut self, new_value: &str) -> UserUpdateCall<'a, C> {
18884 self._name = Some(new_value.to_string());
18885 self
18886 }
18887 /// Optional. Host of the user in the instance.
18888 ///
18889 /// Sets the *host* query property to the given value.
18890 pub fn host(mut self, new_value: &str) -> UserUpdateCall<'a, C> {
18891 self._host = Some(new_value.to_string());
18892 self
18893 }
18894 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18895 /// while executing the actual API request.
18896 ///
18897 /// ````text
18898 /// It should be used to handle progress information, and to implement a certain level of resilience.
18899 /// ````
18900 ///
18901 /// Sets the *delegate* property to the given value.
18902 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserUpdateCall<'a, C> {
18903 self._delegate = Some(new_value);
18904 self
18905 }
18906
18907 /// Set any additional parameter of the query string used in the request.
18908 /// It should be used to set parameters which are not yet available through their own
18909 /// setters.
18910 ///
18911 /// Please note that this method must not be used to set any of the known parameters
18912 /// which have their own setter method. If done anyway, the request will fail.
18913 ///
18914 /// # Additional Parameters
18915 ///
18916 /// * *$.xgafv* (query-string) - V1 error format.
18917 /// * *access_token* (query-string) - OAuth access token.
18918 /// * *alt* (query-string) - Data format for response.
18919 /// * *callback* (query-string) - JSONP
18920 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18921 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18922 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18923 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18924 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18925 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18926 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18927 pub fn param<T>(mut self, name: T, value: T) -> UserUpdateCall<'a, C>
18928 where
18929 T: AsRef<str>,
18930 {
18931 self._additional_params
18932 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18933 self
18934 }
18935
18936 /// Identifies the authorization scope for the method you are building.
18937 ///
18938 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18939 /// [`Scope::CloudPlatform`].
18940 ///
18941 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18942 /// tokens for more than one scope.
18943 ///
18944 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18945 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18946 /// sufficient, a read-write scope will do as well.
18947 pub fn add_scope<St>(mut self, scope: St) -> UserUpdateCall<'a, C>
18948 where
18949 St: AsRef<str>,
18950 {
18951 self._scopes.insert(String::from(scope.as_ref()));
18952 self
18953 }
18954 /// Identifies the authorization scope(s) for the method you are building.
18955 ///
18956 /// See [`Self::add_scope()`] for details.
18957 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserUpdateCall<'a, C>
18958 where
18959 I: IntoIterator<Item = St>,
18960 St: AsRef<str>,
18961 {
18962 self._scopes
18963 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18964 self
18965 }
18966
18967 /// Removes all scopes, and no default scope will be used either.
18968 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18969 /// for details).
18970 pub fn clear_scopes(mut self) -> UserUpdateCall<'a, C> {
18971 self._scopes.clear();
18972 self
18973 }
18974}