Skip to main content

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