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
19use crate::Result;
20use std::sync::Arc;
21
22/// Implements a client for the Cloud IDS API.
23///
24/// # Example
25/// ```
26/// # tokio_test::block_on(async {
27/// # use google_cloud_ids_v1::client::Ids;
28/// let client = Ids::builder().build().await?;
29/// // use `client` to make requests to the {Codec.APITitle}}.
30/// # gax::Result::<()>::Ok(()) });
31/// ```
32///
33/// # Service Description
34///
35/// The IDS Service
36///
37/// # Configuration
38///
39/// To configure `Ids` use the `with_*` methods in the type returned
40/// by [builder()][Ids::builder]. The default configuration should
41/// work for most applications. Common configuration changes include
42///
43/// * [with_endpoint()]: by default this client uses the global default endpoint
44///   (`https://ids.googleapis.com`). Applications using regional
45///   endpoints or running in restricted networks (e.g. a network configured
46//    with [Private Google Access with VPC Service Controls]) may want to
47///   override this default.
48/// * [with_credentials()]: by default this client uses
49///   [Application Default Credentials]. Applications using custom
50///   authentication may need to override this default.
51///
52/// [with_endpoint()]: super::builder::ids::ClientBuilder::with_endpoint
53/// [with_credentials()]: super::builder::ids::ClientBuilder::credentials
54/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
55/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
56///
57/// # Pooling and Cloning
58///
59/// `Ids` holds a connection pool internally, it is advised to
60/// create one and the reuse it.  You do not need to wrap `Ids` in
61/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
62/// internally.
63#[derive(Clone, Debug)]
64pub struct Ids {
65    inner: Arc<dyn super::stub::dynamic::Ids>,
66}
67
68impl Ids {
69    /// Returns a builder for [Ids].
70    ///
71    /// ```
72    /// # tokio_test::block_on(async {
73    /// # use google_cloud_ids_v1::client::Ids;
74    /// let client = Ids::builder().build().await?;
75    /// # gax::Result::<()>::Ok(()) });
76    /// ```
77    pub fn builder() -> super::builder::ids::ClientBuilder {
78        gax::client_builder::internal::new_builder(super::builder::ids::client::Factory)
79    }
80
81    /// Creates a new client from the provided stub.
82    ///
83    /// The most common case for calling this function is in tests mocking the
84    /// client's behavior.
85    pub fn from_stub<T>(stub: T) -> Self
86    where
87        T: super::stub::Ids + 'static,
88    {
89        Self {
90            inner: Arc::new(stub),
91        }
92    }
93
94    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
95        let inner = Self::build_inner(config).await?;
96        Ok(Self { inner })
97    }
98
99    async fn build_inner(
100        conf: gaxi::options::ClientConfig,
101    ) -> Result<Arc<dyn super::stub::dynamic::Ids>> {
102        if gaxi::options::tracing_enabled(&conf) {
103            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
104        }
105        Ok(Arc::new(Self::build_transport(conf).await?))
106    }
107
108    async fn build_transport(conf: gaxi::options::ClientConfig) -> Result<impl super::stub::Ids> {
109        super::transport::Ids::new(conf).await
110    }
111
112    async fn build_with_tracing(
113        conf: gaxi::options::ClientConfig,
114    ) -> Result<impl super::stub::Ids> {
115        Self::build_transport(conf)
116            .await
117            .map(super::tracing::Ids::new)
118    }
119
120    /// Lists Endpoints in a given project and location.
121    pub fn list_endpoints(
122        &self,
123        parent: impl Into<std::string::String>,
124    ) -> super::builder::ids::ListEndpoints {
125        super::builder::ids::ListEndpoints::new(self.inner.clone()).set_parent(parent.into())
126    }
127
128    /// Gets details of a single Endpoint.
129    pub fn get_endpoint(
130        &self,
131        name: impl Into<std::string::String>,
132    ) -> super::builder::ids::GetEndpoint {
133        super::builder::ids::GetEndpoint::new(self.inner.clone()).set_name(name.into())
134    }
135
136    /// Creates a new Endpoint in a given project and location.
137    ///
138    /// # Long running operations
139    ///
140    /// This method is used to start, and/or poll a [long-running Operation].
141    /// The [Working with long-running operations] chapter in the [user guide]
142    /// covers these operations in detail.
143    ///
144    /// [long-running operation]: https://google.aip.dev/151
145    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
146    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
147    pub fn create_endpoint(
148        &self,
149        parent: impl Into<std::string::String>,
150    ) -> super::builder::ids::CreateEndpoint {
151        super::builder::ids::CreateEndpoint::new(self.inner.clone()).set_parent(parent.into())
152    }
153
154    /// Deletes a single Endpoint.
155    ///
156    /// # Long running operations
157    ///
158    /// This method is used to start, and/or poll a [long-running Operation].
159    /// The [Working with long-running operations] chapter in the [user guide]
160    /// covers these operations in detail.
161    ///
162    /// [long-running operation]: https://google.aip.dev/151
163    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
164    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
165    pub fn delete_endpoint(
166        &self,
167        name: impl Into<std::string::String>,
168    ) -> super::builder::ids::DeleteEndpoint {
169        super::builder::ids::DeleteEndpoint::new(self.inner.clone()).set_name(name.into())
170    }
171
172    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
173    ///
174    /// [google.longrunning.Operations]: longrunning::client::Operations
175    pub fn list_operations(
176        &self,
177        name: impl Into<std::string::String>,
178    ) -> super::builder::ids::ListOperations {
179        super::builder::ids::ListOperations::new(self.inner.clone()).set_name(name.into())
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 get_operation(
186        &self,
187        name: impl Into<std::string::String>,
188    ) -> super::builder::ids::GetOperation {
189        super::builder::ids::GetOperation::new(self.inner.clone()).set_name(name.into())
190    }
191
192    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
193    ///
194    /// [google.longrunning.Operations]: longrunning::client::Operations
195    pub fn delete_operation(
196        &self,
197        name: impl Into<std::string::String>,
198    ) -> super::builder::ids::DeleteOperation {
199        super::builder::ids::DeleteOperation::new(self.inner.clone()).set_name(name.into())
200    }
201
202    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
203    ///
204    /// [google.longrunning.Operations]: longrunning::client::Operations
205    pub fn cancel_operation(
206        &self,
207        name: impl Into<std::string::String>,
208    ) -> super::builder::ids::CancelOperation {
209        super::builder::ids::CancelOperation::new(self.inner.clone()).set_name(name.into())
210    }
211}