google_cloud_sql_v1/client.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19use crate::Result;
20
21/// Implements a client for the Cloud SQL Admin API.
22///
23/// # Example
24/// ```
25/// # tokio_test::block_on(async {
26/// # use google_cloud_sql_v1::client::SqlBackupRunsService;
27/// let client = SqlBackupRunsService::builder().build().await?;
28/// // use `client` to make requests to the Cloud SQL Admin API.
29/// # gax::Result::<()>::Ok(()) });
30/// ```
31///
32/// # Service Description
33///
34/// Service for managing database backups.
35///
36/// # Configuration
37///
38/// To configure `SqlBackupRunsService` use the `with_*` methods in the type returned
39/// by [builder()][SqlBackupRunsService::builder]. The default configuration should
40/// work for most applications. Common configuration changes include
41///
42/// * [with_endpoint()]: by default this client uses the global default endpoint
43/// (`https://sqladmin.googleapis.com`). Applications using regional
44/// endpoints or running in restricted networks (e.g. a network configured
45// with [Private Google Access with VPC Service Controls]) may want to
46/// override this default.
47/// * [with_credentials()]: by default this client uses
48/// [Application Default Credentials]. Applications using custom
49/// authentication may need to override this default.
50///
51/// [with_endpoint()]: super::builder::sql_backup_runs_service::ClientBuilder::with_endpoint
52/// [with_credentials()]: super::builder::sql_backup_runs_service::ClientBuilder::credentials
53/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
54/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
55///
56/// # Pooling and Cloning
57///
58/// `SqlBackupRunsService` holds a connection pool internally, it is advised to
59/// create one and the reuse it. You do not need to wrap `SqlBackupRunsService` in
60/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
61/// already uses an `Arc` internally.
62#[derive(Clone, Debug)]
63pub struct SqlBackupRunsService {
64 inner: std::sync::Arc<dyn super::stub::dynamic::SqlBackupRunsService>,
65}
66
67impl SqlBackupRunsService {
68 /// Returns a builder for [SqlBackupRunsService].
69 ///
70 /// ```
71 /// # tokio_test::block_on(async {
72 /// # use google_cloud_sql_v1::client::SqlBackupRunsService;
73 /// let client = SqlBackupRunsService::builder().build().await?;
74 /// # gax::Result::<()>::Ok(()) });
75 /// ```
76 pub fn builder() -> super::builder::sql_backup_runs_service::ClientBuilder {
77 gax::client_builder::internal::new_builder(
78 super::builder::sql_backup_runs_service::client::Factory,
79 )
80 }
81
82 /// Creates a new client from the provided stub.
83 ///
84 /// The most common case for calling this function is in tests mocking the
85 /// client's behavior.
86 pub fn from_stub<T>(stub: T) -> Self
87 where
88 T: super::stub::SqlBackupRunsService + 'static,
89 {
90 Self {
91 inner: std::sync::Arc::new(stub),
92 }
93 }
94
95 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
96 let inner = Self::build_inner(config).await?;
97 Ok(Self { inner })
98 }
99
100 async fn build_inner(
101 conf: gaxi::options::ClientConfig,
102 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlBackupRunsService>> {
103 if gaxi::options::tracing_enabled(&conf) {
104 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
105 }
106 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
107 }
108
109 async fn build_transport(
110 conf: gaxi::options::ClientConfig,
111 ) -> Result<impl super::stub::SqlBackupRunsService> {
112 super::transport::SqlBackupRunsService::new(conf).await
113 }
114
115 async fn build_with_tracing(
116 conf: gaxi::options::ClientConfig,
117 ) -> Result<impl super::stub::SqlBackupRunsService> {
118 Self::build_transport(conf)
119 .await
120 .map(super::tracing::SqlBackupRunsService::new)
121 }
122
123 /// Deletes the backup taken by a backup run.
124 pub fn delete(&self) -> super::builder::sql_backup_runs_service::Delete {
125 super::builder::sql_backup_runs_service::Delete::new(self.inner.clone())
126 }
127
128 /// Retrieves a resource containing information about a backup run.
129 pub fn get(&self) -> super::builder::sql_backup_runs_service::Get {
130 super::builder::sql_backup_runs_service::Get::new(self.inner.clone())
131 }
132
133 /// Creates a new backup run on demand.
134 pub fn insert(&self) -> super::builder::sql_backup_runs_service::Insert {
135 super::builder::sql_backup_runs_service::Insert::new(self.inner.clone())
136 }
137
138 /// Lists all backup runs associated with the project or a given instance
139 /// and configuration in the reverse chronological order of the backup
140 /// initiation time.
141 pub fn list(&self) -> super::builder::sql_backup_runs_service::List {
142 super::builder::sql_backup_runs_service::List::new(self.inner.clone())
143 }
144}
145
146/// Implements a client for the Cloud SQL Admin API.
147///
148/// # Example
149/// ```
150/// # tokio_test::block_on(async {
151/// # use google_cloud_sql_v1::client::SqlConnectService;
152/// let client = SqlConnectService::builder().build().await?;
153/// // use `client` to make requests to the Cloud SQL Admin API.
154/// # gax::Result::<()>::Ok(()) });
155/// ```
156///
157/// # Service Description
158///
159/// Cloud SQL connect service.
160///
161/// # Configuration
162///
163/// To configure `SqlConnectService` use the `with_*` methods in the type returned
164/// by [builder()][SqlConnectService::builder]. The default configuration should
165/// work for most applications. Common configuration changes include
166///
167/// * [with_endpoint()]: by default this client uses the global default endpoint
168/// (`https://sqladmin.googleapis.com`). Applications using regional
169/// endpoints or running in restricted networks (e.g. a network configured
170// with [Private Google Access with VPC Service Controls]) may want to
171/// override this default.
172/// * [with_credentials()]: by default this client uses
173/// [Application Default Credentials]. Applications using custom
174/// authentication may need to override this default.
175///
176/// [with_endpoint()]: super::builder::sql_connect_service::ClientBuilder::with_endpoint
177/// [with_credentials()]: super::builder::sql_connect_service::ClientBuilder::credentials
178/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
179/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
180///
181/// # Pooling and Cloning
182///
183/// `SqlConnectService` holds a connection pool internally, it is advised to
184/// create one and the reuse it. You do not need to wrap `SqlConnectService` in
185/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
186/// already uses an `Arc` internally.
187#[derive(Clone, Debug)]
188pub struct SqlConnectService {
189 inner: std::sync::Arc<dyn super::stub::dynamic::SqlConnectService>,
190}
191
192impl SqlConnectService {
193 /// Returns a builder for [SqlConnectService].
194 ///
195 /// ```
196 /// # tokio_test::block_on(async {
197 /// # use google_cloud_sql_v1::client::SqlConnectService;
198 /// let client = SqlConnectService::builder().build().await?;
199 /// # gax::Result::<()>::Ok(()) });
200 /// ```
201 pub fn builder() -> super::builder::sql_connect_service::ClientBuilder {
202 gax::client_builder::internal::new_builder(
203 super::builder::sql_connect_service::client::Factory,
204 )
205 }
206
207 /// Creates a new client from the provided stub.
208 ///
209 /// The most common case for calling this function is in tests mocking the
210 /// client's behavior.
211 pub fn from_stub<T>(stub: T) -> Self
212 where
213 T: super::stub::SqlConnectService + 'static,
214 {
215 Self {
216 inner: std::sync::Arc::new(stub),
217 }
218 }
219
220 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
221 let inner = Self::build_inner(config).await?;
222 Ok(Self { inner })
223 }
224
225 async fn build_inner(
226 conf: gaxi::options::ClientConfig,
227 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlConnectService>> {
228 if gaxi::options::tracing_enabled(&conf) {
229 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
230 }
231 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
232 }
233
234 async fn build_transport(
235 conf: gaxi::options::ClientConfig,
236 ) -> Result<impl super::stub::SqlConnectService> {
237 super::transport::SqlConnectService::new(conf).await
238 }
239
240 async fn build_with_tracing(
241 conf: gaxi::options::ClientConfig,
242 ) -> Result<impl super::stub::SqlConnectService> {
243 Self::build_transport(conf)
244 .await
245 .map(super::tracing::SqlConnectService::new)
246 }
247
248 /// Retrieves connect settings about a Cloud SQL instance.
249 pub fn get_connect_settings(&self) -> super::builder::sql_connect_service::GetConnectSettings {
250 super::builder::sql_connect_service::GetConnectSettings::new(self.inner.clone())
251 }
252
253 /// Generates a short-lived X509 certificate containing the provided public key
254 /// and signed by a private key specific to the target instance. Users may use
255 /// the certificate to authenticate as themselves when connecting to the
256 /// database.
257 pub fn generate_ephemeral_cert(
258 &self,
259 ) -> super::builder::sql_connect_service::GenerateEphemeralCert {
260 super::builder::sql_connect_service::GenerateEphemeralCert::new(self.inner.clone())
261 }
262}
263
264/// Implements a client for the Cloud SQL Admin API.
265///
266/// # Example
267/// ```
268/// # tokio_test::block_on(async {
269/// # use google_cloud_sql_v1::client::SqlDatabasesService;
270/// let client = SqlDatabasesService::builder().build().await?;
271/// // use `client` to make requests to the Cloud SQL Admin API.
272/// # gax::Result::<()>::Ok(()) });
273/// ```
274///
275/// # Service Description
276///
277/// Service to manage databases.
278///
279/// # Configuration
280///
281/// To configure `SqlDatabasesService` use the `with_*` methods in the type returned
282/// by [builder()][SqlDatabasesService::builder]. The default configuration should
283/// work for most applications. Common configuration changes include
284///
285/// * [with_endpoint()]: by default this client uses the global default endpoint
286/// (`https://sqladmin.googleapis.com`). Applications using regional
287/// endpoints or running in restricted networks (e.g. a network configured
288// with [Private Google Access with VPC Service Controls]) may want to
289/// override this default.
290/// * [with_credentials()]: by default this client uses
291/// [Application Default Credentials]. Applications using custom
292/// authentication may need to override this default.
293///
294/// [with_endpoint()]: super::builder::sql_databases_service::ClientBuilder::with_endpoint
295/// [with_credentials()]: super::builder::sql_databases_service::ClientBuilder::credentials
296/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
297/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
298///
299/// # Pooling and Cloning
300///
301/// `SqlDatabasesService` holds a connection pool internally, it is advised to
302/// create one and the reuse it. You do not need to wrap `SqlDatabasesService` in
303/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
304/// already uses an `Arc` internally.
305#[derive(Clone, Debug)]
306pub struct SqlDatabasesService {
307 inner: std::sync::Arc<dyn super::stub::dynamic::SqlDatabasesService>,
308}
309
310impl SqlDatabasesService {
311 /// Returns a builder for [SqlDatabasesService].
312 ///
313 /// ```
314 /// # tokio_test::block_on(async {
315 /// # use google_cloud_sql_v1::client::SqlDatabasesService;
316 /// let client = SqlDatabasesService::builder().build().await?;
317 /// # gax::Result::<()>::Ok(()) });
318 /// ```
319 pub fn builder() -> super::builder::sql_databases_service::ClientBuilder {
320 gax::client_builder::internal::new_builder(
321 super::builder::sql_databases_service::client::Factory,
322 )
323 }
324
325 /// Creates a new client from the provided stub.
326 ///
327 /// The most common case for calling this function is in tests mocking the
328 /// client's behavior.
329 pub fn from_stub<T>(stub: T) -> Self
330 where
331 T: super::stub::SqlDatabasesService + 'static,
332 {
333 Self {
334 inner: std::sync::Arc::new(stub),
335 }
336 }
337
338 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
339 let inner = Self::build_inner(config).await?;
340 Ok(Self { inner })
341 }
342
343 async fn build_inner(
344 conf: gaxi::options::ClientConfig,
345 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlDatabasesService>> {
346 if gaxi::options::tracing_enabled(&conf) {
347 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
348 }
349 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
350 }
351
352 async fn build_transport(
353 conf: gaxi::options::ClientConfig,
354 ) -> Result<impl super::stub::SqlDatabasesService> {
355 super::transport::SqlDatabasesService::new(conf).await
356 }
357
358 async fn build_with_tracing(
359 conf: gaxi::options::ClientConfig,
360 ) -> Result<impl super::stub::SqlDatabasesService> {
361 Self::build_transport(conf)
362 .await
363 .map(super::tracing::SqlDatabasesService::new)
364 }
365
366 /// Deletes a database from a Cloud SQL instance.
367 pub fn delete(&self) -> super::builder::sql_databases_service::Delete {
368 super::builder::sql_databases_service::Delete::new(self.inner.clone())
369 }
370
371 /// Retrieves a resource containing information about a database inside a Cloud
372 /// SQL instance.
373 pub fn get(&self) -> super::builder::sql_databases_service::Get {
374 super::builder::sql_databases_service::Get::new(self.inner.clone())
375 }
376
377 /// Inserts a resource containing information about a database inside a Cloud
378 /// SQL instance.
379 ///
380 /// **Note:** You can't modify the default character set and collation.
381 pub fn insert(&self) -> super::builder::sql_databases_service::Insert {
382 super::builder::sql_databases_service::Insert::new(self.inner.clone())
383 }
384
385 /// Lists databases in the specified Cloud SQL instance.
386 pub fn list(&self) -> super::builder::sql_databases_service::List {
387 super::builder::sql_databases_service::List::new(self.inner.clone())
388 }
389
390 /// Partially updates a resource containing information about a database inside
391 /// a Cloud SQL instance. This method supports patch semantics.
392 pub fn patch(&self) -> super::builder::sql_databases_service::Patch {
393 super::builder::sql_databases_service::Patch::new(self.inner.clone())
394 }
395
396 /// Updates a resource containing information about a database inside a Cloud
397 /// SQL instance.
398 pub fn update(&self) -> super::builder::sql_databases_service::Update {
399 super::builder::sql_databases_service::Update::new(self.inner.clone())
400 }
401}
402
403/// Implements a client for the Cloud SQL Admin API.
404///
405/// # Example
406/// ```
407/// # tokio_test::block_on(async {
408/// # use google_cloud_sql_v1::client::SqlFlagsService;
409/// let client = SqlFlagsService::builder().build().await?;
410/// // use `client` to make requests to the Cloud SQL Admin API.
411/// # gax::Result::<()>::Ok(()) });
412/// ```
413///
414/// # Service Description
415///
416/// Service to manage database flags for Cloud SQL instances.
417///
418/// # Configuration
419///
420/// To configure `SqlFlagsService` use the `with_*` methods in the type returned
421/// by [builder()][SqlFlagsService::builder]. The default configuration should
422/// work for most applications. Common configuration changes include
423///
424/// * [with_endpoint()]: by default this client uses the global default endpoint
425/// (`https://sqladmin.googleapis.com`). Applications using regional
426/// endpoints or running in restricted networks (e.g. a network configured
427// with [Private Google Access with VPC Service Controls]) may want to
428/// override this default.
429/// * [with_credentials()]: by default this client uses
430/// [Application Default Credentials]. Applications using custom
431/// authentication may need to override this default.
432///
433/// [with_endpoint()]: super::builder::sql_flags_service::ClientBuilder::with_endpoint
434/// [with_credentials()]: super::builder::sql_flags_service::ClientBuilder::credentials
435/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
436/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
437///
438/// # Pooling and Cloning
439///
440/// `SqlFlagsService` holds a connection pool internally, it is advised to
441/// create one and the reuse it. You do not need to wrap `SqlFlagsService` in
442/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
443/// already uses an `Arc` internally.
444#[derive(Clone, Debug)]
445pub struct SqlFlagsService {
446 inner: std::sync::Arc<dyn super::stub::dynamic::SqlFlagsService>,
447}
448
449impl SqlFlagsService {
450 /// Returns a builder for [SqlFlagsService].
451 ///
452 /// ```
453 /// # tokio_test::block_on(async {
454 /// # use google_cloud_sql_v1::client::SqlFlagsService;
455 /// let client = SqlFlagsService::builder().build().await?;
456 /// # gax::Result::<()>::Ok(()) });
457 /// ```
458 pub fn builder() -> super::builder::sql_flags_service::ClientBuilder {
459 gax::client_builder::internal::new_builder(
460 super::builder::sql_flags_service::client::Factory,
461 )
462 }
463
464 /// Creates a new client from the provided stub.
465 ///
466 /// The most common case for calling this function is in tests mocking the
467 /// client's behavior.
468 pub fn from_stub<T>(stub: T) -> Self
469 where
470 T: super::stub::SqlFlagsService + 'static,
471 {
472 Self {
473 inner: std::sync::Arc::new(stub),
474 }
475 }
476
477 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
478 let inner = Self::build_inner(config).await?;
479 Ok(Self { inner })
480 }
481
482 async fn build_inner(
483 conf: gaxi::options::ClientConfig,
484 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlFlagsService>> {
485 if gaxi::options::tracing_enabled(&conf) {
486 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
487 }
488 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
489 }
490
491 async fn build_transport(
492 conf: gaxi::options::ClientConfig,
493 ) -> Result<impl super::stub::SqlFlagsService> {
494 super::transport::SqlFlagsService::new(conf).await
495 }
496
497 async fn build_with_tracing(
498 conf: gaxi::options::ClientConfig,
499 ) -> Result<impl super::stub::SqlFlagsService> {
500 Self::build_transport(conf)
501 .await
502 .map(super::tracing::SqlFlagsService::new)
503 }
504
505 /// Lists all available database flags for Cloud SQL instances.
506 pub fn list(&self) -> super::builder::sql_flags_service::List {
507 super::builder::sql_flags_service::List::new(self.inner.clone())
508 }
509}
510
511/// Implements a client for the Cloud SQL Admin API.
512///
513/// # Example
514/// ```
515/// # tokio_test::block_on(async {
516/// # use google_cloud_sql_v1::client::SqlInstancesService;
517/// let client = SqlInstancesService::builder().build().await?;
518/// // use `client` to make requests to the Cloud SQL Admin API.
519/// # gax::Result::<()>::Ok(()) });
520/// ```
521///
522/// # Service Description
523///
524/// Service to manage Cloud SQL instances.
525///
526/// # Configuration
527///
528/// To configure `SqlInstancesService` use the `with_*` methods in the type returned
529/// by [builder()][SqlInstancesService::builder]. The default configuration should
530/// work for most applications. Common configuration changes include
531///
532/// * [with_endpoint()]: by default this client uses the global default endpoint
533/// (`https://sqladmin.googleapis.com`). Applications using regional
534/// endpoints or running in restricted networks (e.g. a network configured
535// with [Private Google Access with VPC Service Controls]) may want to
536/// override this default.
537/// * [with_credentials()]: by default this client uses
538/// [Application Default Credentials]. Applications using custom
539/// authentication may need to override this default.
540///
541/// [with_endpoint()]: super::builder::sql_instances_service::ClientBuilder::with_endpoint
542/// [with_credentials()]: super::builder::sql_instances_service::ClientBuilder::credentials
543/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
544/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
545///
546/// # Pooling and Cloning
547///
548/// `SqlInstancesService` holds a connection pool internally, it is advised to
549/// create one and the reuse it. You do not need to wrap `SqlInstancesService` in
550/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
551/// already uses an `Arc` internally.
552#[derive(Clone, Debug)]
553pub struct SqlInstancesService {
554 inner: std::sync::Arc<dyn super::stub::dynamic::SqlInstancesService>,
555}
556
557impl SqlInstancesService {
558 /// Returns a builder for [SqlInstancesService].
559 ///
560 /// ```
561 /// # tokio_test::block_on(async {
562 /// # use google_cloud_sql_v1::client::SqlInstancesService;
563 /// let client = SqlInstancesService::builder().build().await?;
564 /// # gax::Result::<()>::Ok(()) });
565 /// ```
566 pub fn builder() -> super::builder::sql_instances_service::ClientBuilder {
567 gax::client_builder::internal::new_builder(
568 super::builder::sql_instances_service::client::Factory,
569 )
570 }
571
572 /// Creates a new client from the provided stub.
573 ///
574 /// The most common case for calling this function is in tests mocking the
575 /// client's behavior.
576 pub fn from_stub<T>(stub: T) -> Self
577 where
578 T: super::stub::SqlInstancesService + 'static,
579 {
580 Self {
581 inner: std::sync::Arc::new(stub),
582 }
583 }
584
585 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
586 let inner = Self::build_inner(config).await?;
587 Ok(Self { inner })
588 }
589
590 async fn build_inner(
591 conf: gaxi::options::ClientConfig,
592 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlInstancesService>> {
593 if gaxi::options::tracing_enabled(&conf) {
594 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
595 }
596 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
597 }
598
599 async fn build_transport(
600 conf: gaxi::options::ClientConfig,
601 ) -> Result<impl super::stub::SqlInstancesService> {
602 super::transport::SqlInstancesService::new(conf).await
603 }
604
605 async fn build_with_tracing(
606 conf: gaxi::options::ClientConfig,
607 ) -> Result<impl super::stub::SqlInstancesService> {
608 Self::build_transport(conf)
609 .await
610 .map(super::tracing::SqlInstancesService::new)
611 }
612
613 /// Adds a new trusted Certificate Authority (CA) version for the specified
614 /// instance. Required to prepare for a certificate rotation. If a CA version
615 /// was previously added but never used in a certificate rotation, this
616 /// operation replaces that version. There cannot be more than one CA version
617 /// waiting to be rotated in. For instances that have enabled Certificate
618 /// Authority Service (CAS) based server CA, please use AddServerCertificate to
619 /// add a new server certificate.
620 pub fn add_server_ca(&self) -> super::builder::sql_instances_service::AddServerCa {
621 super::builder::sql_instances_service::AddServerCa::new(self.inner.clone())
622 }
623
624 /// Creates a Cloud SQL instance as a clone of the source instance. Using this
625 /// operation might cause your instance to restart.
626 #[allow(clippy::should_implement_trait)]
627 pub fn clone(&self) -> super::builder::sql_instances_service::Clone {
628 super::builder::sql_instances_service::Clone::new(self.inner.clone())
629 }
630
631 /// Deletes a Cloud SQL instance.
632 pub fn delete(&self) -> super::builder::sql_instances_service::Delete {
633 super::builder::sql_instances_service::Delete::new(self.inner.clone())
634 }
635
636 /// Demotes the stand-alone instance to be a Cloud SQL read replica for an
637 /// external database server.
638 pub fn demote_master(&self) -> super::builder::sql_instances_service::DemoteMaster {
639 super::builder::sql_instances_service::DemoteMaster::new(self.inner.clone())
640 }
641
642 /// Demotes an existing standalone instance to be a Cloud SQL read replica
643 /// for an external database server.
644 pub fn demote(&self) -> super::builder::sql_instances_service::Demote {
645 super::builder::sql_instances_service::Demote::new(self.inner.clone())
646 }
647
648 /// Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL
649 /// dump or CSV file.
650 pub fn export(&self) -> super::builder::sql_instances_service::Export {
651 super::builder::sql_instances_service::Export::new(self.inner.clone())
652 }
653
654 /// Initiates a manual failover of a high availability (HA) primary instance
655 /// to a standby instance, which becomes the primary instance. Users are
656 /// then rerouted to the new primary. For more information, see the
657 /// [Overview of high
658 /// availability](https://cloud.google.com/sql/docs/mysql/high-availability)
659 /// page in the Cloud SQL documentation.
660 /// If using Legacy HA (MySQL only), this causes the instance to failover to
661 /// its failover replica instance.
662 pub fn failover(&self) -> super::builder::sql_instances_service::Failover {
663 super::builder::sql_instances_service::Failover::new(self.inner.clone())
664 }
665
666 /// Reencrypt CMEK instance with latest key version.
667 pub fn reencrypt(&self) -> super::builder::sql_instances_service::Reencrypt {
668 super::builder::sql_instances_service::Reencrypt::new(self.inner.clone())
669 }
670
671 /// Retrieves a resource containing information about a Cloud SQL instance.
672 pub fn get(&self) -> super::builder::sql_instances_service::Get {
673 super::builder::sql_instances_service::Get::new(self.inner.clone())
674 }
675
676 /// Imports data into a Cloud SQL instance from a SQL dump or CSV file in
677 /// Cloud Storage.
678 pub fn import(&self) -> super::builder::sql_instances_service::Import {
679 super::builder::sql_instances_service::Import::new(self.inner.clone())
680 }
681
682 /// Creates a new Cloud SQL instance.
683 pub fn insert(&self) -> super::builder::sql_instances_service::Insert {
684 super::builder::sql_instances_service::Insert::new(self.inner.clone())
685 }
686
687 /// Lists instances under a given project.
688 pub fn list(&self) -> super::builder::sql_instances_service::List {
689 super::builder::sql_instances_service::List::new(self.inner.clone())
690 }
691
692 /// Lists all of the trusted Certificate Authorities (CAs) for the specified
693 /// instance. There can be up to three CAs listed: the CA that was used to sign
694 /// the certificate that is currently in use, a CA that has been added but not
695 /// yet used to sign a certificate, and a CA used to sign a certificate that
696 /// has previously rotated out.
697 pub fn list_server_cas(&self) -> super::builder::sql_instances_service::ListServerCas {
698 super::builder::sql_instances_service::ListServerCas::new(self.inner.clone())
699 }
700
701 /// Partially updates settings of a Cloud SQL instance by merging the request
702 /// with the current configuration. This method supports patch semantics.
703 pub fn patch(&self) -> super::builder::sql_instances_service::Patch {
704 super::builder::sql_instances_service::Patch::new(self.inner.clone())
705 }
706
707 /// Promotes the read replica instance to be an independent Cloud SQL
708 /// primary instance.
709 /// Using this operation might cause your instance to restart.
710 pub fn promote_replica(&self) -> super::builder::sql_instances_service::PromoteReplica {
711 super::builder::sql_instances_service::PromoteReplica::new(self.inner.clone())
712 }
713
714 /// Switches over from the primary instance to the designated DR replica
715 /// instance.
716 pub fn switchover(&self) -> super::builder::sql_instances_service::Switchover {
717 super::builder::sql_instances_service::Switchover::new(self.inner.clone())
718 }
719
720 /// Deletes all client certificates and generates a new server SSL certificate
721 /// for the instance.
722 pub fn reset_ssl_config(&self) -> super::builder::sql_instances_service::ResetSslConfig {
723 super::builder::sql_instances_service::ResetSslConfig::new(self.inner.clone())
724 }
725
726 /// Restarts a Cloud SQL instance.
727 pub fn restart(&self) -> super::builder::sql_instances_service::Restart {
728 super::builder::sql_instances_service::Restart::new(self.inner.clone())
729 }
730
731 /// Restores a backup of a Cloud SQL instance. Using this operation might cause
732 /// your instance to restart.
733 pub fn restore_backup(&self) -> super::builder::sql_instances_service::RestoreBackup {
734 super::builder::sql_instances_service::RestoreBackup::new(self.inner.clone())
735 }
736
737 /// Rotates the server certificate to one signed by the Certificate Authority
738 /// (CA) version previously added with the addServerCA method. For instances
739 /// that have enabled Certificate Authority Service (CAS) based server CA,
740 /// please use RotateServerCertificate to rotate the server certificate.
741 pub fn rotate_server_ca(&self) -> super::builder::sql_instances_service::RotateServerCa {
742 super::builder::sql_instances_service::RotateServerCa::new(self.inner.clone())
743 }
744
745 /// Starts the replication in the read replica instance.
746 pub fn start_replica(&self) -> super::builder::sql_instances_service::StartReplica {
747 super::builder::sql_instances_service::StartReplica::new(self.inner.clone())
748 }
749
750 /// Stops the replication in the read replica instance.
751 pub fn stop_replica(&self) -> super::builder::sql_instances_service::StopReplica {
752 super::builder::sql_instances_service::StopReplica::new(self.inner.clone())
753 }
754
755 /// Truncate MySQL general and slow query log tables
756 /// MySQL only.
757 pub fn truncate_log(&self) -> super::builder::sql_instances_service::TruncateLog {
758 super::builder::sql_instances_service::TruncateLog::new(self.inner.clone())
759 }
760
761 /// Updates settings of a Cloud SQL instance. Using this operation might cause
762 /// your instance to restart.
763 pub fn update(&self) -> super::builder::sql_instances_service::Update {
764 super::builder::sql_instances_service::Update::new(self.inner.clone())
765 }
766
767 /// Generates a short-lived X509 certificate containing the provided public key
768 /// and signed by a private key specific to the target instance. Users may use
769 /// the certificate to authenticate as themselves when connecting to the
770 /// database.
771 pub fn create_ephemeral(&self) -> super::builder::sql_instances_service::CreateEphemeral {
772 super::builder::sql_instances_service::CreateEphemeral::new(self.inner.clone())
773 }
774
775 /// Reschedules the maintenance on the given instance.
776 pub fn reschedule_maintenance(
777 &self,
778 ) -> super::builder::sql_instances_service::RescheduleMaintenance {
779 super::builder::sql_instances_service::RescheduleMaintenance::new(self.inner.clone())
780 }
781
782 /// Verify External primary instance external sync settings.
783 pub fn verify_external_sync_settings(
784 &self,
785 ) -> super::builder::sql_instances_service::VerifyExternalSyncSettings {
786 super::builder::sql_instances_service::VerifyExternalSyncSettings::new(self.inner.clone())
787 }
788
789 /// Start External primary instance migration.
790 pub fn start_external_sync(&self) -> super::builder::sql_instances_service::StartExternalSync {
791 super::builder::sql_instances_service::StartExternalSync::new(self.inner.clone())
792 }
793
794 /// Perform Disk Shrink on primary instance.
795 pub fn perform_disk_shrink(&self) -> super::builder::sql_instances_service::PerformDiskShrink {
796 super::builder::sql_instances_service::PerformDiskShrink::new(self.inner.clone())
797 }
798
799 /// Get Disk Shrink Config for a given instance.
800 pub fn get_disk_shrink_config(
801 &self,
802 ) -> super::builder::sql_instances_service::GetDiskShrinkConfig {
803 super::builder::sql_instances_service::GetDiskShrinkConfig::new(self.inner.clone())
804 }
805
806 /// Reset Replica Size to primary instance disk size.
807 pub fn reset_replica_size(&self) -> super::builder::sql_instances_service::ResetReplicaSize {
808 super::builder::sql_instances_service::ResetReplicaSize::new(self.inner.clone())
809 }
810
811 /// Get Latest Recovery Time for a given instance.
812 pub fn get_latest_recovery_time(
813 &self,
814 ) -> super::builder::sql_instances_service::GetLatestRecoveryTime {
815 super::builder::sql_instances_service::GetLatestRecoveryTime::new(self.inner.clone())
816 }
817
818 /// Acquire a lease for the setup of SQL Server Reporting Services (SSRS).
819 pub fn acquire_ssrs_lease(&self) -> super::builder::sql_instances_service::AcquireSsrsLease {
820 super::builder::sql_instances_service::AcquireSsrsLease::new(self.inner.clone())
821 }
822
823 /// Release a lease for the setup of SQL Server Reporting Services (SSRS).
824 pub fn release_ssrs_lease(&self) -> super::builder::sql_instances_service::ReleaseSsrsLease {
825 super::builder::sql_instances_service::ReleaseSsrsLease::new(self.inner.clone())
826 }
827}
828
829/// Implements a client for the Cloud SQL Admin API.
830///
831/// # Example
832/// ```
833/// # tokio_test::block_on(async {
834/// # use google_cloud_sql_v1::client::SqlOperationsService;
835/// let client = SqlOperationsService::builder().build().await?;
836/// // use `client` to make requests to the Cloud SQL Admin API.
837/// # gax::Result::<()>::Ok(()) });
838/// ```
839///
840/// # Service Description
841///
842/// Service to fetch operations for database instances.
843///
844/// # Configuration
845///
846/// To configure `SqlOperationsService` use the `with_*` methods in the type returned
847/// by [builder()][SqlOperationsService::builder]. The default configuration should
848/// work for most applications. Common configuration changes include
849///
850/// * [with_endpoint()]: by default this client uses the global default endpoint
851/// (`https://sqladmin.googleapis.com`). Applications using regional
852/// endpoints or running in restricted networks (e.g. a network configured
853// with [Private Google Access with VPC Service Controls]) may want to
854/// override this default.
855/// * [with_credentials()]: by default this client uses
856/// [Application Default Credentials]. Applications using custom
857/// authentication may need to override this default.
858///
859/// [with_endpoint()]: super::builder::sql_operations_service::ClientBuilder::with_endpoint
860/// [with_credentials()]: super::builder::sql_operations_service::ClientBuilder::credentials
861/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
862/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
863///
864/// # Pooling and Cloning
865///
866/// `SqlOperationsService` holds a connection pool internally, it is advised to
867/// create one and the reuse it. You do not need to wrap `SqlOperationsService` in
868/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
869/// already uses an `Arc` internally.
870#[derive(Clone, Debug)]
871pub struct SqlOperationsService {
872 inner: std::sync::Arc<dyn super::stub::dynamic::SqlOperationsService>,
873}
874
875impl SqlOperationsService {
876 /// Returns a builder for [SqlOperationsService].
877 ///
878 /// ```
879 /// # tokio_test::block_on(async {
880 /// # use google_cloud_sql_v1::client::SqlOperationsService;
881 /// let client = SqlOperationsService::builder().build().await?;
882 /// # gax::Result::<()>::Ok(()) });
883 /// ```
884 pub fn builder() -> super::builder::sql_operations_service::ClientBuilder {
885 gax::client_builder::internal::new_builder(
886 super::builder::sql_operations_service::client::Factory,
887 )
888 }
889
890 /// Creates a new client from the provided stub.
891 ///
892 /// The most common case for calling this function is in tests mocking the
893 /// client's behavior.
894 pub fn from_stub<T>(stub: T) -> Self
895 where
896 T: super::stub::SqlOperationsService + 'static,
897 {
898 Self {
899 inner: std::sync::Arc::new(stub),
900 }
901 }
902
903 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
904 let inner = Self::build_inner(config).await?;
905 Ok(Self { inner })
906 }
907
908 async fn build_inner(
909 conf: gaxi::options::ClientConfig,
910 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlOperationsService>> {
911 if gaxi::options::tracing_enabled(&conf) {
912 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
913 }
914 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
915 }
916
917 async fn build_transport(
918 conf: gaxi::options::ClientConfig,
919 ) -> Result<impl super::stub::SqlOperationsService> {
920 super::transport::SqlOperationsService::new(conf).await
921 }
922
923 async fn build_with_tracing(
924 conf: gaxi::options::ClientConfig,
925 ) -> Result<impl super::stub::SqlOperationsService> {
926 Self::build_transport(conf)
927 .await
928 .map(super::tracing::SqlOperationsService::new)
929 }
930
931 /// Retrieves an instance operation that has been performed on an instance.
932 pub fn get(&self) -> super::builder::sql_operations_service::Get {
933 super::builder::sql_operations_service::Get::new(self.inner.clone())
934 }
935
936 /// Lists all instance operations that have been performed on the given Cloud
937 /// SQL instance in the reverse chronological order of the start time.
938 pub fn list(&self) -> super::builder::sql_operations_service::List {
939 super::builder::sql_operations_service::List::new(self.inner.clone())
940 }
941
942 /// Cancels an instance operation that has been performed on an instance.
943 pub fn cancel(&self) -> super::builder::sql_operations_service::Cancel {
944 super::builder::sql_operations_service::Cancel::new(self.inner.clone())
945 }
946}
947
948/// Implements a client for the Cloud SQL Admin API.
949///
950/// # Example
951/// ```
952/// # tokio_test::block_on(async {
953/// # use google_cloud_sql_v1::client::SqlSslCertsService;
954/// let client = SqlSslCertsService::builder().build().await?;
955/// // use `client` to make requests to the Cloud SQL Admin API.
956/// # gax::Result::<()>::Ok(()) });
957/// ```
958///
959/// # Service Description
960///
961/// Service to manage SSL certs for Cloud SQL instances.
962///
963/// # Configuration
964///
965/// To configure `SqlSslCertsService` use the `with_*` methods in the type returned
966/// by [builder()][SqlSslCertsService::builder]. The default configuration should
967/// work for most applications. Common configuration changes include
968///
969/// * [with_endpoint()]: by default this client uses the global default endpoint
970/// (`https://sqladmin.googleapis.com`). Applications using regional
971/// endpoints or running in restricted networks (e.g. a network configured
972// with [Private Google Access with VPC Service Controls]) may want to
973/// override this default.
974/// * [with_credentials()]: by default this client uses
975/// [Application Default Credentials]. Applications using custom
976/// authentication may need to override this default.
977///
978/// [with_endpoint()]: super::builder::sql_ssl_certs_service::ClientBuilder::with_endpoint
979/// [with_credentials()]: super::builder::sql_ssl_certs_service::ClientBuilder::credentials
980/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
981/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
982///
983/// # Pooling and Cloning
984///
985/// `SqlSslCertsService` holds a connection pool internally, it is advised to
986/// create one and the reuse it. You do not need to wrap `SqlSslCertsService` in
987/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
988/// already uses an `Arc` internally.
989#[derive(Clone, Debug)]
990pub struct SqlSslCertsService {
991 inner: std::sync::Arc<dyn super::stub::dynamic::SqlSslCertsService>,
992}
993
994impl SqlSslCertsService {
995 /// Returns a builder for [SqlSslCertsService].
996 ///
997 /// ```
998 /// # tokio_test::block_on(async {
999 /// # use google_cloud_sql_v1::client::SqlSslCertsService;
1000 /// let client = SqlSslCertsService::builder().build().await?;
1001 /// # gax::Result::<()>::Ok(()) });
1002 /// ```
1003 pub fn builder() -> super::builder::sql_ssl_certs_service::ClientBuilder {
1004 gax::client_builder::internal::new_builder(
1005 super::builder::sql_ssl_certs_service::client::Factory,
1006 )
1007 }
1008
1009 /// Creates a new client from the provided stub.
1010 ///
1011 /// The most common case for calling this function is in tests mocking the
1012 /// client's behavior.
1013 pub fn from_stub<T>(stub: T) -> Self
1014 where
1015 T: super::stub::SqlSslCertsService + 'static,
1016 {
1017 Self {
1018 inner: std::sync::Arc::new(stub),
1019 }
1020 }
1021
1022 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
1023 let inner = Self::build_inner(config).await?;
1024 Ok(Self { inner })
1025 }
1026
1027 async fn build_inner(
1028 conf: gaxi::options::ClientConfig,
1029 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlSslCertsService>> {
1030 if gaxi::options::tracing_enabled(&conf) {
1031 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1032 }
1033 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1034 }
1035
1036 async fn build_transport(
1037 conf: gaxi::options::ClientConfig,
1038 ) -> Result<impl super::stub::SqlSslCertsService> {
1039 super::transport::SqlSslCertsService::new(conf).await
1040 }
1041
1042 async fn build_with_tracing(
1043 conf: gaxi::options::ClientConfig,
1044 ) -> Result<impl super::stub::SqlSslCertsService> {
1045 Self::build_transport(conf)
1046 .await
1047 .map(super::tracing::SqlSslCertsService::new)
1048 }
1049
1050 /// Deletes the SSL certificate. For First Generation instances, the
1051 /// certificate remains valid until the instance is restarted.
1052 pub fn delete(&self) -> super::builder::sql_ssl_certs_service::Delete {
1053 super::builder::sql_ssl_certs_service::Delete::new(self.inner.clone())
1054 }
1055
1056 /// Retrieves a particular SSL certificate. Does not include the private key
1057 /// (required for usage). The private key must be saved from the response to
1058 /// initial creation.
1059 pub fn get(&self) -> super::builder::sql_ssl_certs_service::Get {
1060 super::builder::sql_ssl_certs_service::Get::new(self.inner.clone())
1061 }
1062
1063 /// Creates an SSL certificate and returns it along with the private key and
1064 /// server certificate authority. The new certificate will not be usable until
1065 /// the instance is restarted.
1066 pub fn insert(&self) -> super::builder::sql_ssl_certs_service::Insert {
1067 super::builder::sql_ssl_certs_service::Insert::new(self.inner.clone())
1068 }
1069
1070 /// Lists all of the current SSL certificates for the instance.
1071 pub fn list(&self) -> super::builder::sql_ssl_certs_service::List {
1072 super::builder::sql_ssl_certs_service::List::new(self.inner.clone())
1073 }
1074}
1075
1076/// Implements a client for the Cloud SQL Admin API.
1077///
1078/// # Example
1079/// ```
1080/// # tokio_test::block_on(async {
1081/// # use google_cloud_sql_v1::client::SqlTiersService;
1082/// let client = SqlTiersService::builder().build().await?;
1083/// // use `client` to make requests to the Cloud SQL Admin API.
1084/// # gax::Result::<()>::Ok(()) });
1085/// ```
1086///
1087/// # Service Description
1088///
1089/// Service for providing machine types (tiers) for Cloud SQL instances.
1090///
1091/// # Configuration
1092///
1093/// To configure `SqlTiersService` use the `with_*` methods in the type returned
1094/// by [builder()][SqlTiersService::builder]. The default configuration should
1095/// work for most applications. Common configuration changes include
1096///
1097/// * [with_endpoint()]: by default this client uses the global default endpoint
1098/// (`https://sqladmin.googleapis.com`). Applications using regional
1099/// endpoints or running in restricted networks (e.g. a network configured
1100// with [Private Google Access with VPC Service Controls]) may want to
1101/// override this default.
1102/// * [with_credentials()]: by default this client uses
1103/// [Application Default Credentials]. Applications using custom
1104/// authentication may need to override this default.
1105///
1106/// [with_endpoint()]: super::builder::sql_tiers_service::ClientBuilder::with_endpoint
1107/// [with_credentials()]: super::builder::sql_tiers_service::ClientBuilder::credentials
1108/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1109/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1110///
1111/// # Pooling and Cloning
1112///
1113/// `SqlTiersService` holds a connection pool internally, it is advised to
1114/// create one and the reuse it. You do not need to wrap `SqlTiersService` in
1115/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1116/// already uses an `Arc` internally.
1117#[derive(Clone, Debug)]
1118pub struct SqlTiersService {
1119 inner: std::sync::Arc<dyn super::stub::dynamic::SqlTiersService>,
1120}
1121
1122impl SqlTiersService {
1123 /// Returns a builder for [SqlTiersService].
1124 ///
1125 /// ```
1126 /// # tokio_test::block_on(async {
1127 /// # use google_cloud_sql_v1::client::SqlTiersService;
1128 /// let client = SqlTiersService::builder().build().await?;
1129 /// # gax::Result::<()>::Ok(()) });
1130 /// ```
1131 pub fn builder() -> super::builder::sql_tiers_service::ClientBuilder {
1132 gax::client_builder::internal::new_builder(
1133 super::builder::sql_tiers_service::client::Factory,
1134 )
1135 }
1136
1137 /// Creates a new client from the provided stub.
1138 ///
1139 /// The most common case for calling this function is in tests mocking the
1140 /// client's behavior.
1141 pub fn from_stub<T>(stub: T) -> Self
1142 where
1143 T: super::stub::SqlTiersService + 'static,
1144 {
1145 Self {
1146 inner: std::sync::Arc::new(stub),
1147 }
1148 }
1149
1150 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
1151 let inner = Self::build_inner(config).await?;
1152 Ok(Self { inner })
1153 }
1154
1155 async fn build_inner(
1156 conf: gaxi::options::ClientConfig,
1157 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlTiersService>> {
1158 if gaxi::options::tracing_enabled(&conf) {
1159 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1160 }
1161 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1162 }
1163
1164 async fn build_transport(
1165 conf: gaxi::options::ClientConfig,
1166 ) -> Result<impl super::stub::SqlTiersService> {
1167 super::transport::SqlTiersService::new(conf).await
1168 }
1169
1170 async fn build_with_tracing(
1171 conf: gaxi::options::ClientConfig,
1172 ) -> Result<impl super::stub::SqlTiersService> {
1173 Self::build_transport(conf)
1174 .await
1175 .map(super::tracing::SqlTiersService::new)
1176 }
1177
1178 /// Lists all available machine types (tiers) for Cloud SQL, for example,
1179 /// `db-custom-1-3840`. For more information, see
1180 /// <https://cloud.google.com/sql/pricing>.
1181 pub fn list(&self) -> super::builder::sql_tiers_service::List {
1182 super::builder::sql_tiers_service::List::new(self.inner.clone())
1183 }
1184}
1185
1186/// Implements a client for the Cloud SQL Admin API.
1187///
1188/// # Example
1189/// ```
1190/// # tokio_test::block_on(async {
1191/// # use google_cloud_sql_v1::client::SqlUsersService;
1192/// let client = SqlUsersService::builder().build().await?;
1193/// // use `client` to make requests to the Cloud SQL Admin API.
1194/// # gax::Result::<()>::Ok(()) });
1195/// ```
1196///
1197/// # Service Description
1198///
1199/// Cloud SQL users service.
1200///
1201/// # Configuration
1202///
1203/// To configure `SqlUsersService` use the `with_*` methods in the type returned
1204/// by [builder()][SqlUsersService::builder]. The default configuration should
1205/// work for most applications. Common configuration changes include
1206///
1207/// * [with_endpoint()]: by default this client uses the global default endpoint
1208/// (`https://sqladmin.googleapis.com`). Applications using regional
1209/// endpoints or running in restricted networks (e.g. a network configured
1210// with [Private Google Access with VPC Service Controls]) may want to
1211/// override this default.
1212/// * [with_credentials()]: by default this client uses
1213/// [Application Default Credentials]. Applications using custom
1214/// authentication may need to override this default.
1215///
1216/// [with_endpoint()]: super::builder::sql_users_service::ClientBuilder::with_endpoint
1217/// [with_credentials()]: super::builder::sql_users_service::ClientBuilder::credentials
1218/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1219/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1220///
1221/// # Pooling and Cloning
1222///
1223/// `SqlUsersService` holds a connection pool internally, it is advised to
1224/// create one and the reuse it. You do not need to wrap `SqlUsersService` in
1225/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1226/// already uses an `Arc` internally.
1227#[derive(Clone, Debug)]
1228pub struct SqlUsersService {
1229 inner: std::sync::Arc<dyn super::stub::dynamic::SqlUsersService>,
1230}
1231
1232impl SqlUsersService {
1233 /// Returns a builder for [SqlUsersService].
1234 ///
1235 /// ```
1236 /// # tokio_test::block_on(async {
1237 /// # use google_cloud_sql_v1::client::SqlUsersService;
1238 /// let client = SqlUsersService::builder().build().await?;
1239 /// # gax::Result::<()>::Ok(()) });
1240 /// ```
1241 pub fn builder() -> super::builder::sql_users_service::ClientBuilder {
1242 gax::client_builder::internal::new_builder(
1243 super::builder::sql_users_service::client::Factory,
1244 )
1245 }
1246
1247 /// Creates a new client from the provided stub.
1248 ///
1249 /// The most common case for calling this function is in tests mocking the
1250 /// client's behavior.
1251 pub fn from_stub<T>(stub: T) -> Self
1252 where
1253 T: super::stub::SqlUsersService + 'static,
1254 {
1255 Self {
1256 inner: std::sync::Arc::new(stub),
1257 }
1258 }
1259
1260 pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
1261 let inner = Self::build_inner(config).await?;
1262 Ok(Self { inner })
1263 }
1264
1265 async fn build_inner(
1266 conf: gaxi::options::ClientConfig,
1267 ) -> Result<std::sync::Arc<dyn super::stub::dynamic::SqlUsersService>> {
1268 if gaxi::options::tracing_enabled(&conf) {
1269 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1270 }
1271 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1272 }
1273
1274 async fn build_transport(
1275 conf: gaxi::options::ClientConfig,
1276 ) -> Result<impl super::stub::SqlUsersService> {
1277 super::transport::SqlUsersService::new(conf).await
1278 }
1279
1280 async fn build_with_tracing(
1281 conf: gaxi::options::ClientConfig,
1282 ) -> Result<impl super::stub::SqlUsersService> {
1283 Self::build_transport(conf)
1284 .await
1285 .map(super::tracing::SqlUsersService::new)
1286 }
1287
1288 /// Deletes a user from a Cloud SQL instance.
1289 pub fn delete(&self) -> super::builder::sql_users_service::Delete {
1290 super::builder::sql_users_service::Delete::new(self.inner.clone())
1291 }
1292
1293 /// Retrieves a resource containing information about a user.
1294 pub fn get(&self) -> super::builder::sql_users_service::Get {
1295 super::builder::sql_users_service::Get::new(self.inner.clone())
1296 }
1297
1298 /// Creates a new user in a Cloud SQL instance.
1299 pub fn insert(&self) -> super::builder::sql_users_service::Insert {
1300 super::builder::sql_users_service::Insert::new(self.inner.clone())
1301 }
1302
1303 /// Lists users in the specified Cloud SQL instance.
1304 pub fn list(&self) -> super::builder::sql_users_service::List {
1305 super::builder::sql_users_service::List::new(self.inner.clone())
1306 }
1307
1308 /// Updates an existing user in a Cloud SQL instance.
1309 pub fn update(&self) -> super::builder::sql_users_service::Update {
1310 super::builder::sql_users_service::Update::new(self.inner.clone())
1311 }
1312}