// =================================================================
//
//                           * WARNING *
//
//                    This file is generated!
//
//  Changes made to this file will be overwritten. If changes are
//  required to the generated code, the service_crategen project
//  must be updated to generate the changes.
//
// =================================================================

use std::error::Error;
use std::fmt;

use async_trait::async_trait;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError};

use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
use serde_json;
///
Contains an array.

#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct ArrayValue {
    ///
An array of arrays.

    #[serde(rename = "arrayValues")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub array_values: Option<Vec<ArrayValue>>,
    ///
An array of Boolean values.

    #[serde(rename = "booleanValues")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub boolean_values: Option<Vec<bool>>,
    ///
An array of integers.

    #[serde(rename = "doubleValues")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub double_values: Option<Vec<f64>>,
    ///
An array of floating point numbers.

    #[serde(rename = "longValues")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub long_values: Option<Vec<i64>>,
    ///
An array of strings.

    #[serde(rename = "stringValues")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub string_values: Option<Vec<String>>,
}

///
The request parameters represent the input of a SQL statement over an array of data.

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct BatchExecuteStatementRequest {
    ///
The name of the database.

    #[serde(rename = "database")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub database: Option<String>,
    ///

The parameter set for the batch operation.

The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL statement with no parameters, use one of the following options:

Specify one or more empty parameter sets.

Use the ExecuteStatement operation instead of the BatchExecuteStatement operation.

 <note>
Array parameters are not supported.
 </note>

    #[serde(rename = "parameterSets")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parameter_sets: Option<Vec<Vec<SqlParameter>>>,
    ///
The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

    #[serde(rename = "resourceArn")]
    pub resource_arn: String,
    ///
The name of the database schema.

    #[serde(rename = "schema")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub schema: Option<String>,
    ///
The name or ARN of the secret that enables access to the DB cluster.

    #[serde(rename = "secretArn")]
    pub secret_arn: String,
    ///
The SQL statement to run.

    #[serde(rename = "sql")]
    pub sql: String,
    ///
The identifier of a transaction that was started by using the BeginTransaction operation. Specify the transaction ID of the transaction that you want to include the SQL statement in.

If the SQL statement is not part of a transaction, don't set this parameter.

    #[serde(rename = "transactionId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_id: Option<String>,
}

///
The response elements represent the output of a SQL statement over an array of data.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct BatchExecuteStatementResponse {
    ///
The execution results of each batch entry.

    #[serde(rename = "updateResults")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub update_results: Option<Vec<UpdateResult>>,
}

///
The request parameters represent the input of a request to start a SQL transaction.

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct BeginTransactionRequest {
    ///
The name of the database.

    #[serde(rename = "database")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub database: Option<String>,
    ///
The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

    #[serde(rename = "resourceArn")]
    pub resource_arn: String,
    ///
The name of the database schema.

    #[serde(rename = "schema")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub schema: Option<String>,
    ///
The name or ARN of the secret that enables access to the DB cluster.

    #[serde(rename = "secretArn")]
    pub secret_arn: String,
}

///
The response elements represent the output of a request to start a SQL transaction.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct BeginTransactionResponse {
    ///
The transaction ID of the transaction started by the call.

    #[serde(rename = "transactionId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_id: Option<String>,
}

///
Contains the metadata for a column.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ColumnMetadata {
    ///
The type of the column.

    #[serde(rename = "arrayBaseColumnType")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub array_base_column_type: Option<i64>,
    ///
A value that indicates whether the column increments automatically.

    #[serde(rename = "isAutoIncrement")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_auto_increment: Option<bool>,
    ///
A value that indicates whether the column is case-sensitive.

    #[serde(rename = "isCaseSensitive")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_case_sensitive: Option<bool>,
    ///
A value that indicates whether the column contains currency values.

    #[serde(rename = "isCurrency")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_currency: Option<bool>,
    ///
A value that indicates whether an integer column is signed.

    #[serde(rename = "isSigned")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_signed: Option<bool>,
    ///
The label for the column.

    #[serde(rename = "label")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub label: Option<String>,
    ///
The name of the column.

    #[serde(rename = "name")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    ///
A value that indicates whether the column is nullable.

    #[serde(rename = "nullable")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub nullable: Option<i64>,
    ///
The precision value of a decimal number column.

    #[serde(rename = "precision")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub precision: Option<i64>,
    ///
The scale value of a decimal number column.

    #[serde(rename = "scale")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub scale: Option<i64>,
    ///
The name of the schema that owns the table that includes the column.

    #[serde(rename = "schemaName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub schema_name: Option<String>,
    ///
The name of the table that includes the column.

    #[serde(rename = "tableName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub table_name: Option<String>,
    ///
The type of the column.

    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub type_: Option<i64>,
    ///
The database-specific data type of the column.

    #[serde(rename = "typeName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub type_name: Option<String>,
}

///
The request parameters represent the input of a commit transaction request.

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct CommitTransactionRequest {
    ///
The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

    #[serde(rename = "resourceArn")]
    pub resource_arn: String,
    ///
The name or ARN of the secret that enables access to the DB cluster.

    #[serde(rename = "secretArn")]
    pub secret_arn: String,
    ///
The identifier of the transaction to end and commit.

    #[serde(rename = "transactionId")]
    pub transaction_id: String,
}

///
The response elements represent the output of a commit transaction request.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct CommitTransactionResponse {
    ///
The status of the commit operation.

    #[serde(rename = "transactionStatus")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_status: Option<String>,
}

///
The request parameters represent the input of a request to run one or more SQL statements.

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ExecuteSqlRequest {
    ///
The Amazon Resource Name (ARN) of the secret that enables access to the DB cluster.

    #[serde(rename = "awsSecretStoreArn")]
    pub aws_secret_store_arn: String,
    ///
The name of the database.

    #[serde(rename = "database")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub database: Option<String>,
    ///
The ARN of the Aurora Serverless DB cluster.

    #[serde(rename = "dbClusterOrInstanceArn")]
    pub db_cluster_or_instance_arn: String,
    ///
The name of the database schema.

    #[serde(rename = "schema")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub schema: Option<String>,
    ///
One or more SQL statements to run on the DB cluster.

You can separate SQL statements from each other with a semicolon (;). Any valid SQL statement is permitted, including data definition, data manipulation, and commit statements.

    #[serde(rename = "sqlStatements")]
    pub sql_statements: String,
}

///
The response elements represent the output of a request to run one or more SQL statements.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ExecuteSqlResponse {
    ///
The results of the SQL statement or statements.

    #[serde(rename = "sqlStatementResults")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sql_statement_results: Option<Vec<SqlStatementResult>>,
}

///
The request parameters represent the input of a request to run a SQL statement against a database.

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ExecuteStatementRequest {
    ///

A value that indicates whether to continue running the statement after the call times out. By default, the statement stops running when the call times out.
 <important>
For DDL statements, we recommend continuing to run the statement after the call times out. When a DDL statement terminates before it is finished running, it can result in errors and possibly corrupted data structures.
 </important>

    #[serde(rename = "continueAfterTimeout")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub continue_after_timeout: Option<bool>,
    ///
The name of the database.

    #[serde(rename = "database")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub database: Option<String>,
    ///
A value that indicates whether to include metadata in the results.

    #[serde(rename = "includeResultMetadata")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_result_metadata: Option<bool>,
    ///

The parameters for the SQL statement.
 <note>
Array parameters are not supported.
 </note>

    #[serde(rename = "parameters")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parameters: Option<Vec<SqlParameter>>,
    ///
The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

    #[serde(rename = "resourceArn")]
    pub resource_arn: String,
    ///
Options that control how the result set is returned.

    #[serde(rename = "resultSetOptions")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub result_set_options: Option<ResultSetOptions>,
    ///
The name of the database schema.

    #[serde(rename = "schema")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub schema: Option<String>,
    ///
The name or ARN of the secret that enables access to the DB cluster.

    #[serde(rename = "secretArn")]
    pub secret_arn: String,
    ///
The SQL statement to run.

    #[serde(rename = "sql")]
    pub sql: String,
    ///
The identifier of a transaction that was started by using the BeginTransaction operation. Specify the transaction ID of the transaction that you want to include the SQL statement in.

If the SQL statement is not part of a transaction, don't set this parameter.

    #[serde(rename = "transactionId")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_id: Option<String>,
}

///
The response elements represent the output of a request to run a SQL statement against a database.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ExecuteStatementResponse {
    ///
Metadata for the columns included in the results.

    #[serde(rename = "columnMetadata")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub column_metadata: Option<Vec<ColumnMetadata>>,
    ///

Values for fields generated during the request.

 <note> <p>The <code>generatedFields</code> data isn't supported by Aurora PostgreSQL. To get the values of generated fields, use the <code>RETURNING</code> clause. For more information, see <a href="https://www.postgresql.org/docs/10/dml-returning.html">Returning Data From Modified Rows</a> in the PostgreSQL documentation.</p> </note>

    #[serde(rename = "generatedFields")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub generated_fields: Option<Vec<Field>>,
    ///
The number of records updated by the request.

    #[serde(rename = "numberOfRecordsUpdated")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub number_of_records_updated: Option<i64>,
    ///
The records returned by the SQL statement.

    #[serde(rename = "records")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub records: Option<Vec<Vec<Field>>>,
}

///
Contains a value.

#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct Field {
    ///
An array of values.

    #[serde(rename = "arrayValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub array_value: Option<ArrayValue>,
    ///
A value of BLOB data type.

    #[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>,
    ///
A value of Boolean data type.

    #[serde(rename = "booleanValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub boolean_value: Option<bool>,
    ///
A value of double data type.

    #[serde(rename = "doubleValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub double_value: Option<f64>,
    ///
A NULL value.

    #[serde(rename = "isNull")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_null: Option<bool>,
    ///
A value of long data type.

    #[serde(rename = "longValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub long_value: Option<i64>,
    ///
A value of string data type.

    #[serde(rename = "stringValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub string_value: Option<String>,
}

///
A record returned by a call.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct Record {
    ///
The values returned in the record.

    #[serde(rename = "values")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<Value>>,
}

///
The result set returned by a SQL statement.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ResultFrame {
    ///
The records in the result set.

    #[serde(rename = "records")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub records: Option<Vec<Record>>,
    ///
The result-set metadata in the result set.

    #[serde(rename = "resultSetMetadata")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub result_set_metadata: Option<ResultSetMetadata>,
}

///
The metadata of the result set returned by a SQL statement.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ResultSetMetadata {
    ///
The number of columns in the result set.

    #[serde(rename = "columnCount")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub column_count: Option<i64>,
    ///
The metadata of the columns in the result set.

    #[serde(rename = "columnMetadata")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub column_metadata: Option<Vec<ColumnMetadata>>,
}

///
Options that control how the result set is returned.

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ResultSetOptions {
    ///

A value that indicates how a field of DECIMAL type is represented in the response. The value of STRING, the default, specifies that it is converted to a String value. The value of DOUBLEORLONG specifies that it is converted to a Long value if its scale is 0, or to a Double value otherwise.
 <important>
Conversion to Double or Long can result in roundoff errors due to precision loss. We recommend converting to String, especially when working with currency values.
 </important>

    #[serde(rename = "decimalReturnType")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub decimal_return_type: Option<String>,
}

///
The request parameters represent the input of a request to perform a rollback of a transaction.

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct RollbackTransactionRequest {
    ///
The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

    #[serde(rename = "resourceArn")]
    pub resource_arn: String,
    ///
The name or ARN of the secret that enables access to the DB cluster.

    #[serde(rename = "secretArn")]
    pub secret_arn: String,
    ///
The identifier of the transaction to roll back.

    #[serde(rename = "transactionId")]
    pub transaction_id: String,
}

///
The response elements represent the output of a request to perform a rollback of a transaction.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct RollbackTransactionResponse {
    ///
The status of the rollback operation.

    #[serde(rename = "transactionStatus")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_status: Option<String>,
}

///
A parameter used in a SQL statement.

#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct SqlParameter {
    ///
The name of the parameter.

    #[serde(rename = "name")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    ///

A hint that specifies the correct object type for data type mapping.

 Values:

 DECIMAL - The corresponding String parameter value is sent as an object of DECIMAL type to the database.

 TIMESTAMP - The corresponding String parameter value is sent as an object of TIMESTAMP type to the database. The accepted format is YYYY-MM-DD HH:MM:SS[.FFF].

 TIME - The corresponding String parameter value is sent as an object of TIME type to the database. The accepted format is HH:MM:SS[.FFF].

 DATE - The corresponding String parameter value is sent as an object of DATE type to the database. The accepted format is YYYY-MM-DD.

    #[serde(rename = "typeHint")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub type_hint: Option<String>,
    ///
The value of the parameter.

    #[serde(rename = "value")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<Field>,
}

///

The result of a SQL statement.

 <important> <p>This data type is deprecated.</p> </important>

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SqlStatementResult {
    ///
The number of records updated by a SQL statement.

    #[serde(rename = "numberOfRecordsUpdated")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub number_of_records_updated: Option<i64>,
    ///
The result set of the SQL statement.

    #[serde(rename = "resultFrame")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub result_frame: Option<ResultFrame>,
}

///
A structure value returned by a call.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct StructValue {
    ///
The attributes returned in the record.

    #[serde(rename = "attributes")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attributes: Option<Vec<Value>>,
}

///
The response elements represent the results of an update.

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct UpdateResult {
    ///
Values for fields generated during the request.

    #[serde(rename = "generatedFields")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub generated_fields: Option<Vec<Field>>,
}

///

Contains the value of a column.

 <important> <p>This data type is deprecated.</p> </important>

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct Value {
    ///
An array of column values.

    #[serde(rename = "arrayValues")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub array_values: Option<Vec<Value>>,
    ///
A value for a column of big integer data type.

    #[serde(rename = "bigIntValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub big_int_value: Option<i64>,
    ///
A value for a column of BIT data type.

    #[serde(rename = "bitValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bit_value: Option<bool>,
    ///
A value for a column of BLOB data type.

    #[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>,
    ///
A value for a column of double data type.

    #[serde(rename = "doubleValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub double_value: Option<f64>,
    ///
A value for a column of integer data type.

    #[serde(rename = "intValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub int_value: Option<i64>,
    ///
A NULL value.

    #[serde(rename = "isNull")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_null: Option<bool>,
    ///
A value for a column of real data type.

    #[serde(rename = "realValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub real_value: Option<f32>,
    ///
A value for a column of string data type.

    #[serde(rename = "stringValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub string_value: Option<String>,
    ///
A value for a column of STRUCT data type.

    #[serde(rename = "structValue")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub struct_value: Option<StructValue>,
}

/// Errors returned by BatchExecuteStatement
#[derive(Debug, PartialEq)]
pub enum BatchExecuteStatementError {
    ///
There is an error in the call or in a SQL statement.

    BadRequest(String),
    ///
There are insufficient privileges to make the call.

    Forbidden(String),
    ///
An internal error occurred.

    InternalServerError(String),
    ///
The service specified by the resourceArn parameter is not available.

    ServiceUnavailableError(String),
    ///
The execution of the SQL statement timed out.

    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),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for BatchExecuteStatementError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            BatchExecuteStatementError::BadRequest(ref cause) => write!(f, "{}", cause),
            BatchExecuteStatementError::Forbidden(ref cause) => write!(f, "{}", cause),
            BatchExecuteStatementError::InternalServerError(ref cause) => write!(f, "{}", cause),
            BatchExecuteStatementError::ServiceUnavailableError(ref cause) => {
                write!(f, "{}", cause)
            }
            BatchExecuteStatementError::StatementTimeout(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for BatchExecuteStatementError {}
/// Errors returned by BeginTransaction
#[derive(Debug, PartialEq)]
pub enum BeginTransactionError {
    ///
There is an error in the call or in a SQL statement.

    BadRequest(String),
    ///
There are insufficient privileges to make the call.

    Forbidden(String),
    ///
An internal error occurred.

    InternalServerError(String),
    ///
The service specified by the resourceArn parameter is not available.

    ServiceUnavailableError(String),
    ///
The execution of the SQL statement timed out.

    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),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for BeginTransactionError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            BeginTransactionError::BadRequest(ref cause) => write!(f, "{}", cause),
            BeginTransactionError::Forbidden(ref cause) => write!(f, "{}", cause),
            BeginTransactionError::InternalServerError(ref cause) => write!(f, "{}", cause),
            BeginTransactionError::ServiceUnavailableError(ref cause) => write!(f, "{}", cause),
            BeginTransactionError::StatementTimeout(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for BeginTransactionError {}
/// Errors returned by CommitTransaction
#[derive(Debug, PartialEq)]
pub enum CommitTransactionError {
    ///
There is an error in the call or in a SQL statement.

    BadRequest(String),
    ///
There are insufficient privileges to make the call.

    Forbidden(String),
    ///
An internal error occurred.

    InternalServerError(String),
    ///
The resourceArn, secretArn, or transactionId value can't be found.

    NotFound(String),
    ///
The service specified by the resourceArn parameter is not available.

    ServiceUnavailableError(String),
    ///
The execution of the SQL statement timed out.

    StatementTimeout(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,
                    ))
                }
                "StatementTimeoutException" => {
                    return RusotoError::Service(CommitTransactionError::StatementTimeout(err.msg))
                }
                "ValidationException" => return RusotoError::Validation(err.msg),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for CommitTransactionError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            CommitTransactionError::BadRequest(ref cause) => write!(f, "{}", cause),
            CommitTransactionError::Forbidden(ref cause) => write!(f, "{}", cause),
            CommitTransactionError::InternalServerError(ref cause) => write!(f, "{}", cause),
            CommitTransactionError::NotFound(ref cause) => write!(f, "{}", cause),
            CommitTransactionError::ServiceUnavailableError(ref cause) => write!(f, "{}", cause),
            CommitTransactionError::StatementTimeout(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for CommitTransactionError {}
/// Errors returned by ExecuteSql
#[derive(Debug, PartialEq)]
pub enum ExecuteSqlError {
    ///
There is an error in the call or in a SQL statement.

    BadRequest(String),
    ///
There are insufficient privileges to make the call.

    Forbidden(String),
    ///
An internal error occurred.

    InternalServerError(String),
    ///
The service specified by the resourceArn parameter is not available.

    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),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for ExecuteSqlError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            ExecuteSqlError::BadRequest(ref cause) => write!(f, "{}", cause),
            ExecuteSqlError::Forbidden(ref cause) => write!(f, "{}", cause),
            ExecuteSqlError::InternalServerError(ref cause) => write!(f, "{}", cause),
            ExecuteSqlError::ServiceUnavailableError(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for ExecuteSqlError {}
/// Errors returned by ExecuteStatement
#[derive(Debug, PartialEq)]
pub enum ExecuteStatementError {
    ///
There is an error in the call or in a SQL statement.

    BadRequest(String),
    ///
There are insufficient privileges to make the call.

    Forbidden(String),
    ///
An internal error occurred.

    InternalServerError(String),
    ///
The service specified by the resourceArn parameter is not available.

    ServiceUnavailableError(String),
    ///
The execution of the SQL statement timed out.

    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),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for ExecuteStatementError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            ExecuteStatementError::BadRequest(ref cause) => write!(f, "{}", cause),
            ExecuteStatementError::Forbidden(ref cause) => write!(f, "{}", cause),
            ExecuteStatementError::InternalServerError(ref cause) => write!(f, "{}", cause),
            ExecuteStatementError::ServiceUnavailableError(ref cause) => write!(f, "{}", cause),
            ExecuteStatementError::StatementTimeout(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for ExecuteStatementError {}
/// Errors returned by RollbackTransaction
#[derive(Debug, PartialEq)]
pub enum RollbackTransactionError {
    ///
There is an error in the call or in a SQL statement.

    BadRequest(String),
    ///
There are insufficient privileges to make the call.

    Forbidden(String),
    ///
An internal error occurred.

    InternalServerError(String),
    ///
The resourceArn, secretArn, or transactionId value can't be found.

    NotFound(String),
    ///
The service specified by the resourceArn parameter is not available.

    ServiceUnavailableError(String),
    ///
The execution of the SQL statement timed out.

    StatementTimeout(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,
                    ))
                }
                "StatementTimeoutException" => {
                    return RusotoError::Service(RollbackTransactionError::StatementTimeout(
                        err.msg,
                    ))
                }
                "ValidationException" => return RusotoError::Validation(err.msg),
                _ => {}
            }
        }
        RusotoError::Unknown(res)
    }
}
impl fmt::Display for RollbackTransactionError {
    #[allow(unused_variables)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            RollbackTransactionError::BadRequest(ref cause) => write!(f, "{}", cause),
            RollbackTransactionError::Forbidden(ref cause) => write!(f, "{}", cause),
            RollbackTransactionError::InternalServerError(ref cause) => write!(f, "{}", cause),
            RollbackTransactionError::NotFound(ref cause) => write!(f, "{}", cause),
            RollbackTransactionError::ServiceUnavailableError(ref cause) => write!(f, "{}", cause),
            RollbackTransactionError::StatementTimeout(ref cause) => write!(f, "{}", cause),
        }
    }
}
impl Error for RollbackTransactionError {}
/// Trait representing the capabilities of the AWS RDS DataService API. AWS RDS DataService clients implement this trait.
#[async_trait]
pub trait RdsData {
    ///

Runs a batch SQL statement over an array of data.

You can run bulk update and insert operations for multiple records using a DML statement with different parameter sets. Bulk operations can provide a significant performance improvement over individual insert and update operations.
 <important>
If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.
 </important>

    async fn batch_execute_statement(
        &self,
        input: BatchExecuteStatementRequest,
    ) -> Result<BatchExecuteStatementResponse, RusotoError<BatchExecuteStatementError>>;

    ///

Starts a SQL transaction.

 <important> <p>A transaction can run for a maximum of 24 hours. A transaction is terminated and rolled back automatically after 24 hours.</p> <p>A transaction times out if no calls use its transaction ID in three minutes. If a transaction times out before it's committed, it's rolled back automatically.</p> <p>DDL statements inside a transaction cause an implicit commit. We recommend that you run each DDL statement in a separate <code>ExecuteStatement</code> call with <code>continueAfterTimeout</code> enabled.</p> </important>

    async fn begin_transaction(
        &self,
        input: BeginTransactionRequest,
    ) -> Result<BeginTransactionResponse, RusotoError<BeginTransactionError>>;

    ///
Ends a SQL transaction started with the BeginTransaction operation and commits the changes.

    async fn commit_transaction(
        &self,
        input: CommitTransactionRequest,
    ) -> Result<CommitTransactionResponse, RusotoError<CommitTransactionError>>;

    ///

Runs one or more SQL statements.
 <important>
This operation is deprecated. Use the BatchExecuteStatement or ExecuteStatement operation.
 </important>

    async fn execute_sql(
        &self,
        input: ExecuteSqlRequest,
    ) -> Result<ExecuteSqlResponse, RusotoError<ExecuteSqlError>>;

    ///
Runs a SQL statement against a database.
 <important>
If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.
 </important>
The response size limit is 1 MB. If the call returns more than 1 MB of response data, the call is terminated.

    async fn execute_statement(
        &self,
        input: ExecuteStatementRequest,
    ) -> Result<ExecuteStatementResponse, RusotoError<ExecuteStatementError>>;

    ///
Performs a rollback of a transaction. Rolling back a transaction cancels its changes.

    async fn rollback_transaction(
        &self,
        input: RollbackTransactionRequest,
    ) -> Result<RollbackTransactionResponse, RusotoError<RollbackTransactionError>>;
}
/// A client for the AWS RDS DataService API.
#[derive(Clone)]
pub struct RdsDataClient {
    client: Client,
    region: region::Region,
}

impl RdsDataClient {
    /// Creates a client backed by the default tokio event loop.
    ///
    /// The client will use the default credentials provider and tls client.
    pub fn new(region: region::Region) -> RdsDataClient {
        RdsDataClient {
            client: Client::shared(),
            region,
        }
    }

    pub fn new_with
(
        request_dispatcher: D,
        credentials_provider: P,
        region: region::Region,
    ) -> RdsDataClient
    where
        P: ProvideAwsCredentials + Send + Sync + 'static,
        D: DispatchSignedRequest + Send + Sync + 'static,
    {
        RdsDataClient {
            client: Client::new_with(credentials_provider, request_dispatcher),
            region,
        }
    }

    pub fn new_with_client(client: Client, region: region::Region) -> RdsDataClient {
        RdsDataClient { client, region }
    }
}

#[async_trait]
impl RdsData for RdsDataClient {
    ///

Runs a batch SQL statement over an array of data.

You can run bulk update and insert operations for multiple records using a DML statement with different parameter sets. Bulk operations can provide a significant performance improvement over individual insert and update operations.
 <important>
If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.
 </important>

    #[allow(unused_mut)]
    async fn batch_execute_statement(
        &self,
        input: BatchExecuteStatementRequest,
    ) -> Result<BatchExecuteStatementResponse, RusotoError<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);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 200 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<BatchExecuteStatementResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(BatchExecuteStatementError::from_response(response))
        }
    }

    ///

Starts a SQL transaction.

 <important> <p>A transaction can run for a maximum of 24 hours. A transaction is terminated and rolled back automatically after 24 hours.</p> <p>A transaction times out if no calls use its transaction ID in three minutes. If a transaction times out before it's committed, it's rolled back automatically.</p> <p>DDL statements inside a transaction cause an implicit commit. We recommend that you run each DDL statement in a separate <code>ExecuteStatement</code> call with <code>continueAfterTimeout</code> enabled.</p> </important>

    #[allow(unused_mut)]
    async fn begin_transaction(
        &self,
        input: BeginTransactionRequest,
    ) -> Result<BeginTransactionResponse, RusotoError<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);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 200 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<BeginTransactionResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(BeginTransactionError::from_response(response))
        }
    }

    ///
Ends a SQL transaction started with the BeginTransaction operation and commits the changes.

    #[allow(unused_mut)]
    async fn commit_transaction(
        &self,
        input: CommitTransactionRequest,
    ) -> Result<CommitTransactionResponse, RusotoError<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);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 200 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<CommitTransactionResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(CommitTransactionError::from_response(response))
        }
    }

    ///

Runs one or more SQL statements.
 <important>
This operation is deprecated. Use the BatchExecuteStatement or ExecuteStatement operation.
 </important>

    #[allow(unused_mut)]
    async fn execute_sql(
        &self,
        input: ExecuteSqlRequest,
    ) -> Result<ExecuteSqlResponse, RusotoError<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);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 200 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<ExecuteSqlResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(ExecuteSqlError::from_response(response))
        }
    }

    ///
Runs a SQL statement against a database.
 <important>
If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.
 </important>
The response size limit is 1 MB. If the call returns more than 1 MB of response data, the call is terminated.

    #[allow(unused_mut)]
    async fn execute_statement(
        &self,
        input: ExecuteStatementRequest,
    ) -> Result<ExecuteStatementResponse, RusotoError<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);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 200 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<ExecuteStatementResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(ExecuteStatementError::from_response(response))
        }
    }

    ///
Performs a rollback of a transaction. Rolling back a transaction cancels its changes.

    #[allow(unused_mut)]
    async fn rollback_transaction(
        &self,
        input: RollbackTransactionRequest,
    ) -> Result<RollbackTransactionResponse, RusotoError<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);

        let mut response = self
            .client
            .sign_and_dispatch(request)
            .await
            .map_err(RusotoError::from)?;
        if response.status.as_u16() == 200 {
            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            let result = proto::json::ResponsePayload::new(&response)
                .deserialize::<RollbackTransactionResponse, _>()?;

            Ok(result)
        } else {
            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
            Err(RollbackTransactionError::from_response(response))
        }
    }
}

{'repo_name': 'rusoto/rusoto', 'stars': '1808', 'repo_language': 'Rust', 'file_name': 'lib.rs', 'mime_type': 'text/plain', 'hash': 2087968330778697098, 'source_dataset': 'data'}


/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
/* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import flash.utils.ByteArray;

var DESC = "Write aligned bigEndian uint to ByteArray, from literal data.";
include "driver.as"

function bytearray_write_uint(iter: int, a: ByteArray): void
{
    for ( var i:int = 0 ; i < iter ; i++ ) {
        a.position = 0;
        for ( var j:int = 0 ; j < 1000 ; j++ ) {
            a.writeUnsignedInt(1);
            a.writeUnsignedInt(2);
            a.writeUnsignedInt(3);
            a.writeUnsignedInt(4);
            a.writeUnsignedInt(5);
        }
    }
}

var bai: ByteArray = new ByteArray();
(function () {
    for ( var i=0 ; i < 5000 ; i++ )
        bai.writeUnsignedInt(i);
 })();
TEST(function () { bytearray_write_uint(1000, bai); }, "bytearray-write-uint-1");

{'repo_name': 'adobe/avmplus', 'stars': '116', 'repo_language': 'ActionScript', 'file_name': 'legal.dox', 'mime_type': 'text/plain', 'hash': -5093031397867414007, 'source_dataset': 'data'}


<?php

class Mandrill_Tags {
    public function __construct(Mandrill $master) {
        $this->master = $master;
    }

    /**
     * Return all of the user-defined tag information
     * @return array a list of user-defined tags
     *     - return[] struct a user-defined tag
     *         - tag string the actual tag as a string
     *         - reputation integer the tag's current reputation on a scale from 0 to 100.
     *         - sent integer the total number of messages sent with this tag
     *         - hard_bounces integer the total number of hard bounces by messages with this tag
     *         - soft_bounces integer the total number of soft bounces by messages with this tag
     *         - rejects integer the total number of rejected messages with this tag
     *         - complaints integer the total number of spam complaints received for messages with this tag
     *         - unsubs integer the total number of unsubscribe requests received for messages with this tag
     *         - opens integer the total number of times messages with this tag have been opened
     *         - clicks integer the total number of times tracked URLs in messages with this tag have been clicked
     *         - unique_opens integer the number of unique opens for emails sent with this tag
     *         - unique_clicks integer the number of unique clicks for emails sent with this tag
     */
    public function getList() {
        $_params = array();
        return $this->master->call('tags/list', $_params);
    }

    /**
     * Deletes a tag permanently. Deleting a tag removes the tag from any messages
that have been sent, and also deletes the tag's stats. There is no way to
undo this operation, so use it carefully.
     * @param string $tag a tag name
     * @return struct the tag that was deleted
     *     - tag string the actual tag as a string
     *     - reputation integer the tag's current reputation on a scale from 0 to 100.
     *     - sent integer the total number of messages sent with this tag
     *     - hard_bounces integer the total number of hard bounces by messages with this tag
     *     - soft_bounces integer the total number of soft bounces by messages with this tag
     *     - rejects integer the total number of rejected messages with this tag
     *     - complaints integer the total number of spam complaints received for messages with this tag
     *     - unsubs integer the total number of unsubscribe requests received for messages with this tag
     *     - opens integer the total number of times messages with this tag have been opened
     *     - clicks integer the total number of times tracked URLs in messages with this tag have been clicked
     *     - unique_opens integer the number of unique opens for emails sent with this tag
     *     - unique_clicks integer the number of unique clicks for emails sent with this tag
     */
    public function delete($tag) {
        $_params = array("tag" => $tag);
        return $this->master->call('tags/delete', $_params);
    }

    /**
     * Return more detailed information about a single tag, including aggregates of recent stats
     * @param string $tag an existing tag name
     * @return struct the detailed information on the tag
     *     - tag string the actual tag as a string
     *     - sent integer the total number of messages sent with this tag
     *     - hard_bounces integer the total number of hard bounces by messages with this tag
     *     - soft_bounces integer the total number of soft bounces by messages with this tag
     *     - rejects integer the total number of rejected messages with this tag
     *     - complaints integer the total number of spam complaints received for messages with this tag
     *     - unsubs integer the total number of unsubscribe requests received for messages with this tag
     *     - opens integer the total number of times messages with this tag have been opened
     *     - clicks integer the total number of times tracked URLs in messages with this tag have been clicked
     *     - stats struct an aggregate summary of the tag's sending stats
     *         - today struct stats with this tag so far today
     *             - sent integer the number of emails sent with this tag so far today
     *             - hard_bounces integer the number of emails hard bounced with this tag so far today
     *             - soft_bounces integer the number of emails soft bounced with this tag so far today
     *             - rejects integer the number of emails rejected for sending this tag so far today
     *             - complaints integer the number of spam complaints with this tag so far today
     *             - unsubs integer the number of unsubscribes with this tag so far today
     *             - opens integer the number of times emails have been opened with this tag so far today
     *             - unique_opens integer the number of unique opens for emails sent with this tag so far today
     *             - clicks integer the number of URLs that have been clicked with this tag so far today
     *             - unique_clicks integer the number of unique clicks for emails sent with this tag so far today
     *         - last_7_days struct stats with this tag in the last 7 days
     *             - sent integer the number of emails sent with this tag in the last 7 days
     *             - hard_bounces integer the number of emails hard bounced with this tag in the last 7 days
     *             - soft_bounces integer the number of emails soft bounced with this tag in the last 7 days
     *             - rejects integer the number of emails rejected for sending this tag in the last 7 days
     *             - complaints integer the number of spam complaints with this tag in the last 7 days
     *             - unsubs integer the number of unsubscribes with this tag in the last 7 days
     *             - opens integer the number of times emails have been opened with this tag in the last 7 days
     *             - unique_opens integer the number of unique opens for emails sent with this tag in the last 7 days
     *             - clicks integer the number of URLs that have been clicked with this tag in the last 7 days
     *             - unique_clicks integer the number of unique clicks for emails sent with this tag in the last 7 days
     *         - last_30_days struct stats with this tag in the last 30 days
     *             - sent integer the number of emails sent with this tag in the last 30 days
     *             - hard_bounces integer the number of emails hard bounced with this tag in the last 30 days
     *             - soft_bounces integer the number of emails soft bounced with this tag in the last 30 days
     *             - rejects integer the number of emails rejected for sending this tag in the last 30 days
     *             - complaints integer the number of spam complaints with this tag in the last 30 days
     *             - unsubs integer the number of unsubscribes with this tag in the last 30 days
     *             - opens integer the number of times emails have been opened with this tag in the last 30 days
     *             - unique_opens integer the number of unique opens for emails sent with this tag in the last 30 days
     *             - clicks integer the number of URLs that have been clicked with this tag in the last 30 days
     *             - unique_clicks integer the number of unique clicks for emails sent with this tag in the last 30 days
     *         - last_60_days struct stats with this tag in the last 60 days
     *             - sent integer the number of emails sent with this tag in the last 60 days
     *             - hard_bounces integer the number of emails hard bounced with this tag in the last 60 days
     *             - soft_bounces integer the number of emails soft bounced with this tag in the last 60 days
     *             - rejects integer the number of emails rejected for sending this tag in the last 60 days
     *             - complaints integer the number of spam complaints with this tag in the last 60 days
     *             - unsubs integer the number of unsubscribes with this tag in the last 60 days
     *             - opens integer the number of times emails have been opened with this tag in the last 60 days
     *             - unique_opens integer the number of unique opens for emails sent with this tag in the last 60 days
     *             - clicks integer the number of URLs that have been clicked with this tag in the last 60 days
     *             - unique_clicks integer the number of unique clicks for emails sent with this tag in the last 60 days
     *         - last_90_days struct stats with this tag in the last 90 days
     *             - sent integer the number of emails sent with this tag in the last 90 days
     *             - hard_bounces integer the number of emails hard bounced with this tag in the last 90 days
     *             - soft_bounces integer the number of emails soft bounced with this tag in the last 90 days
     *             - rejects integer the number of emails rejected for sending this tag in the last 90 days
     *             - complaints integer the number of spam complaints with this tag in the last 90 days
     *             - unsubs integer the number of unsubscribes with this tag in the last 90 days
     *             - opens integer the number of times emails have been opened with this tag in the last 90 days
     *             - unique_opens integer the number of unique opens for emails sent with this tag in the last 90 days
     *             - clicks integer the number of URLs that have been clicked with this tag in the last 90 days
     *             - unique_clicks integer the number of unique clicks for emails sent with this tag in the last 90 days
     */
    public function info($tag) {
        $_params = array("tag" => $tag);
        return $this->master->call('tags/info', $_params);
    }

    /**
     * Return the recent history (hourly stats for the last 30 days) for a tag
     * @param string $tag an existing tag name
     * @return array the array of history information
     *     - return[] struct the stats for a single hour
     *         - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
     *         - sent integer the number of emails that were sent during the hour
     *         - hard_bounces integer the number of emails that hard bounced during the hour
     *         - soft_bounces integer the number of emails that soft bounced during the hour
     *         - rejects integer the number of emails that were rejected during the hour
     *         - complaints integer the number of spam complaints received during the hour
     *         - unsubs integer the number of unsubscribes received during the hour
     *         - opens integer the number of emails opened during the hour
     *         - unique_opens integer the number of unique opens generated by messages sent during the hour
     *         - clicks integer the number of tracked URLs clicked during the hour
     *         - unique_clicks integer the number of unique clicks generated by messages sent during the hour
     */
    public function timeSeries($tag) {
        $_params = array("tag" => $tag);
        return $this->master->call('tags/time-series', $_params);
    }

    /**
     * Return the recent history (hourly stats for the last 30 days) for all tags
     * @return array the array of history information
     *     - return[] struct the stats for a single hour
     *         - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
     *         - sent integer the number of emails that were sent during the hour
     *         - hard_bounces integer the number of emails that hard bounced during the hour
     *         - soft_bounces integer the number of emails that soft bounced during the hour
     *         - rejects integer the number of emails that were rejected during the hour
     *         - complaints integer the number of spam complaints received during the hour
     *         - unsubs integer the number of unsubscribes received during the hour
     *         - opens integer the number of emails opened during the hour
     *         - unique_opens integer the number of unique opens generated by messages sent during the hour
     *         - clicks integer the number of tracked URLs clicked during the hour
     *         - unique_clicks integer the number of unique clicks generated by messages sent during the hour
     */
    public function allTimeSeries() {
        $_params = array();
        return $this->master->call('tags/all-time-series', $_params);
    }

}

{'repo_name': 'ThinkUpLLC/ThinkUp', 'stars': '3351', 'repo_language': 'PHP', 'file_name': 'cron', 'mime_type': 'text/x-shellscript', 'hash': 6059760186558583425, 'source_dataset': 'data'}


'use strict';
/* jshint indent: 2*/
// Set the jasmine fixture path
// jasmine.getFixtures().fixturesPath = 'base/';

describe('ngCsv directive', function () {

  var $compile;
  var $rootScope;
  var $timeout;

  // Load the myApp module, which contains the directive
  beforeEach(module('ngCsv.directives'));

  // Store references to $rootScope and $compile
  // so they are available to all tests in this describe block
  beforeEach(inject(function (_$compile_, _$rootScope_, $q, _$timeout_) {
    // The injector unwraps the underscores (_) from around the parameter names when matching
    $compile = _$compile_;
    $rootScope = _$rootScope_;
    $timeout = _$timeout_;
    $rootScope.test = [[1, 2, 3], [4, 5, 6]];
    $rootScope.testObj = [{a: 1, b: 2, c: 3}, {a: 4, b: 5, c: 6}];
    $rootScope.testDecimal = [[13.37]];

    var _deferred = $q.defer();
    _deferred.resolve([[1, 2, 3], [4, 5, 6]]);
    $rootScope.testPromise = _deferred.promise;

    _deferred = $q.defer();
    $timeout(function(){_deferred.resolve([[1, 2, 3], [4, 5, 6]])});
    $rootScope.longPromise = _deferred.promise;

    $rootScope.functionPromise = function(){
      var defer = $q.defer();
      defer.resolve([[1, 2, 3]])
      return defer.promise;
    };
  }));

  //This is failing because the current stable build of PhantomJS doesn't support the Blob object. Support for Blobs
  // will be supported in 2.0
  //TODO: Re-enable once PhantomJS 2.0 is released
  xit('Accepts ng-click attribute ', function () {
    $rootScope.clicked = false;
    // Create click handler
    $rootScope.clickTest = function() {
      $rootScope.clicked = true;
    };

    // Make sure clicked is false
    expect($rootScope.clicked).toBeFalsy();

    // Compile a piece of HTML containing the directive
    var element = $compile("

")($rootScope);
    element.triggerHandler('click');

    // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
    $rootScope.$digest();

    // Check if clickTest was executed
    expect($rootScope.clicked).toBeTruthy();
  });

  it('Builds the csv format correctly', function (done) {
    // Compile a piece of HTML containing the directive
    var element = $compile("

")($rootScope);
    // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toBe($rootScope.test);
    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1,2,3\r\n4,5,6\r\n');
      done();
    });
    scope.$apply();
  });

  it('accepts promise as data', function (done) {
    // Compile a piece of HTML containing the directive
    var element = $compile("

")($rootScope);
    // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1,2,3\r\n4,5,6\r\n');
      done();
    });
    scope.$apply();
  });

  it('accepts function returning promise as data', function(done){
    // Compile a piece of HTML containing the directive
    var element = $compile("

")($rootScope);
    // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    scope.buildCSV().then(function() {
      expect(scope.csv).toBe('1,2,3\r\n');
      done();
    });
    scope.$apply();
  });

  it('Accepts $scope expressions as ng-csv', function (done) {
    // Compile a piece of HTML containing the directive
    $rootScope.getTest = function () {return [[1, 2, 3], [4, 5, 6]]; };
    var element = $compile("

")($rootScope);
    // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.getTest());
    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1,2,3\r\n4,5,6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Creates a header row if provided', function (done) {
    // Compile a piece of HTML containing the directive
    var element = $compile(
      '
' +
      '
')($rootScope);
    // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.test);
    expect(scope.$eval(scope.header)).toEqual(['A', 'B', 'C']);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('A,B,C\r\n1,2,3\r\n4,5,6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Creates a header row using keys if csv-label sets to true', function (done) {
    // Compile a piece of HTML containing the directive
    $rootScope.testDelim = [ {a:1, b:2, c:3}, {a:4, b:5, c:6} ];
    var element = $compile(
      '

')($rootScope);

    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('a,b,c\r\n1,2,3\r\n4,5,6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Accepts optional csv-column-order attribute (input array)', function (done) {
    $rootScope.testDelim = [ {a:1, b:2, c:3}, {a:4, b:5, c:6} ];
    $rootScope.order = [ 'b', 'a', 'c' ];
    var element = $compile(
      '

')($rootScope);

    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);
    expect(scope.$eval(scope.columnOrder)).toEqual($rootScope.order);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('2,1,3\r\n5,4,6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Creates a header row follows the order of csv-column-order', function (done) {
    $rootScope.testDelim = [ {a:1, b:2, c:3}, {a:4, b:5, c:6} ];
    $rootScope.order = [ 'b', 'a', 'c' ];
    var element = $compile(
      '

')($rootScope);

    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);
    expect(scope.$eval(scope.columnOrder)).toEqual($rootScope.order);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('b,a,c\r\n2,1,3\r\n5,4,6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Accepts optional text-delimiter attribute (input array)', function (done) {
    $rootScope.testDelim = [[1, 'a', 2], ['b', 'c', 3]];
    var element = $compile(
      '
' +
      '
')($rootScope);

    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1,"a",2\r\n"b","c",3\r\n');
      done();
    });
    scope.$apply();
  });

  it('Accepts optional text-delimiter attribute (input object)', function (done) {
    $rootScope.testDelim = [{a: 1, b: 'a', c: 2}, {a: 'b', b: 'c', c: 3}];
    var element = $compile(
      '
' +
      '
')($rootScope);

    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1,"a",2\r\n"b","c",3\r\n');
      done();
    });
    scope.$apply();
  });

  it('Add optional Byte Order Mark', function (done) {
    // Compile a piece of HTML containing the directive
    var element = $compile("

")($rootScope);
    // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('\ufeff1,2,3\r\n4,5,6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Handles commas in fields properly', function (done) {
    $rootScope.testDelim = [{a: 1, b: 'a,b', c: 2}, {a: 'b', b: 'c', c: 3}];
    var element = $compile(
      '
' +
      '
')($rootScope);

    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1,"a,b",2\r\nb,c,3\r\n');
      done();
    });
    scope.$apply();
  });

  it('Handles CLR in fields properly', function (done) {
    $rootScope.testDelim = [{a: 1, b: 'a\nb', c: 2}, {a: 'b', b: 'c', c: 3}];
    var element = $compile(
      '
' +
      '
')($rootScope);

    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1,"a\nb",2\r\nb,c,3\r\n');
      done();
    });
    scope.$apply();
  });

  it('Handles # in fields properly', function (done) {
    $rootScope.testDelim = [{a: 1, b: 'a#b', c: 2}, {a: 'b', b: 'c', c: 3}];
    var element = $compile(
      '
' +
      '
')($rootScope);

    $rootScope.$digest();

    var scope = element.isolateScope();

    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1,a#b,2\r\nb,c,3\r\n');
      done();
    });
    scope.$apply();
  });

  it('Accepts optional field-separator attribute (input array)', function (done) {
    var element = $compile(
      '
' +
      '
')($rootScope);
    $rootScope.$digest();

    var scope = element.isolateScope();
    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.test);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1;2;3\r\n4;5;6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Accepts optional field-separator attribute (input object)', function (done) {
    var element = $compile(
      '
' +
      '
')($rootScope);
    $rootScope.$digest();

    var scope = element.isolateScope();
    // Check that the compiled element contains the templated content
    expect(scope.$eval(scope.data)).toEqual($rootScope.testObj);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1;2;3\r\n4;5;6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Accepts dynamic field-separator attribute (input object)', function (done) {
    $rootScope.sep = '\t';
    var element = $compile(
      '
' +
      '
')($rootScope);
    $rootScope.$digest();
    $rootScope.sep = ';';
    $rootScope.$digest();

    var scope = element.isolateScope();
    // Check that the compiled element contains the templated content
    expect(scope.fieldSep).toBe($rootScope.sep);
    expect(scope.$eval(scope.data)).toEqual($rootScope.testObj);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1;2;3\r\n4;5;6\r\n');
      done();
    });
    scope.$apply();
  });

  it('Accepts special characters in field-separator attribute', function (done) {
    $rootScope.sep = '\t';
    var element = $compile(
      '
' +
      '
')($rootScope);
    $rootScope.$digest();

    var scope = element.isolateScope();
    // Check that the compiled element contains the templated content
    expect(scope.fieldSep).toBe($rootScope.sep);
    expect(scope.$eval(scope.data)).toEqual($rootScope.testObj);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('1\t2\t3\r\n4\t5\t6\r\n');
      done();
    });
    scope.$apply();
  });

  it('adds and removes loading class with promise', function (done) {
    // Compile a piece of HTML containing the directive
    var element = $compile("

")($rootScope);
    // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
    $rootScope.$digest();
    var scope = element.isolateScope();

    scope.buildCSV(scope.data).then(function() {
      expect(element.hasClass('ng-csv-loading')).toBe(false);
      done();
    });

    expect(element.hasClass('ng-csv-loading')).toBe(true);
    $timeout.flush();
    scope.$apply();
  });

  it('Handles undefined variables without raising any exception', function (done) {
    var element = $compile(
      '
' +
      '
')($rootScope);
    $rootScope.$digest();
    $rootScope.sep = ';';
    $rootScope.$digest();

    var scope = element.isolateScope();
    // Check that the compiled element has indeed undefined variable
    expect(scope.$eval(scope.data)).toEqual(undefined);

    scope.buildCSV(scope.data).then(function() {
      expect(scope.csv).toBe('');
      done();
    });
    scope.$apply();
  });

  describe('charset attribute', function () {

    beforeEach(function () {
      helper.enableBlobForTesting();
      helper.mockCreateObjectURL();
    });

    afterEach(function () {
      helper.unmockCreateObjectURL();
    });

    it('is UTF-8 as default', function () {
      var element = $compile(
        '
' +
        '
')($rootScope);

      window.URL.createObjectURL = function (blob) {
        expect(blob).toBeDefined();
        // for some reason blob.type can't be querried with PhantomJS - therefore I created typeForTest.
        // It will be available only in test!
        // It shall be removed when updating PhantomJS to 2.0
        expect(blob.type || blob.typeForTest()).toBe("text/csv;charset=utf-8;");
      };

      angular.element(element).triggerHandler('click');
    });

    it('can be set to UTF-8', function () {

      var element = $compile(
        '
' +
        '
')($rootScope);

      window.URL.createObjectURL = function (blob) {
        expect(blob.type).toBe("text/csv;charset=utf-8;");
      };

      angular.element(element).triggerHandler('click');
    });

    it('can be set to ISO-8859-1', function () {
      var element = $compile(
        '
' +
        '
')($rootScope);

      window.URL.createObjectURL = function (blob) {
        expect(blob.type).toBe("text/csv;charset=iso-8859-1;");
      };

      angular.element(element).triggerHandler('click');
    });

  });

  it('should convert decimal values to localeString if decimal-separator="locale"', function(done) {
    $rootScope.decSep = 'locale';

    var element = $compile(
      '
' +
      '
')($rootScope);

      $rootScope.$digest();

      var scope = element.isolateScope();

      expect(scope.decimalSep).toBe($rootScope.decSep);

      scope.buildCSV(scope.data).then(function() {
        var locale = $rootScope.testDecimal[0][0].toLocaleString();

        expect(scope.csv).toBe(locale + '\r\n');
        done();
      });

    scope.$apply();
  });

  it('should convert decimal values using the decimal-separator option', function(done) {
    $rootScope.decSep = ',';

    var element = $compile(
      '
' +
      '
')($rootScope);

      $rootScope.$digest();

      var scope = element.isolateScope();

      expect(scope.decimalSep).toBe($rootScope.decSep);

      scope.buildCSV(scope.data).then(function() {
        expect(scope.csv).toBe('13,37\r\n');
        done();
      });

    scope.$apply();
  });
});

{'repo_name': 'asafdav/ng-csv', 'stars': '585', 'repo_language': 'JavaScript', 'file_name': 'index.html', 'mime_type': 'text/html', 'hash': 605372847324688630, 'source_dataset': 'data'}