google_cloud_managedkafka_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 Managed Service for Apache Kafka API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_managedkafka_v1::client::ManagedKafka;
25/// let client = ManagedKafka::builder().build().await?;
26/// // use `client` to make requests to the Managed Service for Apache Kafka API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// The service that a client application uses to manage Apache Kafka clusters,
33/// topics and consumer groups.
34///
35/// # Configuration
36///
37/// To configure `ManagedKafka` use the `with_*` methods in the type returned
38/// by [builder()][ManagedKafka::builder]. The default configuration should
39/// work for most applications. Common configuration changes include
40///
41/// * [with_endpoint()]: by default this client uses the global default endpoint
42///   (`https://managedkafka.googleapis.com`). Applications using regional
43///   endpoints or running in restricted networks (e.g. a network configured
44//    with [Private Google Access with VPC Service Controls]) may want to
45///   override this default.
46/// * [with_credentials()]: by default this client uses
47///   [Application Default Credentials]. Applications using custom
48///   authentication may need to override this default.
49///
50/// [with_endpoint()]: super::builder::managed_kafka::ClientBuilder::with_endpoint
51/// [with_credentials()]: super::builder::managed_kafka::ClientBuilder::credentials
52/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
53/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
54///
55/// # Pooling and Cloning
56///
57/// `ManagedKafka` holds a connection pool internally, it is advised to
58/// create one and the reuse it.  You do not need to wrap `ManagedKafka` in
59/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
60/// already uses an `Arc` internally.
61#[derive(Clone, Debug)]
62pub struct ManagedKafka {
63    inner: std::sync::Arc<dyn super::stub::dynamic::ManagedKafka>,
64}
65
66impl ManagedKafka {
67    /// Returns a builder for [ManagedKafka].
68    ///
69    /// ```
70    /// # tokio_test::block_on(async {
71    /// # use google_cloud_managedkafka_v1::client::ManagedKafka;
72    /// let client = ManagedKafka::builder().build().await?;
73    /// # gax::client_builder::Result::<()>::Ok(()) });
74    /// ```
75    pub fn builder() -> super::builder::managed_kafka::ClientBuilder {
76        gax::client_builder::internal::new_builder(super::builder::managed_kafka::client::Factory)
77    }
78
79    /// Creates a new client from the provided stub.
80    ///
81    /// The most common case for calling this function is in tests mocking the
82    /// client's behavior.
83    pub fn from_stub<T>(stub: T) -> Self
84    where
85        T: super::stub::ManagedKafka + 'static,
86    {
87        Self {
88            inner: std::sync::Arc::new(stub),
89        }
90    }
91
92    pub(crate) async fn new(
93        config: gaxi::options::ClientConfig,
94    ) -> gax::client_builder::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    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ManagedKafka>> {
102        if gaxi::options::tracing_enabled(&conf) {
103            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
104        }
105        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
106    }
107
108    async fn build_transport(
109        conf: gaxi::options::ClientConfig,
110    ) -> gax::client_builder::Result<impl super::stub::ManagedKafka> {
111        super::transport::ManagedKafka::new(conf).await
112    }
113
114    async fn build_with_tracing(
115        conf: gaxi::options::ClientConfig,
116    ) -> gax::client_builder::Result<impl super::stub::ManagedKafka> {
117        Self::build_transport(conf)
118            .await
119            .map(super::tracing::ManagedKafka::new)
120    }
121
122    /// Lists the clusters in a given project and location.
123    pub fn list_clusters(&self) -> super::builder::managed_kafka::ListClusters {
124        super::builder::managed_kafka::ListClusters::new(self.inner.clone())
125    }
126
127    /// Returns the properties of a single cluster.
128    pub fn get_cluster(&self) -> super::builder::managed_kafka::GetCluster {
129        super::builder::managed_kafka::GetCluster::new(self.inner.clone())
130    }
131
132    /// Creates a new cluster in a given project and location.
133    ///
134    /// # Long running operations
135    ///
136    /// This method is used to start, and/or poll a [long-running Operation].
137    /// The [Working with long-running operations] chapter in the [user guide]
138    /// covers these operations in detail.
139    ///
140    /// [long-running operation]: https://google.aip.dev/151
141    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
142    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
143    pub fn create_cluster(&self) -> super::builder::managed_kafka::CreateCluster {
144        super::builder::managed_kafka::CreateCluster::new(self.inner.clone())
145    }
146
147    /// Updates the properties of a single cluster.
148    ///
149    /// # Long running operations
150    ///
151    /// This method is used to start, and/or poll a [long-running Operation].
152    /// The [Working with long-running operations] chapter in the [user guide]
153    /// covers these operations in detail.
154    ///
155    /// [long-running operation]: https://google.aip.dev/151
156    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
157    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
158    pub fn update_cluster(&self) -> super::builder::managed_kafka::UpdateCluster {
159        super::builder::managed_kafka::UpdateCluster::new(self.inner.clone())
160    }
161
162    /// Deletes a single cluster.
163    ///
164    /// # Long running operations
165    ///
166    /// This method is used to start, and/or poll a [long-running Operation].
167    /// The [Working with long-running operations] chapter in the [user guide]
168    /// covers these operations in detail.
169    ///
170    /// [long-running operation]: https://google.aip.dev/151
171    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
172    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
173    pub fn delete_cluster(&self) -> super::builder::managed_kafka::DeleteCluster {
174        super::builder::managed_kafka::DeleteCluster::new(self.inner.clone())
175    }
176
177    /// Lists the topics in a given cluster.
178    pub fn list_topics(&self) -> super::builder::managed_kafka::ListTopics {
179        super::builder::managed_kafka::ListTopics::new(self.inner.clone())
180    }
181
182    /// Returns the properties of a single topic.
183    pub fn get_topic(&self) -> super::builder::managed_kafka::GetTopic {
184        super::builder::managed_kafka::GetTopic::new(self.inner.clone())
185    }
186
187    /// Creates a new topic in a given project and location.
188    pub fn create_topic(&self) -> super::builder::managed_kafka::CreateTopic {
189        super::builder::managed_kafka::CreateTopic::new(self.inner.clone())
190    }
191
192    /// Updates the properties of a single topic.
193    pub fn update_topic(&self) -> super::builder::managed_kafka::UpdateTopic {
194        super::builder::managed_kafka::UpdateTopic::new(self.inner.clone())
195    }
196
197    /// Deletes a single topic.
198    pub fn delete_topic(&self) -> super::builder::managed_kafka::DeleteTopic {
199        super::builder::managed_kafka::DeleteTopic::new(self.inner.clone())
200    }
201
202    /// Lists the consumer groups in a given cluster.
203    pub fn list_consumer_groups(&self) -> super::builder::managed_kafka::ListConsumerGroups {
204        super::builder::managed_kafka::ListConsumerGroups::new(self.inner.clone())
205    }
206
207    /// Returns the properties of a single consumer group.
208    pub fn get_consumer_group(&self) -> super::builder::managed_kafka::GetConsumerGroup {
209        super::builder::managed_kafka::GetConsumerGroup::new(self.inner.clone())
210    }
211
212    /// Updates the properties of a single consumer group.
213    pub fn update_consumer_group(&self) -> super::builder::managed_kafka::UpdateConsumerGroup {
214        super::builder::managed_kafka::UpdateConsumerGroup::new(self.inner.clone())
215    }
216
217    /// Deletes a single consumer group.
218    pub fn delete_consumer_group(&self) -> super::builder::managed_kafka::DeleteConsumerGroup {
219        super::builder::managed_kafka::DeleteConsumerGroup::new(self.inner.clone())
220    }
221
222    /// Lists the acls in a given cluster.
223    pub fn list_acls(&self) -> super::builder::managed_kafka::ListAcls {
224        super::builder::managed_kafka::ListAcls::new(self.inner.clone())
225    }
226
227    /// Returns the properties of a single acl.
228    pub fn get_acl(&self) -> super::builder::managed_kafka::GetAcl {
229        super::builder::managed_kafka::GetAcl::new(self.inner.clone())
230    }
231
232    /// Creates a new acl in the given project, location, and cluster.
233    pub fn create_acl(&self) -> super::builder::managed_kafka::CreateAcl {
234        super::builder::managed_kafka::CreateAcl::new(self.inner.clone())
235    }
236
237    /// Updates the properties of a single acl.
238    pub fn update_acl(&self) -> super::builder::managed_kafka::UpdateAcl {
239        super::builder::managed_kafka::UpdateAcl::new(self.inner.clone())
240    }
241
242    /// Deletes an acl.
243    pub fn delete_acl(&self) -> super::builder::managed_kafka::DeleteAcl {
244        super::builder::managed_kafka::DeleteAcl::new(self.inner.clone())
245    }
246
247    /// Incremental update: Adds an acl entry to an acl. Creates the acl if it does
248    /// not exist yet.
249    pub fn add_acl_entry(&self) -> super::builder::managed_kafka::AddAclEntry {
250        super::builder::managed_kafka::AddAclEntry::new(self.inner.clone())
251    }
252
253    /// Incremental update: Removes an acl entry from an acl. Deletes the acl if
254    /// its acl entries become empty (i.e. if the removed entry was the last one in
255    /// the acl).
256    pub fn remove_acl_entry(&self) -> super::builder::managed_kafka::RemoveAclEntry {
257        super::builder::managed_kafka::RemoveAclEntry::new(self.inner.clone())
258    }
259
260    /// Lists information about the supported locations for this service.
261    pub fn list_locations(&self) -> super::builder::managed_kafka::ListLocations {
262        super::builder::managed_kafka::ListLocations::new(self.inner.clone())
263    }
264
265    /// Gets information about a location.
266    pub fn get_location(&self) -> super::builder::managed_kafka::GetLocation {
267        super::builder::managed_kafka::GetLocation::new(self.inner.clone())
268    }
269
270    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
271    ///
272    /// [google.longrunning.Operations]: longrunning::client::Operations
273    pub fn list_operations(&self) -> super::builder::managed_kafka::ListOperations {
274        super::builder::managed_kafka::ListOperations::new(self.inner.clone())
275    }
276
277    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
278    ///
279    /// [google.longrunning.Operations]: longrunning::client::Operations
280    pub fn get_operation(&self) -> super::builder::managed_kafka::GetOperation {
281        super::builder::managed_kafka::GetOperation::new(self.inner.clone())
282    }
283
284    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
285    ///
286    /// [google.longrunning.Operations]: longrunning::client::Operations
287    pub fn delete_operation(&self) -> super::builder::managed_kafka::DeleteOperation {
288        super::builder::managed_kafka::DeleteOperation::new(self.inner.clone())
289    }
290
291    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
292    ///
293    /// [google.longrunning.Operations]: longrunning::client::Operations
294    pub fn cancel_operation(&self) -> super::builder::managed_kafka::CancelOperation {
295        super::builder::managed_kafka::CancelOperation::new(self.inner.clone())
296    }
297}
298
299/// Implements a client for the Managed Service for Apache Kafka API.
300///
301/// # Example
302/// ```
303/// # tokio_test::block_on(async {
304/// # use google_cloud_managedkafka_v1::client::ManagedKafkaConnect;
305/// let client = ManagedKafkaConnect::builder().build().await?;
306/// // use `client` to make requests to the Managed Service for Apache Kafka API.
307/// # gax::client_builder::Result::<()>::Ok(()) });
308/// ```
309///
310/// # Service Description
311///
312/// The service that a client application uses to manage Apache Kafka Connect
313/// clusters and connectors.
314///
315/// # Configuration
316///
317/// To configure `ManagedKafkaConnect` use the `with_*` methods in the type returned
318/// by [builder()][ManagedKafkaConnect::builder]. The default configuration should
319/// work for most applications. Common configuration changes include
320///
321/// * [with_endpoint()]: by default this client uses the global default endpoint
322///   (`https://managedkafka.googleapis.com`). Applications using regional
323///   endpoints or running in restricted networks (e.g. a network configured
324//    with [Private Google Access with VPC Service Controls]) may want to
325///   override this default.
326/// * [with_credentials()]: by default this client uses
327///   [Application Default Credentials]. Applications using custom
328///   authentication may need to override this default.
329///
330/// [with_endpoint()]: super::builder::managed_kafka_connect::ClientBuilder::with_endpoint
331/// [with_credentials()]: super::builder::managed_kafka_connect::ClientBuilder::credentials
332/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
333/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
334///
335/// # Pooling and Cloning
336///
337/// `ManagedKafkaConnect` holds a connection pool internally, it is advised to
338/// create one and the reuse it.  You do not need to wrap `ManagedKafkaConnect` in
339/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
340/// already uses an `Arc` internally.
341#[derive(Clone, Debug)]
342pub struct ManagedKafkaConnect {
343    inner: std::sync::Arc<dyn super::stub::dynamic::ManagedKafkaConnect>,
344}
345
346impl ManagedKafkaConnect {
347    /// Returns a builder for [ManagedKafkaConnect].
348    ///
349    /// ```
350    /// # tokio_test::block_on(async {
351    /// # use google_cloud_managedkafka_v1::client::ManagedKafkaConnect;
352    /// let client = ManagedKafkaConnect::builder().build().await?;
353    /// # gax::client_builder::Result::<()>::Ok(()) });
354    /// ```
355    pub fn builder() -> super::builder::managed_kafka_connect::ClientBuilder {
356        gax::client_builder::internal::new_builder(
357            super::builder::managed_kafka_connect::client::Factory,
358        )
359    }
360
361    /// Creates a new client from the provided stub.
362    ///
363    /// The most common case for calling this function is in tests mocking the
364    /// client's behavior.
365    pub fn from_stub<T>(stub: T) -> Self
366    where
367        T: super::stub::ManagedKafkaConnect + 'static,
368    {
369        Self {
370            inner: std::sync::Arc::new(stub),
371        }
372    }
373
374    pub(crate) async fn new(
375        config: gaxi::options::ClientConfig,
376    ) -> gax::client_builder::Result<Self> {
377        let inner = Self::build_inner(config).await?;
378        Ok(Self { inner })
379    }
380
381    async fn build_inner(
382        conf: gaxi::options::ClientConfig,
383    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ManagedKafkaConnect>>
384    {
385        if gaxi::options::tracing_enabled(&conf) {
386            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
387        }
388        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
389    }
390
391    async fn build_transport(
392        conf: gaxi::options::ClientConfig,
393    ) -> gax::client_builder::Result<impl super::stub::ManagedKafkaConnect> {
394        super::transport::ManagedKafkaConnect::new(conf).await
395    }
396
397    async fn build_with_tracing(
398        conf: gaxi::options::ClientConfig,
399    ) -> gax::client_builder::Result<impl super::stub::ManagedKafkaConnect> {
400        Self::build_transport(conf)
401            .await
402            .map(super::tracing::ManagedKafkaConnect::new)
403    }
404
405    /// Lists the Kafka Connect clusters in a given project and location.
406    pub fn list_connect_clusters(
407        &self,
408    ) -> super::builder::managed_kafka_connect::ListConnectClusters {
409        super::builder::managed_kafka_connect::ListConnectClusters::new(self.inner.clone())
410    }
411
412    /// Returns the properties of a single Kafka Connect cluster.
413    pub fn get_connect_cluster(&self) -> super::builder::managed_kafka_connect::GetConnectCluster {
414        super::builder::managed_kafka_connect::GetConnectCluster::new(self.inner.clone())
415    }
416
417    /// Creates a new Kafka Connect cluster in a given project and location.
418    ///
419    /// # Long running operations
420    ///
421    /// This method is used to start, and/or poll a [long-running Operation].
422    /// The [Working with long-running operations] chapter in the [user guide]
423    /// covers these operations in detail.
424    ///
425    /// [long-running operation]: https://google.aip.dev/151
426    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
427    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
428    pub fn create_connect_cluster(
429        &self,
430    ) -> super::builder::managed_kafka_connect::CreateConnectCluster {
431        super::builder::managed_kafka_connect::CreateConnectCluster::new(self.inner.clone())
432    }
433
434    /// Updates the properties of a single Kafka Connect cluster.
435    ///
436    /// # Long running operations
437    ///
438    /// This method is used to start, and/or poll a [long-running Operation].
439    /// The [Working with long-running operations] chapter in the [user guide]
440    /// covers these operations in detail.
441    ///
442    /// [long-running operation]: https://google.aip.dev/151
443    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
444    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
445    pub fn update_connect_cluster(
446        &self,
447    ) -> super::builder::managed_kafka_connect::UpdateConnectCluster {
448        super::builder::managed_kafka_connect::UpdateConnectCluster::new(self.inner.clone())
449    }
450
451    /// Deletes a single Connect cluster.
452    ///
453    /// # Long running operations
454    ///
455    /// This method is used to start, and/or poll a [long-running Operation].
456    /// The [Working with long-running operations] chapter in the [user guide]
457    /// covers these operations in detail.
458    ///
459    /// [long-running operation]: https://google.aip.dev/151
460    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
461    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
462    pub fn delete_connect_cluster(
463        &self,
464    ) -> super::builder::managed_kafka_connect::DeleteConnectCluster {
465        super::builder::managed_kafka_connect::DeleteConnectCluster::new(self.inner.clone())
466    }
467
468    /// Lists the connectors in a given Connect cluster.
469    pub fn list_connectors(&self) -> super::builder::managed_kafka_connect::ListConnectors {
470        super::builder::managed_kafka_connect::ListConnectors::new(self.inner.clone())
471    }
472
473    /// Returns the properties of a single connector.
474    pub fn get_connector(&self) -> super::builder::managed_kafka_connect::GetConnector {
475        super::builder::managed_kafka_connect::GetConnector::new(self.inner.clone())
476    }
477
478    /// Creates a new connector in a given Connect cluster.
479    pub fn create_connector(&self) -> super::builder::managed_kafka_connect::CreateConnector {
480        super::builder::managed_kafka_connect::CreateConnector::new(self.inner.clone())
481    }
482
483    /// Updates the properties of a connector.
484    pub fn update_connector(&self) -> super::builder::managed_kafka_connect::UpdateConnector {
485        super::builder::managed_kafka_connect::UpdateConnector::new(self.inner.clone())
486    }
487
488    /// Deletes a connector.
489    pub fn delete_connector(&self) -> super::builder::managed_kafka_connect::DeleteConnector {
490        super::builder::managed_kafka_connect::DeleteConnector::new(self.inner.clone())
491    }
492
493    /// Pauses the connector and its tasks.
494    pub fn pause_connector(&self) -> super::builder::managed_kafka_connect::PauseConnector {
495        super::builder::managed_kafka_connect::PauseConnector::new(self.inner.clone())
496    }
497
498    /// Resumes the connector and its tasks.
499    pub fn resume_connector(&self) -> super::builder::managed_kafka_connect::ResumeConnector {
500        super::builder::managed_kafka_connect::ResumeConnector::new(self.inner.clone())
501    }
502
503    /// Restarts the connector.
504    pub fn restart_connector(&self) -> super::builder::managed_kafka_connect::RestartConnector {
505        super::builder::managed_kafka_connect::RestartConnector::new(self.inner.clone())
506    }
507
508    /// Stops the connector.
509    pub fn stop_connector(&self) -> super::builder::managed_kafka_connect::StopConnector {
510        super::builder::managed_kafka_connect::StopConnector::new(self.inner.clone())
511    }
512
513    /// Lists information about the supported locations for this service.
514    pub fn list_locations(&self) -> super::builder::managed_kafka_connect::ListLocations {
515        super::builder::managed_kafka_connect::ListLocations::new(self.inner.clone())
516    }
517
518    /// Gets information about a location.
519    pub fn get_location(&self) -> super::builder::managed_kafka_connect::GetLocation {
520        super::builder::managed_kafka_connect::GetLocation::new(self.inner.clone())
521    }
522
523    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
524    ///
525    /// [google.longrunning.Operations]: longrunning::client::Operations
526    pub fn list_operations(&self) -> super::builder::managed_kafka_connect::ListOperations {
527        super::builder::managed_kafka_connect::ListOperations::new(self.inner.clone())
528    }
529
530    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
531    ///
532    /// [google.longrunning.Operations]: longrunning::client::Operations
533    pub fn get_operation(&self) -> super::builder::managed_kafka_connect::GetOperation {
534        super::builder::managed_kafka_connect::GetOperation::new(self.inner.clone())
535    }
536
537    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
538    ///
539    /// [google.longrunning.Operations]: longrunning::client::Operations
540    pub fn delete_operation(&self) -> super::builder::managed_kafka_connect::DeleteOperation {
541        super::builder::managed_kafka_connect::DeleteOperation::new(self.inner.clone())
542    }
543
544    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
545    ///
546    /// [google.longrunning.Operations]: longrunning::client::Operations
547    pub fn cancel_operation(&self) -> super::builder::managed_kafka_connect::CancelOperation {
548        super::builder::managed_kafka_connect::CancelOperation::new(self.inner.clone())
549    }
550}