use std::error::Error;
use std::fmt;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError, RusotoFuture};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
use serde_json;
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchExecuteStatementRequest {
#[serde(rename = "database")]
#[serde(skip_serializing_if = "Option::is_none")]
pub database: Option<String>,
#[serde(rename = "parameterSets")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parameter_sets: Option<Vec<Vec<SqlParameter>>>,
#[serde(rename = "resourceArn")]
pub resource_arn: String,
#[serde(rename = "schema")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schema: Option<String>,
#[serde(rename = "secretArn")]
pub secret_arn: String,
#[serde(rename = "sql")]
pub sql: String,
#[serde(rename = "transactionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchExecuteStatementResponse {
#[serde(rename = "updateResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub update_results: Option<Vec<UpdateResult>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BeginTransactionRequest {
#[serde(rename = "database")]
#[serde(skip_serializing_if = "Option::is_none")]
pub database: Option<String>,
#[serde(rename = "resourceArn")]
pub resource_arn: String,
#[serde(rename = "schema")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schema: Option<String>,
#[serde(rename = "secretArn")]
pub secret_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BeginTransactionResponse {
#[serde(rename = "transactionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ColumnMetadata {
#[serde(rename = "arrayBaseColumnType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub array_base_column_type: Option<i64>,
#[serde(rename = "isAutoIncrement")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_auto_increment: Option<bool>,
#[serde(rename = "isCaseSensitive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_case_sensitive: Option<bool>,
#[serde(rename = "isCurrency")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_currency: Option<bool>,
#[serde(rename = "isSigned")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_signed: Option<bool>,
#[serde(rename = "label")]
#[serde(skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "nullable")]
#[serde(skip_serializing_if = "Option::is_none")]
pub nullable: Option<i64>,
#[serde(rename = "precision")]
#[serde(skip_serializing_if = "Option::is_none")]
pub precision: Option<i64>,
#[serde(rename = "scale")]
#[serde(skip_serializing_if = "Option::is_none")]
pub scale: Option<i64>,
#[serde(rename = "schemaName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schema_name: Option<String>,
#[serde(rename = "tableName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub table_name: Option<String>,
#[serde(rename = "type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<i64>,
#[serde(rename = "typeName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CommitTransactionRequest {
#[serde(rename = "resourceArn")]
pub resource_arn: String,
#[serde(rename = "secretArn")]
pub secret_arn: String,
#[serde(rename = "transactionId")]
pub transaction_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CommitTransactionResponse {
#[serde(rename = "transactionStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ExecuteSqlRequest {
#[serde(rename = "awsSecretStoreArn")]
pub aws_secret_store_arn: String,
#[serde(rename = "database")]
#[serde(skip_serializing_if = "Option::is_none")]
pub database: Option<String>,
#[serde(rename = "dbClusterOrInstanceArn")]
pub db_cluster_or_instance_arn: String,
#[serde(rename = "schema")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schema: Option<String>,
#[serde(rename = "sqlStatements")]
pub sql_statements: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ExecuteSqlResponse {
#[serde(rename = "sqlStatementResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sql_statement_results: Option<Vec<SqlStatementResult>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ExecuteStatementRequest {
#[serde(rename = "continueAfterTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub continue_after_timeout: Option<bool>,
#[serde(rename = "database")]
#[serde(skip_serializing_if = "Option::is_none")]
pub database: Option<String>,
#[serde(rename = "includeResultMetadata")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_result_metadata: Option<bool>,
#[serde(rename = "parameters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parameters: Option<Vec<SqlParameter>>,
#[serde(rename = "resourceArn")]
pub resource_arn: String,
#[serde(rename = "schema")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schema: Option<String>,
#[serde(rename = "secretArn")]
pub secret_arn: String,
#[serde(rename = "sql")]
pub sql: String,
#[serde(rename = "transactionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ExecuteStatementResponse {
#[serde(rename = "columnMetadata")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_metadata: Option<Vec<ColumnMetadata>>,
#[serde(rename = "generatedFields")]
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_fields: Option<Vec<Field>>,
#[serde(rename = "numberOfRecordsUpdated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number_of_records_updated: Option<i64>,
#[serde(rename = "records")]
#[serde(skip_serializing_if = "Option::is_none")]
pub records: Option<Vec<Vec<Field>>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Field {
#[serde(rename = "blobValue")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub blob_value: Option<bytes::Bytes>,
#[serde(rename = "booleanValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub boolean_value: Option<bool>,
#[serde(rename = "doubleValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub double_value: Option<f64>,
#[serde(rename = "isNull")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_null: Option<bool>,
#[serde(rename = "longValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub long_value: Option<i64>,
#[serde(rename = "stringValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub string_value: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Record {
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Vec<Value>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResultFrame {
#[serde(rename = "records")]
#[serde(skip_serializing_if = "Option::is_none")]
pub records: Option<Vec<Record>>,
#[serde(rename = "resultSetMetadata")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_set_metadata: Option<ResultSetMetadata>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResultSetMetadata {
#[serde(rename = "columnCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_count: Option<i64>,
#[serde(rename = "columnMetadata")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_metadata: Option<Vec<ColumnMetadata>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RollbackTransactionRequest {
#[serde(rename = "resourceArn")]
pub resource_arn: String,
#[serde(rename = "secretArn")]
pub secret_arn: String,
#[serde(rename = "transactionId")]
pub transaction_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RollbackTransactionResponse {
#[serde(rename = "transactionStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct SqlParameter {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<Field>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SqlStatementResult {
#[serde(rename = "numberOfRecordsUpdated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number_of_records_updated: Option<i64>,
#[serde(rename = "resultFrame")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_frame: Option<ResultFrame>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StructValue {
#[serde(rename = "attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<Vec<Value>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateResult {
#[serde(rename = "generatedFields")]
#[serde(skip_serializing_if = "Option::is_none")]
pub generated_fields: Option<Vec<Field>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Value {
#[serde(rename = "arrayValues")]
#[serde(skip_serializing_if = "Option::is_none")]
pub array_values: Option<Vec<Value>>,
#[serde(rename = "bigIntValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub big_int_value: Option<i64>,
#[serde(rename = "bitValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bit_value: Option<bool>,
#[serde(rename = "blobValue")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub blob_value: Option<bytes::Bytes>,
#[serde(rename = "doubleValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub double_value: Option<f64>,
#[serde(rename = "intValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub int_value: Option<i64>,
#[serde(rename = "isNull")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_null: Option<bool>,
#[serde(rename = "realValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub real_value: Option<f32>,
#[serde(rename = "stringValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub string_value: Option<String>,
#[serde(rename = "structValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub struct_value: Option<StructValue>,
}
#[derive(Debug, PartialEq)]
pub enum BatchExecuteStatementError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
ServiceUnavailableError(String),
StatementTimeout(String),
}
impl BatchExecuteStatementError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<BatchExecuteStatementError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(BatchExecuteStatementError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(BatchExecuteStatementError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(BatchExecuteStatementError::InternalServerError(
err.msg,
))
}
"ServiceUnavailableError" => {
return RusotoError::Service(
BatchExecuteStatementError::ServiceUnavailableError(err.msg),
)
}
"StatementTimeoutException" => {
return RusotoError::Service(BatchExecuteStatementError::StatementTimeout(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for BatchExecuteStatementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchExecuteStatementError {
fn description(&self) -> &str {
match *self {
BatchExecuteStatementError::BadRequest(ref cause) => cause,
BatchExecuteStatementError::Forbidden(ref cause) => cause,
BatchExecuteStatementError::InternalServerError(ref cause) => cause,
BatchExecuteStatementError::ServiceUnavailableError(ref cause) => cause,
BatchExecuteStatementError::StatementTimeout(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum BeginTransactionError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
ServiceUnavailableError(String),
StatementTimeout(String),
}
impl BeginTransactionError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<BeginTransactionError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(BeginTransactionError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(BeginTransactionError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(BeginTransactionError::InternalServerError(
err.msg,
))
}
"ServiceUnavailableError" => {
return RusotoError::Service(BeginTransactionError::ServiceUnavailableError(
err.msg,
))
}
"StatementTimeoutException" => {
return RusotoError::Service(BeginTransactionError::StatementTimeout(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for BeginTransactionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BeginTransactionError {
fn description(&self) -> &str {
match *self {
BeginTransactionError::BadRequest(ref cause) => cause,
BeginTransactionError::Forbidden(ref cause) => cause,
BeginTransactionError::InternalServerError(ref cause) => cause,
BeginTransactionError::ServiceUnavailableError(ref cause) => cause,
BeginTransactionError::StatementTimeout(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum CommitTransactionError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailableError(String),
}
impl CommitTransactionError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CommitTransactionError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(CommitTransactionError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(CommitTransactionError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(CommitTransactionError::InternalServerError(
err.msg,
))
}
"NotFoundException" => {
return RusotoError::Service(CommitTransactionError::NotFound(err.msg))
}
"ServiceUnavailableError" => {
return RusotoError::Service(CommitTransactionError::ServiceUnavailableError(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CommitTransactionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CommitTransactionError {
fn description(&self) -> &str {
match *self {
CommitTransactionError::BadRequest(ref cause) => cause,
CommitTransactionError::Forbidden(ref cause) => cause,
CommitTransactionError::InternalServerError(ref cause) => cause,
CommitTransactionError::NotFound(ref cause) => cause,
CommitTransactionError::ServiceUnavailableError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ExecuteSqlError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
ServiceUnavailableError(String),
}
impl ExecuteSqlError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ExecuteSqlError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ExecuteSqlError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(ExecuteSqlError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(ExecuteSqlError::InternalServerError(err.msg))
}
"ServiceUnavailableError" => {
return RusotoError::Service(ExecuteSqlError::ServiceUnavailableError(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ExecuteSqlError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ExecuteSqlError {
fn description(&self) -> &str {
match *self {
ExecuteSqlError::BadRequest(ref cause) => cause,
ExecuteSqlError::Forbidden(ref cause) => cause,
ExecuteSqlError::InternalServerError(ref cause) => cause,
ExecuteSqlError::ServiceUnavailableError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ExecuteStatementError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
ServiceUnavailableError(String),
StatementTimeout(String),
}
impl ExecuteStatementError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ExecuteStatementError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ExecuteStatementError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(ExecuteStatementError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(ExecuteStatementError::InternalServerError(
err.msg,
))
}
"ServiceUnavailableError" => {
return RusotoError::Service(ExecuteStatementError::ServiceUnavailableError(
err.msg,
))
}
"StatementTimeoutException" => {
return RusotoError::Service(ExecuteStatementError::StatementTimeout(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ExecuteStatementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ExecuteStatementError {
fn description(&self) -> &str {
match *self {
ExecuteStatementError::BadRequest(ref cause) => cause,
ExecuteStatementError::Forbidden(ref cause) => cause,
ExecuteStatementError::InternalServerError(ref cause) => cause,
ExecuteStatementError::ServiceUnavailableError(ref cause) => cause,
ExecuteStatementError::StatementTimeout(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum RollbackTransactionError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailableError(String),
}
impl RollbackTransactionError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<RollbackTransactionError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(RollbackTransactionError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(RollbackTransactionError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(RollbackTransactionError::InternalServerError(
err.msg,
))
}
"NotFoundException" => {
return RusotoError::Service(RollbackTransactionError::NotFound(err.msg))
}
"ServiceUnavailableError" => {
return RusotoError::Service(RollbackTransactionError::ServiceUnavailableError(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for RollbackTransactionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RollbackTransactionError {
fn description(&self) -> &str {
match *self {
RollbackTransactionError::BadRequest(ref cause) => cause,
RollbackTransactionError::Forbidden(ref cause) => cause,
RollbackTransactionError::InternalServerError(ref cause) => cause,
RollbackTransactionError::NotFound(ref cause) => cause,
RollbackTransactionError::ServiceUnavailableError(ref cause) => cause,
}
}
}
pub trait RdsData {
fn batch_execute_statement(
&self,
input: BatchExecuteStatementRequest,
) -> RusotoFuture<BatchExecuteStatementResponse, BatchExecuteStatementError>;
fn begin_transaction(
&self,
input: BeginTransactionRequest,
) -> RusotoFuture<BeginTransactionResponse, BeginTransactionError>;
fn commit_transaction(
&self,
input: CommitTransactionRequest,
) -> RusotoFuture<CommitTransactionResponse, CommitTransactionError>;
fn execute_sql(
&self,
input: ExecuteSqlRequest,
) -> RusotoFuture<ExecuteSqlResponse, ExecuteSqlError>;
fn execute_statement(
&self,
input: ExecuteStatementRequest,
) -> RusotoFuture<ExecuteStatementResponse, ExecuteStatementError>;
fn rollback_transaction(
&self,
input: RollbackTransactionRequest,
) -> RusotoFuture<RollbackTransactionResponse, RollbackTransactionError>;
}
#[derive(Clone)]
pub struct RdsDataClient {
client: Client,
region: region::Region,
}
impl RdsDataClient {
pub fn new(region: region::Region) -> RdsDataClient {
RdsDataClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> RdsDataClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
RdsDataClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl RdsData for RdsDataClient {
fn batch_execute_statement(
&self,
input: BatchExecuteStatementRequest,
) -> RusotoFuture<BatchExecuteStatementResponse, BatchExecuteStatementError> {
let request_uri = "/BatchExecute";
let mut request = SignedRequest::new("POST", "rds-data", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<BatchExecuteStatementResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(BatchExecuteStatementError::from_response(response))
}),
)
}
})
}
fn begin_transaction(
&self,
input: BeginTransactionRequest,
) -> RusotoFuture<BeginTransactionResponse, BeginTransactionError> {
let request_uri = "/BeginTransaction";
let mut request = SignedRequest::new("POST", "rds-data", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<BeginTransactionResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(BeginTransactionError::from_response(response))),
)
}
})
}
fn commit_transaction(
&self,
input: CommitTransactionRequest,
) -> RusotoFuture<CommitTransactionResponse, CommitTransactionError> {
let request_uri = "/CommitTransaction";
let mut request = SignedRequest::new("POST", "rds-data", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<CommitTransactionResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CommitTransactionError::from_response(response))),
)
}
})
}
fn execute_sql(
&self,
input: ExecuteSqlRequest,
) -> RusotoFuture<ExecuteSqlResponse, ExecuteSqlError> {
let request_uri = "/ExecuteSql";
let mut request = SignedRequest::new("POST", "rds-data", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ExecuteSqlResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ExecuteSqlError::from_response(response))),
)
}
})
}
fn execute_statement(
&self,
input: ExecuteStatementRequest,
) -> RusotoFuture<ExecuteStatementResponse, ExecuteStatementError> {
let request_uri = "/Execute";
let mut request = SignedRequest::new("POST", "rds-data", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ExecuteStatementResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ExecuteStatementError::from_response(response))),
)
}
})
}
fn rollback_transaction(
&self,
input: RollbackTransactionRequest,
) -> RusotoFuture<RollbackTransactionResponse, RollbackTransactionError> {
let request_uri = "/RollbackTransaction";
let mut request = SignedRequest::new("POST", "rds-data", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<RollbackTransactionResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(RollbackTransactionError::from_response(response))
}),
)
}
})
}
}