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() -> Result<(), Box<dyn std::error::Error>> {
26///     let client = ConfidentialComputing::builder().build().await?;
27///     let parent = "parent_value";
28///     let response = client.create_challenge()
29///         .set_parent(parent)
30///         .set_challenge(
31///             Challenge::new()/* set fields */
32///         )
33///         .send().await?;
34///     println!("response {:?}", response);
35/// # Ok(()) }
36/// ```
37///
38/// # Service Description
39///
40/// Service describing handlers for resources
41///
42/// # Configuration
43///
44/// To configure `ConfidentialComputing` use the `with_*` methods in the type returned
45/// by [builder()][ConfidentialComputing::builder]. The default configuration should
46/// work for most applications. Common configuration changes include
47///
48/// * [with_endpoint()]: by default this client uses the global default endpoint
49///   (`https://confidentialcomputing.googleapis.com`). Applications using regional
50///   endpoints or running in restricted networks (e.g. a network configured
51//    with [Private Google Access with VPC Service Controls]) may want to
52///   override this default.
53/// * [with_credentials()]: by default this client uses
54///   [Application Default Credentials]. Applications using custom
55///   authentication may need to override this default.
56///
57/// [with_endpoint()]: super::builder::confidential_computing::ClientBuilder::with_endpoint
58/// [with_credentials()]: super::builder::confidential_computing::ClientBuilder::with_credentials
59/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
60/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
61///
62/// # Pooling and Cloning
63///
64/// `ConfidentialComputing` holds a connection pool internally, it is advised to
65/// create one and reuse it. You do not need to wrap `ConfidentialComputing` in
66/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
67/// already uses an `Arc` internally.
68#[derive(Clone, Debug)]
69pub struct ConfidentialComputing {
70    inner: std::sync::Arc<dyn super::stub::dynamic::ConfidentialComputing>,
71}
72
73impl ConfidentialComputing {
74    /// Returns a builder for [ConfidentialComputing].
75    ///
76    /// ```
77    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
78    /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
79    /// let client = ConfidentialComputing::builder().build().await?;
80    /// # Ok(()) }
81    /// ```
82    pub fn builder() -> super::builder::confidential_computing::ClientBuilder {
83        crate::new_client_builder(super::builder::confidential_computing::client::Factory)
84    }
85
86    /// Creates a new client from the provided stub.
87    ///
88    /// The most common case for calling this function is in tests mocking the
89    /// client's behavior.
90    pub fn from_stub<T>(stub: T) -> Self
91    where
92        T: super::stub::ConfidentialComputing + 'static,
93    {
94        Self {
95            inner: std::sync::Arc::new(stub),
96        }
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    /// This method can be called in two ways:
223    ///
224    /// * **List all public locations:** Use the path `GET /v1/locations`.
225    /// * **List project-visible locations:** Use the path
226    ///   `GET /v1/projects/{project_id}/locations`. This may include public
227    ///   locations as well as private or other locations specifically visible
228    ///   to the project.
229    ///
230    /// # Example
231    /// ```
232    /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
233    /// use google_cloud_gax::paginator::ItemPaginator as _;
234    /// use google_cloud_confidentialcomputing_v1::Result;
235    /// async fn sample(
236    ///    client: &ConfidentialComputing
237    /// ) -> Result<()> {
238    ///     let mut list = client.list_locations()
239    ///         /* set fields */
240    ///         .by_item();
241    ///     while let Some(item) = list.next().await.transpose()? {
242    ///         println!("{:?}", item);
243    ///     }
244    ///     Ok(())
245    /// }
246    /// ```
247    pub fn list_locations(&self) -> super::builder::confidential_computing::ListLocations {
248        super::builder::confidential_computing::ListLocations::new(self.inner.clone())
249    }
250
251    /// Gets information about a location.
252    ///
253    /// # Example
254    /// ```
255    /// # use google_cloud_confidentialcomputing_v1::client::ConfidentialComputing;
256    /// use google_cloud_confidentialcomputing_v1::Result;
257    /// async fn sample(
258    ///    client: &ConfidentialComputing
259    /// ) -> Result<()> {
260    ///     let response = client.get_location()
261    ///         /* set fields */
262    ///         .send().await?;
263    ///     println!("response {:?}", response);
264    ///     Ok(())
265    /// }
266    /// ```
267    pub fn get_location(&self) -> super::builder::confidential_computing::GetLocation {
268        super::builder::confidential_computing::GetLocation::new(self.inner.clone())
269    }
270}