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