google_cloud_redis_cluster_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 Google Cloud Memorystore for Redis API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_redis_cluster_v1::client::CloudRedisCluster;
25/// let client = CloudRedisCluster::builder().build().await?;
26/// // use `client` to make requests to the Google Cloud Memorystore for Redis API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Configures and manages Cloud Memorystore for Redis clusters
33///
34/// Google Cloud Memorystore for Redis Cluster
35///
36/// The `redis.googleapis.com` service implements the Google Cloud Memorystore
37/// for Redis API and defines the following resource model for managing Redis
38/// clusters:
39///
40/// * The service works with a collection of cloud projects, named: `/projects/*`
41/// * Each project has a collection of available locations, named: `/locations/*`
42/// * Each location has a collection of Redis clusters, named: `/clusters/*`
43/// * As such, Redis clusters are resources of the form:
44///   `/projects/{project_id}/locations/{location_id}/clusters/{instance_id}`
45///
46/// Note that location_id must be a GCP `region`; for example:
47///
48/// * `projects/redpepper-1290/locations/us-central1/clusters/my-redis`
49///
50/// # Configuration
51///
52/// To configure `CloudRedisCluster` use the `with_*` methods in the type returned
53/// by [builder()][CloudRedisCluster::builder]. The default configuration should
54/// work for most applications. Common configuration changes include
55///
56/// * [with_endpoint()]: by default this client uses the global default endpoint
57///   (`https://redis.googleapis.com`). Applications using regional
58///   endpoints or running in restricted networks (e.g. a network configured
59//    with [Private Google Access with VPC Service Controls]) may want to
60///   override this default.
61/// * [with_credentials()]: by default this client uses
62///   [Application Default Credentials]. Applications using custom
63///   authentication may need to override this default.
64///
65/// [with_endpoint()]: super::builder::cloud_redis_cluster::ClientBuilder::with_endpoint
66/// [with_credentials()]: super::builder::cloud_redis_cluster::ClientBuilder::credentials
67/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
68/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
69///
70/// # Pooling and Cloning
71///
72/// `CloudRedisCluster` holds a connection pool internally, it is advised to
73/// create one and the reuse it.  You do not need to wrap `CloudRedisCluster` in
74/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
75/// already uses an `Arc` internally.
76#[derive(Clone, Debug)]
77pub struct CloudRedisCluster {
78    inner: std::sync::Arc<dyn super::stub::dynamic::CloudRedisCluster>,
79}
80
81impl CloudRedisCluster {
82    /// Returns a builder for [CloudRedisCluster].
83    ///
84    /// ```
85    /// # tokio_test::block_on(async {
86    /// # use google_cloud_redis_cluster_v1::client::CloudRedisCluster;
87    /// let client = CloudRedisCluster::builder().build().await?;
88    /// # gax::client_builder::Result::<()>::Ok(()) });
89    /// ```
90    pub fn builder() -> super::builder::cloud_redis_cluster::ClientBuilder {
91        gax::client_builder::internal::new_builder(
92            super::builder::cloud_redis_cluster::client::Factory,
93        )
94    }
95
96    /// Creates a new client from the provided stub.
97    ///
98    /// The most common case for calling this function is in tests mocking the
99    /// client's behavior.
100    pub fn from_stub<T>(stub: T) -> Self
101    where
102        T: super::stub::CloudRedisCluster + 'static,
103    {
104        Self {
105            inner: std::sync::Arc::new(stub),
106        }
107    }
108
109    pub(crate) async fn new(
110        config: gaxi::options::ClientConfig,
111    ) -> gax::client_builder::Result<Self> {
112        let inner = Self::build_inner(config).await?;
113        Ok(Self { inner })
114    }
115
116    async fn build_inner(
117        conf: gaxi::options::ClientConfig,
118    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::CloudRedisCluster>>
119    {
120        if gaxi::options::tracing_enabled(&conf) {
121            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
122        }
123        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
124    }
125
126    async fn build_transport(
127        conf: gaxi::options::ClientConfig,
128    ) -> gax::client_builder::Result<impl super::stub::CloudRedisCluster> {
129        super::transport::CloudRedisCluster::new(conf).await
130    }
131
132    async fn build_with_tracing(
133        conf: gaxi::options::ClientConfig,
134    ) -> gax::client_builder::Result<impl super::stub::CloudRedisCluster> {
135        Self::build_transport(conf)
136            .await
137            .map(super::tracing::CloudRedisCluster::new)
138    }
139
140    /// Lists all Redis clusters owned by a project in either the specified
141    /// location (region) or all locations.
142    ///
143    /// The location should have the following format:
144    ///
145    /// * `projects/{project_id}/locations/{location_id}`
146    ///
147    /// If `location_id` is specified as `-` (wildcard), then all regions
148    /// available to the project are queried, and the results are aggregated.
149    pub fn list_clusters(&self) -> super::builder::cloud_redis_cluster::ListClusters {
150        super::builder::cloud_redis_cluster::ListClusters::new(self.inner.clone())
151    }
152
153    /// Gets the details of a specific Redis cluster.
154    pub fn get_cluster(&self) -> super::builder::cloud_redis_cluster::GetCluster {
155        super::builder::cloud_redis_cluster::GetCluster::new(self.inner.clone())
156    }
157
158    /// Updates the metadata and configuration of a specific Redis cluster.
159    ///
160    /// Completed longrunning.Operation will contain the new cluster object
161    /// in the response field. The returned operation is automatically deleted
162    /// after a few hours, so there is no need to call DeleteOperation.
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 update_cluster(&self) -> super::builder::cloud_redis_cluster::UpdateCluster {
174        super::builder::cloud_redis_cluster::UpdateCluster::new(self.inner.clone())
175    }
176
177    /// Deletes a specific Redis cluster. Cluster stops serving and data is
178    /// deleted.
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    pub fn delete_cluster(&self) -> super::builder::cloud_redis_cluster::DeleteCluster {
190        super::builder::cloud_redis_cluster::DeleteCluster::new(self.inner.clone())
191    }
192
193    /// Creates a Redis cluster based on the specified properties.
194    /// The creation is executed asynchronously and callers may check the returned
195    /// operation to track its progress. Once the operation is completed the Redis
196    /// cluster will be fully functional. The completed longrunning.Operation will
197    /// contain the new cluster object in the response field.
198    ///
199    /// The returned operation is automatically deleted after a few hours, so there
200    /// is no need to call DeleteOperation.
201    ///
202    /// # Long running operations
203    ///
204    /// This method is used to start, and/or poll a [long-running Operation].
205    /// The [Working with long-running operations] chapter in the [user guide]
206    /// covers these operations in detail.
207    ///
208    /// [long-running operation]: https://google.aip.dev/151
209    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
210    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
211    pub fn create_cluster(&self) -> super::builder::cloud_redis_cluster::CreateCluster {
212        super::builder::cloud_redis_cluster::CreateCluster::new(self.inner.clone())
213    }
214
215    /// Gets the details of certificate authority information for Redis cluster.
216    pub fn get_cluster_certificate_authority(
217        &self,
218    ) -> super::builder::cloud_redis_cluster::GetClusterCertificateAuthority {
219        super::builder::cloud_redis_cluster::GetClusterCertificateAuthority::new(self.inner.clone())
220    }
221
222    /// Reschedules upcoming maintenance event.
223    ///
224    /// # Long running operations
225    ///
226    /// This method is used to start, and/or poll a [long-running Operation].
227    /// The [Working with long-running operations] chapter in the [user guide]
228    /// covers these operations in detail.
229    ///
230    /// [long-running operation]: https://google.aip.dev/151
231    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
232    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
233    pub fn reschedule_cluster_maintenance(
234        &self,
235    ) -> super::builder::cloud_redis_cluster::RescheduleClusterMaintenance {
236        super::builder::cloud_redis_cluster::RescheduleClusterMaintenance::new(self.inner.clone())
237    }
238
239    /// Lists all backup collections owned by a consumer project in either the
240    /// specified location (region) or all locations.
241    ///
242    /// If `location_id` is specified as `-` (wildcard), then all regions
243    /// available to the project are queried, and the results are aggregated.
244    pub fn list_backup_collections(
245        &self,
246    ) -> super::builder::cloud_redis_cluster::ListBackupCollections {
247        super::builder::cloud_redis_cluster::ListBackupCollections::new(self.inner.clone())
248    }
249
250    /// Get a backup collection.
251    pub fn get_backup_collection(
252        &self,
253    ) -> super::builder::cloud_redis_cluster::GetBackupCollection {
254        super::builder::cloud_redis_cluster::GetBackupCollection::new(self.inner.clone())
255    }
256
257    /// Lists all backups owned by a backup collection.
258    pub fn list_backups(&self) -> super::builder::cloud_redis_cluster::ListBackups {
259        super::builder::cloud_redis_cluster::ListBackups::new(self.inner.clone())
260    }
261
262    /// Gets the details of a specific backup.
263    pub fn get_backup(&self) -> super::builder::cloud_redis_cluster::GetBackup {
264        super::builder::cloud_redis_cluster::GetBackup::new(self.inner.clone())
265    }
266
267    /// Deletes a specific backup.
268    ///
269    /// # Long running operations
270    ///
271    /// This method is used to start, and/or poll a [long-running Operation].
272    /// The [Working with long-running operations] chapter in the [user guide]
273    /// covers these operations in detail.
274    ///
275    /// [long-running operation]: https://google.aip.dev/151
276    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
277    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
278    pub fn delete_backup(&self) -> super::builder::cloud_redis_cluster::DeleteBackup {
279        super::builder::cloud_redis_cluster::DeleteBackup::new(self.inner.clone())
280    }
281
282    /// Exports a specific backup to a customer target Cloud Storage URI.
283    ///
284    /// # Long running operations
285    ///
286    /// This method is used to start, and/or poll a [long-running Operation].
287    /// The [Working with long-running operations] chapter in the [user guide]
288    /// covers these operations in detail.
289    ///
290    /// [long-running operation]: https://google.aip.dev/151
291    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
292    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
293    pub fn export_backup(&self) -> super::builder::cloud_redis_cluster::ExportBackup {
294        super::builder::cloud_redis_cluster::ExportBackup::new(self.inner.clone())
295    }
296
297    /// Backup Redis Cluster.
298    /// If this is the first time a backup is being created, a backup collection
299    /// will be created at the backend, and this backup belongs to this collection.
300    /// Both collection and backup will have a resource name. Backup will be
301    /// executed for each shard. A replica (primary if nonHA) will be selected to
302    /// perform the execution. Backup call will be rejected if there is an ongoing
303    /// backup or update operation. Be aware that during preview, if the cluster's
304    /// internal software version is too old, critical update will be performed
305    /// before actual backup. Once the internal software version is updated to the
306    /// minimum version required by the backup feature, subsequent backups will not
307    /// require critical update. After preview, there will be no critical update
308    /// needed for backup.
309    ///
310    /// # Long running operations
311    ///
312    /// This method is used to start, and/or poll a [long-running Operation].
313    /// The [Working with long-running operations] chapter in the [user guide]
314    /// covers these operations in detail.
315    ///
316    /// [long-running operation]: https://google.aip.dev/151
317    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
318    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
319    pub fn backup_cluster(&self) -> super::builder::cloud_redis_cluster::BackupCluster {
320        super::builder::cloud_redis_cluster::BackupCluster::new(self.inner.clone())
321    }
322
323    /// Lists information about the supported locations for this service.
324    pub fn list_locations(&self) -> super::builder::cloud_redis_cluster::ListLocations {
325        super::builder::cloud_redis_cluster::ListLocations::new(self.inner.clone())
326    }
327
328    /// Gets information about a location.
329    pub fn get_location(&self) -> super::builder::cloud_redis_cluster::GetLocation {
330        super::builder::cloud_redis_cluster::GetLocation::new(self.inner.clone())
331    }
332
333    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
334    ///
335    /// [google.longrunning.Operations]: longrunning::client::Operations
336    pub fn list_operations(&self) -> super::builder::cloud_redis_cluster::ListOperations {
337        super::builder::cloud_redis_cluster::ListOperations::new(self.inner.clone())
338    }
339
340    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
341    ///
342    /// [google.longrunning.Operations]: longrunning::client::Operations
343    pub fn get_operation(&self) -> super::builder::cloud_redis_cluster::GetOperation {
344        super::builder::cloud_redis_cluster::GetOperation::new(self.inner.clone())
345    }
346
347    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
348    ///
349    /// [google.longrunning.Operations]: longrunning::client::Operations
350    pub fn delete_operation(&self) -> super::builder::cloud_redis_cluster::DeleteOperation {
351        super::builder::cloud_redis_cluster::DeleteOperation::new(self.inner.clone())
352    }
353
354    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
355    ///
356    /// [google.longrunning.Operations]: longrunning::client::Operations
357    pub fn cancel_operation(&self) -> super::builder::cloud_redis_cluster::CancelOperation {
358        super::builder::cloud_redis_cluster::CancelOperation::new(self.inner.clone())
359    }
360}