google_cloud_vpcaccess_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 Serverless VPC Access API.
20///
21/// # Example
22/// ```
23/// # async fn sample() -> gax::client_builder::Result<()> {
24/// # use google_cloud_vpcaccess_v1::client::VpcAccessService;
25/// let client = VpcAccessService::builder().build().await?;
26/// // use `client` to make requests to the Serverless VPC Access API.
27/// # Ok(()) }
28/// ```
29///
30/// # Service Description
31///
32/// Serverless VPC Access API allows users to create and manage connectors for
33/// App Engine, Cloud Functions and Cloud Run to have internal connections to
34/// Virtual Private Cloud networks.
35///
36/// # Configuration
37///
38/// To configure `VpcAccessService` use the `with_*` methods in the type returned
39/// by [builder()][VpcAccessService::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://vpcaccess.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::vpc_access_service::ClientBuilder::with_endpoint
52/// [with_credentials()]: super::builder::vpc_access_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/// `VpcAccessService` holds a connection pool internally, it is advised to
59/// create one and the reuse it.  You do not need to wrap `VpcAccessService` 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 VpcAccessService {
64    inner: std::sync::Arc<dyn super::stub::dynamic::VpcAccessService>,
65}
66
67impl VpcAccessService {
68    /// Returns a builder for [VpcAccessService].
69    ///
70    /// ```
71    /// # async fn sample() -> gax::client_builder::Result<()> {
72    /// # use google_cloud_vpcaccess_v1::client::VpcAccessService;
73    /// let client = VpcAccessService::builder().build().await?;
74    /// # Ok(()) }
75    /// ```
76    pub fn builder() -> super::builder::vpc_access_service::ClientBuilder {
77        gax::client_builder::internal::new_builder(
78            super::builder::vpc_access_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::VpcAccessService + 'static,
89    {
90        Self {
91            inner: std::sync::Arc::new(stub),
92        }
93    }
94
95    pub(crate) async fn new(
96        config: gaxi::options::ClientConfig,
97    ) -> gax::client_builder::Result<Self> {
98        let inner = Self::build_inner(config).await?;
99        Ok(Self { inner })
100    }
101
102    async fn build_inner(
103        conf: gaxi::options::ClientConfig,
104    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::VpcAccessService>>
105    {
106        if gaxi::options::tracing_enabled(&conf) {
107            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
108        }
109        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
110    }
111
112    async fn build_transport(
113        conf: gaxi::options::ClientConfig,
114    ) -> gax::client_builder::Result<impl super::stub::VpcAccessService> {
115        super::transport::VpcAccessService::new(conf).await
116    }
117
118    async fn build_with_tracing(
119        conf: gaxi::options::ClientConfig,
120    ) -> gax::client_builder::Result<impl super::stub::VpcAccessService> {
121        Self::build_transport(conf)
122            .await
123            .map(super::tracing::VpcAccessService::new)
124    }
125
126    /// Creates a Serverless VPC Access connector, returns an operation.
127    ///
128    /// # Long running operations
129    ///
130    /// This method is used to start, and/or poll a [long-running Operation].
131    /// The [Working with long-running operations] chapter in the [user guide]
132    /// covers these operations in detail.
133    ///
134    /// [long-running operation]: https://google.aip.dev/151
135    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
136    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
137    pub fn create_connector(&self) -> super::builder::vpc_access_service::CreateConnector {
138        super::builder::vpc_access_service::CreateConnector::new(self.inner.clone())
139    }
140
141    /// Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource
142    /// does not exist.
143    pub fn get_connector(&self) -> super::builder::vpc_access_service::GetConnector {
144        super::builder::vpc_access_service::GetConnector::new(self.inner.clone())
145    }
146
147    /// Lists Serverless VPC Access connectors.
148    pub fn list_connectors(&self) -> super::builder::vpc_access_service::ListConnectors {
149        super::builder::vpc_access_service::ListConnectors::new(self.inner.clone())
150    }
151
152    /// Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the
153    /// resource does not exist.
154    ///
155    /// # Long running operations
156    ///
157    /// This method is used to start, and/or poll a [long-running Operation].
158    /// The [Working with long-running operations] chapter in the [user guide]
159    /// covers these operations in detail.
160    ///
161    /// [long-running operation]: https://google.aip.dev/151
162    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
163    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
164    pub fn delete_connector(&self) -> super::builder::vpc_access_service::DeleteConnector {
165        super::builder::vpc_access_service::DeleteConnector::new(self.inner.clone())
166    }
167
168    /// Lists information about the supported locations for this service.
169    pub fn list_locations(&self) -> super::builder::vpc_access_service::ListLocations {
170        super::builder::vpc_access_service::ListLocations::new(self.inner.clone())
171    }
172
173    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
174    ///
175    /// [google.longrunning.Operations]: longrunning::client::Operations
176    pub fn list_operations(&self) -> super::builder::vpc_access_service::ListOperations {
177        super::builder::vpc_access_service::ListOperations::new(self.inner.clone())
178    }
179
180    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
181    ///
182    /// [google.longrunning.Operations]: longrunning::client::Operations
183    pub fn get_operation(&self) -> super::builder::vpc_access_service::GetOperation {
184        super::builder::vpc_access_service::GetOperation::new(self.inner.clone())
185    }
186}