google_cloud_datastream_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;
20use std::sync::Arc;
21
22/// Implements a client for the Datastream API.
23///
24/// # Example
25/// ```
26/// # tokio_test::block_on(async {
27/// # use google_cloud_datastream_v1::client::Datastream;
28/// let client = Datastream::builder().build().await?;
29/// // use `client` to make requests to the {Codec.APITitle}}.
30/// # gax::Result::<()>::Ok(()) });
31/// ```
32///
33/// # Service Description
34///
35/// Datastream service
36///
37/// # Configuration
38///
39/// To configure `Datastream` use the `with_*` methods in the type returned
40/// by [builder()][Datastream::builder]. The default configuration should
41/// work for most applications. Common configuration changes include
42///
43/// * [with_endpoint()]: by default this client uses the global default endpoint
44///   (`https://datastream.googleapis.com`). Applications using regional
45///   endpoints or running in restricted networks (e.g. a network configured
46//    with [Private Google Access with VPC Service Controls]) may want to
47///   override this default.
48/// * [with_credentials()]: by default this client uses
49///   [Application Default Credentials]. Applications using custom
50///   authentication may need to override this default.
51///
52/// [with_endpoint()]: super::builder::datastream::ClientBuilder::with_endpoint
53/// [with_credentials()]: super::builder::datastream::ClientBuilder::credentials
54/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
55/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
56///
57/// # Pooling and Cloning
58///
59/// `Datastream` holds a connection pool internally, it is advised to
60/// create one and the reuse it.  You do not need to wrap `Datastream` in
61/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc`
62/// internally.
63#[derive(Clone, Debug)]
64pub struct Datastream {
65    inner: Arc<dyn super::stub::dynamic::Datastream>,
66}
67
68impl Datastream {
69    /// Returns a builder for [Datastream].
70    ///
71    /// ```
72    /// # tokio_test::block_on(async {
73    /// # use google_cloud_datastream_v1::client::Datastream;
74    /// let client = Datastream::builder().build().await?;
75    /// # gax::Result::<()>::Ok(()) });
76    /// ```
77    pub fn builder() -> super::builder::datastream::ClientBuilder {
78        gax::client_builder::internal::new_builder(super::builder::datastream::client::Factory)
79    }
80
81    /// Creates a new client from the provided stub.
82    ///
83    /// The most common case for calling this function is in tests mocking the
84    /// client's behavior.
85    pub fn from_stub<T>(stub: T) -> Self
86    where
87        T: super::stub::Datastream + 'static,
88    {
89        Self {
90            inner: Arc::new(stub),
91        }
92    }
93
94    pub(crate) async fn new(config: gaxi::options::ClientConfig) -> Result<Self> {
95        let inner = Self::build_inner(config).await?;
96        Ok(Self { inner })
97    }
98
99    async fn build_inner(
100        conf: gaxi::options::ClientConfig,
101    ) -> Result<Arc<dyn super::stub::dynamic::Datastream>> {
102        if gaxi::options::tracing_enabled(&conf) {
103            return Ok(Arc::new(Self::build_with_tracing(conf).await?));
104        }
105        Ok(Arc::new(Self::build_transport(conf).await?))
106    }
107
108    async fn build_transport(
109        conf: gaxi::options::ClientConfig,
110    ) -> Result<impl super::stub::Datastream> {
111        super::transport::Datastream::new(conf).await
112    }
113
114    async fn build_with_tracing(
115        conf: gaxi::options::ClientConfig,
116    ) -> Result<impl super::stub::Datastream> {
117        Self::build_transport(conf)
118            .await
119            .map(super::tracing::Datastream::new)
120    }
121
122    /// Use this method to list connection profiles created in a project and
123    /// location.
124    pub fn list_connection_profiles(
125        &self,
126        parent: impl Into<std::string::String>,
127    ) -> super::builder::datastream::ListConnectionProfiles {
128        super::builder::datastream::ListConnectionProfiles::new(self.inner.clone())
129            .set_parent(parent.into())
130    }
131
132    /// Use this method to get details about a connection profile.
133    pub fn get_connection_profile(
134        &self,
135        name: impl Into<std::string::String>,
136    ) -> super::builder::datastream::GetConnectionProfile {
137        super::builder::datastream::GetConnectionProfile::new(self.inner.clone())
138            .set_name(name.into())
139    }
140
141    /// Use this method to create a connection profile in a project and location.
142    ///
143    /// # Long running operations
144    ///
145    /// This method is used to start, and/or poll a [long-running Operation].
146    /// The [Working with long-running operations] chapter in the [user guide]
147    /// covers these operations in detail.
148    ///
149    /// [long-running operation]: https://google.aip.dev/151
150    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
151    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
152    pub fn create_connection_profile(
153        &self,
154        parent: impl Into<std::string::String>,
155    ) -> super::builder::datastream::CreateConnectionProfile {
156        super::builder::datastream::CreateConnectionProfile::new(self.inner.clone())
157            .set_parent(parent.into())
158    }
159
160    /// Use this method to update the parameters of a connection profile.
161    ///
162    /// # Long running operations
163    ///
164    /// This method is used to start, and/or poll a [long-running Operation].
165    /// The [Working with long-running operations] chapter in the [user guide]
166    /// covers these operations in detail.
167    ///
168    /// [long-running operation]: https://google.aip.dev/151
169    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
170    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
171    pub fn update_connection_profile(
172        &self,
173        connection_profile: impl Into<crate::model::ConnectionProfile>,
174    ) -> super::builder::datastream::UpdateConnectionProfile {
175        super::builder::datastream::UpdateConnectionProfile::new(self.inner.clone())
176            .set_connection_profile(connection_profile.into())
177    }
178
179    /// Use this method to delete a connection profile.
180    ///
181    /// # Long running operations
182    ///
183    /// This method is used to start, and/or poll a [long-running Operation].
184    /// The [Working with long-running operations] chapter in the [user guide]
185    /// covers these operations in detail.
186    ///
187    /// [long-running operation]: https://google.aip.dev/151
188    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
189    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
190    pub fn delete_connection_profile(
191        &self,
192        name: impl Into<std::string::String>,
193    ) -> super::builder::datastream::DeleteConnectionProfile {
194        super::builder::datastream::DeleteConnectionProfile::new(self.inner.clone())
195            .set_name(name.into())
196    }
197
198    /// Use this method to discover a connection profile.
199    /// The discover API call exposes the data objects and metadata belonging to
200    /// the profile. Typically, a request returns children data objects of a
201    /// parent data object that's optionally supplied in the request.
202    pub fn discover_connection_profile(
203        &self,
204        parent: impl Into<std::string::String>,
205    ) -> super::builder::datastream::DiscoverConnectionProfile {
206        super::builder::datastream::DiscoverConnectionProfile::new(self.inner.clone())
207            .set_parent(parent.into())
208    }
209
210    /// Use this method to list streams in a project and location.
211    pub fn list_streams(
212        &self,
213        parent: impl Into<std::string::String>,
214    ) -> super::builder::datastream::ListStreams {
215        super::builder::datastream::ListStreams::new(self.inner.clone()).set_parent(parent.into())
216    }
217
218    /// Use this method to get details about a stream.
219    pub fn get_stream(
220        &self,
221        name: impl Into<std::string::String>,
222    ) -> super::builder::datastream::GetStream {
223        super::builder::datastream::GetStream::new(self.inner.clone()).set_name(name.into())
224    }
225
226    /// Use this method to create a stream.
227    ///
228    /// # Long running operations
229    ///
230    /// This method is used to start, and/or poll a [long-running Operation].
231    /// The [Working with long-running operations] chapter in the [user guide]
232    /// covers these operations in detail.
233    ///
234    /// [long-running operation]: https://google.aip.dev/151
235    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
236    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
237    pub fn create_stream(
238        &self,
239        parent: impl Into<std::string::String>,
240    ) -> super::builder::datastream::CreateStream {
241        super::builder::datastream::CreateStream::new(self.inner.clone()).set_parent(parent.into())
242    }
243
244    /// Use this method to update the configuration of a stream.
245    ///
246    /// # Long running operations
247    ///
248    /// This method is used to start, and/or poll a [long-running Operation].
249    /// The [Working with long-running operations] chapter in the [user guide]
250    /// covers these operations in detail.
251    ///
252    /// [long-running operation]: https://google.aip.dev/151
253    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
254    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
255    pub fn update_stream(
256        &self,
257        stream: impl Into<crate::model::Stream>,
258    ) -> super::builder::datastream::UpdateStream {
259        super::builder::datastream::UpdateStream::new(self.inner.clone()).set_stream(stream.into())
260    }
261
262    /// Use this method to delete a stream.
263    ///
264    /// # Long running operations
265    ///
266    /// This method is used to start, and/or poll a [long-running Operation].
267    /// The [Working with long-running operations] chapter in the [user guide]
268    /// covers these operations in detail.
269    ///
270    /// [long-running operation]: https://google.aip.dev/151
271    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
272    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
273    pub fn delete_stream(
274        &self,
275        name: impl Into<std::string::String>,
276    ) -> super::builder::datastream::DeleteStream {
277        super::builder::datastream::DeleteStream::new(self.inner.clone()).set_name(name.into())
278    }
279
280    /// Use this method to start, resume or recover a stream with a non default CDC
281    /// strategy.
282    ///
283    /// # Long running operations
284    ///
285    /// This method is used to start, and/or poll a [long-running Operation].
286    /// The [Working with long-running operations] chapter in the [user guide]
287    /// covers these operations in detail.
288    ///
289    /// [long-running operation]: https://google.aip.dev/151
290    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
291    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
292    pub fn run_stream(
293        &self,
294        name: impl Into<std::string::String>,
295    ) -> super::builder::datastream::RunStream {
296        super::builder::datastream::RunStream::new(self.inner.clone()).set_name(name.into())
297    }
298
299    /// Use this method to get details about a stream object.
300    pub fn get_stream_object(
301        &self,
302        name: impl Into<std::string::String>,
303    ) -> super::builder::datastream::GetStreamObject {
304        super::builder::datastream::GetStreamObject::new(self.inner.clone()).set_name(name.into())
305    }
306
307    /// Use this method to look up a stream object by its source object identifier.
308    pub fn lookup_stream_object(
309        &self,
310        parent: impl Into<std::string::String>,
311    ) -> super::builder::datastream::LookupStreamObject {
312        super::builder::datastream::LookupStreamObject::new(self.inner.clone())
313            .set_parent(parent.into())
314    }
315
316    /// Use this method to list the objects of a specific stream.
317    pub fn list_stream_objects(
318        &self,
319        parent: impl Into<std::string::String>,
320    ) -> super::builder::datastream::ListStreamObjects {
321        super::builder::datastream::ListStreamObjects::new(self.inner.clone())
322            .set_parent(parent.into())
323    }
324
325    /// Use this method to start a backfill job for the specified stream object.
326    pub fn start_backfill_job(
327        &self,
328        object: impl Into<std::string::String>,
329    ) -> super::builder::datastream::StartBackfillJob {
330        super::builder::datastream::StartBackfillJob::new(self.inner.clone())
331            .set_object(object.into())
332    }
333
334    /// Use this method to stop a backfill job for the specified stream object.
335    pub fn stop_backfill_job(
336        &self,
337        object: impl Into<std::string::String>,
338    ) -> super::builder::datastream::StopBackfillJob {
339        super::builder::datastream::StopBackfillJob::new(self.inner.clone())
340            .set_object(object.into())
341    }
342
343    /// The FetchStaticIps API call exposes the static IP addresses used by
344    /// Datastream.
345    pub fn fetch_static_ips(
346        &self,
347        name: impl Into<std::string::String>,
348    ) -> super::builder::datastream::FetchStaticIps {
349        super::builder::datastream::FetchStaticIps::new(self.inner.clone()).set_name(name.into())
350    }
351
352    /// Use this method to create a private connectivity configuration.
353    ///
354    /// # Long running operations
355    ///
356    /// This method is used to start, and/or poll a [long-running Operation].
357    /// The [Working with long-running operations] chapter in the [user guide]
358    /// covers these operations in detail.
359    ///
360    /// [long-running operation]: https://google.aip.dev/151
361    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
362    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
363    pub fn create_private_connection(
364        &self,
365        parent: impl Into<std::string::String>,
366    ) -> super::builder::datastream::CreatePrivateConnection {
367        super::builder::datastream::CreatePrivateConnection::new(self.inner.clone())
368            .set_parent(parent.into())
369    }
370
371    /// Use this method to get details about a private connectivity configuration.
372    pub fn get_private_connection(
373        &self,
374        name: impl Into<std::string::String>,
375    ) -> super::builder::datastream::GetPrivateConnection {
376        super::builder::datastream::GetPrivateConnection::new(self.inner.clone())
377            .set_name(name.into())
378    }
379
380    /// Use this method to list private connectivity configurations in a project
381    /// and location.
382    pub fn list_private_connections(
383        &self,
384        parent: impl Into<std::string::String>,
385    ) -> super::builder::datastream::ListPrivateConnections {
386        super::builder::datastream::ListPrivateConnections::new(self.inner.clone())
387            .set_parent(parent.into())
388    }
389
390    /// Use this method to delete a private connectivity configuration.
391    ///
392    /// # Long running operations
393    ///
394    /// This method is used to start, and/or poll a [long-running Operation].
395    /// The [Working with long-running operations] chapter in the [user guide]
396    /// covers these operations in detail.
397    ///
398    /// [long-running operation]: https://google.aip.dev/151
399    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
400    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
401    pub fn delete_private_connection(
402        &self,
403        name: impl Into<std::string::String>,
404    ) -> super::builder::datastream::DeletePrivateConnection {
405        super::builder::datastream::DeletePrivateConnection::new(self.inner.clone())
406            .set_name(name.into())
407    }
408
409    /// Use this method to create a route for a private connectivity configuration
410    /// in a project and location.
411    ///
412    /// # Long running operations
413    ///
414    /// This method is used to start, and/or poll a [long-running Operation].
415    /// The [Working with long-running operations] chapter in the [user guide]
416    /// covers these operations in detail.
417    ///
418    /// [long-running operation]: https://google.aip.dev/151
419    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
420    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
421    pub fn create_route(
422        &self,
423        parent: impl Into<std::string::String>,
424    ) -> super::builder::datastream::CreateRoute {
425        super::builder::datastream::CreateRoute::new(self.inner.clone()).set_parent(parent.into())
426    }
427
428    /// Use this method to get details about a route.
429    pub fn get_route(
430        &self,
431        name: impl Into<std::string::String>,
432    ) -> super::builder::datastream::GetRoute {
433        super::builder::datastream::GetRoute::new(self.inner.clone()).set_name(name.into())
434    }
435
436    /// Use this method to list routes created for a private connectivity
437    /// configuration in a project and location.
438    pub fn list_routes(
439        &self,
440        parent: impl Into<std::string::String>,
441    ) -> super::builder::datastream::ListRoutes {
442        super::builder::datastream::ListRoutes::new(self.inner.clone()).set_parent(parent.into())
443    }
444
445    /// Use this method to delete a route.
446    ///
447    /// # Long running operations
448    ///
449    /// This method is used to start, and/or poll a [long-running Operation].
450    /// The [Working with long-running operations] chapter in the [user guide]
451    /// covers these operations in detail.
452    ///
453    /// [long-running operation]: https://google.aip.dev/151
454    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
455    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
456    pub fn delete_route(
457        &self,
458        name: impl Into<std::string::String>,
459    ) -> super::builder::datastream::DeleteRoute {
460        super::builder::datastream::DeleteRoute::new(self.inner.clone()).set_name(name.into())
461    }
462
463    /// Lists information about the supported locations for this service.
464    pub fn list_locations(
465        &self,
466        name: impl Into<std::string::String>,
467    ) -> super::builder::datastream::ListLocations {
468        super::builder::datastream::ListLocations::new(self.inner.clone()).set_name(name.into())
469    }
470
471    /// Gets information about a location.
472    pub fn get_location(
473        &self,
474        name: impl Into<std::string::String>,
475    ) -> super::builder::datastream::GetLocation {
476        super::builder::datastream::GetLocation::new(self.inner.clone()).set_name(name.into())
477    }
478
479    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
480    ///
481    /// [google.longrunning.Operations]: longrunning::client::Operations
482    pub fn list_operations(
483        &self,
484        name: impl Into<std::string::String>,
485    ) -> super::builder::datastream::ListOperations {
486        super::builder::datastream::ListOperations::new(self.inner.clone()).set_name(name.into())
487    }
488
489    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
490    ///
491    /// [google.longrunning.Operations]: longrunning::client::Operations
492    pub fn get_operation(
493        &self,
494        name: impl Into<std::string::String>,
495    ) -> super::builder::datastream::GetOperation {
496        super::builder::datastream::GetOperation::new(self.inner.clone()).set_name(name.into())
497    }
498
499    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
500    ///
501    /// [google.longrunning.Operations]: longrunning::client::Operations
502    pub fn delete_operation(
503        &self,
504        name: impl Into<std::string::String>,
505    ) -> super::builder::datastream::DeleteOperation {
506        super::builder::datastream::DeleteOperation::new(self.inner.clone()).set_name(name.into())
507    }
508
509    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
510    ///
511    /// [google.longrunning.Operations]: longrunning::client::Operations
512    pub fn cancel_operation(
513        &self,
514        name: impl Into<std::string::String>,
515    ) -> super::builder::datastream::CancelOperation {
516        super::builder::datastream::CancelOperation::new(self.inner.clone()).set_name(name.into())
517    }
518}