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, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectDominantLanguageItemResult {
#[serde(rename = "Index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
#[serde(rename = "Languages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub languages: Option<Vec<DominantLanguage>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchDetectDominantLanguageRequest {
#[serde(rename = "TextList")]
pub text_list: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectDominantLanguageResponse {
#[serde(rename = "ErrorList")]
pub error_list: Vec<BatchItemError>,
#[serde(rename = "ResultList")]
pub result_list: Vec<BatchDetectDominantLanguageItemResult>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectEntitiesItemResult {
#[serde(rename = "Entities")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entities: Option<Vec<Entity>>,
#[serde(rename = "Index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchDetectEntitiesRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "TextList")]
pub text_list: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectEntitiesResponse {
#[serde(rename = "ErrorList")]
pub error_list: Vec<BatchItemError>,
#[serde(rename = "ResultList")]
pub result_list: Vec<BatchDetectEntitiesItemResult>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectKeyPhrasesItemResult {
#[serde(rename = "Index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
#[serde(rename = "KeyPhrases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_phrases: Option<Vec<KeyPhrase>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchDetectKeyPhrasesRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "TextList")]
pub text_list: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectKeyPhrasesResponse {
#[serde(rename = "ErrorList")]
pub error_list: Vec<BatchItemError>,
#[serde(rename = "ResultList")]
pub result_list: Vec<BatchDetectKeyPhrasesItemResult>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectSentimentItemResult {
#[serde(rename = "Index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
#[serde(rename = "Sentiment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sentiment: Option<String>,
#[serde(rename = "SentimentScore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sentiment_score: Option<SentimentScore>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchDetectSentimentRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "TextList")]
pub text_list: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectSentimentResponse {
#[serde(rename = "ErrorList")]
pub error_list: Vec<BatchItemError>,
#[serde(rename = "ResultList")]
pub result_list: Vec<BatchDetectSentimentItemResult>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectSyntaxItemResult {
#[serde(rename = "Index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
#[serde(rename = "SyntaxTokens")]
#[serde(skip_serializing_if = "Option::is_none")]
pub syntax_tokens: Option<Vec<SyntaxToken>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchDetectSyntaxRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "TextList")]
pub text_list: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchDetectSyntaxResponse {
#[serde(rename = "ErrorList")]
pub error_list: Vec<BatchItemError>,
#[serde(rename = "ResultList")]
pub result_list: Vec<BatchDetectSyntaxItemResult>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchItemError {
#[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 = "Index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeDominantLanguageDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeDominantLanguageDetectionJobResponse {
#[serde(rename = "DominantLanguageDetectionJobProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dominant_language_detection_job_properties: Option<DominantLanguageDetectionJobProperties>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeEntitiesDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeEntitiesDetectionJobResponse {
#[serde(rename = "EntitiesDetectionJobProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entities_detection_job_properties: Option<EntitiesDetectionJobProperties>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeKeyPhrasesDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeKeyPhrasesDetectionJobResponse {
#[serde(rename = "KeyPhrasesDetectionJobProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_phrases_detection_job_properties: Option<KeyPhrasesDetectionJobProperties>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeSentimentDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeSentimentDetectionJobResponse {
#[serde(rename = "SentimentDetectionJobProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sentiment_detection_job_properties: Option<SentimentDetectionJobProperties>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeTopicsDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeTopicsDetectionJobResponse {
#[serde(rename = "TopicsDetectionJobProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub topics_detection_job_properties: Option<TopicsDetectionJobProperties>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DetectDominantLanguageRequest {
#[serde(rename = "Text")]
pub text: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DetectDominantLanguageResponse {
#[serde(rename = "Languages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub languages: Option<Vec<DominantLanguage>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DetectEntitiesRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "Text")]
pub text: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DetectEntitiesResponse {
#[serde(rename = "Entities")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entities: Option<Vec<Entity>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DetectKeyPhrasesRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "Text")]
pub text: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DetectKeyPhrasesResponse {
#[serde(rename = "KeyPhrases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_phrases: Option<Vec<KeyPhrase>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DetectSentimentRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "Text")]
pub text: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DetectSentimentResponse {
#[serde(rename = "Sentiment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sentiment: Option<String>,
#[serde(rename = "SentimentScore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sentiment_score: Option<SentimentScore>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DetectSyntaxRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "Text")]
pub text: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DetectSyntaxResponse {
#[serde(rename = "SyntaxTokens")]
#[serde(skip_serializing_if = "Option::is_none")]
pub syntax_tokens: Option<Vec<SyntaxToken>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DominantLanguage {
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "Score")]
#[serde(skip_serializing_if = "Option::is_none")]
pub score: Option<f32>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DominantLanguageDetectionJobFilter {
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "SubmitTimeAfter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_after: Option<f64>,
#[serde(rename = "SubmitTimeBefore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_before: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DominantLanguageDetectionJobProperties {
#[serde(rename = "DataAccessRoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data_access_role_arn: Option<String>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "InputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub input_data_config: Option<InputDataConfig>,
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "OutputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_data_config: Option<OutputDataConfig>,
#[serde(rename = "SubmitTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct EntitiesDetectionJobFilter {
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "SubmitTimeAfter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_after: Option<f64>,
#[serde(rename = "SubmitTimeBefore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_before: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EntitiesDetectionJobProperties {
#[serde(rename = "DataAccessRoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data_access_role_arn: Option<String>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "InputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub input_data_config: Option<InputDataConfig>,
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "OutputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_data_config: Option<OutputDataConfig>,
#[serde(rename = "SubmitTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Entity {
#[serde(rename = "BeginOffset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub begin_offset: Option<i64>,
#[serde(rename = "EndOffset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_offset: Option<i64>,
#[serde(rename = "Score")]
#[serde(skip_serializing_if = "Option::is_none")]
pub score: Option<f32>,
#[serde(rename = "Text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InputDataConfig {
#[serde(rename = "InputFormat")]
#[serde(skip_serializing_if = "Option::is_none")]
pub input_format: Option<String>,
#[serde(rename = "S3Uri")]
pub s3_uri: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct KeyPhrase {
#[serde(rename = "BeginOffset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub begin_offset: Option<i64>,
#[serde(rename = "EndOffset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_offset: Option<i64>,
#[serde(rename = "Score")]
#[serde(skip_serializing_if = "Option::is_none")]
pub score: Option<f32>,
#[serde(rename = "Text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct KeyPhrasesDetectionJobFilter {
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "SubmitTimeAfter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_after: Option<f64>,
#[serde(rename = "SubmitTimeBefore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_before: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct KeyPhrasesDetectionJobProperties {
#[serde(rename = "DataAccessRoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data_access_role_arn: Option<String>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "InputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub input_data_config: Option<InputDataConfig>,
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "OutputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_data_config: Option<OutputDataConfig>,
#[serde(rename = "SubmitTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListDominantLanguageDetectionJobsRequest {
#[serde(rename = "Filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<DominantLanguageDetectionJobFilter>,
#[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 ListDominantLanguageDetectionJobsResponse {
#[serde(rename = "DominantLanguageDetectionJobPropertiesList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dominant_language_detection_job_properties_list:
Option<Vec<DominantLanguageDetectionJobProperties>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListEntitiesDetectionJobsRequest {
#[serde(rename = "Filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<EntitiesDetectionJobFilter>,
#[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 ListEntitiesDetectionJobsResponse {
#[serde(rename = "EntitiesDetectionJobPropertiesList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entities_detection_job_properties_list: Option<Vec<EntitiesDetectionJobProperties>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListKeyPhrasesDetectionJobsRequest {
#[serde(rename = "Filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<KeyPhrasesDetectionJobFilter>,
#[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 ListKeyPhrasesDetectionJobsResponse {
#[serde(rename = "KeyPhrasesDetectionJobPropertiesList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_phrases_detection_job_properties_list: Option<Vec<KeyPhrasesDetectionJobProperties>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListSentimentDetectionJobsRequest {
#[serde(rename = "Filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<SentimentDetectionJobFilter>,
#[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 ListSentimentDetectionJobsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "SentimentDetectionJobPropertiesList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sentiment_detection_job_properties_list: Option<Vec<SentimentDetectionJobProperties>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListTopicsDetectionJobsRequest {
#[serde(rename = "Filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<TopicsDetectionJobFilter>,
#[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 ListTopicsDetectionJobsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "TopicsDetectionJobPropertiesList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub topics_detection_job_properties_list: Option<Vec<TopicsDetectionJobProperties>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct OutputDataConfig {
#[serde(rename = "S3Uri")]
pub s3_uri: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PartOfSpeechTag {
#[serde(rename = "Score")]
#[serde(skip_serializing_if = "Option::is_none")]
pub score: Option<f32>,
#[serde(rename = "Tag")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tag: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct SentimentDetectionJobFilter {
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "SubmitTimeAfter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_after: Option<f64>,
#[serde(rename = "SubmitTimeBefore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_before: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SentimentDetectionJobProperties {
#[serde(rename = "DataAccessRoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data_access_role_arn: Option<String>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "InputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub input_data_config: Option<InputDataConfig>,
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "OutputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_data_config: Option<OutputDataConfig>,
#[serde(rename = "SubmitTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SentimentScore {
#[serde(rename = "Mixed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mixed: Option<f32>,
#[serde(rename = "Negative")]
#[serde(skip_serializing_if = "Option::is_none")]
pub negative: Option<f32>,
#[serde(rename = "Neutral")]
#[serde(skip_serializing_if = "Option::is_none")]
pub neutral: Option<f32>,
#[serde(rename = "Positive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub positive: Option<f32>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartDominantLanguageDetectionJobRequest {
#[serde(rename = "ClientRequestToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_request_token: Option<String>,
#[serde(rename = "DataAccessRoleArn")]
pub data_access_role_arn: String,
#[serde(rename = "InputDataConfig")]
pub input_data_config: InputDataConfig,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "OutputDataConfig")]
pub output_data_config: OutputDataConfig,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartDominantLanguageDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartEntitiesDetectionJobRequest {
#[serde(rename = "ClientRequestToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_request_token: Option<String>,
#[serde(rename = "DataAccessRoleArn")]
pub data_access_role_arn: String,
#[serde(rename = "InputDataConfig")]
pub input_data_config: InputDataConfig,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "OutputDataConfig")]
pub output_data_config: OutputDataConfig,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartEntitiesDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartKeyPhrasesDetectionJobRequest {
#[serde(rename = "ClientRequestToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_request_token: Option<String>,
#[serde(rename = "DataAccessRoleArn")]
pub data_access_role_arn: String,
#[serde(rename = "InputDataConfig")]
pub input_data_config: InputDataConfig,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "OutputDataConfig")]
pub output_data_config: OutputDataConfig,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartKeyPhrasesDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartSentimentDetectionJobRequest {
#[serde(rename = "ClientRequestToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_request_token: Option<String>,
#[serde(rename = "DataAccessRoleArn")]
pub data_access_role_arn: String,
#[serde(rename = "InputDataConfig")]
pub input_data_config: InputDataConfig,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "OutputDataConfig")]
pub output_data_config: OutputDataConfig,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartSentimentDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartTopicsDetectionJobRequest {
#[serde(rename = "ClientRequestToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_request_token: Option<String>,
#[serde(rename = "DataAccessRoleArn")]
pub data_access_role_arn: String,
#[serde(rename = "InputDataConfig")]
pub input_data_config: InputDataConfig,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "NumberOfTopics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number_of_topics: Option<i64>,
#[serde(rename = "OutputDataConfig")]
pub output_data_config: OutputDataConfig,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartTopicsDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StopDominantLanguageDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StopDominantLanguageDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StopEntitiesDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StopEntitiesDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StopKeyPhrasesDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StopKeyPhrasesDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StopSentimentDetectionJobRequest {
#[serde(rename = "JobId")]
pub job_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StopSentimentDetectionJobResponse {
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SyntaxToken {
#[serde(rename = "BeginOffset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub begin_offset: Option<i64>,
#[serde(rename = "EndOffset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_offset: Option<i64>,
#[serde(rename = "PartOfSpeech")]
#[serde(skip_serializing_if = "Option::is_none")]
pub part_of_speech: Option<PartOfSpeechTag>,
#[serde(rename = "Text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(rename = "TokenId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub token_id: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TopicsDetectionJobFilter {
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "SubmitTimeAfter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_after: Option<f64>,
#[serde(rename = "SubmitTimeBefore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time_before: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TopicsDetectionJobProperties {
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "InputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub input_data_config: Option<InputDataConfig>,
#[serde(rename = "JobId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_id: Option<String>,
#[serde(rename = "JobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name: Option<String>,
#[serde(rename = "JobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_status: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "NumberOfTopics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number_of_topics: Option<i64>,
#[serde(rename = "OutputDataConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_data_config: Option<OutputDataConfig>,
#[serde(rename = "SubmitTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submit_time: Option<f64>,
}
#[derive(Debug, PartialEq)]
pub enum BatchDetectDominantLanguageError {
BatchSizeLimitExceeded(String),
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchDetectDominantLanguageError {
pub fn from_response(res: BufferedHttpResponse) -> BatchDetectDominantLanguageError {
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 {
"BatchSizeLimitExceededException" => {
return BatchDetectDominantLanguageError::BatchSizeLimitExceeded(String::from(
error_message,
))
}
"InternalServerException" => {
return BatchDetectDominantLanguageError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return BatchDetectDominantLanguageError::InvalidRequest(String::from(
error_message,
))
}
"TextSizeLimitExceededException" => {
return BatchDetectDominantLanguageError::TextSizeLimitExceeded(String::from(
error_message,
))
}
"ValidationException" => {
return BatchDetectDominantLanguageError::Validation(error_message.to_string())
}
_ => {}
}
}
return BatchDetectDominantLanguageError::Unknown(res);
}
}
impl From<serde_json::error::Error> for BatchDetectDominantLanguageError {
fn from(err: serde_json::error::Error) -> BatchDetectDominantLanguageError {
BatchDetectDominantLanguageError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for BatchDetectDominantLanguageError {
fn from(err: CredentialsError) -> BatchDetectDominantLanguageError {
BatchDetectDominantLanguageError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchDetectDominantLanguageError {
fn from(err: HttpDispatchError) -> BatchDetectDominantLanguageError {
BatchDetectDominantLanguageError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchDetectDominantLanguageError {
fn from(err: io::Error) -> BatchDetectDominantLanguageError {
BatchDetectDominantLanguageError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for BatchDetectDominantLanguageError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchDetectDominantLanguageError {
fn description(&self) -> &str {
match *self {
BatchDetectDominantLanguageError::BatchSizeLimitExceeded(ref cause) => cause,
BatchDetectDominantLanguageError::InternalServer(ref cause) => cause,
BatchDetectDominantLanguageError::InvalidRequest(ref cause) => cause,
BatchDetectDominantLanguageError::TextSizeLimitExceeded(ref cause) => cause,
BatchDetectDominantLanguageError::Validation(ref cause) => cause,
BatchDetectDominantLanguageError::Credentials(ref err) => err.description(),
BatchDetectDominantLanguageError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchDetectDominantLanguageError::ParseError(ref cause) => cause,
BatchDetectDominantLanguageError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum BatchDetectEntitiesError {
BatchSizeLimitExceeded(String),
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
UnsupportedLanguage(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchDetectEntitiesError {
pub fn from_response(res: BufferedHttpResponse) -> BatchDetectEntitiesError {
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 {
"BatchSizeLimitExceededException" => {
return BatchDetectEntitiesError::BatchSizeLimitExceeded(String::from(
error_message,
))
}
"InternalServerException" => {
return BatchDetectEntitiesError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return BatchDetectEntitiesError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return BatchDetectEntitiesError::TextSizeLimitExceeded(String::from(
error_message,
))
}
"UnsupportedLanguageException" => {
return BatchDetectEntitiesError::UnsupportedLanguage(String::from(
error_message,
))
}
"ValidationException" => {
return BatchDetectEntitiesError::Validation(error_message.to_string())
}
_ => {}
}
}
return BatchDetectEntitiesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for BatchDetectEntitiesError {
fn from(err: serde_json::error::Error) -> BatchDetectEntitiesError {
BatchDetectEntitiesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for BatchDetectEntitiesError {
fn from(err: CredentialsError) -> BatchDetectEntitiesError {
BatchDetectEntitiesError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchDetectEntitiesError {
fn from(err: HttpDispatchError) -> BatchDetectEntitiesError {
BatchDetectEntitiesError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchDetectEntitiesError {
fn from(err: io::Error) -> BatchDetectEntitiesError {
BatchDetectEntitiesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for BatchDetectEntitiesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchDetectEntitiesError {
fn description(&self) -> &str {
match *self {
BatchDetectEntitiesError::BatchSizeLimitExceeded(ref cause) => cause,
BatchDetectEntitiesError::InternalServer(ref cause) => cause,
BatchDetectEntitiesError::InvalidRequest(ref cause) => cause,
BatchDetectEntitiesError::TextSizeLimitExceeded(ref cause) => cause,
BatchDetectEntitiesError::UnsupportedLanguage(ref cause) => cause,
BatchDetectEntitiesError::Validation(ref cause) => cause,
BatchDetectEntitiesError::Credentials(ref err) => err.description(),
BatchDetectEntitiesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchDetectEntitiesError::ParseError(ref cause) => cause,
BatchDetectEntitiesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum BatchDetectKeyPhrasesError {
BatchSizeLimitExceeded(String),
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
UnsupportedLanguage(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchDetectKeyPhrasesError {
pub fn from_response(res: BufferedHttpResponse) -> BatchDetectKeyPhrasesError {
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 {
"BatchSizeLimitExceededException" => {
return BatchDetectKeyPhrasesError::BatchSizeLimitExceeded(String::from(
error_message,
))
}
"InternalServerException" => {
return BatchDetectKeyPhrasesError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return BatchDetectKeyPhrasesError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return BatchDetectKeyPhrasesError::TextSizeLimitExceeded(String::from(
error_message,
))
}
"UnsupportedLanguageException" => {
return BatchDetectKeyPhrasesError::UnsupportedLanguage(String::from(
error_message,
))
}
"ValidationException" => {
return BatchDetectKeyPhrasesError::Validation(error_message.to_string())
}
_ => {}
}
}
return BatchDetectKeyPhrasesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for BatchDetectKeyPhrasesError {
fn from(err: serde_json::error::Error) -> BatchDetectKeyPhrasesError {
BatchDetectKeyPhrasesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for BatchDetectKeyPhrasesError {
fn from(err: CredentialsError) -> BatchDetectKeyPhrasesError {
BatchDetectKeyPhrasesError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchDetectKeyPhrasesError {
fn from(err: HttpDispatchError) -> BatchDetectKeyPhrasesError {
BatchDetectKeyPhrasesError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchDetectKeyPhrasesError {
fn from(err: io::Error) -> BatchDetectKeyPhrasesError {
BatchDetectKeyPhrasesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for BatchDetectKeyPhrasesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchDetectKeyPhrasesError {
fn description(&self) -> &str {
match *self {
BatchDetectKeyPhrasesError::BatchSizeLimitExceeded(ref cause) => cause,
BatchDetectKeyPhrasesError::InternalServer(ref cause) => cause,
BatchDetectKeyPhrasesError::InvalidRequest(ref cause) => cause,
BatchDetectKeyPhrasesError::TextSizeLimitExceeded(ref cause) => cause,
BatchDetectKeyPhrasesError::UnsupportedLanguage(ref cause) => cause,
BatchDetectKeyPhrasesError::Validation(ref cause) => cause,
BatchDetectKeyPhrasesError::Credentials(ref err) => err.description(),
BatchDetectKeyPhrasesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchDetectKeyPhrasesError::ParseError(ref cause) => cause,
BatchDetectKeyPhrasesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum BatchDetectSentimentError {
BatchSizeLimitExceeded(String),
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
UnsupportedLanguage(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchDetectSentimentError {
pub fn from_response(res: BufferedHttpResponse) -> BatchDetectSentimentError {
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 {
"BatchSizeLimitExceededException" => {
return BatchDetectSentimentError::BatchSizeLimitExceeded(String::from(
error_message,
))
}
"InternalServerException" => {
return BatchDetectSentimentError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return BatchDetectSentimentError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return BatchDetectSentimentError::TextSizeLimitExceeded(String::from(
error_message,
))
}
"UnsupportedLanguageException" => {
return BatchDetectSentimentError::UnsupportedLanguage(String::from(
error_message,
))
}
"ValidationException" => {
return BatchDetectSentimentError::Validation(error_message.to_string())
}
_ => {}
}
}
return BatchDetectSentimentError::Unknown(res);
}
}
impl From<serde_json::error::Error> for BatchDetectSentimentError {
fn from(err: serde_json::error::Error) -> BatchDetectSentimentError {
BatchDetectSentimentError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for BatchDetectSentimentError {
fn from(err: CredentialsError) -> BatchDetectSentimentError {
BatchDetectSentimentError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchDetectSentimentError {
fn from(err: HttpDispatchError) -> BatchDetectSentimentError {
BatchDetectSentimentError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchDetectSentimentError {
fn from(err: io::Error) -> BatchDetectSentimentError {
BatchDetectSentimentError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for BatchDetectSentimentError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchDetectSentimentError {
fn description(&self) -> &str {
match *self {
BatchDetectSentimentError::BatchSizeLimitExceeded(ref cause) => cause,
BatchDetectSentimentError::InternalServer(ref cause) => cause,
BatchDetectSentimentError::InvalidRequest(ref cause) => cause,
BatchDetectSentimentError::TextSizeLimitExceeded(ref cause) => cause,
BatchDetectSentimentError::UnsupportedLanguage(ref cause) => cause,
BatchDetectSentimentError::Validation(ref cause) => cause,
BatchDetectSentimentError::Credentials(ref err) => err.description(),
BatchDetectSentimentError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchDetectSentimentError::ParseError(ref cause) => cause,
BatchDetectSentimentError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum BatchDetectSyntaxError {
BatchSizeLimitExceeded(String),
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
UnsupportedLanguage(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchDetectSyntaxError {
pub fn from_response(res: BufferedHttpResponse) -> BatchDetectSyntaxError {
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 {
"BatchSizeLimitExceededException" => {
return BatchDetectSyntaxError::BatchSizeLimitExceeded(String::from(
error_message,
))
}
"InternalServerException" => {
return BatchDetectSyntaxError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return BatchDetectSyntaxError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return BatchDetectSyntaxError::TextSizeLimitExceeded(String::from(
error_message,
))
}
"UnsupportedLanguageException" => {
return BatchDetectSyntaxError::UnsupportedLanguage(String::from(error_message))
}
"ValidationException" => {
return BatchDetectSyntaxError::Validation(error_message.to_string())
}
_ => {}
}
}
return BatchDetectSyntaxError::Unknown(res);
}
}
impl From<serde_json::error::Error> for BatchDetectSyntaxError {
fn from(err: serde_json::error::Error) -> BatchDetectSyntaxError {
BatchDetectSyntaxError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for BatchDetectSyntaxError {
fn from(err: CredentialsError) -> BatchDetectSyntaxError {
BatchDetectSyntaxError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchDetectSyntaxError {
fn from(err: HttpDispatchError) -> BatchDetectSyntaxError {
BatchDetectSyntaxError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchDetectSyntaxError {
fn from(err: io::Error) -> BatchDetectSyntaxError {
BatchDetectSyntaxError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for BatchDetectSyntaxError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchDetectSyntaxError {
fn description(&self) -> &str {
match *self {
BatchDetectSyntaxError::BatchSizeLimitExceeded(ref cause) => cause,
BatchDetectSyntaxError::InternalServer(ref cause) => cause,
BatchDetectSyntaxError::InvalidRequest(ref cause) => cause,
BatchDetectSyntaxError::TextSizeLimitExceeded(ref cause) => cause,
BatchDetectSyntaxError::UnsupportedLanguage(ref cause) => cause,
BatchDetectSyntaxError::Validation(ref cause) => cause,
BatchDetectSyntaxError::Credentials(ref err) => err.description(),
BatchDetectSyntaxError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchDetectSyntaxError::ParseError(ref cause) => cause,
BatchDetectSyntaxError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeDominantLanguageDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeDominantLanguageDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeDominantLanguageDetectionJobError {
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 DescribeDominantLanguageDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return DescribeDominantLanguageDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return DescribeDominantLanguageDetectionJobError::JobNotFound(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return DescribeDominantLanguageDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return DescribeDominantLanguageDetectionJobError::Validation(
error_message.to_string(),
)
}
_ => {}
}
}
return DescribeDominantLanguageDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeDominantLanguageDetectionJobError {
fn from(err: serde_json::error::Error) -> DescribeDominantLanguageDetectionJobError {
DescribeDominantLanguageDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeDominantLanguageDetectionJobError {
fn from(err: CredentialsError) -> DescribeDominantLanguageDetectionJobError {
DescribeDominantLanguageDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeDominantLanguageDetectionJobError {
fn from(err: HttpDispatchError) -> DescribeDominantLanguageDetectionJobError {
DescribeDominantLanguageDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeDominantLanguageDetectionJobError {
fn from(err: io::Error) -> DescribeDominantLanguageDetectionJobError {
DescribeDominantLanguageDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeDominantLanguageDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeDominantLanguageDetectionJobError {
fn description(&self) -> &str {
match *self {
DescribeDominantLanguageDetectionJobError::InternalServer(ref cause) => cause,
DescribeDominantLanguageDetectionJobError::InvalidRequest(ref cause) => cause,
DescribeDominantLanguageDetectionJobError::JobNotFound(ref cause) => cause,
DescribeDominantLanguageDetectionJobError::TooManyRequests(ref cause) => cause,
DescribeDominantLanguageDetectionJobError::Validation(ref cause) => cause,
DescribeDominantLanguageDetectionJobError::Credentials(ref err) => err.description(),
DescribeDominantLanguageDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeDominantLanguageDetectionJobError::ParseError(ref cause) => cause,
DescribeDominantLanguageDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeEntitiesDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeEntitiesDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeEntitiesDetectionJobError {
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 DescribeEntitiesDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return DescribeEntitiesDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return DescribeEntitiesDetectionJobError::JobNotFound(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return DescribeEntitiesDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return DescribeEntitiesDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return DescribeEntitiesDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeEntitiesDetectionJobError {
fn from(err: serde_json::error::Error) -> DescribeEntitiesDetectionJobError {
DescribeEntitiesDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeEntitiesDetectionJobError {
fn from(err: CredentialsError) -> DescribeEntitiesDetectionJobError {
DescribeEntitiesDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeEntitiesDetectionJobError {
fn from(err: HttpDispatchError) -> DescribeEntitiesDetectionJobError {
DescribeEntitiesDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeEntitiesDetectionJobError {
fn from(err: io::Error) -> DescribeEntitiesDetectionJobError {
DescribeEntitiesDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeEntitiesDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeEntitiesDetectionJobError {
fn description(&self) -> &str {
match *self {
DescribeEntitiesDetectionJobError::InternalServer(ref cause) => cause,
DescribeEntitiesDetectionJobError::InvalidRequest(ref cause) => cause,
DescribeEntitiesDetectionJobError::JobNotFound(ref cause) => cause,
DescribeEntitiesDetectionJobError::TooManyRequests(ref cause) => cause,
DescribeEntitiesDetectionJobError::Validation(ref cause) => cause,
DescribeEntitiesDetectionJobError::Credentials(ref err) => err.description(),
DescribeEntitiesDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeEntitiesDetectionJobError::ParseError(ref cause) => cause,
DescribeEntitiesDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeKeyPhrasesDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeKeyPhrasesDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeKeyPhrasesDetectionJobError {
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 DescribeKeyPhrasesDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return DescribeKeyPhrasesDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return DescribeKeyPhrasesDetectionJobError::JobNotFound(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return DescribeKeyPhrasesDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return DescribeKeyPhrasesDetectionJobError::Validation(
error_message.to_string(),
)
}
_ => {}
}
}
return DescribeKeyPhrasesDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeKeyPhrasesDetectionJobError {
fn from(err: serde_json::error::Error) -> DescribeKeyPhrasesDetectionJobError {
DescribeKeyPhrasesDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeKeyPhrasesDetectionJobError {
fn from(err: CredentialsError) -> DescribeKeyPhrasesDetectionJobError {
DescribeKeyPhrasesDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeKeyPhrasesDetectionJobError {
fn from(err: HttpDispatchError) -> DescribeKeyPhrasesDetectionJobError {
DescribeKeyPhrasesDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeKeyPhrasesDetectionJobError {
fn from(err: io::Error) -> DescribeKeyPhrasesDetectionJobError {
DescribeKeyPhrasesDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeKeyPhrasesDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeKeyPhrasesDetectionJobError {
fn description(&self) -> &str {
match *self {
DescribeKeyPhrasesDetectionJobError::InternalServer(ref cause) => cause,
DescribeKeyPhrasesDetectionJobError::InvalidRequest(ref cause) => cause,
DescribeKeyPhrasesDetectionJobError::JobNotFound(ref cause) => cause,
DescribeKeyPhrasesDetectionJobError::TooManyRequests(ref cause) => cause,
DescribeKeyPhrasesDetectionJobError::Validation(ref cause) => cause,
DescribeKeyPhrasesDetectionJobError::Credentials(ref err) => err.description(),
DescribeKeyPhrasesDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeKeyPhrasesDetectionJobError::ParseError(ref cause) => cause,
DescribeKeyPhrasesDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeSentimentDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeSentimentDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeSentimentDetectionJobError {
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 DescribeSentimentDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return DescribeSentimentDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return DescribeSentimentDetectionJobError::JobNotFound(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return DescribeSentimentDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return DescribeSentimentDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return DescribeSentimentDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeSentimentDetectionJobError {
fn from(err: serde_json::error::Error) -> DescribeSentimentDetectionJobError {
DescribeSentimentDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeSentimentDetectionJobError {
fn from(err: CredentialsError) -> DescribeSentimentDetectionJobError {
DescribeSentimentDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeSentimentDetectionJobError {
fn from(err: HttpDispatchError) -> DescribeSentimentDetectionJobError {
DescribeSentimentDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeSentimentDetectionJobError {
fn from(err: io::Error) -> DescribeSentimentDetectionJobError {
DescribeSentimentDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeSentimentDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeSentimentDetectionJobError {
fn description(&self) -> &str {
match *self {
DescribeSentimentDetectionJobError::InternalServer(ref cause) => cause,
DescribeSentimentDetectionJobError::InvalidRequest(ref cause) => cause,
DescribeSentimentDetectionJobError::JobNotFound(ref cause) => cause,
DescribeSentimentDetectionJobError::TooManyRequests(ref cause) => cause,
DescribeSentimentDetectionJobError::Validation(ref cause) => cause,
DescribeSentimentDetectionJobError::Credentials(ref err) => err.description(),
DescribeSentimentDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeSentimentDetectionJobError::ParseError(ref cause) => cause,
DescribeSentimentDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeTopicsDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeTopicsDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeTopicsDetectionJobError {
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 DescribeTopicsDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return DescribeTopicsDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return DescribeTopicsDetectionJobError::JobNotFound(String::from(error_message))
}
"TooManyRequestsException" => {
return DescribeTopicsDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return DescribeTopicsDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return DescribeTopicsDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeTopicsDetectionJobError {
fn from(err: serde_json::error::Error) -> DescribeTopicsDetectionJobError {
DescribeTopicsDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeTopicsDetectionJobError {
fn from(err: CredentialsError) -> DescribeTopicsDetectionJobError {
DescribeTopicsDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeTopicsDetectionJobError {
fn from(err: HttpDispatchError) -> DescribeTopicsDetectionJobError {
DescribeTopicsDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeTopicsDetectionJobError {
fn from(err: io::Error) -> DescribeTopicsDetectionJobError {
DescribeTopicsDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeTopicsDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeTopicsDetectionJobError {
fn description(&self) -> &str {
match *self {
DescribeTopicsDetectionJobError::InternalServer(ref cause) => cause,
DescribeTopicsDetectionJobError::InvalidRequest(ref cause) => cause,
DescribeTopicsDetectionJobError::JobNotFound(ref cause) => cause,
DescribeTopicsDetectionJobError::TooManyRequests(ref cause) => cause,
DescribeTopicsDetectionJobError::Validation(ref cause) => cause,
DescribeTopicsDetectionJobError::Credentials(ref err) => err.description(),
DescribeTopicsDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeTopicsDetectionJobError::ParseError(ref cause) => cause,
DescribeTopicsDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DetectDominantLanguageError {
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DetectDominantLanguageError {
pub fn from_response(res: BufferedHttpResponse) -> DetectDominantLanguageError {
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 DetectDominantLanguageError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return DetectDominantLanguageError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return DetectDominantLanguageError::TextSizeLimitExceeded(String::from(
error_message,
))
}
"ValidationException" => {
return DetectDominantLanguageError::Validation(error_message.to_string())
}
_ => {}
}
}
return DetectDominantLanguageError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DetectDominantLanguageError {
fn from(err: serde_json::error::Error) -> DetectDominantLanguageError {
DetectDominantLanguageError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DetectDominantLanguageError {
fn from(err: CredentialsError) -> DetectDominantLanguageError {
DetectDominantLanguageError::Credentials(err)
}
}
impl From<HttpDispatchError> for DetectDominantLanguageError {
fn from(err: HttpDispatchError) -> DetectDominantLanguageError {
DetectDominantLanguageError::HttpDispatch(err)
}
}
impl From<io::Error> for DetectDominantLanguageError {
fn from(err: io::Error) -> DetectDominantLanguageError {
DetectDominantLanguageError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DetectDominantLanguageError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DetectDominantLanguageError {
fn description(&self) -> &str {
match *self {
DetectDominantLanguageError::InternalServer(ref cause) => cause,
DetectDominantLanguageError::InvalidRequest(ref cause) => cause,
DetectDominantLanguageError::TextSizeLimitExceeded(ref cause) => cause,
DetectDominantLanguageError::Validation(ref cause) => cause,
DetectDominantLanguageError::Credentials(ref err) => err.description(),
DetectDominantLanguageError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DetectDominantLanguageError::ParseError(ref cause) => cause,
DetectDominantLanguageError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DetectEntitiesError {
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
UnsupportedLanguage(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DetectEntitiesError {
pub fn from_response(res: BufferedHttpResponse) -> DetectEntitiesError {
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 DetectEntitiesError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return DetectEntitiesError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return DetectEntitiesError::TextSizeLimitExceeded(String::from(error_message))
}
"UnsupportedLanguageException" => {
return DetectEntitiesError::UnsupportedLanguage(String::from(error_message))
}
"ValidationException" => {
return DetectEntitiesError::Validation(error_message.to_string())
}
_ => {}
}
}
return DetectEntitiesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DetectEntitiesError {
fn from(err: serde_json::error::Error) -> DetectEntitiesError {
DetectEntitiesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DetectEntitiesError {
fn from(err: CredentialsError) -> DetectEntitiesError {
DetectEntitiesError::Credentials(err)
}
}
impl From<HttpDispatchError> for DetectEntitiesError {
fn from(err: HttpDispatchError) -> DetectEntitiesError {
DetectEntitiesError::HttpDispatch(err)
}
}
impl From<io::Error> for DetectEntitiesError {
fn from(err: io::Error) -> DetectEntitiesError {
DetectEntitiesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DetectEntitiesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DetectEntitiesError {
fn description(&self) -> &str {
match *self {
DetectEntitiesError::InternalServer(ref cause) => cause,
DetectEntitiesError::InvalidRequest(ref cause) => cause,
DetectEntitiesError::TextSizeLimitExceeded(ref cause) => cause,
DetectEntitiesError::UnsupportedLanguage(ref cause) => cause,
DetectEntitiesError::Validation(ref cause) => cause,
DetectEntitiesError::Credentials(ref err) => err.description(),
DetectEntitiesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DetectEntitiesError::ParseError(ref cause) => cause,
DetectEntitiesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DetectKeyPhrasesError {
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
UnsupportedLanguage(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DetectKeyPhrasesError {
pub fn from_response(res: BufferedHttpResponse) -> DetectKeyPhrasesError {
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 DetectKeyPhrasesError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return DetectKeyPhrasesError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return DetectKeyPhrasesError::TextSizeLimitExceeded(String::from(error_message))
}
"UnsupportedLanguageException" => {
return DetectKeyPhrasesError::UnsupportedLanguage(String::from(error_message))
}
"ValidationException" => {
return DetectKeyPhrasesError::Validation(error_message.to_string())
}
_ => {}
}
}
return DetectKeyPhrasesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DetectKeyPhrasesError {
fn from(err: serde_json::error::Error) -> DetectKeyPhrasesError {
DetectKeyPhrasesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DetectKeyPhrasesError {
fn from(err: CredentialsError) -> DetectKeyPhrasesError {
DetectKeyPhrasesError::Credentials(err)
}
}
impl From<HttpDispatchError> for DetectKeyPhrasesError {
fn from(err: HttpDispatchError) -> DetectKeyPhrasesError {
DetectKeyPhrasesError::HttpDispatch(err)
}
}
impl From<io::Error> for DetectKeyPhrasesError {
fn from(err: io::Error) -> DetectKeyPhrasesError {
DetectKeyPhrasesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DetectKeyPhrasesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DetectKeyPhrasesError {
fn description(&self) -> &str {
match *self {
DetectKeyPhrasesError::InternalServer(ref cause) => cause,
DetectKeyPhrasesError::InvalidRequest(ref cause) => cause,
DetectKeyPhrasesError::TextSizeLimitExceeded(ref cause) => cause,
DetectKeyPhrasesError::UnsupportedLanguage(ref cause) => cause,
DetectKeyPhrasesError::Validation(ref cause) => cause,
DetectKeyPhrasesError::Credentials(ref err) => err.description(),
DetectKeyPhrasesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DetectKeyPhrasesError::ParseError(ref cause) => cause,
DetectKeyPhrasesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DetectSentimentError {
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
UnsupportedLanguage(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DetectSentimentError {
pub fn from_response(res: BufferedHttpResponse) -> DetectSentimentError {
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 DetectSentimentError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return DetectSentimentError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return DetectSentimentError::TextSizeLimitExceeded(String::from(error_message))
}
"UnsupportedLanguageException" => {
return DetectSentimentError::UnsupportedLanguage(String::from(error_message))
}
"ValidationException" => {
return DetectSentimentError::Validation(error_message.to_string())
}
_ => {}
}
}
return DetectSentimentError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DetectSentimentError {
fn from(err: serde_json::error::Error) -> DetectSentimentError {
DetectSentimentError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DetectSentimentError {
fn from(err: CredentialsError) -> DetectSentimentError {
DetectSentimentError::Credentials(err)
}
}
impl From<HttpDispatchError> for DetectSentimentError {
fn from(err: HttpDispatchError) -> DetectSentimentError {
DetectSentimentError::HttpDispatch(err)
}
}
impl From<io::Error> for DetectSentimentError {
fn from(err: io::Error) -> DetectSentimentError {
DetectSentimentError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DetectSentimentError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DetectSentimentError {
fn description(&self) -> &str {
match *self {
DetectSentimentError::InternalServer(ref cause) => cause,
DetectSentimentError::InvalidRequest(ref cause) => cause,
DetectSentimentError::TextSizeLimitExceeded(ref cause) => cause,
DetectSentimentError::UnsupportedLanguage(ref cause) => cause,
DetectSentimentError::Validation(ref cause) => cause,
DetectSentimentError::Credentials(ref err) => err.description(),
DetectSentimentError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DetectSentimentError::ParseError(ref cause) => cause,
DetectSentimentError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DetectSyntaxError {
InternalServer(String),
InvalidRequest(String),
TextSizeLimitExceeded(String),
UnsupportedLanguage(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DetectSyntaxError {
pub fn from_response(res: BufferedHttpResponse) -> DetectSyntaxError {
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 DetectSyntaxError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return DetectSyntaxError::InvalidRequest(String::from(error_message))
}
"TextSizeLimitExceededException" => {
return DetectSyntaxError::TextSizeLimitExceeded(String::from(error_message))
}
"UnsupportedLanguageException" => {
return DetectSyntaxError::UnsupportedLanguage(String::from(error_message))
}
"ValidationException" => {
return DetectSyntaxError::Validation(error_message.to_string())
}
_ => {}
}
}
return DetectSyntaxError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DetectSyntaxError {
fn from(err: serde_json::error::Error) -> DetectSyntaxError {
DetectSyntaxError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DetectSyntaxError {
fn from(err: CredentialsError) -> DetectSyntaxError {
DetectSyntaxError::Credentials(err)
}
}
impl From<HttpDispatchError> for DetectSyntaxError {
fn from(err: HttpDispatchError) -> DetectSyntaxError {
DetectSyntaxError::HttpDispatch(err)
}
}
impl From<io::Error> for DetectSyntaxError {
fn from(err: io::Error) -> DetectSyntaxError {
DetectSyntaxError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DetectSyntaxError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DetectSyntaxError {
fn description(&self) -> &str {
match *self {
DetectSyntaxError::InternalServer(ref cause) => cause,
DetectSyntaxError::InvalidRequest(ref cause) => cause,
DetectSyntaxError::TextSizeLimitExceeded(ref cause) => cause,
DetectSyntaxError::UnsupportedLanguage(ref cause) => cause,
DetectSyntaxError::Validation(ref cause) => cause,
DetectSyntaxError::Credentials(ref err) => err.description(),
DetectSyntaxError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DetectSyntaxError::ParseError(ref cause) => cause,
DetectSyntaxError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListDominantLanguageDetectionJobsError {
InternalServer(String),
InvalidFilter(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListDominantLanguageDetectionJobsError {
pub fn from_response(res: BufferedHttpResponse) -> ListDominantLanguageDetectionJobsError {
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 ListDominantLanguageDetectionJobsError::InternalServer(String::from(
error_message,
))
}
"InvalidFilterException" => {
return ListDominantLanguageDetectionJobsError::InvalidFilter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return ListDominantLanguageDetectionJobsError::InvalidRequest(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return ListDominantLanguageDetectionJobsError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return ListDominantLanguageDetectionJobsError::Validation(
error_message.to_string(),
)
}
_ => {}
}
}
return ListDominantLanguageDetectionJobsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListDominantLanguageDetectionJobsError {
fn from(err: serde_json::error::Error) -> ListDominantLanguageDetectionJobsError {
ListDominantLanguageDetectionJobsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListDominantLanguageDetectionJobsError {
fn from(err: CredentialsError) -> ListDominantLanguageDetectionJobsError {
ListDominantLanguageDetectionJobsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListDominantLanguageDetectionJobsError {
fn from(err: HttpDispatchError) -> ListDominantLanguageDetectionJobsError {
ListDominantLanguageDetectionJobsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListDominantLanguageDetectionJobsError {
fn from(err: io::Error) -> ListDominantLanguageDetectionJobsError {
ListDominantLanguageDetectionJobsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListDominantLanguageDetectionJobsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListDominantLanguageDetectionJobsError {
fn description(&self) -> &str {
match *self {
ListDominantLanguageDetectionJobsError::InternalServer(ref cause) => cause,
ListDominantLanguageDetectionJobsError::InvalidFilter(ref cause) => cause,
ListDominantLanguageDetectionJobsError::InvalidRequest(ref cause) => cause,
ListDominantLanguageDetectionJobsError::TooManyRequests(ref cause) => cause,
ListDominantLanguageDetectionJobsError::Validation(ref cause) => cause,
ListDominantLanguageDetectionJobsError::Credentials(ref err) => err.description(),
ListDominantLanguageDetectionJobsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListDominantLanguageDetectionJobsError::ParseError(ref cause) => cause,
ListDominantLanguageDetectionJobsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListEntitiesDetectionJobsError {
InternalServer(String),
InvalidFilter(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListEntitiesDetectionJobsError {
pub fn from_response(res: BufferedHttpResponse) -> ListEntitiesDetectionJobsError {
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 ListEntitiesDetectionJobsError::InternalServer(String::from(
error_message,
))
}
"InvalidFilterException" => {
return ListEntitiesDetectionJobsError::InvalidFilter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return ListEntitiesDetectionJobsError::InvalidRequest(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return ListEntitiesDetectionJobsError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return ListEntitiesDetectionJobsError::Validation(error_message.to_string())
}
_ => {}
}
}
return ListEntitiesDetectionJobsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListEntitiesDetectionJobsError {
fn from(err: serde_json::error::Error) -> ListEntitiesDetectionJobsError {
ListEntitiesDetectionJobsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListEntitiesDetectionJobsError {
fn from(err: CredentialsError) -> ListEntitiesDetectionJobsError {
ListEntitiesDetectionJobsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListEntitiesDetectionJobsError {
fn from(err: HttpDispatchError) -> ListEntitiesDetectionJobsError {
ListEntitiesDetectionJobsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListEntitiesDetectionJobsError {
fn from(err: io::Error) -> ListEntitiesDetectionJobsError {
ListEntitiesDetectionJobsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListEntitiesDetectionJobsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListEntitiesDetectionJobsError {
fn description(&self) -> &str {
match *self {
ListEntitiesDetectionJobsError::InternalServer(ref cause) => cause,
ListEntitiesDetectionJobsError::InvalidFilter(ref cause) => cause,
ListEntitiesDetectionJobsError::InvalidRequest(ref cause) => cause,
ListEntitiesDetectionJobsError::TooManyRequests(ref cause) => cause,
ListEntitiesDetectionJobsError::Validation(ref cause) => cause,
ListEntitiesDetectionJobsError::Credentials(ref err) => err.description(),
ListEntitiesDetectionJobsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListEntitiesDetectionJobsError::ParseError(ref cause) => cause,
ListEntitiesDetectionJobsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListKeyPhrasesDetectionJobsError {
InternalServer(String),
InvalidFilter(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListKeyPhrasesDetectionJobsError {
pub fn from_response(res: BufferedHttpResponse) -> ListKeyPhrasesDetectionJobsError {
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 ListKeyPhrasesDetectionJobsError::InternalServer(String::from(
error_message,
))
}
"InvalidFilterException" => {
return ListKeyPhrasesDetectionJobsError::InvalidFilter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return ListKeyPhrasesDetectionJobsError::InvalidRequest(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return ListKeyPhrasesDetectionJobsError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return ListKeyPhrasesDetectionJobsError::Validation(error_message.to_string())
}
_ => {}
}
}
return ListKeyPhrasesDetectionJobsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListKeyPhrasesDetectionJobsError {
fn from(err: serde_json::error::Error) -> ListKeyPhrasesDetectionJobsError {
ListKeyPhrasesDetectionJobsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListKeyPhrasesDetectionJobsError {
fn from(err: CredentialsError) -> ListKeyPhrasesDetectionJobsError {
ListKeyPhrasesDetectionJobsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListKeyPhrasesDetectionJobsError {
fn from(err: HttpDispatchError) -> ListKeyPhrasesDetectionJobsError {
ListKeyPhrasesDetectionJobsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListKeyPhrasesDetectionJobsError {
fn from(err: io::Error) -> ListKeyPhrasesDetectionJobsError {
ListKeyPhrasesDetectionJobsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListKeyPhrasesDetectionJobsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListKeyPhrasesDetectionJobsError {
fn description(&self) -> &str {
match *self {
ListKeyPhrasesDetectionJobsError::InternalServer(ref cause) => cause,
ListKeyPhrasesDetectionJobsError::InvalidFilter(ref cause) => cause,
ListKeyPhrasesDetectionJobsError::InvalidRequest(ref cause) => cause,
ListKeyPhrasesDetectionJobsError::TooManyRequests(ref cause) => cause,
ListKeyPhrasesDetectionJobsError::Validation(ref cause) => cause,
ListKeyPhrasesDetectionJobsError::Credentials(ref err) => err.description(),
ListKeyPhrasesDetectionJobsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListKeyPhrasesDetectionJobsError::ParseError(ref cause) => cause,
ListKeyPhrasesDetectionJobsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListSentimentDetectionJobsError {
InternalServer(String),
InvalidFilter(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListSentimentDetectionJobsError {
pub fn from_response(res: BufferedHttpResponse) -> ListSentimentDetectionJobsError {
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 ListSentimentDetectionJobsError::InternalServer(String::from(
error_message,
))
}
"InvalidFilterException" => {
return ListSentimentDetectionJobsError::InvalidFilter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return ListSentimentDetectionJobsError::InvalidRequest(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return ListSentimentDetectionJobsError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return ListSentimentDetectionJobsError::Validation(error_message.to_string())
}
_ => {}
}
}
return ListSentimentDetectionJobsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListSentimentDetectionJobsError {
fn from(err: serde_json::error::Error) -> ListSentimentDetectionJobsError {
ListSentimentDetectionJobsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListSentimentDetectionJobsError {
fn from(err: CredentialsError) -> ListSentimentDetectionJobsError {
ListSentimentDetectionJobsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListSentimentDetectionJobsError {
fn from(err: HttpDispatchError) -> ListSentimentDetectionJobsError {
ListSentimentDetectionJobsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListSentimentDetectionJobsError {
fn from(err: io::Error) -> ListSentimentDetectionJobsError {
ListSentimentDetectionJobsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListSentimentDetectionJobsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListSentimentDetectionJobsError {
fn description(&self) -> &str {
match *self {
ListSentimentDetectionJobsError::InternalServer(ref cause) => cause,
ListSentimentDetectionJobsError::InvalidFilter(ref cause) => cause,
ListSentimentDetectionJobsError::InvalidRequest(ref cause) => cause,
ListSentimentDetectionJobsError::TooManyRequests(ref cause) => cause,
ListSentimentDetectionJobsError::Validation(ref cause) => cause,
ListSentimentDetectionJobsError::Credentials(ref err) => err.description(),
ListSentimentDetectionJobsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListSentimentDetectionJobsError::ParseError(ref cause) => cause,
ListSentimentDetectionJobsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListTopicsDetectionJobsError {
InternalServer(String),
InvalidFilter(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListTopicsDetectionJobsError {
pub fn from_response(res: BufferedHttpResponse) -> ListTopicsDetectionJobsError {
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 ListTopicsDetectionJobsError::InternalServer(String::from(error_message))
}
"InvalidFilterException" => {
return ListTopicsDetectionJobsError::InvalidFilter(String::from(error_message))
}
"InvalidRequestException" => {
return ListTopicsDetectionJobsError::InvalidRequest(String::from(error_message))
}
"TooManyRequestsException" => {
return ListTopicsDetectionJobsError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return ListTopicsDetectionJobsError::Validation(error_message.to_string())
}
_ => {}
}
}
return ListTopicsDetectionJobsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListTopicsDetectionJobsError {
fn from(err: serde_json::error::Error) -> ListTopicsDetectionJobsError {
ListTopicsDetectionJobsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListTopicsDetectionJobsError {
fn from(err: CredentialsError) -> ListTopicsDetectionJobsError {
ListTopicsDetectionJobsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListTopicsDetectionJobsError {
fn from(err: HttpDispatchError) -> ListTopicsDetectionJobsError {
ListTopicsDetectionJobsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListTopicsDetectionJobsError {
fn from(err: io::Error) -> ListTopicsDetectionJobsError {
ListTopicsDetectionJobsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListTopicsDetectionJobsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListTopicsDetectionJobsError {
fn description(&self) -> &str {
match *self {
ListTopicsDetectionJobsError::InternalServer(ref cause) => cause,
ListTopicsDetectionJobsError::InvalidFilter(ref cause) => cause,
ListTopicsDetectionJobsError::InvalidRequest(ref cause) => cause,
ListTopicsDetectionJobsError::TooManyRequests(ref cause) => cause,
ListTopicsDetectionJobsError::Validation(ref cause) => cause,
ListTopicsDetectionJobsError::Credentials(ref err) => err.description(),
ListTopicsDetectionJobsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListTopicsDetectionJobsError::ParseError(ref cause) => cause,
ListTopicsDetectionJobsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartDominantLanguageDetectionJobError {
InternalServer(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StartDominantLanguageDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StartDominantLanguageDetectionJobError {
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 StartDominantLanguageDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StartDominantLanguageDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return StartDominantLanguageDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return StartDominantLanguageDetectionJobError::Validation(
error_message.to_string(),
)
}
_ => {}
}
}
return StartDominantLanguageDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StartDominantLanguageDetectionJobError {
fn from(err: serde_json::error::Error) -> StartDominantLanguageDetectionJobError {
StartDominantLanguageDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StartDominantLanguageDetectionJobError {
fn from(err: CredentialsError) -> StartDominantLanguageDetectionJobError {
StartDominantLanguageDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StartDominantLanguageDetectionJobError {
fn from(err: HttpDispatchError) -> StartDominantLanguageDetectionJobError {
StartDominantLanguageDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StartDominantLanguageDetectionJobError {
fn from(err: io::Error) -> StartDominantLanguageDetectionJobError {
StartDominantLanguageDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StartDominantLanguageDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartDominantLanguageDetectionJobError {
fn description(&self) -> &str {
match *self {
StartDominantLanguageDetectionJobError::InternalServer(ref cause) => cause,
StartDominantLanguageDetectionJobError::InvalidRequest(ref cause) => cause,
StartDominantLanguageDetectionJobError::TooManyRequests(ref cause) => cause,
StartDominantLanguageDetectionJobError::Validation(ref cause) => cause,
StartDominantLanguageDetectionJobError::Credentials(ref err) => err.description(),
StartDominantLanguageDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StartDominantLanguageDetectionJobError::ParseError(ref cause) => cause,
StartDominantLanguageDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartEntitiesDetectionJobError {
InternalServer(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StartEntitiesDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StartEntitiesDetectionJobError {
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 StartEntitiesDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StartEntitiesDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return StartEntitiesDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return StartEntitiesDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return StartEntitiesDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StartEntitiesDetectionJobError {
fn from(err: serde_json::error::Error) -> StartEntitiesDetectionJobError {
StartEntitiesDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StartEntitiesDetectionJobError {
fn from(err: CredentialsError) -> StartEntitiesDetectionJobError {
StartEntitiesDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StartEntitiesDetectionJobError {
fn from(err: HttpDispatchError) -> StartEntitiesDetectionJobError {
StartEntitiesDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StartEntitiesDetectionJobError {
fn from(err: io::Error) -> StartEntitiesDetectionJobError {
StartEntitiesDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StartEntitiesDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartEntitiesDetectionJobError {
fn description(&self) -> &str {
match *self {
StartEntitiesDetectionJobError::InternalServer(ref cause) => cause,
StartEntitiesDetectionJobError::InvalidRequest(ref cause) => cause,
StartEntitiesDetectionJobError::TooManyRequests(ref cause) => cause,
StartEntitiesDetectionJobError::Validation(ref cause) => cause,
StartEntitiesDetectionJobError::Credentials(ref err) => err.description(),
StartEntitiesDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StartEntitiesDetectionJobError::ParseError(ref cause) => cause,
StartEntitiesDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartKeyPhrasesDetectionJobError {
InternalServer(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StartKeyPhrasesDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StartKeyPhrasesDetectionJobError {
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 StartKeyPhrasesDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StartKeyPhrasesDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return StartKeyPhrasesDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return StartKeyPhrasesDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return StartKeyPhrasesDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StartKeyPhrasesDetectionJobError {
fn from(err: serde_json::error::Error) -> StartKeyPhrasesDetectionJobError {
StartKeyPhrasesDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StartKeyPhrasesDetectionJobError {
fn from(err: CredentialsError) -> StartKeyPhrasesDetectionJobError {
StartKeyPhrasesDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StartKeyPhrasesDetectionJobError {
fn from(err: HttpDispatchError) -> StartKeyPhrasesDetectionJobError {
StartKeyPhrasesDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StartKeyPhrasesDetectionJobError {
fn from(err: io::Error) -> StartKeyPhrasesDetectionJobError {
StartKeyPhrasesDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StartKeyPhrasesDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartKeyPhrasesDetectionJobError {
fn description(&self) -> &str {
match *self {
StartKeyPhrasesDetectionJobError::InternalServer(ref cause) => cause,
StartKeyPhrasesDetectionJobError::InvalidRequest(ref cause) => cause,
StartKeyPhrasesDetectionJobError::TooManyRequests(ref cause) => cause,
StartKeyPhrasesDetectionJobError::Validation(ref cause) => cause,
StartKeyPhrasesDetectionJobError::Credentials(ref err) => err.description(),
StartKeyPhrasesDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StartKeyPhrasesDetectionJobError::ParseError(ref cause) => cause,
StartKeyPhrasesDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartSentimentDetectionJobError {
InternalServer(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StartSentimentDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StartSentimentDetectionJobError {
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 StartSentimentDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StartSentimentDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"TooManyRequestsException" => {
return StartSentimentDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return StartSentimentDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return StartSentimentDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StartSentimentDetectionJobError {
fn from(err: serde_json::error::Error) -> StartSentimentDetectionJobError {
StartSentimentDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StartSentimentDetectionJobError {
fn from(err: CredentialsError) -> StartSentimentDetectionJobError {
StartSentimentDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StartSentimentDetectionJobError {
fn from(err: HttpDispatchError) -> StartSentimentDetectionJobError {
StartSentimentDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StartSentimentDetectionJobError {
fn from(err: io::Error) -> StartSentimentDetectionJobError {
StartSentimentDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StartSentimentDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartSentimentDetectionJobError {
fn description(&self) -> &str {
match *self {
StartSentimentDetectionJobError::InternalServer(ref cause) => cause,
StartSentimentDetectionJobError::InvalidRequest(ref cause) => cause,
StartSentimentDetectionJobError::TooManyRequests(ref cause) => cause,
StartSentimentDetectionJobError::Validation(ref cause) => cause,
StartSentimentDetectionJobError::Credentials(ref err) => err.description(),
StartSentimentDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StartSentimentDetectionJobError::ParseError(ref cause) => cause,
StartSentimentDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartTopicsDetectionJobError {
InternalServer(String),
InvalidRequest(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StartTopicsDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StartTopicsDetectionJobError {
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 StartTopicsDetectionJobError::InternalServer(String::from(error_message))
}
"InvalidRequestException" => {
return StartTopicsDetectionJobError::InvalidRequest(String::from(error_message))
}
"TooManyRequestsException" => {
return StartTopicsDetectionJobError::TooManyRequests(String::from(
error_message,
))
}
"ValidationException" => {
return StartTopicsDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return StartTopicsDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StartTopicsDetectionJobError {
fn from(err: serde_json::error::Error) -> StartTopicsDetectionJobError {
StartTopicsDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StartTopicsDetectionJobError {
fn from(err: CredentialsError) -> StartTopicsDetectionJobError {
StartTopicsDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StartTopicsDetectionJobError {
fn from(err: HttpDispatchError) -> StartTopicsDetectionJobError {
StartTopicsDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StartTopicsDetectionJobError {
fn from(err: io::Error) -> StartTopicsDetectionJobError {
StartTopicsDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StartTopicsDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartTopicsDetectionJobError {
fn description(&self) -> &str {
match *self {
StartTopicsDetectionJobError::InternalServer(ref cause) => cause,
StartTopicsDetectionJobError::InvalidRequest(ref cause) => cause,
StartTopicsDetectionJobError::TooManyRequests(ref cause) => cause,
StartTopicsDetectionJobError::Validation(ref cause) => cause,
StartTopicsDetectionJobError::Credentials(ref err) => err.description(),
StartTopicsDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StartTopicsDetectionJobError::ParseError(ref cause) => cause,
StartTopicsDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StopDominantLanguageDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StopDominantLanguageDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StopDominantLanguageDetectionJobError {
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 StopDominantLanguageDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StopDominantLanguageDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return StopDominantLanguageDetectionJobError::JobNotFound(String::from(
error_message,
))
}
"ValidationException" => {
return StopDominantLanguageDetectionJobError::Validation(
error_message.to_string(),
)
}
_ => {}
}
}
return StopDominantLanguageDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StopDominantLanguageDetectionJobError {
fn from(err: serde_json::error::Error) -> StopDominantLanguageDetectionJobError {
StopDominantLanguageDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StopDominantLanguageDetectionJobError {
fn from(err: CredentialsError) -> StopDominantLanguageDetectionJobError {
StopDominantLanguageDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StopDominantLanguageDetectionJobError {
fn from(err: HttpDispatchError) -> StopDominantLanguageDetectionJobError {
StopDominantLanguageDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StopDominantLanguageDetectionJobError {
fn from(err: io::Error) -> StopDominantLanguageDetectionJobError {
StopDominantLanguageDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StopDominantLanguageDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StopDominantLanguageDetectionJobError {
fn description(&self) -> &str {
match *self {
StopDominantLanguageDetectionJobError::InternalServer(ref cause) => cause,
StopDominantLanguageDetectionJobError::InvalidRequest(ref cause) => cause,
StopDominantLanguageDetectionJobError::JobNotFound(ref cause) => cause,
StopDominantLanguageDetectionJobError::Validation(ref cause) => cause,
StopDominantLanguageDetectionJobError::Credentials(ref err) => err.description(),
StopDominantLanguageDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StopDominantLanguageDetectionJobError::ParseError(ref cause) => cause,
StopDominantLanguageDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StopEntitiesDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StopEntitiesDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StopEntitiesDetectionJobError {
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 StopEntitiesDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StopEntitiesDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return StopEntitiesDetectionJobError::JobNotFound(String::from(error_message))
}
"ValidationException" => {
return StopEntitiesDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return StopEntitiesDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StopEntitiesDetectionJobError {
fn from(err: serde_json::error::Error) -> StopEntitiesDetectionJobError {
StopEntitiesDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StopEntitiesDetectionJobError {
fn from(err: CredentialsError) -> StopEntitiesDetectionJobError {
StopEntitiesDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StopEntitiesDetectionJobError {
fn from(err: HttpDispatchError) -> StopEntitiesDetectionJobError {
StopEntitiesDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StopEntitiesDetectionJobError {
fn from(err: io::Error) -> StopEntitiesDetectionJobError {
StopEntitiesDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StopEntitiesDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StopEntitiesDetectionJobError {
fn description(&self) -> &str {
match *self {
StopEntitiesDetectionJobError::InternalServer(ref cause) => cause,
StopEntitiesDetectionJobError::InvalidRequest(ref cause) => cause,
StopEntitiesDetectionJobError::JobNotFound(ref cause) => cause,
StopEntitiesDetectionJobError::Validation(ref cause) => cause,
StopEntitiesDetectionJobError::Credentials(ref err) => err.description(),
StopEntitiesDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StopEntitiesDetectionJobError::ParseError(ref cause) => cause,
StopEntitiesDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StopKeyPhrasesDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StopKeyPhrasesDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StopKeyPhrasesDetectionJobError {
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 StopKeyPhrasesDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StopKeyPhrasesDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return StopKeyPhrasesDetectionJobError::JobNotFound(String::from(error_message))
}
"ValidationException" => {
return StopKeyPhrasesDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return StopKeyPhrasesDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StopKeyPhrasesDetectionJobError {
fn from(err: serde_json::error::Error) -> StopKeyPhrasesDetectionJobError {
StopKeyPhrasesDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StopKeyPhrasesDetectionJobError {
fn from(err: CredentialsError) -> StopKeyPhrasesDetectionJobError {
StopKeyPhrasesDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StopKeyPhrasesDetectionJobError {
fn from(err: HttpDispatchError) -> StopKeyPhrasesDetectionJobError {
StopKeyPhrasesDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StopKeyPhrasesDetectionJobError {
fn from(err: io::Error) -> StopKeyPhrasesDetectionJobError {
StopKeyPhrasesDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StopKeyPhrasesDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StopKeyPhrasesDetectionJobError {
fn description(&self) -> &str {
match *self {
StopKeyPhrasesDetectionJobError::InternalServer(ref cause) => cause,
StopKeyPhrasesDetectionJobError::InvalidRequest(ref cause) => cause,
StopKeyPhrasesDetectionJobError::JobNotFound(ref cause) => cause,
StopKeyPhrasesDetectionJobError::Validation(ref cause) => cause,
StopKeyPhrasesDetectionJobError::Credentials(ref err) => err.description(),
StopKeyPhrasesDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StopKeyPhrasesDetectionJobError::ParseError(ref cause) => cause,
StopKeyPhrasesDetectionJobError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StopSentimentDetectionJobError {
InternalServer(String),
InvalidRequest(String),
JobNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StopSentimentDetectionJobError {
pub fn from_response(res: BufferedHttpResponse) -> StopSentimentDetectionJobError {
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 StopSentimentDetectionJobError::InternalServer(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StopSentimentDetectionJobError::InvalidRequest(String::from(
error_message,
))
}
"JobNotFoundException" => {
return StopSentimentDetectionJobError::JobNotFound(String::from(error_message))
}
"ValidationException" => {
return StopSentimentDetectionJobError::Validation(error_message.to_string())
}
_ => {}
}
}
return StopSentimentDetectionJobError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StopSentimentDetectionJobError {
fn from(err: serde_json::error::Error) -> StopSentimentDetectionJobError {
StopSentimentDetectionJobError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StopSentimentDetectionJobError {
fn from(err: CredentialsError) -> StopSentimentDetectionJobError {
StopSentimentDetectionJobError::Credentials(err)
}
}
impl From<HttpDispatchError> for StopSentimentDetectionJobError {
fn from(err: HttpDispatchError) -> StopSentimentDetectionJobError {
StopSentimentDetectionJobError::HttpDispatch(err)
}
}
impl From<io::Error> for StopSentimentDetectionJobError {
fn from(err: io::Error) -> StopSentimentDetectionJobError {
StopSentimentDetectionJobError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StopSentimentDetectionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StopSentimentDetectionJobError {
fn description(&self) -> &str {
match *self {
StopSentimentDetectionJobError::InternalServer(ref cause) => cause,
StopSentimentDetectionJobError::InvalidRequest(ref cause) => cause,
StopSentimentDetectionJobError::JobNotFound(ref cause) => cause,
StopSentimentDetectionJobError::Validation(ref cause) => cause,
StopSentimentDetectionJobError::Credentials(ref err) => err.description(),
StopSentimentDetectionJobError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StopSentimentDetectionJobError::ParseError(ref cause) => cause,
StopSentimentDetectionJobError::Unknown(_) => "unknown error",
}
}
}
pub trait Comprehend {
fn batch_detect_dominant_language(
&self,
input: BatchDetectDominantLanguageRequest,
) -> RusotoFuture<BatchDetectDominantLanguageResponse, BatchDetectDominantLanguageError>;
fn batch_detect_entities(
&self,
input: BatchDetectEntitiesRequest,
) -> RusotoFuture<BatchDetectEntitiesResponse, BatchDetectEntitiesError>;
fn batch_detect_key_phrases(
&self,
input: BatchDetectKeyPhrasesRequest,
) -> RusotoFuture<BatchDetectKeyPhrasesResponse, BatchDetectKeyPhrasesError>;
fn batch_detect_sentiment(
&self,
input: BatchDetectSentimentRequest,
) -> RusotoFuture<BatchDetectSentimentResponse, BatchDetectSentimentError>;
fn batch_detect_syntax(
&self,
input: BatchDetectSyntaxRequest,
) -> RusotoFuture<BatchDetectSyntaxResponse, BatchDetectSyntaxError>;
fn describe_dominant_language_detection_job(
&self,
input: DescribeDominantLanguageDetectionJobRequest,
) -> RusotoFuture<
DescribeDominantLanguageDetectionJobResponse,
DescribeDominantLanguageDetectionJobError,
>;
fn describe_entities_detection_job(
&self,
input: DescribeEntitiesDetectionJobRequest,
) -> RusotoFuture<DescribeEntitiesDetectionJobResponse, DescribeEntitiesDetectionJobError>;
fn describe_key_phrases_detection_job(
&self,
input: DescribeKeyPhrasesDetectionJobRequest,
) -> RusotoFuture<DescribeKeyPhrasesDetectionJobResponse, DescribeKeyPhrasesDetectionJobError>;
fn describe_sentiment_detection_job(
&self,
input: DescribeSentimentDetectionJobRequest,
) -> RusotoFuture<DescribeSentimentDetectionJobResponse, DescribeSentimentDetectionJobError>;
fn describe_topics_detection_job(
&self,
input: DescribeTopicsDetectionJobRequest,
) -> RusotoFuture<DescribeTopicsDetectionJobResponse, DescribeTopicsDetectionJobError>;
fn detect_dominant_language(
&self,
input: DetectDominantLanguageRequest,
) -> RusotoFuture<DetectDominantLanguageResponse, DetectDominantLanguageError>;
fn detect_entities(
&self,
input: DetectEntitiesRequest,
) -> RusotoFuture<DetectEntitiesResponse, DetectEntitiesError>;
fn detect_key_phrases(
&self,
input: DetectKeyPhrasesRequest,
) -> RusotoFuture<DetectKeyPhrasesResponse, DetectKeyPhrasesError>;
fn detect_sentiment(
&self,
input: DetectSentimentRequest,
) -> RusotoFuture<DetectSentimentResponse, DetectSentimentError>;
fn detect_syntax(
&self,
input: DetectSyntaxRequest,
) -> RusotoFuture<DetectSyntaxResponse, DetectSyntaxError>;
fn list_dominant_language_detection_jobs(
&self,
input: ListDominantLanguageDetectionJobsRequest,
) -> RusotoFuture<
ListDominantLanguageDetectionJobsResponse,
ListDominantLanguageDetectionJobsError,
>;
fn list_entities_detection_jobs(
&self,
input: ListEntitiesDetectionJobsRequest,
) -> RusotoFuture<ListEntitiesDetectionJobsResponse, ListEntitiesDetectionJobsError>;
fn list_key_phrases_detection_jobs(
&self,
input: ListKeyPhrasesDetectionJobsRequest,
) -> RusotoFuture<ListKeyPhrasesDetectionJobsResponse, ListKeyPhrasesDetectionJobsError>;
fn list_sentiment_detection_jobs(
&self,
input: ListSentimentDetectionJobsRequest,
) -> RusotoFuture<ListSentimentDetectionJobsResponse, ListSentimentDetectionJobsError>;
fn list_topics_detection_jobs(
&self,
input: ListTopicsDetectionJobsRequest,
) -> RusotoFuture<ListTopicsDetectionJobsResponse, ListTopicsDetectionJobsError>;
fn start_dominant_language_detection_job(
&self,
input: StartDominantLanguageDetectionJobRequest,
) -> RusotoFuture<
StartDominantLanguageDetectionJobResponse,
StartDominantLanguageDetectionJobError,
>;
fn start_entities_detection_job(
&self,
input: StartEntitiesDetectionJobRequest,
) -> RusotoFuture<StartEntitiesDetectionJobResponse, StartEntitiesDetectionJobError>;
fn start_key_phrases_detection_job(
&self,
input: StartKeyPhrasesDetectionJobRequest,
) -> RusotoFuture<StartKeyPhrasesDetectionJobResponse, StartKeyPhrasesDetectionJobError>;
fn start_sentiment_detection_job(
&self,
input: StartSentimentDetectionJobRequest,
) -> RusotoFuture<StartSentimentDetectionJobResponse, StartSentimentDetectionJobError>;
fn start_topics_detection_job(
&self,
input: StartTopicsDetectionJobRequest,
) -> RusotoFuture<StartTopicsDetectionJobResponse, StartTopicsDetectionJobError>;
fn stop_dominant_language_detection_job(
&self,
input: StopDominantLanguageDetectionJobRequest,
) -> RusotoFuture<StopDominantLanguageDetectionJobResponse, StopDominantLanguageDetectionJobError>;
fn stop_entities_detection_job(
&self,
input: StopEntitiesDetectionJobRequest,
) -> RusotoFuture<StopEntitiesDetectionJobResponse, StopEntitiesDetectionJobError>;
fn stop_key_phrases_detection_job(
&self,
input: StopKeyPhrasesDetectionJobRequest,
) -> RusotoFuture<StopKeyPhrasesDetectionJobResponse, StopKeyPhrasesDetectionJobError>;
fn stop_sentiment_detection_job(
&self,
input: StopSentimentDetectionJobRequest,
) -> RusotoFuture<StopSentimentDetectionJobResponse, StopSentimentDetectionJobError>;
}
pub struct ComprehendClient {
client: Client,
region: region::Region,
}
impl ComprehendClient {
pub fn new(region: region::Region) -> ComprehendClient {
ComprehendClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> ComprehendClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
ComprehendClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl Comprehend for ComprehendClient {
fn batch_detect_dominant_language(
&self,
input: BatchDetectDominantLanguageRequest,
) -> RusotoFuture<BatchDetectDominantLanguageResponse, BatchDetectDominantLanguageError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.BatchDetectDominantLanguage",
);
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::<BatchDetectDominantLanguageResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(BatchDetectDominantLanguageError::from_response(response))
}))
}
})
}
fn batch_detect_entities(
&self,
input: BatchDetectEntitiesRequest,
) -> RusotoFuture<BatchDetectEntitiesResponse, BatchDetectEntitiesError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.BatchDetectEntities");
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::<BatchDetectEntitiesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(BatchDetectEntitiesError::from_response(response))
}),
)
}
})
}
fn batch_detect_key_phrases(
&self,
input: BatchDetectKeyPhrasesRequest,
) -> RusotoFuture<BatchDetectKeyPhrasesResponse, BatchDetectKeyPhrasesError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.BatchDetectKeyPhrases");
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::<BatchDetectKeyPhrasesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(BatchDetectKeyPhrasesError::from_response(response))
}),
)
}
})
}
fn batch_detect_sentiment(
&self,
input: BatchDetectSentimentRequest,
) -> RusotoFuture<BatchDetectSentimentResponse, BatchDetectSentimentError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.BatchDetectSentiment");
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::<BatchDetectSentimentResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(BatchDetectSentimentError::from_response(response))
}),
)
}
})
}
fn batch_detect_syntax(
&self,
input: BatchDetectSyntaxRequest,
) -> RusotoFuture<BatchDetectSyntaxResponse, BatchDetectSyntaxError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.BatchDetectSyntax");
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::<BatchDetectSyntaxResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(BatchDetectSyntaxError::from_response(response))),
)
}
})
}
fn describe_dominant_language_detection_job(
&self,
input: DescribeDominantLanguageDetectionJobRequest,
) -> RusotoFuture<
DescribeDominantLanguageDetectionJobResponse,
DescribeDominantLanguageDetectionJobError,
> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.DescribeDominantLanguageDetectionJob",
);
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::<DescribeDominantLanguageDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeDominantLanguageDetectionJobError::from_response(
response,
))
}))
}
})
}
fn describe_entities_detection_job(
&self,
input: DescribeEntitiesDetectionJobRequest,
) -> RusotoFuture<DescribeEntitiesDetectionJobResponse, DescribeEntitiesDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.DescribeEntitiesDetectionJob",
);
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::<DescribeEntitiesDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeEntitiesDetectionJobError::from_response(response))
}))
}
})
}
fn describe_key_phrases_detection_job(
&self,
input: DescribeKeyPhrasesDetectionJobRequest,
) -> RusotoFuture<DescribeKeyPhrasesDetectionJobResponse, DescribeKeyPhrasesDetectionJobError>
{
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.DescribeKeyPhrasesDetectionJob",
);
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::<DescribeKeyPhrasesDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeKeyPhrasesDetectionJobError::from_response(response))
}))
}
})
}
fn describe_sentiment_detection_job(
&self,
input: DescribeSentimentDetectionJobRequest,
) -> RusotoFuture<DescribeSentimentDetectionJobResponse, DescribeSentimentDetectionJobError>
{
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.DescribeSentimentDetectionJob",
);
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::<DescribeSentimentDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeSentimentDetectionJobError::from_response(response))
}))
}
})
}
fn describe_topics_detection_job(
&self,
input: DescribeTopicsDetectionJobRequest,
) -> RusotoFuture<DescribeTopicsDetectionJobResponse, DescribeTopicsDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.DescribeTopicsDetectionJob",
);
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::<DescribeTopicsDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeTopicsDetectionJobError::from_response(response))
}))
}
})
}
fn detect_dominant_language(
&self,
input: DetectDominantLanguageRequest,
) -> RusotoFuture<DetectDominantLanguageResponse, DetectDominantLanguageError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.DetectDominantLanguage");
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::<DetectDominantLanguageResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DetectDominantLanguageError::from_response(response))
}),
)
}
})
}
fn detect_entities(
&self,
input: DetectEntitiesRequest,
) -> RusotoFuture<DetectEntitiesResponse, DetectEntitiesError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.DetectEntities");
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::<DetectEntitiesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DetectEntitiesError::from_response(response))),
)
}
})
}
fn detect_key_phrases(
&self,
input: DetectKeyPhrasesRequest,
) -> RusotoFuture<DetectKeyPhrasesResponse, DetectKeyPhrasesError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.DetectKeyPhrases");
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::<DetectKeyPhrasesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DetectKeyPhrasesError::from_response(response))),
)
}
})
}
fn detect_sentiment(
&self,
input: DetectSentimentRequest,
) -> RusotoFuture<DetectSentimentResponse, DetectSentimentError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.DetectSentiment");
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::<DetectSentimentResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DetectSentimentError::from_response(response))),
)
}
})
}
fn detect_syntax(
&self,
input: DetectSyntaxRequest,
) -> RusotoFuture<DetectSyntaxResponse, DetectSyntaxError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Comprehend_20171127.DetectSyntax");
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::<DetectSyntaxResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DetectSyntaxError::from_response(response))),
)
}
})
}
fn list_dominant_language_detection_jobs(
&self,
input: ListDominantLanguageDetectionJobsRequest,
) -> RusotoFuture<
ListDominantLanguageDetectionJobsResponse,
ListDominantLanguageDetectionJobsError,
> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.ListDominantLanguageDetectionJobs",
);
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::<ListDominantLanguageDetectionJobsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListDominantLanguageDetectionJobsError::from_response(
response,
))
}))
}
})
}
fn list_entities_detection_jobs(
&self,
input: ListEntitiesDetectionJobsRequest,
) -> RusotoFuture<ListEntitiesDetectionJobsResponse, ListEntitiesDetectionJobsError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.ListEntitiesDetectionJobs",
);
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::<ListEntitiesDetectionJobsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListEntitiesDetectionJobsError::from_response(response))
}))
}
})
}
fn list_key_phrases_detection_jobs(
&self,
input: ListKeyPhrasesDetectionJobsRequest,
) -> RusotoFuture<ListKeyPhrasesDetectionJobsResponse, ListKeyPhrasesDetectionJobsError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.ListKeyPhrasesDetectionJobs",
);
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::<ListKeyPhrasesDetectionJobsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListKeyPhrasesDetectionJobsError::from_response(response))
}))
}
})
}
fn list_sentiment_detection_jobs(
&self,
input: ListSentimentDetectionJobsRequest,
) -> RusotoFuture<ListSentimentDetectionJobsResponse, ListSentimentDetectionJobsError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.ListSentimentDetectionJobs",
);
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::<ListSentimentDetectionJobsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListSentimentDetectionJobsError::from_response(response))
}))
}
})
}
fn list_topics_detection_jobs(
&self,
input: ListTopicsDetectionJobsRequest,
) -> RusotoFuture<ListTopicsDetectionJobsResponse, ListTopicsDetectionJobsError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.ListTopicsDetectionJobs",
);
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::<ListTopicsDetectionJobsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListTopicsDetectionJobsError::from_response(response))
}))
}
})
}
fn start_dominant_language_detection_job(
&self,
input: StartDominantLanguageDetectionJobRequest,
) -> RusotoFuture<
StartDominantLanguageDetectionJobResponse,
StartDominantLanguageDetectionJobError,
> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StartDominantLanguageDetectionJob",
);
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::<StartDominantLanguageDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StartDominantLanguageDetectionJobError::from_response(
response,
))
}))
}
})
}
fn start_entities_detection_job(
&self,
input: StartEntitiesDetectionJobRequest,
) -> RusotoFuture<StartEntitiesDetectionJobResponse, StartEntitiesDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StartEntitiesDetectionJob",
);
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::<StartEntitiesDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StartEntitiesDetectionJobError::from_response(response))
}))
}
})
}
fn start_key_phrases_detection_job(
&self,
input: StartKeyPhrasesDetectionJobRequest,
) -> RusotoFuture<StartKeyPhrasesDetectionJobResponse, StartKeyPhrasesDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StartKeyPhrasesDetectionJob",
);
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::<StartKeyPhrasesDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StartKeyPhrasesDetectionJobError::from_response(response))
}))
}
})
}
fn start_sentiment_detection_job(
&self,
input: StartSentimentDetectionJobRequest,
) -> RusotoFuture<StartSentimentDetectionJobResponse, StartSentimentDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StartSentimentDetectionJob",
);
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::<StartSentimentDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StartSentimentDetectionJobError::from_response(response))
}))
}
})
}
fn start_topics_detection_job(
&self,
input: StartTopicsDetectionJobRequest,
) -> RusotoFuture<StartTopicsDetectionJobResponse, StartTopicsDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StartTopicsDetectionJob",
);
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::<StartTopicsDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StartTopicsDetectionJobError::from_response(response))
}))
}
})
}
fn stop_dominant_language_detection_job(
&self,
input: StopDominantLanguageDetectionJobRequest,
) -> RusotoFuture<StopDominantLanguageDetectionJobResponse, StopDominantLanguageDetectionJobError>
{
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StopDominantLanguageDetectionJob",
);
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::<StopDominantLanguageDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StopDominantLanguageDetectionJobError::from_response(
response,
))
}))
}
})
}
fn stop_entities_detection_job(
&self,
input: StopEntitiesDetectionJobRequest,
) -> RusotoFuture<StopEntitiesDetectionJobResponse, StopEntitiesDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StopEntitiesDetectionJob",
);
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::<StopEntitiesDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StopEntitiesDetectionJobError::from_response(response))
}))
}
})
}
fn stop_key_phrases_detection_job(
&self,
input: StopKeyPhrasesDetectionJobRequest,
) -> RusotoFuture<StopKeyPhrasesDetectionJobResponse, StopKeyPhrasesDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StopKeyPhrasesDetectionJob",
);
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::<StopKeyPhrasesDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StopKeyPhrasesDetectionJobError::from_response(response))
}))
}
})
}
fn stop_sentiment_detection_job(
&self,
input: StopSentimentDetectionJobRequest,
) -> RusotoFuture<StopSentimentDetectionJobResponse, StopSentimentDetectionJobError> {
let mut request = SignedRequest::new("POST", "comprehend", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"Comprehend_20171127.StopSentimentDetectionJob",
);
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::<StopSentimentDetectionJobResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StopSentimentDetectionJobError::from_response(response))
}))
}
})
}
}
#[cfg(test)]
mod protocol_tests {}