google_cloud_confidentialcomputing_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::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Confidential Computing API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
26/// use google_cloud_confidentialcomputing_v1::model::Challenge;
27/// async fn sample(
28/// parent: &str,
29/// ) -> anyhow::Result<()> {
30/// let client = ConfidentialComputing::builder().build().await?;
31/// let response = client.create_challenge()
32/// .set_parent(parent)
33/// .set_challenge(
34/// Challenge::new()/* set fields */
35/// )
36/// .send().await?;
37/// println!("response {:?}", response);
38/// Ok(())
39/// }
40/// ```
41///
42/// # Service Description
43///
44/// Service describing handlers for resources
45///
46/// # Configuration
47///
48/// To configure `ConfidentialComputing` use the `with_*` methods in the type returned
49/// by [builder()][ConfidentialComputing::builder]. The default configuration should
50/// work for most applications. Common configuration changes include
51///
52/// * [with_endpoint()]: by default this client uses the global default endpoint
53/// (`https://confidentialcomputing.googleapis.com`). Applications using regional
54/// endpoints or running in restricted networks (e.g. a network configured
55/// with [Private Google Access with VPC Service Controls]) may want to
56/// override this default.
57/// * [with_credentials()]: by default this client uses
58/// [Application Default Credentials]. Applications using custom
59/// authentication may need to override this default.
60///
61/// [with_endpoint()]: super::builder::confidential_computing::ClientBuilder::with_endpoint
62/// [with_credentials()]: super::builder::confidential_computing::ClientBuilder::with_credentials
63/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
64/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
65///
66/// # Pooling and Cloning
67///
68/// `ConfidentialComputing` holds a connection pool internally, it is advised to
69/// create one and reuse it. You do not need to wrap `ConfidentialComputing` in
70/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
71/// already uses an `Arc` internally.
72#[derive(Clone, Debug)]
73pub struct ConfidentialComputing {
74 inner: std::sync::Arc<dyn super::stub::dynamic::ConfidentialComputing>,
75}
76
77impl ConfidentialComputing {
78 /// Returns a builder for [ConfidentialComputing].
79 ///
80 /// ```
81 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
82 /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
83 /// let client = ConfidentialComputing::builder().build().await?;
84 /// # Ok(()) }
85 /// ```
86 pub fn builder() -> super::builder::confidential_computing::ClientBuilder {
87 crate::new_client_builder(super::builder::confidential_computing::client::Factory)
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: impl Into<std::sync::Arc<T>>) -> Self
95 where
96 T: super::stub::ConfidentialComputing + 'static,
97 {
98 Self { inner: stub.into() }
99 }
100
101 pub(crate) async fn new(
102 config: gaxi::options::ClientConfig,
103 ) -> crate::ClientBuilderResult<Self> {
104 let inner = Self::build_inner(config).await?;
105 Ok(Self { inner })
106 }
107
108 async fn build_inner(
109 conf: gaxi::options::ClientConfig,
110 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ConfidentialComputing>>
111 {
112 if gaxi::options::tracing_enabled(&conf) {
113 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
114 }
115 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
116 }
117
118 async fn build_transport(
119 conf: gaxi::options::ClientConfig,
120 ) -> crate::ClientBuilderResult<impl super::stub::ConfidentialComputing> {
121 super::transport::ConfidentialComputing::new(conf).await
122 }
123
124 async fn build_with_tracing(
125 conf: gaxi::options::ClientConfig,
126 ) -> crate::ClientBuilderResult<impl super::stub::ConfidentialComputing> {
127 Self::build_transport(conf)
128 .await
129 .map(super::tracing::ConfidentialComputing::new)
130 }
131
132 /// Creates a new Challenge in a given project and location.
133 ///
134 /// # Example
135 /// ```
136 /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
137 /// use google_cloud_confidentialcomputing_v1::model::Challenge;
138 /// use google_cloud_confidentialcomputing_v1::Result;
139 /// async fn sample(
140 /// client: &ConfidentialComputing, parent: &str
141 /// ) -> Result<()> {
142 /// let response = client.create_challenge()
143 /// .set_parent(parent)
144 /// .set_challenge(
145 /// Challenge::new()/* set fields */
146 /// )
147 /// .send().await?;
148 /// println!("response {:?}", response);
149 /// Ok(())
150 /// }
151 /// ```
152 pub fn create_challenge(&self) -> super::builder::confidential_computing::CreateChallenge {
153 super::builder::confidential_computing::CreateChallenge::new(self.inner.clone())
154 }
155
156 /// Verifies the provided attestation info, returning a signed attestation
157 /// token.
158 ///
159 /// # Example
160 /// ```
161 /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
162 /// use google_cloud_confidentialcomputing_v1::Result;
163 /// async fn sample(
164 /// client: &ConfidentialComputing
165 /// ) -> Result<()> {
166 /// let response = client.verify_attestation()
167 /// /* set fields */
168 /// .send().await?;
169 /// println!("response {:?}", response);
170 /// Ok(())
171 /// }
172 /// ```
173 pub fn verify_attestation(&self) -> super::builder::confidential_computing::VerifyAttestation {
174 super::builder::confidential_computing::VerifyAttestation::new(self.inner.clone())
175 }
176
177 /// Verifies whether the provided attestation info is valid, returning a signed
178 /// attestation token if so.
179 ///
180 /// # Example
181 /// ```
182 /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
183 /// use google_cloud_confidentialcomputing_v1::Result;
184 /// async fn sample(
185 /// client: &ConfidentialComputing
186 /// ) -> Result<()> {
187 /// let response = client.verify_confidential_space()
188 /// /* set fields */
189 /// .send().await?;
190 /// println!("response {:?}", response);
191 /// Ok(())
192 /// }
193 /// ```
194 pub fn verify_confidential_space(
195 &self,
196 ) -> super::builder::confidential_computing::VerifyConfidentialSpace {
197 super::builder::confidential_computing::VerifyConfidentialSpace::new(self.inner.clone())
198 }
199
200 /// Verifies the provided Confidential GKE attestation info, returning a signed
201 /// OIDC token.
202 ///
203 /// # Example
204 /// ```
205 /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
206 /// use google_cloud_confidentialcomputing_v1::Result;
207 /// async fn sample(
208 /// client: &ConfidentialComputing
209 /// ) -> Result<()> {
210 /// let response = client.verify_confidential_gke()
211 /// /* set fields */
212 /// .send().await?;
213 /// println!("response {:?}", response);
214 /// Ok(())
215 /// }
216 /// ```
217 pub fn verify_confidential_gke(
218 &self,
219 ) -> super::builder::confidential_computing::VerifyConfidentialGke {
220 super::builder::confidential_computing::VerifyConfidentialGke::new(self.inner.clone())
221 }
222
223 /// Lists information about the supported locations for this service.
224 ///
225 /// This method lists locations based on the resource scope provided in
226 /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
227 /// **Global locations**: If `name` is empty, the method lists the
228 /// public locations available to all projects. * **Project-specific
229 /// locations**: If `name` follows the format
230 /// `projects/{project}`, the method lists locations visible to that
231 /// specific project. This includes public, private, or other
232 /// project-specific locations enabled for the project.
233 ///
234 /// For gRPC and client library implementations, the resource name is
235 /// passed as the `name` field. For direct service calls, the resource
236 /// name is
237 /// incorporated into the request path based on the specific service
238 /// implementation and version.
239 ///
240 /// [google.cloud.location.ListLocationsRequest.name]: google_cloud_location::model::ListLocationsRequest::name
241 ///
242 /// # Example
243 /// ```
244 /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
245 /// use google_cloud_gax::paginator::ItemPaginator as _;
246 /// use google_cloud_confidentialcomputing_v1::Result;
247 /// async fn sample(
248 /// client: &ConfidentialComputing
249 /// ) -> Result<()> {
250 /// let mut list = client.list_locations()
251 /// /* set fields */
252 /// .by_item();
253 /// while let Some(item) = list.next().await.transpose()? {
254 /// println!("{:?}", item);
255 /// }
256 /// Ok(())
257 /// }
258 /// ```
259 pub fn list_locations(&self) -> super::builder::confidential_computing::ListLocations {
260 super::builder::confidential_computing::ListLocations::new(self.inner.clone())
261 }
262
263 /// Gets information about a location.
264 ///
265 /// # Example
266 /// ```
267 /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
268 /// use google_cloud_confidentialcomputing_v1::Result;
269 /// async fn sample(
270 /// client: &ConfidentialComputing
271 /// ) -> Result<()> {
272 /// let response = client.get_location()
273 /// /* set fields */
274 /// .send().await?;
275 /// println!("response {:?}", response);
276 /// Ok(())
277 /// }
278 /// ```
279 pub fn get_location(&self) -> super::builder::confidential_computing::GetLocation {
280 super::builder::confidential_computing::GetLocation::new(self.inner.clone())
281 }
282}