Skip to main content

google_cloud_blockchainnodeengine_v1/
client.rs

1// Copyright 2026 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 Blockchain Node Engine API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28///    project_id: &str,
29///    location_id: &str,
30/// ) -> anyhow::Result<()> {
31///     let client = BlockchainNodeEngine::builder().build().await?;
32///     let mut list = client.list_blockchain_nodes()
33///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
34///         .by_item();
35///     while let Some(item) = list.next().await.transpose()? {
36///         println!("{:?}", item);
37///     }
38///     Ok(())
39/// }
40/// ```
41///
42/// # Service Description
43///
44/// This service is the control plane API for Blockchain Node Engine,
45/// and can be used to create, read, and delete blockchain nodes.
46///
47/// # Configuration
48///
49/// To configure `BlockchainNodeEngine` use the `with_*` methods in the type returned
50/// by [builder()][BlockchainNodeEngine::builder]. The default configuration should
51/// work for most applications. Common configuration changes include
52///
53/// * [with_endpoint()]: by default this client uses the global default endpoint
54///   (`https://blockchainnodeengine.googleapis.com`). Applications using regional
55///   endpoints or running in restricted networks (e.g. a network configured
56///   with [Private Google Access with VPC Service Controls]) may want to
57///   override this default.
58/// * [with_credentials()]: by default this client uses
59///   [Application Default Credentials]. Applications using custom
60///   authentication may need to override this default.
61///
62/// [with_endpoint()]: super::builder::blockchain_node_engine::ClientBuilder::with_endpoint
63/// [with_credentials()]: super::builder::blockchain_node_engine::ClientBuilder::with_credentials
64/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
65/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
66///
67/// # Pooling and Cloning
68///
69/// `BlockchainNodeEngine` holds a connection pool internally, it is advised to
70/// create one and reuse it. You do not need to wrap `BlockchainNodeEngine` in
71/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
72/// already uses an `Arc` internally.
73#[derive(Clone, Debug)]
74pub struct BlockchainNodeEngine {
75    inner: std::sync::Arc<dyn super::stub::dynamic::BlockchainNodeEngine>,
76}
77
78impl BlockchainNodeEngine {
79    /// Returns a builder for [BlockchainNodeEngine].
80    ///
81    /// ```
82    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
83    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
84    /// let client = BlockchainNodeEngine::builder().build().await?;
85    /// # Ok(()) }
86    /// ```
87    pub fn builder() -> super::builder::blockchain_node_engine::ClientBuilder {
88        crate::new_client_builder(super::builder::blockchain_node_engine::client::Factory)
89    }
90
91    /// Creates a new client from the provided stub.
92    ///
93    /// The most common case for calling this function is in tests mocking the
94    /// client's behavior.
95    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
96    where
97        T: super::stub::BlockchainNodeEngine + 'static,
98    {
99        Self { inner: stub.into() }
100    }
101
102    pub(crate) async fn new(
103        config: gaxi::options::ClientConfig,
104    ) -> crate::ClientBuilderResult<Self> {
105        let inner = Self::build_inner(config).await?;
106        Ok(Self { inner })
107    }
108
109    async fn build_inner(
110        conf: gaxi::options::ClientConfig,
111    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::BlockchainNodeEngine>>
112    {
113        if gaxi::options::tracing_enabled(&conf) {
114            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
115        }
116        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
117    }
118
119    async fn build_transport(
120        conf: gaxi::options::ClientConfig,
121    ) -> crate::ClientBuilderResult<impl super::stub::BlockchainNodeEngine> {
122        super::transport::BlockchainNodeEngine::new(conf).await
123    }
124
125    async fn build_with_tracing(
126        conf: gaxi::options::ClientConfig,
127    ) -> crate::ClientBuilderResult<impl super::stub::BlockchainNodeEngine> {
128        Self::build_transport(conf)
129            .await
130            .map(super::tracing::BlockchainNodeEngine::new)
131    }
132
133    /// Lists blockchain nodes in a given project and location.
134    ///
135    /// # Example
136    /// ```
137    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
138    /// use google_cloud_gax::paginator::ItemPaginator as _;
139    /// use google_cloud_blockchainnodeengine_v1::Result;
140    /// async fn sample(
141    ///    client: &BlockchainNodeEngine, project_id: &str, location_id: &str
142    /// ) -> Result<()> {
143    ///     let mut list = client.list_blockchain_nodes()
144    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
145    ///         .by_item();
146    ///     while let Some(item) = list.next().await.transpose()? {
147    ///         println!("{:?}", item);
148    ///     }
149    ///     Ok(())
150    /// }
151    /// ```
152    pub fn list_blockchain_nodes(
153        &self,
154    ) -> super::builder::blockchain_node_engine::ListBlockchainNodes {
155        super::builder::blockchain_node_engine::ListBlockchainNodes::new(self.inner.clone())
156    }
157
158    /// Gets details of a single blockchain node.
159    ///
160    /// # Example
161    /// ```
162    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
163    /// use google_cloud_blockchainnodeengine_v1::Result;
164    /// async fn sample(
165    ///    client: &BlockchainNodeEngine, project_id: &str, location_id: &str, blockchain_node_id: &str
166    /// ) -> Result<()> {
167    ///     let response = client.get_blockchain_node()
168    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/blockchainNodes/{blockchain_node_id}"))
169    ///         .send().await?;
170    ///     println!("response {:?}", response);
171    ///     Ok(())
172    /// }
173    /// ```
174    pub fn get_blockchain_node(&self) -> super::builder::blockchain_node_engine::GetBlockchainNode {
175        super::builder::blockchain_node_engine::GetBlockchainNode::new(self.inner.clone())
176    }
177
178    /// Creates a new blockchain node in a given project and location.
179    ///
180    /// # Long running operations
181    ///
182    /// This method is used to start, and/or poll a [long-running Operation].
183    /// The [Working with long-running operations] chapter in the [user guide]
184    /// covers these operations in detail.
185    ///
186    /// [long-running operation]: https://google.aip.dev/151
187    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
188    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
189    ///
190    /// # Example
191    /// ```
192    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
193    /// use google_cloud_lro::Poller;
194    /// use google_cloud_blockchainnodeengine_v1::model::BlockchainNode;
195    /// use google_cloud_blockchainnodeengine_v1::Result;
196    /// async fn sample(
197    ///    client: &BlockchainNodeEngine, project_id: &str, location_id: &str
198    /// ) -> Result<()> {
199    ///     let response = client.create_blockchain_node()
200    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
201    ///         .set_blockchain_node(
202    ///             BlockchainNode::new()/* set fields */
203    ///         )
204    ///         .poller().until_done().await?;
205    ///     println!("response {:?}", response);
206    ///     Ok(())
207    /// }
208    /// ```
209    pub fn create_blockchain_node(
210        &self,
211    ) -> super::builder::blockchain_node_engine::CreateBlockchainNode {
212        super::builder::blockchain_node_engine::CreateBlockchainNode::new(self.inner.clone())
213    }
214
215    /// Updates the parameters of a single blockchain node.
216    ///
217    /// # Long running operations
218    ///
219    /// This method is used to start, and/or poll a [long-running Operation].
220    /// The [Working with long-running operations] chapter in the [user guide]
221    /// covers these operations in detail.
222    ///
223    /// [long-running operation]: https://google.aip.dev/151
224    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
225    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
226    ///
227    /// # Example
228    /// ```
229    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
230    /// use google_cloud_lro::Poller;
231    /// # extern crate wkt as google_cloud_wkt;
232    /// use google_cloud_wkt::FieldMask;
233    /// use google_cloud_blockchainnodeengine_v1::model::BlockchainNode;
234    /// use google_cloud_blockchainnodeengine_v1::Result;
235    /// async fn sample(
236    ///    client: &BlockchainNodeEngine, project_id: &str, location_id: &str, blockchain_node_id: &str
237    /// ) -> Result<()> {
238    ///     let response = client.update_blockchain_node()
239    ///         .set_blockchain_node(
240    ///             BlockchainNode::new().set_name(format!("projects/{project_id}/locations/{location_id}/blockchainNodes/{blockchain_node_id}"))/* set fields */
241    ///         )
242    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
243    ///         .poller().until_done().await?;
244    ///     println!("response {:?}", response);
245    ///     Ok(())
246    /// }
247    /// ```
248    pub fn update_blockchain_node(
249        &self,
250    ) -> super::builder::blockchain_node_engine::UpdateBlockchainNode {
251        super::builder::blockchain_node_engine::UpdateBlockchainNode::new(self.inner.clone())
252    }
253
254    /// Deletes a single blockchain node.
255    ///
256    /// # Long running operations
257    ///
258    /// This method is used to start, and/or poll a [long-running Operation].
259    /// The [Working with long-running operations] chapter in the [user guide]
260    /// covers these operations in detail.
261    ///
262    /// [long-running operation]: https://google.aip.dev/151
263    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
264    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
265    ///
266    /// # Example
267    /// ```
268    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
269    /// use google_cloud_lro::Poller;
270    /// use google_cloud_blockchainnodeengine_v1::Result;
271    /// async fn sample(
272    ///    client: &BlockchainNodeEngine, project_id: &str, location_id: &str, blockchain_node_id: &str
273    /// ) -> Result<()> {
274    ///     client.delete_blockchain_node()
275    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/blockchainNodes/{blockchain_node_id}"))
276    ///         .poller().until_done().await?;
277    ///     Ok(())
278    /// }
279    /// ```
280    pub fn delete_blockchain_node(
281        &self,
282    ) -> super::builder::blockchain_node_engine::DeleteBlockchainNode {
283        super::builder::blockchain_node_engine::DeleteBlockchainNode::new(self.inner.clone())
284    }
285
286    /// Lists information about the supported locations for this service.
287    ///
288    /// # Example
289    /// ```
290    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
291    /// use google_cloud_gax::paginator::ItemPaginator as _;
292    /// use google_cloud_blockchainnodeengine_v1::Result;
293    /// async fn sample(
294    ///    client: &BlockchainNodeEngine
295    /// ) -> Result<()> {
296    ///     let mut list = client.list_locations()
297    ///         /* set fields */
298    ///         .by_item();
299    ///     while let Some(item) = list.next().await.transpose()? {
300    ///         println!("{:?}", item);
301    ///     }
302    ///     Ok(())
303    /// }
304    /// ```
305    pub fn list_locations(&self) -> super::builder::blockchain_node_engine::ListLocations {
306        super::builder::blockchain_node_engine::ListLocations::new(self.inner.clone())
307    }
308
309    /// Gets information about a location.
310    ///
311    /// # Example
312    /// ```
313    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
314    /// use google_cloud_blockchainnodeengine_v1::Result;
315    /// async fn sample(
316    ///    client: &BlockchainNodeEngine
317    /// ) -> Result<()> {
318    ///     let response = client.get_location()
319    ///         /* set fields */
320    ///         .send().await?;
321    ///     println!("response {:?}", response);
322    ///     Ok(())
323    /// }
324    /// ```
325    pub fn get_location(&self) -> super::builder::blockchain_node_engine::GetLocation {
326        super::builder::blockchain_node_engine::GetLocation::new(self.inner.clone())
327    }
328
329    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
330    ///
331    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
332    ///
333    /// # Example
334    /// ```
335    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
336    /// use google_cloud_gax::paginator::ItemPaginator as _;
337    /// use google_cloud_blockchainnodeengine_v1::Result;
338    /// async fn sample(
339    ///    client: &BlockchainNodeEngine
340    /// ) -> Result<()> {
341    ///     let mut list = client.list_operations()
342    ///         /* set fields */
343    ///         .by_item();
344    ///     while let Some(item) = list.next().await.transpose()? {
345    ///         println!("{:?}", item);
346    ///     }
347    ///     Ok(())
348    /// }
349    /// ```
350    pub fn list_operations(&self) -> super::builder::blockchain_node_engine::ListOperations {
351        super::builder::blockchain_node_engine::ListOperations::new(self.inner.clone())
352    }
353
354    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
355    ///
356    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
357    ///
358    /// # Example
359    /// ```
360    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
361    /// use google_cloud_blockchainnodeengine_v1::Result;
362    /// async fn sample(
363    ///    client: &BlockchainNodeEngine
364    /// ) -> Result<()> {
365    ///     let response = client.get_operation()
366    ///         /* set fields */
367    ///         .send().await?;
368    ///     println!("response {:?}", response);
369    ///     Ok(())
370    /// }
371    /// ```
372    pub fn get_operation(&self) -> super::builder::blockchain_node_engine::GetOperation {
373        super::builder::blockchain_node_engine::GetOperation::new(self.inner.clone())
374    }
375
376    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
377    ///
378    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
379    ///
380    /// # Example
381    /// ```
382    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
383    /// use google_cloud_blockchainnodeengine_v1::Result;
384    /// async fn sample(
385    ///    client: &BlockchainNodeEngine
386    /// ) -> Result<()> {
387    ///     client.delete_operation()
388    ///         /* set fields */
389    ///         .send().await?;
390    ///     Ok(())
391    /// }
392    /// ```
393    pub fn delete_operation(&self) -> super::builder::blockchain_node_engine::DeleteOperation {
394        super::builder::blockchain_node_engine::DeleteOperation::new(self.inner.clone())
395    }
396
397    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
398    ///
399    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
400    ///
401    /// # Example
402    /// ```
403    /// # use google_cloud_blockchainnodeengine_v1::client::BlockchainNodeEngine;
404    /// use google_cloud_blockchainnodeengine_v1::Result;
405    /// async fn sample(
406    ///    client: &BlockchainNodeEngine
407    /// ) -> Result<()> {
408    ///     client.cancel_operation()
409    ///         /* set fields */
410    ///         .send().await?;
411    ///     Ok(())
412    /// }
413    /// ```
414    pub fn cancel_operation(&self) -> super::builder::blockchain_node_engine::CancelOperation {
415        super::builder::blockchain_node_engine::CancelOperation::new(self.inner.clone())
416    }
417}