google_cloud_beyondcorp_clientgateways_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 BeyondCorp API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
25/// let client = ClientGatewaysService::builder().build().await?;
26/// // use `client` to make requests to the BeyondCorp API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// API Overview:
33///
34/// The `beyondcorp.googleapis.com` service implements the Google Cloud
35/// BeyondCorp API.
36///
37/// Data Model:
38///
39/// The ClientGatewaysService exposes the following resources:
40///
41/// * Client Gateways, named as follows:
42/// `projects/{project_id}/locations/{location_id}/clientGateways/{client_gateway_id}`.
43///
44/// # Configuration
45///
46/// To configure `ClientGatewaysService` use the `with_*` methods in the type returned
47/// by [builder()][ClientGatewaysService::builder]. The default configuration should
48/// work for most applications. Common configuration changes include
49///
50/// * [with_endpoint()]: by default this client uses the global default endpoint
51/// (`https://beyondcorp.googleapis.com`). Applications using regional
52/// endpoints or running in restricted networks (e.g. a network configured
53// with [Private Google Access with VPC Service Controls]) may want to
54/// override this default.
55/// * [with_credentials()]: by default this client uses
56/// [Application Default Credentials]. Applications using custom
57/// authentication may need to override this default.
58///
59/// [with_endpoint()]: super::builder::client_gateways_service::ClientBuilder::with_endpoint
60/// [with_credentials()]: super::builder::client_gateways_service::ClientBuilder::credentials
61/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
62/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
63///
64/// # Pooling and Cloning
65///
66/// `ClientGatewaysService` holds a connection pool internally, it is advised to
67/// create one and the reuse it. You do not need to wrap `ClientGatewaysService` in
68/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
69/// already uses an `Arc` internally.
70#[derive(Clone, Debug)]
71pub struct ClientGatewaysService {
72 inner: std::sync::Arc<dyn super::stub::dynamic::ClientGatewaysService>,
73}
74
75impl ClientGatewaysService {
76 /// Returns a builder for [ClientGatewaysService].
77 ///
78 /// ```
79 /// # tokio_test::block_on(async {
80 /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
81 /// let client = ClientGatewaysService::builder().build().await?;
82 /// # gax::client_builder::Result::<()>::Ok(()) });
83 /// ```
84 pub fn builder() -> super::builder::client_gateways_service::ClientBuilder {
85 gax::client_builder::internal::new_builder(
86 super::builder::client_gateways_service::client::Factory,
87 )
88 }
89
90 /// Creates a new client from the provided stub.
91 ///
92 /// The most common case for calling this function is in tests mocking the
93 /// client's behavior.
94 pub fn from_stub<T>(stub: T) -> Self
95 where
96 T: super::stub::ClientGatewaysService + 'static,
97 {
98 Self {
99 inner: std::sync::Arc::new(stub),
100 }
101 }
102
103 pub(crate) async fn new(
104 config: gaxi::options::ClientConfig,
105 ) -> gax::client_builder::Result<Self> {
106 let inner = Self::build_inner(config).await?;
107 Ok(Self { inner })
108 }
109
110 async fn build_inner(
111 conf: gaxi::options::ClientConfig,
112 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ClientGatewaysService>>
113 {
114 if gaxi::options::tracing_enabled(&conf) {
115 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
116 }
117 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
118 }
119
120 async fn build_transport(
121 conf: gaxi::options::ClientConfig,
122 ) -> gax::client_builder::Result<impl super::stub::ClientGatewaysService> {
123 super::transport::ClientGatewaysService::new(conf).await
124 }
125
126 async fn build_with_tracing(
127 conf: gaxi::options::ClientConfig,
128 ) -> gax::client_builder::Result<impl super::stub::ClientGatewaysService> {
129 Self::build_transport(conf)
130 .await
131 .map(super::tracing::ClientGatewaysService::new)
132 }
133
134 /// Lists ClientGateways in a given project and location.
135 pub fn list_client_gateways(
136 &self,
137 ) -> super::builder::client_gateways_service::ListClientGateways {
138 super::builder::client_gateways_service::ListClientGateways::new(self.inner.clone())
139 }
140
141 /// Gets details of a single ClientGateway.
142 pub fn get_client_gateway(&self) -> super::builder::client_gateways_service::GetClientGateway {
143 super::builder::client_gateways_service::GetClientGateway::new(self.inner.clone())
144 }
145
146 /// Creates a new ClientGateway in a given project and location.
147 ///
148 /// # Long running operations
149 ///
150 /// This method is used to start, and/or poll a [long-running Operation].
151 /// The [Working with long-running operations] chapter in the [user guide]
152 /// covers these operations in detail.
153 ///
154 /// [long-running operation]: https://google.aip.dev/151
155 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
156 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
157 pub fn create_client_gateway(
158 &self,
159 ) -> super::builder::client_gateways_service::CreateClientGateway {
160 super::builder::client_gateways_service::CreateClientGateway::new(self.inner.clone())
161 }
162
163 /// Deletes a single ClientGateway.
164 ///
165 /// # Long running operations
166 ///
167 /// This method is used to start, and/or poll a [long-running Operation].
168 /// The [Working with long-running operations] chapter in the [user guide]
169 /// covers these operations in detail.
170 ///
171 /// [long-running operation]: https://google.aip.dev/151
172 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
173 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
174 pub fn delete_client_gateway(
175 &self,
176 ) -> super::builder::client_gateways_service::DeleteClientGateway {
177 super::builder::client_gateways_service::DeleteClientGateway::new(self.inner.clone())
178 }
179
180 /// Lists information about the supported locations for this service.
181 pub fn list_locations(&self) -> super::builder::client_gateways_service::ListLocations {
182 super::builder::client_gateways_service::ListLocations::new(self.inner.clone())
183 }
184
185 /// Gets information about a location.
186 pub fn get_location(&self) -> super::builder::client_gateways_service::GetLocation {
187 super::builder::client_gateways_service::GetLocation::new(self.inner.clone())
188 }
189
190 /// Sets the access control policy on the specified resource. Replaces
191 /// any existing policy.
192 ///
193 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
194 /// errors.
195 pub fn set_iam_policy(&self) -> super::builder::client_gateways_service::SetIamPolicy {
196 super::builder::client_gateways_service::SetIamPolicy::new(self.inner.clone())
197 }
198
199 /// Gets the access control policy for a resource. Returns an empty policy
200 /// if the resource exists and does not have a policy set.
201 pub fn get_iam_policy(&self) -> super::builder::client_gateways_service::GetIamPolicy {
202 super::builder::client_gateways_service::GetIamPolicy::new(self.inner.clone())
203 }
204
205 /// Returns permissions that a caller has on the specified resource. If the
206 /// resource does not exist, this will return an empty set of
207 /// permissions, not a `NOT_FOUND` error.
208 ///
209 /// Note: This operation is designed to be used for building
210 /// permission-aware UIs and command-line tools, not for authorization
211 /// checking. This operation may "fail open" without warning.
212 pub fn test_iam_permissions(
213 &self,
214 ) -> super::builder::client_gateways_service::TestIamPermissions {
215 super::builder::client_gateways_service::TestIamPermissions::new(self.inner.clone())
216 }
217
218 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
219 ///
220 /// [google.longrunning.Operations]: longrunning::client::Operations
221 pub fn list_operations(&self) -> super::builder::client_gateways_service::ListOperations {
222 super::builder::client_gateways_service::ListOperations::new(self.inner.clone())
223 }
224
225 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
226 ///
227 /// [google.longrunning.Operations]: longrunning::client::Operations
228 pub fn get_operation(&self) -> super::builder::client_gateways_service::GetOperation {
229 super::builder::client_gateways_service::GetOperation::new(self.inner.clone())
230 }
231
232 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
233 ///
234 /// [google.longrunning.Operations]: longrunning::client::Operations
235 pub fn delete_operation(&self) -> super::builder::client_gateways_service::DeleteOperation {
236 super::builder::client_gateways_service::DeleteOperation::new(self.inner.clone())
237 }
238
239 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
240 ///
241 /// [google.longrunning.Operations]: longrunning::client::Operations
242 pub fn cancel_operation(&self) -> super::builder::client_gateways_service::CancelOperation {
243 super::builder::client_gateways_service::CancelOperation::new(self.inner.clone())
244 }
245}