use std::error::Error;
use std::fmt;
use std::io;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoFuture};
use rusoto_core::credential::{CredentialsError, ProvideAwsCredentials};
use rusoto_core::request::HttpDispatchError;
use rusoto_core::signature::SignedRequest;
use serde_json;
use serde_json::from_slice;
use serde_json::Value as SerdeJsonValue;
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchGetNamedQueryInput {
#[serde(rename = "NamedQueryIds")]
pub named_query_ids: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchGetNamedQueryOutput {
#[serde(rename = "NamedQueries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub named_queries: Option<Vec<NamedQuery>>,
#[serde(rename = "UnprocessedNamedQueryIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unprocessed_named_query_ids: Option<Vec<UnprocessedNamedQueryId>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchGetQueryExecutionInput {
#[serde(rename = "QueryExecutionIds")]
pub query_execution_ids: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchGetQueryExecutionOutput {
#[serde(rename = "QueryExecutions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_executions: Option<Vec<QueryExecution>>,
#[serde(rename = "UnprocessedQueryExecutionIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unprocessed_query_execution_ids: Option<Vec<UnprocessedQueryExecutionId>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ColumnInfo {
#[serde(rename = "CaseSensitive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub case_sensitive: Option<bool>,
#[serde(rename = "CatalogName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub catalog_name: Option<String>,
#[serde(rename = "Label")]
#[serde(skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "Nullable")]
#[serde(skip_serializing_if = "Option::is_none")]
pub nullable: Option<String>,
#[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")]
pub type_: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateNamedQueryInput {
#[serde(rename = "ClientRequestToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_request_token: Option<String>,
#[serde(rename = "Database")]
pub database: String,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "QueryString")]
pub query_string: String,
#[serde(rename = "WorkGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_group: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateNamedQueryOutput {
#[serde(rename = "NamedQueryId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub named_query_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateWorkGroupInput {
#[serde(rename = "Configuration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration: Option<WorkGroupConfiguration>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Name")]
pub name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateWorkGroupOutput {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Datum {
#[serde(rename = "VarCharValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub var_char_value: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteNamedQueryInput {
#[serde(rename = "NamedQueryId")]
pub named_query_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteNamedQueryOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteWorkGroupInput {
#[serde(rename = "RecursiveDeleteOption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub recursive_delete_option: Option<bool>,
#[serde(rename = "WorkGroup")]
pub work_group: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteWorkGroupOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EncryptionConfiguration {
#[serde(rename = "EncryptionOption")]
pub encryption_option: String,
#[serde(rename = "KmsKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kms_key: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetNamedQueryInput {
#[serde(rename = "NamedQueryId")]
pub named_query_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetNamedQueryOutput {
#[serde(rename = "NamedQuery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub named_query: Option<NamedQuery>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetQueryExecutionInput {
#[serde(rename = "QueryExecutionId")]
pub query_execution_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetQueryExecutionOutput {
#[serde(rename = "QueryExecution")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_execution: Option<QueryExecution>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetQueryResultsInput {
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "QueryExecutionId")]
pub query_execution_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetQueryResultsOutput {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "ResultSet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_set: Option<ResultSet>,
#[serde(rename = "UpdateCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub update_count: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetWorkGroupInput {
#[serde(rename = "WorkGroup")]
pub work_group: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetWorkGroupOutput {
#[serde(rename = "WorkGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_group: Option<WorkGroup>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListNamedQueriesInput {
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "WorkGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_group: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListNamedQueriesOutput {
#[serde(rename = "NamedQueryIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub named_query_ids: Option<Vec<String>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListQueryExecutionsInput {
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "WorkGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_group: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListQueryExecutionsOutput {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "QueryExecutionIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_execution_ids: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListWorkGroupsInput {
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListWorkGroupsOutput {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "WorkGroups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_groups: Option<Vec<WorkGroupSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct NamedQuery {
#[serde(rename = "Database")]
pub database: String,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "NamedQueryId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub named_query_id: Option<String>,
#[serde(rename = "QueryString")]
pub query_string: String,
#[serde(rename = "WorkGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_group: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct QueryExecution {
#[serde(rename = "Query")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query: Option<String>,
#[serde(rename = "QueryExecutionContext")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_execution_context: Option<QueryExecutionContext>,
#[serde(rename = "QueryExecutionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_execution_id: Option<String>,
#[serde(rename = "ResultConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_configuration: Option<ResultConfiguration>,
#[serde(rename = "StatementType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub statement_type: Option<String>,
#[serde(rename = "Statistics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub statistics: Option<QueryExecutionStatistics>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<QueryExecutionStatus>,
#[serde(rename = "WorkGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_group: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct QueryExecutionContext {
#[serde(rename = "Database")]
#[serde(skip_serializing_if = "Option::is_none")]
pub database: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct QueryExecutionStatistics {
#[serde(rename = "DataScannedInBytes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data_scanned_in_bytes: Option<i64>,
#[serde(rename = "EngineExecutionTimeInMillis")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_execution_time_in_millis: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct QueryExecutionStatus {
#[serde(rename = "CompletionDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub completion_date_time: Option<f64>,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "StateChangeReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state_change_reason: Option<String>,
#[serde(rename = "SubmissionDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submission_date_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResultConfiguration {
#[serde(rename = "EncryptionConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption_configuration: Option<EncryptionConfiguration>,
#[serde(rename = "OutputLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_location: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ResultConfigurationUpdates {
#[serde(rename = "EncryptionConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption_configuration: Option<EncryptionConfiguration>,
#[serde(rename = "OutputLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_location: Option<String>,
#[serde(rename = "RemoveEncryptionConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remove_encryption_configuration: Option<bool>,
#[serde(rename = "RemoveOutputLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remove_output_location: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResultSet {
#[serde(rename = "ResultSetMetadata")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_set_metadata: Option<ResultSetMetadata>,
#[serde(rename = "Rows")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rows: Option<Vec<Row>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResultSetMetadata {
#[serde(rename = "ColumnInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_info: Option<Vec<ColumnInfo>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Row {
#[serde(rename = "Data")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<Vec<Datum>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartQueryExecutionInput {
#[serde(rename = "ClientRequestToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_request_token: Option<String>,
#[serde(rename = "QueryExecutionContext")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_execution_context: Option<QueryExecutionContext>,
#[serde(rename = "QueryString")]
pub query_string: String,
#[serde(rename = "ResultConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_configuration: Option<ResultConfiguration>,
#[serde(rename = "WorkGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_group: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartQueryExecutionOutput {
#[serde(rename = "QueryExecutionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_execution_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StopQueryExecutionInput {
#[serde(rename = "QueryExecutionId")]
pub query_execution_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StopQueryExecutionOutput {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UnprocessedNamedQueryId {
#[serde(rename = "ErrorCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
#[serde(rename = "ErrorMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_message: Option<String>,
#[serde(rename = "NamedQueryId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub named_query_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UnprocessedQueryExecutionId {
#[serde(rename = "ErrorCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
#[serde(rename = "ErrorMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_message: Option<String>,
#[serde(rename = "QueryExecutionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_execution_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateWorkGroupInput {
#[serde(rename = "ConfigurationUpdates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_updates: Option<WorkGroupConfigurationUpdates>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "WorkGroup")]
pub work_group: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateWorkGroupOutput {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct WorkGroup {
#[serde(rename = "Configuration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration: Option<WorkGroupConfiguration>,
#[serde(rename = "CreationTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creation_time: Option<f64>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WorkGroupConfiguration {
#[serde(rename = "BytesScannedCutoffPerQuery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bytes_scanned_cutoff_per_query: Option<i64>,
#[serde(rename = "EnforceWorkGroupConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enforce_work_group_configuration: Option<bool>,
#[serde(rename = "PublishCloudWatchMetricsEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publish_cloud_watch_metrics_enabled: Option<bool>,
#[serde(rename = "ResultConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_configuration: Option<ResultConfiguration>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct WorkGroupConfigurationUpdates {
#[serde(rename = "BytesScannedCutoffPerQuery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bytes_scanned_cutoff_per_query: Option<i64>,
#[serde(rename = "EnforceWorkGroupConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enforce_work_group_configuration: Option<bool>,
#[serde(rename = "PublishCloudWatchMetricsEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publish_cloud_watch_metrics_enabled: Option<bool>,
#[serde(rename = "RemoveBytesScannedCutoffPerQuery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remove_bytes_scanned_cutoff_per_query: Option<bool>,
#[serde(rename = "ResultConfigurationUpdates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_configuration_updates: Option<ResultConfigurationUpdates>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct WorkGroupSummary {
#[serde(rename = "CreationTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creation_time: Option<f64>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}
#[derive(Debug, PartialEq)]
pub enum BatchGetNamedQueryError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchGetNamedQueryError {
pub fn from_response(res: BufferedHttpResponse) -> BatchGetNamedQueryError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return BatchGetNamedQueryError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return BatchGetNamedQueryError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return BatchGetNamedQueryError::Validation(error_message.to_string());
}
_ => {}
}
}
return BatchGetNamedQueryError::Unknown(res);
}
}
impl From<serde_json::error::Error> for BatchGetNamedQueryError {
fn from(err: serde_json::error::Error) -> BatchGetNamedQueryError {
BatchGetNamedQueryError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for BatchGetNamedQueryError {
fn from(err: CredentialsError) -> BatchGetNamedQueryError {
BatchGetNamedQueryError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchGetNamedQueryError {
fn from(err: HttpDispatchError) -> BatchGetNamedQueryError {
BatchGetNamedQueryError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchGetNamedQueryError {
fn from(err: io::Error) -> BatchGetNamedQueryError {
BatchGetNamedQueryError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for BatchGetNamedQueryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchGetNamedQueryError {
fn description(&self) -> &str {
match *self {
BatchGetNamedQueryError::InternalServer(ref cause) => cause,
BatchGetNamedQueryError::InvalidRequest(ref cause) => cause,
BatchGetNamedQueryError::Validation(ref cause) => cause,
BatchGetNamedQueryError::Credentials(ref err) => err.description(),
BatchGetNamedQueryError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchGetNamedQueryError::ParseError(ref cause) => cause,
BatchGetNamedQueryError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum BatchGetQueryExecutionError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchGetQueryExecutionError {
pub fn from_response(res: BufferedHttpResponse) -> BatchGetQueryExecutionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return BatchGetQueryExecutionError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return BatchGetQueryExecutionError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return BatchGetQueryExecutionError::Validation(error_message.to_string());
}
_ => {}
}
}
return BatchGetQueryExecutionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for BatchGetQueryExecutionError {
fn from(err: serde_json::error::Error) -> BatchGetQueryExecutionError {
BatchGetQueryExecutionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for BatchGetQueryExecutionError {
fn from(err: CredentialsError) -> BatchGetQueryExecutionError {
BatchGetQueryExecutionError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchGetQueryExecutionError {
fn from(err: HttpDispatchError) -> BatchGetQueryExecutionError {
BatchGetQueryExecutionError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchGetQueryExecutionError {
fn from(err: io::Error) -> BatchGetQueryExecutionError {
BatchGetQueryExecutionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for BatchGetQueryExecutionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchGetQueryExecutionError {
fn description(&self) -> &str {
match *self {
BatchGetQueryExecutionError::InternalServer(ref cause) => cause,
BatchGetQueryExecutionError::InvalidRequest(ref cause) => cause,
BatchGetQueryExecutionError::Validation(ref cause) => cause,
BatchGetQueryExecutionError::Credentials(ref err) => err.description(),
BatchGetQueryExecutionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchGetQueryExecutionError::ParseError(ref cause) => cause,
BatchGetQueryExecutionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateNamedQueryError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateNamedQueryError {
pub fn from_response(res: BufferedHttpResponse) -> CreateNamedQueryError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return CreateNamedQueryError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return CreateNamedQueryError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return CreateNamedQueryError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateNamedQueryError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateNamedQueryError {
fn from(err: serde_json::error::Error) -> CreateNamedQueryError {
CreateNamedQueryError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateNamedQueryError {
fn from(err: CredentialsError) -> CreateNamedQueryError {
CreateNamedQueryError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateNamedQueryError {
fn from(err: HttpDispatchError) -> CreateNamedQueryError {
CreateNamedQueryError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateNamedQueryError {
fn from(err: io::Error) -> CreateNamedQueryError {
CreateNamedQueryError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateNamedQueryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateNamedQueryError {
fn description(&self) -> &str {
match *self {
CreateNamedQueryError::InternalServer(ref cause) => cause,
CreateNamedQueryError::InvalidRequest(ref cause) => cause,
CreateNamedQueryError::Validation(ref cause) => cause,
CreateNamedQueryError::Credentials(ref err) => err.description(),
CreateNamedQueryError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateNamedQueryError::ParseError(ref cause) => cause,
CreateNamedQueryError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateWorkGroupError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateWorkGroupError {
pub fn from_response(res: BufferedHttpResponse) -> CreateWorkGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return CreateWorkGroupError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return CreateWorkGroupError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return CreateWorkGroupError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateWorkGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateWorkGroupError {
fn from(err: serde_json::error::Error) -> CreateWorkGroupError {
CreateWorkGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateWorkGroupError {
fn from(err: CredentialsError) -> CreateWorkGroupError {
CreateWorkGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateWorkGroupError {
fn from(err: HttpDispatchError) -> CreateWorkGroupError {
CreateWorkGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateWorkGroupError {
fn from(err: io::Error) -> CreateWorkGroupError {
CreateWorkGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateWorkGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateWorkGroupError {
fn description(&self) -> &str {
match *self {
CreateWorkGroupError::InternalServer(ref cause) => cause,
CreateWorkGroupError::InvalidRequest(ref cause) => cause,
CreateWorkGroupError::Validation(ref cause) => cause,
CreateWorkGroupError::Credentials(ref err) => err.description(),
CreateWorkGroupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateWorkGroupError::ParseError(ref cause) => cause,
CreateWorkGroupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteNamedQueryError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteNamedQueryError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteNamedQueryError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return DeleteNamedQueryError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return DeleteNamedQueryError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return DeleteNamedQueryError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteNamedQueryError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteNamedQueryError {
fn from(err: serde_json::error::Error) -> DeleteNamedQueryError {
DeleteNamedQueryError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteNamedQueryError {
fn from(err: CredentialsError) -> DeleteNamedQueryError {
DeleteNamedQueryError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteNamedQueryError {
fn from(err: HttpDispatchError) -> DeleteNamedQueryError {
DeleteNamedQueryError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteNamedQueryError {
fn from(err: io::Error) -> DeleteNamedQueryError {
DeleteNamedQueryError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteNamedQueryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteNamedQueryError {
fn description(&self) -> &str {
match *self {
DeleteNamedQueryError::InternalServer(ref cause) => cause,
DeleteNamedQueryError::InvalidRequest(ref cause) => cause,
DeleteNamedQueryError::Validation(ref cause) => cause,
DeleteNamedQueryError::Credentials(ref err) => err.description(),
DeleteNamedQueryError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteNamedQueryError::ParseError(ref cause) => cause,
DeleteNamedQueryError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteWorkGroupError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteWorkGroupError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteWorkGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return DeleteWorkGroupError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return DeleteWorkGroupError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return DeleteWorkGroupError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteWorkGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteWorkGroupError {
fn from(err: serde_json::error::Error) -> DeleteWorkGroupError {
DeleteWorkGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteWorkGroupError {
fn from(err: CredentialsError) -> DeleteWorkGroupError {
DeleteWorkGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteWorkGroupError {
fn from(err: HttpDispatchError) -> DeleteWorkGroupError {
DeleteWorkGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteWorkGroupError {
fn from(err: io::Error) -> DeleteWorkGroupError {
DeleteWorkGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteWorkGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteWorkGroupError {
fn description(&self) -> &str {
match *self {
DeleteWorkGroupError::InternalServer(ref cause) => cause,
DeleteWorkGroupError::InvalidRequest(ref cause) => cause,
DeleteWorkGroupError::Validation(ref cause) => cause,
DeleteWorkGroupError::Credentials(ref err) => err.description(),
DeleteWorkGroupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteWorkGroupError::ParseError(ref cause) => cause,
DeleteWorkGroupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetNamedQueryError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetNamedQueryError {
pub fn from_response(res: BufferedHttpResponse) -> GetNamedQueryError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return GetNamedQueryError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return GetNamedQueryError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return GetNamedQueryError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetNamedQueryError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetNamedQueryError {
fn from(err: serde_json::error::Error) -> GetNamedQueryError {
GetNamedQueryError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetNamedQueryError {
fn from(err: CredentialsError) -> GetNamedQueryError {
GetNamedQueryError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetNamedQueryError {
fn from(err: HttpDispatchError) -> GetNamedQueryError {
GetNamedQueryError::HttpDispatch(err)
}
}
impl From<io::Error> for GetNamedQueryError {
fn from(err: io::Error) -> GetNamedQueryError {
GetNamedQueryError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetNamedQueryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetNamedQueryError {
fn description(&self) -> &str {
match *self {
GetNamedQueryError::InternalServer(ref cause) => cause,
GetNamedQueryError::InvalidRequest(ref cause) => cause,
GetNamedQueryError::Validation(ref cause) => cause,
GetNamedQueryError::Credentials(ref err) => err.description(),
GetNamedQueryError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetNamedQueryError::ParseError(ref cause) => cause,
GetNamedQueryError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetQueryExecutionError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetQueryExecutionError {
pub fn from_response(res: BufferedHttpResponse) -> GetQueryExecutionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return GetQueryExecutionError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return GetQueryExecutionError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return GetQueryExecutionError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetQueryExecutionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetQueryExecutionError {
fn from(err: serde_json::error::Error) -> GetQueryExecutionError {
GetQueryExecutionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetQueryExecutionError {
fn from(err: CredentialsError) -> GetQueryExecutionError {
GetQueryExecutionError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetQueryExecutionError {
fn from(err: HttpDispatchError) -> GetQueryExecutionError {
GetQueryExecutionError::HttpDispatch(err)
}
}
impl From<io::Error> for GetQueryExecutionError {
fn from(err: io::Error) -> GetQueryExecutionError {
GetQueryExecutionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetQueryExecutionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetQueryExecutionError {
fn description(&self) -> &str {
match *self {
GetQueryExecutionError::InternalServer(ref cause) => cause,
GetQueryExecutionError::InvalidRequest(ref cause) => cause,
GetQueryExecutionError::Validation(ref cause) => cause,
GetQueryExecutionError::Credentials(ref err) => err.description(),
GetQueryExecutionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetQueryExecutionError::ParseError(ref cause) => cause,
GetQueryExecutionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetQueryResultsError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetQueryResultsError {
pub fn from_response(res: BufferedHttpResponse) -> GetQueryResultsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return GetQueryResultsError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return GetQueryResultsError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return GetQueryResultsError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetQueryResultsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetQueryResultsError {
fn from(err: serde_json::error::Error) -> GetQueryResultsError {
GetQueryResultsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetQueryResultsError {
fn from(err: CredentialsError) -> GetQueryResultsError {
GetQueryResultsError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetQueryResultsError {
fn from(err: HttpDispatchError) -> GetQueryResultsError {
GetQueryResultsError::HttpDispatch(err)
}
}
impl From<io::Error> for GetQueryResultsError {
fn from(err: io::Error) -> GetQueryResultsError {
GetQueryResultsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetQueryResultsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetQueryResultsError {
fn description(&self) -> &str {
match *self {
GetQueryResultsError::InternalServer(ref cause) => cause,
GetQueryResultsError::InvalidRequest(ref cause) => cause,
GetQueryResultsError::Validation(ref cause) => cause,
GetQueryResultsError::Credentials(ref err) => err.description(),
GetQueryResultsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetQueryResultsError::ParseError(ref cause) => cause,
GetQueryResultsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetWorkGroupError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetWorkGroupError {
pub fn from_response(res: BufferedHttpResponse) -> GetWorkGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return GetWorkGroupError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return GetWorkGroupError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return GetWorkGroupError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetWorkGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetWorkGroupError {
fn from(err: serde_json::error::Error) -> GetWorkGroupError {
GetWorkGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetWorkGroupError {
fn from(err: CredentialsError) -> GetWorkGroupError {
GetWorkGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetWorkGroupError {
fn from(err: HttpDispatchError) -> GetWorkGroupError {
GetWorkGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for GetWorkGroupError {
fn from(err: io::Error) -> GetWorkGroupError {
GetWorkGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetWorkGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetWorkGroupError {
fn description(&self) -> &str {
match *self {
GetWorkGroupError::InternalServer(ref cause) => cause,
GetWorkGroupError::InvalidRequest(ref cause) => cause,
GetWorkGroupError::Validation(ref cause) => cause,
GetWorkGroupError::Credentials(ref err) => err.description(),
GetWorkGroupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetWorkGroupError::ParseError(ref cause) => cause,
GetWorkGroupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListNamedQueriesError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListNamedQueriesError {
pub fn from_response(res: BufferedHttpResponse) -> ListNamedQueriesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return ListNamedQueriesError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return ListNamedQueriesError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return ListNamedQueriesError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListNamedQueriesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListNamedQueriesError {
fn from(err: serde_json::error::Error) -> ListNamedQueriesError {
ListNamedQueriesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListNamedQueriesError {
fn from(err: CredentialsError) -> ListNamedQueriesError {
ListNamedQueriesError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListNamedQueriesError {
fn from(err: HttpDispatchError) -> ListNamedQueriesError {
ListNamedQueriesError::HttpDispatch(err)
}
}
impl From<io::Error> for ListNamedQueriesError {
fn from(err: io::Error) -> ListNamedQueriesError {
ListNamedQueriesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListNamedQueriesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListNamedQueriesError {
fn description(&self) -> &str {
match *self {
ListNamedQueriesError::InternalServer(ref cause) => cause,
ListNamedQueriesError::InvalidRequest(ref cause) => cause,
ListNamedQueriesError::Validation(ref cause) => cause,
ListNamedQueriesError::Credentials(ref err) => err.description(),
ListNamedQueriesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListNamedQueriesError::ParseError(ref cause) => cause,
ListNamedQueriesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListQueryExecutionsError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListQueryExecutionsError {
pub fn from_response(res: BufferedHttpResponse) -> ListQueryExecutionsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return ListQueryExecutionsError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return ListQueryExecutionsError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return ListQueryExecutionsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListQueryExecutionsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListQueryExecutionsError {
fn from(err: serde_json::error::Error) -> ListQueryExecutionsError {
ListQueryExecutionsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListQueryExecutionsError {
fn from(err: CredentialsError) -> ListQueryExecutionsError {
ListQueryExecutionsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListQueryExecutionsError {
fn from(err: HttpDispatchError) -> ListQueryExecutionsError {
ListQueryExecutionsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListQueryExecutionsError {
fn from(err: io::Error) -> ListQueryExecutionsError {
ListQueryExecutionsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListQueryExecutionsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListQueryExecutionsError {
fn description(&self) -> &str {
match *self {
ListQueryExecutionsError::InternalServer(ref cause) => cause,
ListQueryExecutionsError::InvalidRequest(ref cause) => cause,
ListQueryExecutionsError::Validation(ref cause) => cause,
ListQueryExecutionsError::Credentials(ref err) => err.description(),
ListQueryExecutionsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListQueryExecutionsError::ParseError(ref cause) => cause,
ListQueryExecutionsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListWorkGroupsError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListWorkGroupsError {
pub fn from_response(res: BufferedHttpResponse) -> ListWorkGroupsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return ListWorkGroupsError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return ListWorkGroupsError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return ListWorkGroupsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListWorkGroupsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListWorkGroupsError {
fn from(err: serde_json::error::Error) -> ListWorkGroupsError {
ListWorkGroupsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListWorkGroupsError {
fn from(err: CredentialsError) -> ListWorkGroupsError {
ListWorkGroupsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListWorkGroupsError {
fn from(err: HttpDispatchError) -> ListWorkGroupsError {
ListWorkGroupsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListWorkGroupsError {
fn from(err: io::Error) -> ListWorkGroupsError {
ListWorkGroupsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListWorkGroupsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListWorkGroupsError {
fn description(&self) -> &str {
match *self {
ListWorkGroupsError::InternalServer(ref cause) => cause,
ListWorkGroupsError::InvalidRequest(ref cause) => cause,
ListWorkGroupsError::Validation(ref cause) => cause,
ListWorkGroupsError::Credentials(ref err) => err.description(),
ListWorkGroupsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListWorkGroupsError::ParseError(ref cause) => cause,
ListWorkGroupsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartQueryExecutionError {
InternalServer(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StartQueryExecutionError {
pub fn from_response(res: BufferedHttpResponse) -> StartQueryExecutionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return StartQueryExecutionError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return StartQueryExecutionError::InvalidRequest(String::from(error_message));
}
"TooManyRequestsException" => {
return StartQueryExecutionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return StartQueryExecutionError::Validation(error_message.to_string());
}
_ => {}
}
}
return StartQueryExecutionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StartQueryExecutionError {
fn from(err: serde_json::error::Error) -> StartQueryExecutionError {
StartQueryExecutionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StartQueryExecutionError {
fn from(err: CredentialsError) -> StartQueryExecutionError {
StartQueryExecutionError::Credentials(err)
}
}
impl From<HttpDispatchError> for StartQueryExecutionError {
fn from(err: HttpDispatchError) -> StartQueryExecutionError {
StartQueryExecutionError::HttpDispatch(err)
}
}
impl From<io::Error> for StartQueryExecutionError {
fn from(err: io::Error) -> StartQueryExecutionError {
StartQueryExecutionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StartQueryExecutionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartQueryExecutionError {
fn description(&self) -> &str {
match *self {
StartQueryExecutionError::InternalServer(ref cause) => cause,
StartQueryExecutionError::InvalidRequest(ref cause) => cause,
StartQueryExecutionError::TooManyRequests(ref cause) => cause,
StartQueryExecutionError::Validation(ref cause) => cause,
StartQueryExecutionError::Credentials(ref err) => err.description(),
StartQueryExecutionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StartQueryExecutionError::ParseError(ref cause) => cause,
StartQueryExecutionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StopQueryExecutionError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StopQueryExecutionError {
pub fn from_response(res: BufferedHttpResponse) -> StopQueryExecutionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return StopQueryExecutionError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return StopQueryExecutionError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return StopQueryExecutionError::Validation(error_message.to_string());
}
_ => {}
}
}
return StopQueryExecutionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StopQueryExecutionError {
fn from(err: serde_json::error::Error) -> StopQueryExecutionError {
StopQueryExecutionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StopQueryExecutionError {
fn from(err: CredentialsError) -> StopQueryExecutionError {
StopQueryExecutionError::Credentials(err)
}
}
impl From<HttpDispatchError> for StopQueryExecutionError {
fn from(err: HttpDispatchError) -> StopQueryExecutionError {
StopQueryExecutionError::HttpDispatch(err)
}
}
impl From<io::Error> for StopQueryExecutionError {
fn from(err: io::Error) -> StopQueryExecutionError {
StopQueryExecutionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StopQueryExecutionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StopQueryExecutionError {
fn description(&self) -> &str {
match *self {
StopQueryExecutionError::InternalServer(ref cause) => cause,
StopQueryExecutionError::InvalidRequest(ref cause) => cause,
StopQueryExecutionError::Validation(ref cause) => cause,
StopQueryExecutionError::Credentials(ref err) => err.description(),
StopQueryExecutionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StopQueryExecutionError::ParseError(ref cause) => cause,
StopQueryExecutionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateWorkGroupError {
InternalServer(String),
InvalidRequest(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateWorkGroupError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateWorkGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerException" => {
return UpdateWorkGroupError::InternalServer(String::from(error_message));
}
"InvalidRequestException" => {
return UpdateWorkGroupError::InvalidRequest(String::from(error_message));
}
"ValidationException" => {
return UpdateWorkGroupError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateWorkGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateWorkGroupError {
fn from(err: serde_json::error::Error) -> UpdateWorkGroupError {
UpdateWorkGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateWorkGroupError {
fn from(err: CredentialsError) -> UpdateWorkGroupError {
UpdateWorkGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateWorkGroupError {
fn from(err: HttpDispatchError) -> UpdateWorkGroupError {
UpdateWorkGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateWorkGroupError {
fn from(err: io::Error) -> UpdateWorkGroupError {
UpdateWorkGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateWorkGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateWorkGroupError {
fn description(&self) -> &str {
match *self {
UpdateWorkGroupError::InternalServer(ref cause) => cause,
UpdateWorkGroupError::InvalidRequest(ref cause) => cause,
UpdateWorkGroupError::Validation(ref cause) => cause,
UpdateWorkGroupError::Credentials(ref err) => err.description(),
UpdateWorkGroupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
UpdateWorkGroupError::ParseError(ref cause) => cause,
UpdateWorkGroupError::Unknown(_) => "unknown error",
}
}
}
pub trait Athena {
fn batch_get_named_query(
&self,
input: BatchGetNamedQueryInput,
) -> RusotoFuture<BatchGetNamedQueryOutput, BatchGetNamedQueryError>;
fn batch_get_query_execution(
&self,
input: BatchGetQueryExecutionInput,
) -> RusotoFuture<BatchGetQueryExecutionOutput, BatchGetQueryExecutionError>;
fn create_named_query(
&self,
input: CreateNamedQueryInput,
) -> RusotoFuture<CreateNamedQueryOutput, CreateNamedQueryError>;
fn create_work_group(
&self,
input: CreateWorkGroupInput,
) -> RusotoFuture<CreateWorkGroupOutput, CreateWorkGroupError>;
fn delete_named_query(
&self,
input: DeleteNamedQueryInput,
) -> RusotoFuture<DeleteNamedQueryOutput, DeleteNamedQueryError>;
fn delete_work_group(
&self,
input: DeleteWorkGroupInput,
) -> RusotoFuture<DeleteWorkGroupOutput, DeleteWorkGroupError>;
fn get_named_query(
&self,
input: GetNamedQueryInput,
) -> RusotoFuture<GetNamedQueryOutput, GetNamedQueryError>;
fn get_query_execution(
&self,
input: GetQueryExecutionInput,
) -> RusotoFuture<GetQueryExecutionOutput, GetQueryExecutionError>;
fn get_query_results(
&self,
input: GetQueryResultsInput,
) -> RusotoFuture<GetQueryResultsOutput, GetQueryResultsError>;
fn get_work_group(
&self,
input: GetWorkGroupInput,
) -> RusotoFuture<GetWorkGroupOutput, GetWorkGroupError>;
fn list_named_queries(
&self,
input: ListNamedQueriesInput,
) -> RusotoFuture<ListNamedQueriesOutput, ListNamedQueriesError>;
fn list_query_executions(
&self,
input: ListQueryExecutionsInput,
) -> RusotoFuture<ListQueryExecutionsOutput, ListQueryExecutionsError>;
fn list_work_groups(
&self,
input: ListWorkGroupsInput,
) -> RusotoFuture<ListWorkGroupsOutput, ListWorkGroupsError>;
fn start_query_execution(
&self,
input: StartQueryExecutionInput,
) -> RusotoFuture<StartQueryExecutionOutput, StartQueryExecutionError>;
fn stop_query_execution(
&self,
input: StopQueryExecutionInput,
) -> RusotoFuture<StopQueryExecutionOutput, StopQueryExecutionError>;
fn update_work_group(
&self,
input: UpdateWorkGroupInput,
) -> RusotoFuture<UpdateWorkGroupOutput, UpdateWorkGroupError>;
}
#[derive(Clone)]
pub struct AthenaClient {
client: Client,
region: region::Region,
}
impl AthenaClient {
pub fn new(region: region::Region) -> AthenaClient {
AthenaClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> AthenaClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
AthenaClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl Athena for AthenaClient {
fn batch_get_named_query(
&self,
input: BatchGetNamedQueryInput,
) -> RusotoFuture<BatchGetNamedQueryOutput, BatchGetNamedQueryError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.BatchGetNamedQuery");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<BatchGetNamedQueryOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(BatchGetNamedQueryError::from_response(response))),
)
}
})
}
fn batch_get_query_execution(
&self,
input: BatchGetQueryExecutionInput,
) -> RusotoFuture<BatchGetQueryExecutionOutput, BatchGetQueryExecutionError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.BatchGetQueryExecution");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<BatchGetQueryExecutionOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(BatchGetQueryExecutionError::from_response(response))
}),
)
}
})
}
fn create_named_query(
&self,
input: CreateNamedQueryInput,
) -> RusotoFuture<CreateNamedQueryOutput, CreateNamedQueryError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.CreateNamedQuery");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<CreateNamedQueryOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateNamedQueryError::from_response(response))),
)
}
})
}
fn create_work_group(
&self,
input: CreateWorkGroupInput,
) -> RusotoFuture<CreateWorkGroupOutput, CreateWorkGroupError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.CreateWorkGroup");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<CreateWorkGroupOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateWorkGroupError::from_response(response))),
)
}
})
}
fn delete_named_query(
&self,
input: DeleteNamedQueryInput,
) -> RusotoFuture<DeleteNamedQueryOutput, DeleteNamedQueryError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.DeleteNamedQuery");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DeleteNamedQueryOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteNamedQueryError::from_response(response))),
)
}
})
}
fn delete_work_group(
&self,
input: DeleteWorkGroupInput,
) -> RusotoFuture<DeleteWorkGroupOutput, DeleteWorkGroupError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.DeleteWorkGroup");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DeleteWorkGroupOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteWorkGroupError::from_response(response))),
)
}
})
}
fn get_named_query(
&self,
input: GetNamedQueryInput,
) -> RusotoFuture<GetNamedQueryOutput, GetNamedQueryError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.GetNamedQuery");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetNamedQueryOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetNamedQueryError::from_response(response))),
)
}
})
}
fn get_query_execution(
&self,
input: GetQueryExecutionInput,
) -> RusotoFuture<GetQueryExecutionOutput, GetQueryExecutionError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.GetQueryExecution");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetQueryExecutionOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetQueryExecutionError::from_response(response))),
)
}
})
}
fn get_query_results(
&self,
input: GetQueryResultsInput,
) -> RusotoFuture<GetQueryResultsOutput, GetQueryResultsError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.GetQueryResults");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetQueryResultsOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetQueryResultsError::from_response(response))),
)
}
})
}
fn get_work_group(
&self,
input: GetWorkGroupInput,
) -> RusotoFuture<GetWorkGroupOutput, GetWorkGroupError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.GetWorkGroup");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetWorkGroupOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetWorkGroupError::from_response(response))),
)
}
})
}
fn list_named_queries(
&self,
input: ListNamedQueriesInput,
) -> RusotoFuture<ListNamedQueriesOutput, ListNamedQueriesError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.ListNamedQueries");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<ListNamedQueriesOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListNamedQueriesError::from_response(response))),
)
}
})
}
fn list_query_executions(
&self,
input: ListQueryExecutionsInput,
) -> RusotoFuture<ListQueryExecutionsOutput, ListQueryExecutionsError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.ListQueryExecutions");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<ListQueryExecutionsOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListQueryExecutionsError::from_response(response))
}),
)
}
})
}
fn list_work_groups(
&self,
input: ListWorkGroupsInput,
) -> RusotoFuture<ListWorkGroupsOutput, ListWorkGroupsError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.ListWorkGroups");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<ListWorkGroupsOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListWorkGroupsError::from_response(response))),
)
}
})
}
fn start_query_execution(
&self,
input: StartQueryExecutionInput,
) -> RusotoFuture<StartQueryExecutionOutput, StartQueryExecutionError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.StartQueryExecution");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<StartQueryExecutionOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(StartQueryExecutionError::from_response(response))
}),
)
}
})
}
fn stop_query_execution(
&self,
input: StopQueryExecutionInput,
) -> RusotoFuture<StopQueryExecutionOutput, StopQueryExecutionError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.StopQueryExecution");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<StopQueryExecutionOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(StopQueryExecutionError::from_response(response))),
)
}
})
}
fn update_work_group(
&self,
input: UpdateWorkGroupInput,
) -> RusotoFuture<UpdateWorkGroupOutput, UpdateWorkGroupError> {
let mut request = SignedRequest::new("POST", "athena", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AmazonAthena.UpdateWorkGroup");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<UpdateWorkGroupOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateWorkGroupError::from_response(response))),
)
}
})
}
}
#[cfg(test)]
mod protocol_tests {}