volcengine_rust_sdk/service/rds/service_rds.rs
1/*
2 * @Author: Jerry.Yang
3 * @Date: 2024-11-05 10:36:29
4 * @LastEditors: Jerry.Yang
5 * @LastEditTime: 2025-02-06 11:38:48
6 * @Description: Implementation of the RDS service, providing methods for managing RDS instances, databases, endpoints, and accounts.
7 */
8use crate::service::rds::api_create_db_account;
9use crate::service::rds::api_create_db_database;
10use crate::service::rds::api_create_db_endpoint;
11use crate::service::rds::api_create_db_instance;
12use crate::service::rds::api_describe_db_accounts;
13use crate::service::rds::api_describe_db_database;
14use crate::service::rds::api_describe_db_instance_detail;
15use crate::service::rds::api_describe_db_instances;
16use crate::service::rds::api_modify_allow_list;
17use crate::service::rds::api_modify_db_endpoint;
18use crate::service::rds::api_modify_db_instance_spec;
19use crate::service::rds::{Rds, RdsService};
20use crate::volcengine::client::client;
21use crate::volcengine::client::client_info;
22use crate::volcengine::client::config as client_config;
23use crate::volcengine::common;
24use crate::volcengine::error::error;
25use crate::volcengine::request::handles;
26use crate::volcengine::session::session;
27
28/// Implementation of the RdsService trait for the Rds struct.
29/// This implementation provides the necessary logic to interact with the Volcengine RDS service,
30/// including creating instances, databases, endpoints, and accounts, as well as modifying and describing them.
31impl RdsService for Rds {
32 /// Creates a new RDS service instance from a given session.
33 ///
34 /// # Arguments
35 /// - `session`: The session object containing the necessary configuration and credentials.
36 ///
37 /// # Returns
38 /// - `Result<Self, error::Error>`: On success, returns a new instance of the Rds struct.
39 /// On failure, returns an error indicating the cause of the failure.
40 fn new_rds(session: session::Session) -> Result<Self, error::Error> {
41 // Create a new client configuration for the RDS service.
42 let client_config = session.new_client_config(client_config::ClientServiceName::Rds);
43
44 // Build the client information with the required parameters.
45 let client_info = client_info::ClientInfo::builder()
46 .with_service_name(client_config::ClientServiceName::Rds)
47 .with_api_version(common::COMMON_VERSION_2022_01_01)
48 .with_signing_region(&client_config.signing_region)
49 .build()?;
50
51 // Initialize the request handles.
52 let request_handles = handles::Handles {};
53
54 // Build the client with the provided information.
55 let client = client::Client::builder()
56 .with_client_info(&client_info)
57 .with_config(&client_config)
58 .with_handles(&request_handles)
59 .build()?;
60
61 // Return the new RDS service instance.
62 Ok(Rds { client: client })
63 }
64
65 /// Creates a new database instance.
66 ///
67 /// # Arguments
68 /// - `&self`: Reference to the current RDS service instance.
69 /// - `request`: The request structure containing the parameters for creating a database instance.
70 ///
71 /// # Returns
72 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_instance::CreateDbInstanceResp, error::Error>`: On success, returns the response from the RDS service.
73 /// On failure, returns an error indicating the cause of the failure.
74 async fn new_create_db_instance(
75 &self,
76 request: volcengine_sdk_protobuf::protobuf::rds_instance::CreateDbInstanceReq,
77 ) -> Result<volcengine_sdk_protobuf::protobuf::rds_instance::CreateDbInstanceResp, error::Error>
78 {
79 api_create_db_instance::ApiCreateDbInstanceRds
80 .new_create_db_instance(self, request)
81 .await
82 }
83
84 /// Describes the details of a specific database instance.
85 ///
86 /// # Arguments
87 /// - `&self`: Reference to the current RDS service instance.
88 /// - `request`: The request structure containing the parameters for describing a database instance.
89 ///
90 /// # Returns
91 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_instance::DescribeDbInstanceDetailResp, error::Error>`: On success, returns the response from the RDS service.
92 /// On failure, returns an error indicating the cause of the failure.
93 async fn new_describe_db_instance_detail(
94 &self,
95 request: volcengine_sdk_protobuf::protobuf::rds_instance::DescribeDbInstanceDetailReq,
96 ) -> Result<
97 volcengine_sdk_protobuf::protobuf::rds_instance::DescribeDbInstanceDetailResp,
98 error::Error,
99 > {
100 api_describe_db_instance_detail::ApiDescribeDbInstanceDetailRds
101 .new_describe_db_instance_detail(self, request)
102 .await
103 }
104
105 /// Creates a new database endpoint.
106 ///
107 /// # Arguments
108 /// - `&self`: Reference to the current RDS service instance.
109 /// - `request`: The request structure containing the parameters for creating a database endpoint.
110 ///
111 /// # Returns
112 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_endpoint::CreateDbEndpointResp, error::Error>`: On success, returns the response from the RDS service.
113 /// On failure, returns an error indicating the cause of the failure.
114 async fn new_create_db_endpoint(
115 &self,
116 request: volcengine_sdk_protobuf::protobuf::rds_endpoint::CreateDbEndpointReq,
117 ) -> Result<volcengine_sdk_protobuf::protobuf::rds_endpoint::CreateDbEndpointResp, error::Error>
118 {
119 api_create_db_endpoint::ApiCreateDbEndpointRds
120 .new_create_db_endpoint(self, request)
121 .await
122 }
123
124 /// Creates a new database account.
125 ///
126 /// # Arguments
127 /// - `&self`: Reference to the current RDS service instance.
128 /// - `request`: The request structure containing the parameters for creating a database account.
129 ///
130 /// # Returns
131 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_account::CreateDbAccountResp, error::Error>`: On success, returns the response from the RDS service.
132 /// On failure, returns an error indicating the cause of the failure.
133 async fn new_create_db_account(
134 &self,
135 request: volcengine_sdk_protobuf::protobuf::rds_account::CreateDbAccountReq,
136 ) -> Result<volcengine_sdk_protobuf::protobuf::rds_account::CreateDbAccountResp, error::Error>
137 {
138 api_create_db_account::ApiCreateDbAccountRds
139 .new_create_db_account(self, request)
140 .await
141 }
142
143 /// Creates a new database.
144 ///
145 /// # Arguments
146 /// - `&self`: Reference to the current RDS service instance.
147 /// - `request`: The request structure containing the parameters for creating a database.
148 ///
149 /// # Returns
150 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_database::CreateDatabaseResp, error::Error>`: On success, returns the response from the RDS service.
151 /// On failure, returns an error indicating the cause of the failure.
152 async fn new_create_db_database(
153 &self,
154 request: volcengine_sdk_protobuf::protobuf::rds_database::CreateDatabaseReq,
155 ) -> Result<volcengine_sdk_protobuf::protobuf::rds_database::CreateDatabaseResp, error::Error>
156 {
157 api_create_db_database::ApiCreateDbDatabaseRds
158 .new_create_db_database(self, request)
159 .await
160 }
161
162 /// Modifies the allow list of a database instance.
163 ///
164 /// # Arguments
165 /// - `&self`: Reference to the current RDS service instance.
166 /// - `request`: The request structure containing the parameters for modifying the allow list.
167 ///
168 /// # Returns
169 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_allow::ModifyAllowListResp, error::Error>`: On success, returns the response from the RDS service.
170 /// On failure, returns an error indicating the cause of the failure.
171 async fn new_modify_allow_list(
172 &self,
173 request: volcengine_sdk_protobuf::protobuf::rds_allow::ModifyAllowListReq,
174 ) -> Result<volcengine_sdk_protobuf::protobuf::rds_allow::ModifyAllowListResp, error::Error>
175 {
176 api_modify_allow_list::ApiModifyAllowListRds
177 .new_modify_allow_list(self, request)
178 .await
179 }
180
181 /// Modifies the specifications of a database instance.
182 ///
183 /// # Arguments
184 /// - `&self`: Reference to the current RDS service instance.
185 /// - `request`: The request structure containing the parameters for modifying the instance specifications.
186 ///
187 /// # Returns
188 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_instance::ModifyDbInstanceSpecResp, error::Error>`: On success, returns the response from the RDS service.
189 /// On failure, returns an error indicating the cause of the failure.
190 async fn new_modify_db_instance_spec(
191 &self,
192 request: volcengine_sdk_protobuf::protobuf::rds_instance::ModifyDbInstanceSpecReq,
193 ) -> Result<
194 volcengine_sdk_protobuf::protobuf::rds_instance::ModifyDbInstanceSpecResp,
195 error::Error,
196 > {
197 api_modify_db_instance_spec::ApiModifyDBInstanceSpecRds
198 .new_modify_db_instance_spec(self, request)
199 .await
200 }
201
202 /// Describes the databases of a specific database instance.
203 ///
204 /// # Arguments
205 /// - `&self`: Reference to the current RDS service instance.
206 /// - `request`: The request structure containing the parameters for describing databases.
207 ///
208 /// # Returns
209 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_database::DescribeDatabasesResp, error::Error>`: On success, returns the response from the RDS service.
210 /// On failure, returns an error indicating the cause of the failure.
211 async fn new_describe_db_databases(
212 &self,
213 request: volcengine_sdk_protobuf::protobuf::rds_database::DescribeDatabasesReq,
214 ) -> Result<volcengine_sdk_protobuf::protobuf::rds_database::DescribeDatabasesResp, error::Error>
215 {
216 api_describe_db_database::ApiDescribeDbDatabasesRds
217 .new_describe_db_databases(self, request)
218 .await
219 }
220
221 /// Describes the accounts of a specific database instance.
222 ///
223 /// # Arguments
224 /// - `&self`: Reference to the current RDS service instance.
225 /// - `request`: The request structure containing the parameters for describing accounts.
226 ///
227 /// # Returns
228 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_account::DescribeDbAccountsResp, error::Error>`: On success, returns the response from the RDS service.
229 /// On failure, returns an error indicating the cause of the failure.
230 async fn new_describe_db_accounts(
231 &self,
232 request: volcengine_sdk_protobuf::protobuf::rds_account::DescribeDbAccountsReq,
233 ) -> Result<volcengine_sdk_protobuf::protobuf::rds_account::DescribeDbAccountsResp, error::Error>
234 {
235 api_describe_db_accounts::ApiDescribeDBAccountsRds
236 .new_describe_db_accounts(self, request)
237 .await
238 }
239
240 /// Modifies a database endpoint.
241 ///
242 /// # Arguments
243 /// - `&self`: Reference to the current RDS service instance.
244 /// - `request`: The request structure containing the parameters for modifying a database endpoint.
245 ///
246 /// # Returns
247 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_endpoint::ModifyDbEndpointResp, error::Error>`: On success, returns the response from the RDS service.
248 /// On failure, returns an error indicating the cause of the failure.
249 async fn new_modify_db_endpoint(
250 &self,
251 request: volcengine_sdk_protobuf::protobuf::rds_endpoint::ModifyDbEndpointReq,
252 ) -> Result<volcengine_sdk_protobuf::protobuf::rds_endpoint::ModifyDbEndpointResp, error::Error>
253 {
254 api_modify_db_endpoint::ApiModifyDBEndpointRds
255 .new_modify_db_endpoint(self, request)
256 .await
257 }
258
259 /// Describes the database instances.
260 ///
261 /// # Arguments
262 /// - `&self`: Reference to the current RDS service instance.
263 /// - `request`: The request structure containing the parameters for describing database instances.
264 ///
265 /// # Returns
266 /// - `Result<volcengine_sdk_protobuf::protobuf::rds_instance::DescribeDbInstancesResp, error::Error>`: On success, returns the response from the RDS service.
267 /// On failure, returns an error indicating the cause of the failure.
268 async fn new_describe_db_instances(
269 &self,
270 request: volcengine_sdk_protobuf::protobuf::rds_instance::DescribeDbInstancesReq,
271 ) -> Result<
272 volcengine_sdk_protobuf::protobuf::rds_instance::DescribeDbInstancesResp,
273 error::Error,
274 > {
275 api_describe_db_instances::ApiDescribeDBInstancesRds
276 .new_describe_db_instances(self, request)
277 .await
278 }
279}