google-cloud-redis-v1 1.6.0

Google Cloud Client Libraries for Rust - Google Cloud Memorystore for Redis API
Documentation
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Google Cloud Memorystore for Redis API.
///
/// # Example
/// ```
/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
/// # use google_cloud_redis_v1::client::CloudRedis;
/// let client = CloudRedis::builder().build().await?;
/// // use `client` to make requests to the Google Cloud Memorystore for Redis API.
/// # Ok(()) }
/// ```
///
/// # Service Description
///
/// Configures and manages Cloud Memorystore for Redis instances
///
/// Google Cloud Memorystore for Redis v1
///
/// The `redis.googleapis.com` service implements the Google Cloud Memorystore
/// for Redis API and defines the following resource model for managing Redis
/// instances:
///
/// * The service works with a collection of cloud projects, named: `/projects/*`
/// * Each project has a collection of available locations, named: `/locations/*`
/// * Each location has a collection of Redis instances, named: `/instances/*`
/// * As such, Redis instances are resources of the form:
///   `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
///
/// Note that location_id must be referring to a GCP `region`; for example:
///
/// * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
///
/// # Configuration
///
/// To configure `CloudRedis` use the `with_*` methods in the type returned
/// by [builder()][CloudRedis::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://redis.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::cloud_redis::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::cloud_redis::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `CloudRedis` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `CloudRedis` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct CloudRedis {
    inner: std::sync::Arc<dyn super::stub::dynamic::CloudRedis>,
}

impl CloudRedis {
    /// Returns a builder for [CloudRedis].
    ///
    /// ```
    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
    /// # use google_cloud_redis_v1::client::CloudRedis;
    /// let client = CloudRedis::builder().build().await?;
    /// # Ok(()) }
    /// ```
    pub fn builder() -> super::builder::cloud_redis::ClientBuilder {
        crate::new_client_builder(super::builder::cloud_redis::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::CloudRedis + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CloudRedis>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::CloudRedis> {
        super::transport::CloudRedis::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::CloudRedis> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::CloudRedis::new)
    }

    /// Lists all Redis instances owned by a project in either the specified
    /// location (region) or all locations.
    ///
    /// The location should have the following format:
    ///
    /// * `projects/{project_id}/locations/{location_id}`
    ///
    /// If `location_id` is specified as `-` (wildcard), then all regions
    /// available to the project are queried, and the results are aggregated.
    pub fn list_instances(&self) -> super::builder::cloud_redis::ListInstances {
        super::builder::cloud_redis::ListInstances::new(self.inner.clone())
    }

    /// Gets the details of a specific Redis instance.
    pub fn get_instance(&self) -> super::builder::cloud_redis::GetInstance {
        super::builder::cloud_redis::GetInstance::new(self.inner.clone())
    }

    /// Gets the AUTH string for a Redis instance. If AUTH is not enabled for the
    /// instance the response will be empty. This information is not included in
    /// the details returned to GetInstance.
    pub fn get_instance_auth_string(&self) -> super::builder::cloud_redis::GetInstanceAuthString {
        super::builder::cloud_redis::GetInstanceAuthString::new(self.inner.clone())
    }

    /// Creates a Redis instance based on the specified tier and memory size.
    ///
    /// By default, the instance is accessible from the project's
    /// [default network](https://cloud.google.com/vpc/docs/vpc).
    ///
    /// The creation is executed asynchronously and callers may check the returned
    /// operation to track its progress. Once the operation is completed the Redis
    /// instance will be fully functional. Completed longrunning.Operation will
    /// contain the new instance object in the response field.
    ///
    /// The returned operation is automatically deleted after a few hours, so there
    /// is no need to call DeleteOperation.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_instance(&self) -> super::builder::cloud_redis::CreateInstance {
        super::builder::cloud_redis::CreateInstance::new(self.inner.clone())
    }

    /// Updates the metadata and configuration of a specific Redis instance.
    ///
    /// Completed longrunning.Operation will contain the new instance object
    /// in the response field. The returned operation is automatically deleted
    /// after a few hours, so there is no need to call DeleteOperation.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_instance(&self) -> super::builder::cloud_redis::UpdateInstance {
        super::builder::cloud_redis::UpdateInstance::new(self.inner.clone())
    }

    /// Upgrades Redis instance to the newer Redis version specified in the
    /// request.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn upgrade_instance(&self) -> super::builder::cloud_redis::UpgradeInstance {
        super::builder::cloud_redis::UpgradeInstance::new(self.inner.clone())
    }

    /// Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
    ///
    /// Redis may stop serving during this operation. Instance state will be
    /// IMPORTING for entire operation. When complete, the instance will contain
    /// only data from the imported file.
    ///
    /// The returned operation is automatically deleted after a few hours, so
    /// there is no need to call DeleteOperation.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn import_instance(&self) -> super::builder::cloud_redis::ImportInstance {
        super::builder::cloud_redis::ImportInstance::new(self.inner.clone())
    }

    /// Export Redis instance data into a Redis RDB format file in Cloud Storage.
    ///
    /// Redis will continue serving during this operation.
    ///
    /// The returned operation is automatically deleted after a few hours, so
    /// there is no need to call DeleteOperation.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn export_instance(&self) -> super::builder::cloud_redis::ExportInstance {
        super::builder::cloud_redis::ExportInstance::new(self.inner.clone())
    }

    /// Initiates a failover of the primary node to current replica node for a
    /// specific STANDARD tier Cloud Memorystore for Redis instance.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn failover_instance(&self) -> super::builder::cloud_redis::FailoverInstance {
        super::builder::cloud_redis::FailoverInstance::new(self.inner.clone())
    }

    /// Deletes a specific Redis instance.  Instance stops serving and data is
    /// deleted.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_instance(&self) -> super::builder::cloud_redis::DeleteInstance {
        super::builder::cloud_redis::DeleteInstance::new(self.inner.clone())
    }

    /// Reschedule maintenance for a given instance in a given project and
    /// location.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn reschedule_maintenance(&self) -> super::builder::cloud_redis::RescheduleMaintenance {
        super::builder::cloud_redis::RescheduleMaintenance::new(self.inner.clone())
    }

    /// Lists information about the supported locations for this service.
    pub fn list_locations(&self) -> super::builder::cloud_redis::ListLocations {
        super::builder::cloud_redis::ListLocations::new(self.inner.clone())
    }

    /// Gets information about a location.
    pub fn get_location(&self) -> super::builder::cloud_redis::GetLocation {
        super::builder::cloud_redis::GetLocation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::cloud_redis::ListOperations {
        super::builder::cloud_redis::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::cloud_redis::GetOperation {
        super::builder::cloud_redis::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn delete_operation(&self) -> super::builder::cloud_redis::DeleteOperation {
        super::builder::cloud_redis::DeleteOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::cloud_redis::CancelOperation {
        super::builder::cloud_redis::CancelOperation::new(self.inner.clone())
    }
}