Skip to main content

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/// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// async fn sample(
26///    project_id: &str,
27///    location_id: &str,
28/// ) -> anyhow::Result<()> {
29///     let client = ClientGatewaysService::builder().build().await?;
30///     let mut list = client.list_client_gateways()
31///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
32///         .by_item();
33///     while let Some(item) = list.next().await.transpose()? {
34///         println!("{:?}", item);
35///     }
36///     Ok(())
37/// }
38/// ```
39///
40/// # Service Description
41///
42/// API Overview:
43///
44/// The `beyondcorp.googleapis.com` service implements the Google Cloud
45/// BeyondCorp API.
46///
47/// Data Model:
48///
49/// The ClientGatewaysService exposes the following resources:
50///
51/// * Client Gateways, named as follows:
52///   `projects/{project_id}/locations/{location_id}/clientGateways/{client_gateway_id}`.
53///
54/// # Configuration
55///
56/// To configure `ClientGatewaysService` use the `with_*` methods in the type returned
57/// by [builder()][ClientGatewaysService::builder]. The default configuration should
58/// work for most applications. Common configuration changes include
59///
60/// * [with_endpoint()]: by default this client uses the global default endpoint
61///   (`https://beyondcorp.googleapis.com`). Applications using regional
62///   endpoints or running in restricted networks (e.g. a network configured
63//    with [Private Google Access with VPC Service Controls]) may want to
64///   override this default.
65/// * [with_credentials()]: by default this client uses
66///   [Application Default Credentials]. Applications using custom
67///   authentication may need to override this default.
68///
69/// [with_endpoint()]: super::builder::client_gateways_service::ClientBuilder::with_endpoint
70/// [with_credentials()]: super::builder::client_gateways_service::ClientBuilder::with_credentials
71/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
72/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
73///
74/// # Pooling and Cloning
75///
76/// `ClientGatewaysService` holds a connection pool internally, it is advised to
77/// create one and reuse it. You do not need to wrap `ClientGatewaysService` in
78/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
79/// already uses an `Arc` internally.
80#[derive(Clone, Debug)]
81pub struct ClientGatewaysService {
82    inner: std::sync::Arc<dyn super::stub::dynamic::ClientGatewaysService>,
83}
84
85impl ClientGatewaysService {
86    /// Returns a builder for [ClientGatewaysService].
87    ///
88    /// ```
89    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
90    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
91    /// let client = ClientGatewaysService::builder().build().await?;
92    /// # Ok(()) }
93    /// ```
94    pub fn builder() -> super::builder::client_gateways_service::ClientBuilder {
95        crate::new_client_builder(super::builder::client_gateways_service::client::Factory)
96    }
97
98    /// Creates a new client from the provided stub.
99    ///
100    /// The most common case for calling this function is in tests mocking the
101    /// client's behavior.
102    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
103    where
104        T: super::stub::ClientGatewaysService + 'static,
105    {
106        Self { inner: stub.into() }
107    }
108
109    pub(crate) async fn new(
110        config: gaxi::options::ClientConfig,
111    ) -> crate::ClientBuilderResult<Self> {
112        let inner = Self::build_inner(config).await?;
113        Ok(Self { inner })
114    }
115
116    async fn build_inner(
117        conf: gaxi::options::ClientConfig,
118    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ClientGatewaysService>>
119    {
120        if gaxi::options::tracing_enabled(&conf) {
121            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
122        }
123        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
124    }
125
126    async fn build_transport(
127        conf: gaxi::options::ClientConfig,
128    ) -> crate::ClientBuilderResult<impl super::stub::ClientGatewaysService> {
129        super::transport::ClientGatewaysService::new(conf).await
130    }
131
132    async fn build_with_tracing(
133        conf: gaxi::options::ClientConfig,
134    ) -> crate::ClientBuilderResult<impl super::stub::ClientGatewaysService> {
135        Self::build_transport(conf)
136            .await
137            .map(super::tracing::ClientGatewaysService::new)
138    }
139
140    /// Lists ClientGateways in a given project and location.
141    ///
142    /// # Example
143    /// ```
144    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
145    /// use google_cloud_gax::paginator::ItemPaginator as _;
146    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
147    /// async fn sample(
148    ///    client: &ClientGatewaysService, project_id: &str, location_id: &str
149    /// ) -> Result<()> {
150    ///     let mut list = client.list_client_gateways()
151    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
152    ///         .by_item();
153    ///     while let Some(item) = list.next().await.transpose()? {
154    ///         println!("{:?}", item);
155    ///     }
156    ///     Ok(())
157    /// }
158    /// ```
159    pub fn list_client_gateways(
160        &self,
161    ) -> super::builder::client_gateways_service::ListClientGateways {
162        super::builder::client_gateways_service::ListClientGateways::new(self.inner.clone())
163    }
164
165    /// Gets details of a single ClientGateway.
166    ///
167    /// # Example
168    /// ```
169    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
170    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
171    /// async fn sample(
172    ///    client: &ClientGatewaysService, project_id: &str, location_id: &str, client_gateway_id: &str
173    /// ) -> Result<()> {
174    ///     let response = client.get_client_gateway()
175    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/clientGateways/{client_gateway_id}"))
176    ///         .send().await?;
177    ///     println!("response {:?}", response);
178    ///     Ok(())
179    /// }
180    /// ```
181    pub fn get_client_gateway(&self) -> super::builder::client_gateways_service::GetClientGateway {
182        super::builder::client_gateways_service::GetClientGateway::new(self.inner.clone())
183    }
184
185    /// Creates a new ClientGateway in a given project and location.
186    ///
187    /// # Long running operations
188    ///
189    /// This method is used to start, and/or poll a [long-running Operation].
190    /// The [Working with long-running operations] chapter in the [user guide]
191    /// covers these operations in detail.
192    ///
193    /// [long-running operation]: https://google.aip.dev/151
194    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
195    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
196    ///
197    /// # Example
198    /// ```
199    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
200    /// use google_cloud_lro::Poller;
201    /// use google_cloud_beyondcorp_clientgateways_v1::model::ClientGateway;
202    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
203    /// async fn sample(
204    ///    client: &ClientGatewaysService, project_id: &str, location_id: &str
205    /// ) -> Result<()> {
206    ///     let response = client.create_client_gateway()
207    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
208    ///         .set_client_gateway(
209    ///             ClientGateway::new()/* set fields */
210    ///         )
211    ///         .poller().until_done().await?;
212    ///     println!("response {:?}", response);
213    ///     Ok(())
214    /// }
215    /// ```
216    pub fn create_client_gateway(
217        &self,
218    ) -> super::builder::client_gateways_service::CreateClientGateway {
219        super::builder::client_gateways_service::CreateClientGateway::new(self.inner.clone())
220    }
221
222    /// Deletes a single ClientGateway.
223    ///
224    /// # Long running operations
225    ///
226    /// This method is used to start, and/or poll a [long-running Operation].
227    /// The [Working with long-running operations] chapter in the [user guide]
228    /// covers these operations in detail.
229    ///
230    /// [long-running operation]: https://google.aip.dev/151
231    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
232    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
233    ///
234    /// # Example
235    /// ```
236    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
237    /// use google_cloud_lro::Poller;
238    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
239    /// async fn sample(
240    ///    client: &ClientGatewaysService, project_id: &str, location_id: &str, client_gateway_id: &str
241    /// ) -> Result<()> {
242    ///     client.delete_client_gateway()
243    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/clientGateways/{client_gateway_id}"))
244    ///         .poller().until_done().await?;
245    ///     Ok(())
246    /// }
247    /// ```
248    pub fn delete_client_gateway(
249        &self,
250    ) -> super::builder::client_gateways_service::DeleteClientGateway {
251        super::builder::client_gateways_service::DeleteClientGateway::new(self.inner.clone())
252    }
253
254    /// Lists information about the supported locations for this service.
255    ///
256    /// # Example
257    /// ```
258    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
259    /// use google_cloud_gax::paginator::ItemPaginator as _;
260    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
261    /// async fn sample(
262    ///    client: &ClientGatewaysService
263    /// ) -> Result<()> {
264    ///     let mut list = client.list_locations()
265    ///         /* set fields */
266    ///         .by_item();
267    ///     while let Some(item) = list.next().await.transpose()? {
268    ///         println!("{:?}", item);
269    ///     }
270    ///     Ok(())
271    /// }
272    /// ```
273    pub fn list_locations(&self) -> super::builder::client_gateways_service::ListLocations {
274        super::builder::client_gateways_service::ListLocations::new(self.inner.clone())
275    }
276
277    /// Gets information about a location.
278    ///
279    /// # Example
280    /// ```
281    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
282    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
283    /// async fn sample(
284    ///    client: &ClientGatewaysService
285    /// ) -> Result<()> {
286    ///     let response = client.get_location()
287    ///         /* set fields */
288    ///         .send().await?;
289    ///     println!("response {:?}", response);
290    ///     Ok(())
291    /// }
292    /// ```
293    pub fn get_location(&self) -> super::builder::client_gateways_service::GetLocation {
294        super::builder::client_gateways_service::GetLocation::new(self.inner.clone())
295    }
296
297    /// Sets the access control policy on the specified resource. Replaces
298    /// any existing policy.
299    ///
300    /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
301    /// errors.
302    ///
303    /// # Example
304    /// ```
305    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
306    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
307    /// async fn sample(
308    ///    client: &ClientGatewaysService
309    /// ) -> Result<()> {
310    ///     let response = client.set_iam_policy()
311    ///         /* set fields */
312    ///         .send().await?;
313    ///     println!("response {:?}", response);
314    ///     Ok(())
315    /// }
316    /// ```
317    pub fn set_iam_policy(&self) -> super::builder::client_gateways_service::SetIamPolicy {
318        super::builder::client_gateways_service::SetIamPolicy::new(self.inner.clone())
319    }
320
321    /// Gets the access control policy for a resource. Returns an empty policy
322    /// if the resource exists and does not have a policy set.
323    ///
324    /// # Example
325    /// ```
326    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
327    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
328    /// async fn sample(
329    ///    client: &ClientGatewaysService
330    /// ) -> Result<()> {
331    ///     let response = client.get_iam_policy()
332    ///         /* set fields */
333    ///         .send().await?;
334    ///     println!("response {:?}", response);
335    ///     Ok(())
336    /// }
337    /// ```
338    pub fn get_iam_policy(&self) -> super::builder::client_gateways_service::GetIamPolicy {
339        super::builder::client_gateways_service::GetIamPolicy::new(self.inner.clone())
340    }
341
342    /// Returns permissions that a caller has on the specified resource. If the
343    /// resource does not exist, this will return an empty set of
344    /// permissions, not a `NOT_FOUND` error.
345    ///
346    /// Note: This operation is designed to be used for building
347    /// permission-aware UIs and command-line tools, not for authorization
348    /// checking. This operation may "fail open" without warning.
349    ///
350    /// # Example
351    /// ```
352    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
353    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
354    /// async fn sample(
355    ///    client: &ClientGatewaysService
356    /// ) -> Result<()> {
357    ///     let response = client.test_iam_permissions()
358    ///         /* set fields */
359    ///         .send().await?;
360    ///     println!("response {:?}", response);
361    ///     Ok(())
362    /// }
363    /// ```
364    pub fn test_iam_permissions(
365        &self,
366    ) -> super::builder::client_gateways_service::TestIamPermissions {
367        super::builder::client_gateways_service::TestIamPermissions::new(self.inner.clone())
368    }
369
370    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
371    ///
372    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
373    ///
374    /// # Example
375    /// ```
376    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
377    /// use google_cloud_gax::paginator::ItemPaginator as _;
378    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
379    /// async fn sample(
380    ///    client: &ClientGatewaysService
381    /// ) -> Result<()> {
382    ///     let mut list = client.list_operations()
383    ///         /* set fields */
384    ///         .by_item();
385    ///     while let Some(item) = list.next().await.transpose()? {
386    ///         println!("{:?}", item);
387    ///     }
388    ///     Ok(())
389    /// }
390    /// ```
391    pub fn list_operations(&self) -> super::builder::client_gateways_service::ListOperations {
392        super::builder::client_gateways_service::ListOperations::new(self.inner.clone())
393    }
394
395    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
396    ///
397    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
398    ///
399    /// # Example
400    /// ```
401    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
402    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
403    /// async fn sample(
404    ///    client: &ClientGatewaysService
405    /// ) -> Result<()> {
406    ///     let response = client.get_operation()
407    ///         /* set fields */
408    ///         .send().await?;
409    ///     println!("response {:?}", response);
410    ///     Ok(())
411    /// }
412    /// ```
413    pub fn get_operation(&self) -> super::builder::client_gateways_service::GetOperation {
414        super::builder::client_gateways_service::GetOperation::new(self.inner.clone())
415    }
416
417    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
418    ///
419    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
420    ///
421    /// # Example
422    /// ```
423    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
424    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
425    /// async fn sample(
426    ///    client: &ClientGatewaysService
427    /// ) -> Result<()> {
428    ///     client.delete_operation()
429    ///         /* set fields */
430    ///         .send().await?;
431    ///     Ok(())
432    /// }
433    /// ```
434    pub fn delete_operation(&self) -> super::builder::client_gateways_service::DeleteOperation {
435        super::builder::client_gateways_service::DeleteOperation::new(self.inner.clone())
436    }
437
438    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
439    ///
440    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
441    ///
442    /// # Example
443    /// ```
444    /// # use google_cloud_beyondcorp_clientgateways_v1::client::ClientGatewaysService;
445    /// use google_cloud_beyondcorp_clientgateways_v1::Result;
446    /// async fn sample(
447    ///    client: &ClientGatewaysService
448    /// ) -> Result<()> {
449    ///     client.cancel_operation()
450    ///         /* set fields */
451    ///         .send().await?;
452    ///     Ok(())
453    /// }
454    /// ```
455    pub fn cancel_operation(&self) -> super::builder::client_gateways_service::CancelOperation {
456        super::builder::client_gateways_service::CancelOperation::new(self.inner.clone())
457    }
458}