volcengine_rust_sdk/service/redis/
mod.rs

1/*
2 * @Author: Jerry.Yang
3 * @Date: 2024-11-07 10:40:08
4 * @LastEditors: Jerry.Yang
5 * @LastEditTime: 2025-02-19 10:59:03
6 * @Description: Module for managing Redis database instances using the Volcengine SDK.
7 */
8use crate::volcengine::client::client;
9use crate::volcengine::error::error;
10use crate::volcengine::session::session;
11use std::future::Future;
12use volcengine_sdk_protobuf::protobuf::{redis_allow, redis_instance};
13
14// Import modules for various Redis operations
15mod api_create_db_instance;
16mod api_create_db_instance_model;
17mod api_decrease_db_instance_node_number;
18mod api_decrease_db_instance_node_number_model;
19mod api_describe_db_instance_detail;
20mod api_describe_db_instance_detail_model;
21mod api_describe_db_instances;
22mod api_describe_db_instances_models;
23mod api_enable_sharded_cluster;
24mod api_enable_sharded_cluster_model;
25mod api_increase_db_instance_node_number;
26mod api_increase_db_instance_node_number_model;
27mod api_modify_allow_list;
28mod api_modify_allow_list_model;
29mod api_modify_db_instance_shard_capacity;
30mod api_modify_db_instance_shard_capacity_model;
31mod api_modify_db_instance_shard_number;
32mod api_modify_db_instance_shard_number_model;
33pub mod service_redis;
34mod tests;
35
36/// Defines the RedisService trait, providing methods for various Redis operations.
37/// This trait encapsulates the functionality required to interact with the Volcengine Redis service.
38pub trait RedisService {
39    /// Creates a new Redis service instance from a given session.
40    ///
41    /// # Arguments
42    /// - `session`: The session object containing the necessary configuration and credentials.
43    ///
44    /// # Returns
45    /// - `Result<Redis, error::Error>`: On success, returns a new instance of the Redis struct.
46    ///   On failure, returns an error indicating the cause of the failure.
47    fn new_redis(session: session::Session) -> Result<Redis, error::Error>;
48
49    /// Creates a new Redis database instance.
50    ///
51    /// # Arguments
52    /// - `&self`: Reference to the current Redis service instance.
53    /// - `request`: The request structure containing the parameters for creating a Redis database instance.
54    ///
55    /// # Returns
56    /// - `impl Future<Output = Result<redis_instance::CreateDbInstanceResp, error::Error>>`: On success, returns a future that resolves to the response from the Redis service.
57    ///   On failure, returns an error indicating the cause of the failure.
58    fn new_create_db_instance(
59        &self,
60        request: redis_instance::RedisCreateDbInstanceReq,
61    ) -> impl Future<Output = Result<redis_instance::RedisCreateDbInstanceResp, error::Error>>;
62
63    /// Describes the details of a specific Redis database instance.
64    ///
65    /// # Arguments
66    /// - `&self`: Reference to the current Redis service instance.
67    /// - `request`: The request structure containing the parameters for describing a Redis database instance.
68    ///
69    /// # Returns
70    /// - `impl Future<Output = Result<redis_instance::DescribeDbInstanceDetailResp, error::Error>>`: On success, returns a future that resolves to the response from the Redis service.
71    ///   On failure, returns an error indicating the cause of the failure.
72    fn new_describe_db_instance_detail(
73        &self,
74        request: redis_instance::RedisDescribeDbInstanceDetailReq,
75    ) -> impl Future<Output = Result<redis_instance::RedisDescribeDbInstanceDetailResp, error::Error>>;
76
77    /// Modifies the allow list of a Redis database instance.
78    ///
79    /// # Arguments
80    /// - `&self`: Reference to the current Redis service instance.
81    /// - `request`: The request structure containing the parameters for modifying the allow list.
82    ///
83    /// # Returns
84    /// - `impl Future<Output = Result<redis_allow::ModifyAllowListResp, error::Error>>`: On success, returns a future that resolves to the response from the Redis service.
85    ///   On failure, returns an error indicating the cause of the failure.
86    fn new_modify_allow_list(
87        &self,
88        request: redis_allow::RedisModifyAllowListReq,
89    ) -> impl Future<Output = Result<redis_allow::RedisModifyAllowListResp, error::Error>>;
90
91    /// Increase the number of nodes in a Redis instance.
92    ///
93    /// This function adds nodes to a Redis instance to scale up its capacity or performance.
94    /// It takes a request object containing necessary parameters such as the instance ID and the number of nodes to add.
95    ///
96    /// # Parameters
97    /// - `request`: `redis_instance::IncreaseDbInstanceNodeNumberReq` - The request object with parameters for adding nodes.
98    ///
99    /// # Returns
100    /// - `Ok`: `redis_instance::IncreaseDbInstanceNodeNumberResp` - The response indicating the result of the operation.
101    /// - `Err`: `error::Error` - The error if the operation fails.
102    ///   On failure, returns an error indicating the cause of the failure.
103    fn new_increase_db_instance_node_number(
104        &self,
105        request: redis_instance::RedisIncreaseDbInstanceNodeNumberReq,
106    ) -> impl Future<Output = Result<redis_instance::RedisIncreaseDbInstanceNodeNumberResp, error::Error>>;
107
108    /// Decreases the node number of a Redis database instance.
109    ///
110    /// This function sends a request to the Volcengine Redis service to decrease the number of nodes
111    /// in a Redis database instance. It returns a future that resolves to a result containing either
112    /// the response from the Redis service or an error indicating the cause of the failure.
113    ///
114    /// # Arguments
115    /// * `request` - A `DecreaseDbInstanceNodeNumberReq` structure containing the request parameters.
116    ///
117    /// # Returns
118    /// * `impl Future<Output = Result<redis_instance::DecreaseDbInstanceNodeNumberResp, error::Error>>` -
119    ///   A future that resolves to a result containing either the response from the Redis service or an error.
120    fn new_decrease_db_instance_node_number(
121        &self,
122        request: redis_instance::RedisDecreaseDbInstanceNodeNumberReq,
123    ) -> impl Future<Output = Result<redis_instance::RedisDecreaseDbInstanceNodeNumberResp, error::Error>>;
124
125    /// Modifies the shard capacity of a Redis database instance.
126    ///
127    /// This function sends a request to the Volcengine Redis service to modify the shard capacity
128    /// of a Redis database instance. It returns a future that resolves to a result containing either
129    /// the response from the Redis service or an error indicating the cause of the failure.
130    ///
131    /// # Arguments
132    /// * `request` - A `ModifyDbInstanceShardCapacityReq` structure containing the request parameters.
133    ///
134    /// # Returns
135    /// * `impl Future<Output = Result<redis_instance::ModifyDbInstanceShardCapacityResp, error::Error>>` -
136    ///   A future that resolves to a result containing either the response from the Redis service or an error.
137    fn new_modify_db_instance_shard_capacity(
138        &self,
139        request: redis_instance::RedisModifyDbInstanceShardCapacityReq,
140    ) -> impl Future<Output = Result<redis_instance::RedisModifyDbInstanceShardCapacityResp, error::Error>>;
141
142    /// Modifies the shard number of a Redis database instance.
143    ///
144    /// This function sends a request to the Volcengine Redis service to modify the shard number
145    /// of a Redis database instance. It returns a future that resolves to a result containing either
146    /// the response from the Redis service or an error indicating the cause of the failure.
147    ///
148    /// # Arguments
149    /// * `request` - A `ModifyDbInstanceShardNumberReq` structure containing the request parameters.
150    ///
151    /// # Returns
152    /// * `impl Future<Output = Result<redis_instance::ModifyDbInstanceShardNumberResp, error::Error>>` -
153    ///   A future that resolves to a result containing either the response from the Redis service or an error.
154    fn new_modify_db_instance_shard_number(
155        &self,
156        request: redis_instance::RedisModifyDbInstanceShardNumberReq,
157    ) -> impl Future<Output = Result<redis_instance::RedisModifyDbInstanceShardNumberResp, error::Error>>;
158
159    /// Enables sharded cluster mode for a Redis database instance.
160    ///
161    /// This function sends a request to the Volcengine Redis service to enable sharded cluster mode
162    /// for a Redis database instance. It returns a future that resolves to a result containing either
163    /// the response from the Redis service or an error indicating the cause of the failure.
164    ///
165    /// # Arguments
166    /// * `request` - A `EnableShardedClusterReq` structure containing the request parameters.
167    ///
168    /// # Returns
169    /// * `impl Future<Output = Result<redis_instance::EnableShardedClusterResp, error::Error>>` -
170    ///   A future that resolves to a result containing either the response from the Redis service or an error.
171    fn new_enable_sharded_cluster(
172        &self,
173        request: redis_instance::RedisEnableShardedClusterReq,
174    ) -> impl Future<Output = Result<redis_instance::RedisEnableShardedClusterResp, error::Error>>;
175
176    /// Public method to initiate a request for describing the details of a Redis database instance.
177    ///
178    /// This method returns a future that, when awaited, sends a request to the Volcengine Redis service
179    /// to retrieve detailed information about Redis database instances.
180    ///
181    /// # Arguments
182    /// - `&self`: Reference to the current instance of the struct.
183    /// - `request`: A `RedisDescribeDbInstancesReq` structure containing the request parameters.
184    ///
185    /// # Returns
186    /// - `impl Future<Output = Result<redis_instance::RedisDescribeDbInstancesResp, error::Error>>`:
187    ///   A future that resolves to either a `RedisDescribeDbInstancesResp` structure containing the response from the Redis service,
188    ///   or an `error::Error` indicating the cause of the failure.
189    fn new_describe_db_instances(
190        &self,
191        request: redis_instance::RedisDescribeDbInstancesReq,
192    ) -> impl Future<Output = Result<redis_instance::RedisDescribeDbInstancesResp, error::Error>>;
193}
194
195/// Represents the Redis service, encapsulating the client information required to interact with the Volcengine Redis service.
196#[derive(Debug, Clone)]
197pub struct Redis {
198    /// The client used to make requests to the Volcengine Redis service.
199    client: client::Client,
200}