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