google_cloud_ids_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 IDS API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_ids_v1::client::Ids;
25/// let client = Ids::builder().build().await?;
26/// // use `client` to make requests to the Cloud IDS API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// The IDS Service
33///
34/// # Configuration
35///
36/// To configure `Ids` use the `with_*` methods in the type returned
37/// by [builder()][Ids::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://ids.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::ids::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::ids::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/// `Ids` holds a connection pool internally, it is advised to
57/// create one and the reuse it.  You do not need to wrap `Ids` 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 Ids {
62    inner: std::sync::Arc<dyn super::stub::dynamic::Ids>,
63}
64
65impl Ids {
66    /// Returns a builder for [Ids].
67    ///
68    /// ```
69    /// # tokio_test::block_on(async {
70    /// # use google_cloud_ids_v1::client::Ids;
71    /// let client = Ids::builder().build().await?;
72    /// # gax::client_builder::Result::<()>::Ok(()) });
73    /// ```
74    pub fn builder() -> super::builder::ids::ClientBuilder {
75        gax::client_builder::internal::new_builder(super::builder::ids::client::Factory)
76    }
77
78    /// Creates a new client from the provided stub.
79    ///
80    /// The most common case for calling this function is in tests mocking the
81    /// client's behavior.
82    pub fn from_stub<T>(stub: T) -> Self
83    where
84        T: super::stub::Ids + 'static,
85    {
86        Self {
87            inner: std::sync::Arc::new(stub),
88        }
89    }
90
91    pub(crate) async fn new(
92        config: gaxi::options::ClientConfig,
93    ) -> gax::client_builder::Result<Self> {
94        let inner = Self::build_inner(config).await?;
95        Ok(Self { inner })
96    }
97
98    async fn build_inner(
99        conf: gaxi::options::ClientConfig,
100    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Ids>> {
101        if gaxi::options::tracing_enabled(&conf) {
102            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
103        }
104        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
105    }
106
107    async fn build_transport(
108        conf: gaxi::options::ClientConfig,
109    ) -> gax::client_builder::Result<impl super::stub::Ids> {
110        super::transport::Ids::new(conf).await
111    }
112
113    async fn build_with_tracing(
114        conf: gaxi::options::ClientConfig,
115    ) -> gax::client_builder::Result<impl super::stub::Ids> {
116        Self::build_transport(conf)
117            .await
118            .map(super::tracing::Ids::new)
119    }
120
121    /// Lists Endpoints in a given project and location.
122    pub fn list_endpoints(&self) -> super::builder::ids::ListEndpoints {
123        super::builder::ids::ListEndpoints::new(self.inner.clone())
124    }
125
126    /// Gets details of a single Endpoint.
127    pub fn get_endpoint(&self) -> super::builder::ids::GetEndpoint {
128        super::builder::ids::GetEndpoint::new(self.inner.clone())
129    }
130
131    /// Creates a new Endpoint in a given project and location.
132    ///
133    /// # Long running operations
134    ///
135    /// This method is used to start, and/or poll a [long-running Operation].
136    /// The [Working with long-running operations] chapter in the [user guide]
137    /// covers these operations in detail.
138    ///
139    /// [long-running operation]: https://google.aip.dev/151
140    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
141    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
142    pub fn create_endpoint(&self) -> super::builder::ids::CreateEndpoint {
143        super::builder::ids::CreateEndpoint::new(self.inner.clone())
144    }
145
146    /// Deletes a single Endpoint.
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 delete_endpoint(&self) -> super::builder::ids::DeleteEndpoint {
158        super::builder::ids::DeleteEndpoint::new(self.inner.clone())
159    }
160
161    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
162    ///
163    /// [google.longrunning.Operations]: longrunning::client::Operations
164    pub fn list_operations(&self) -> super::builder::ids::ListOperations {
165        super::builder::ids::ListOperations::new(self.inner.clone())
166    }
167
168    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
169    ///
170    /// [google.longrunning.Operations]: longrunning::client::Operations
171    pub fn get_operation(&self) -> super::builder::ids::GetOperation {
172        super::builder::ids::GetOperation::new(self.inner.clone())
173    }
174
175    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
176    ///
177    /// [google.longrunning.Operations]: longrunning::client::Operations
178    pub fn delete_operation(&self) -> super::builder::ids::DeleteOperation {
179        super::builder::ids::DeleteOperation::new(self.inner.clone())
180    }
181
182    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
183    ///
184    /// [google.longrunning.Operations]: longrunning::client::Operations
185    pub fn cancel_operation(&self) -> super::builder::ids::CancelOperation {
186        super::builder::ids::CancelOperation::new(self.inner.clone())
187    }
188}