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