use std::error::Error;
use std::fmt;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError, RusotoFuture};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
use serde_json;
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AffectedEntity {
#[serde(rename = "awsAccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub aws_account_id: Option<String>,
#[serde(rename = "entityArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_arn: Option<String>,
#[serde(rename = "entityUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_url: Option<String>,
#[serde(rename = "entityValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_value: Option<String>,
#[serde(rename = "eventArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_arn: Option<String>,
#[serde(rename = "lastUpdatedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_updated_time: Option<f64>,
#[serde(rename = "statusCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status_code: Option<String>,
#[serde(rename = "tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DateTimeRange {
#[serde(rename = "from")]
#[serde(skip_serializing_if = "Option::is_none")]
pub from: Option<f64>,
#[serde(rename = "to")]
#[serde(skip_serializing_if = "Option::is_none")]
pub to: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeAffectedEntitiesRequest {
#[serde(rename = "filter")]
pub filter: EntityFilter,
#[serde(rename = "locale")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locale: Option<String>,
#[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 DescribeAffectedEntitiesResponse {
#[serde(rename = "entities")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entities: Option<Vec<AffectedEntity>>,
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeEntityAggregatesRequest {
#[serde(rename = "eventArns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_arns: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeEntityAggregatesResponse {
#[serde(rename = "entityAggregates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_aggregates: Option<Vec<EntityAggregate>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeEventAggregatesRequest {
#[serde(rename = "aggregateField")]
pub aggregate_field: String,
#[serde(rename = "filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<EventFilter>,
#[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 DescribeEventAggregatesResponse {
#[serde(rename = "eventAggregates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_aggregates: Option<Vec<EventAggregate>>,
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeEventDetailsRequest {
#[serde(rename = "eventArns")]
pub event_arns: Vec<String>,
#[serde(rename = "locale")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locale: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeEventDetailsResponse {
#[serde(rename = "failedSet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_set: Option<Vec<EventDetailsErrorItem>>,
#[serde(rename = "successfulSet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub successful_set: Option<Vec<EventDetails>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeEventTypesRequest {
#[serde(rename = "filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<EventTypeFilter>,
#[serde(rename = "locale")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locale: Option<String>,
#[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 DescribeEventTypesResponse {
#[serde(rename = "eventTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_types: Option<Vec<String>>,
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeEventsRequest {
#[serde(rename = "filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<EventFilter>,
#[serde(rename = "locale")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locale: Option<String>,
#[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 DescribeEventsResponse {
#[serde(rename = "events")]
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<Event>>,
#[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 EntityAggregate {
#[serde(rename = "count")]
#[serde(skip_serializing_if = "Option::is_none")]
pub count: Option<i64>,
#[serde(rename = "eventArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct EntityFilter {
#[serde(rename = "entityArns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_arns: Option<Vec<String>>,
#[serde(rename = "entityValues")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_values: Option<Vec<String>>,
#[serde(rename = "eventArns")]
pub event_arns: Vec<String>,
#[serde(rename = "lastUpdatedTimes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_updated_times: Option<Vec<DateTimeRange>>,
#[serde(rename = "statusCodes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status_codes: Option<Vec<String>>,
#[serde(rename = "tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<::std::collections::HashMap<String, String>>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Event {
#[serde(rename = "arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "availabilityZone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub availability_zone: Option<String>,
#[serde(rename = "endTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "eventTypeCategory")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_type_category: Option<String>,
#[serde(rename = "eventTypeCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_type_code: Option<String>,
#[serde(rename = "lastUpdatedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_updated_time: Option<f64>,
#[serde(rename = "region")]
#[serde(skip_serializing_if = "Option::is_none")]
pub region: Option<String>,
#[serde(rename = "service")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service: Option<String>,
#[serde(rename = "startTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<f64>,
#[serde(rename = "statusCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status_code: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EventAggregate {
#[serde(rename = "aggregateValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub aggregate_value: Option<String>,
#[serde(rename = "count")]
#[serde(skip_serializing_if = "Option::is_none")]
pub count: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EventDetails {
#[serde(rename = "event")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event: Option<Event>,
#[serde(rename = "eventDescription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_description: Option<String>,
#[serde(rename = "eventMetadata")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_metadata: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EventDetailsErrorItem {
#[serde(rename = "errorMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_message: Option<String>,
#[serde(rename = "errorName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_name: Option<String>,
#[serde(rename = "eventArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct EventFilter {
#[serde(rename = "availabilityZones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub availability_zones: Option<Vec<String>>,
#[serde(rename = "endTimes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_times: Option<Vec<DateTimeRange>>,
#[serde(rename = "entityArns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_arns: Option<Vec<String>>,
#[serde(rename = "entityValues")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_values: Option<Vec<String>>,
#[serde(rename = "eventArns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_arns: Option<Vec<String>>,
#[serde(rename = "eventStatusCodes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_status_codes: Option<Vec<String>>,
#[serde(rename = "eventTypeCategories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_type_categories: Option<Vec<String>>,
#[serde(rename = "eventTypeCodes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_type_codes: Option<Vec<String>>,
#[serde(rename = "lastUpdatedTimes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_updated_times: Option<Vec<DateTimeRange>>,
#[serde(rename = "regions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub regions: Option<Vec<String>>,
#[serde(rename = "services")]
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<String>>,
#[serde(rename = "startTimes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_times: Option<Vec<DateTimeRange>>,
#[serde(rename = "tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<::std::collections::HashMap<String, String>>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct EventTypeFilter {
#[serde(rename = "eventTypeCategories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_type_categories: Option<Vec<String>>,
#[serde(rename = "eventTypeCodes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_type_codes: Option<Vec<String>>,
#[serde(rename = "services")]
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<String>>,
}
#[derive(Debug, PartialEq)]
pub enum DescribeAffectedEntitiesError {
InvalidPaginationToken(String),
UnsupportedLocale(String),
}
impl DescribeAffectedEntitiesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeAffectedEntitiesError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InvalidPaginationToken" => {
return RusotoError::Service(
DescribeAffectedEntitiesError::InvalidPaginationToken(err.msg),
)
}
"UnsupportedLocale" => {
return RusotoError::Service(DescribeAffectedEntitiesError::UnsupportedLocale(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeAffectedEntitiesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeAffectedEntitiesError {
fn description(&self) -> &str {
match *self {
DescribeAffectedEntitiesError::InvalidPaginationToken(ref cause) => cause,
DescribeAffectedEntitiesError::UnsupportedLocale(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeEntityAggregatesError {}
impl DescribeEntityAggregatesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeEntityAggregatesError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeEntityAggregatesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeEntityAggregatesError {
fn description(&self) -> &str {
match *self {}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeEventAggregatesError {
InvalidPaginationToken(String),
}
impl DescribeEventAggregatesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeEventAggregatesError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InvalidPaginationToken" => {
return RusotoError::Service(
DescribeEventAggregatesError::InvalidPaginationToken(err.msg),
)
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeEventAggregatesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeEventAggregatesError {
fn description(&self) -> &str {
match *self {
DescribeEventAggregatesError::InvalidPaginationToken(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeEventDetailsError {
UnsupportedLocale(String),
}
impl DescribeEventDetailsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeEventDetailsError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"UnsupportedLocale" => {
return RusotoError::Service(DescribeEventDetailsError::UnsupportedLocale(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeEventDetailsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeEventDetailsError {
fn description(&self) -> &str {
match *self {
DescribeEventDetailsError::UnsupportedLocale(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeEventTypesError {
InvalidPaginationToken(String),
UnsupportedLocale(String),
}
impl DescribeEventTypesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeEventTypesError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InvalidPaginationToken" => {
return RusotoError::Service(DescribeEventTypesError::InvalidPaginationToken(
err.msg,
))
}
"UnsupportedLocale" => {
return RusotoError::Service(DescribeEventTypesError::UnsupportedLocale(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeEventTypesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeEventTypesError {
fn description(&self) -> &str {
match *self {
DescribeEventTypesError::InvalidPaginationToken(ref cause) => cause,
DescribeEventTypesError::UnsupportedLocale(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeEventsError {
InvalidPaginationToken(String),
UnsupportedLocale(String),
}
impl DescribeEventsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeEventsError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InvalidPaginationToken" => {
return RusotoError::Service(DescribeEventsError::InvalidPaginationToken(
err.msg,
))
}
"UnsupportedLocale" => {
return RusotoError::Service(DescribeEventsError::UnsupportedLocale(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeEventsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeEventsError {
fn description(&self) -> &str {
match *self {
DescribeEventsError::InvalidPaginationToken(ref cause) => cause,
DescribeEventsError::UnsupportedLocale(ref cause) => cause,
}
}
}
pub trait AWSHealth {
fn describe_affected_entities(
&self,
input: DescribeAffectedEntitiesRequest,
) -> RusotoFuture<DescribeAffectedEntitiesResponse, DescribeAffectedEntitiesError>;
fn describe_entity_aggregates(
&self,
input: DescribeEntityAggregatesRequest,
) -> RusotoFuture<DescribeEntityAggregatesResponse, DescribeEntityAggregatesError>;
fn describe_event_aggregates(
&self,
input: DescribeEventAggregatesRequest,
) -> RusotoFuture<DescribeEventAggregatesResponse, DescribeEventAggregatesError>;
fn describe_event_details(
&self,
input: DescribeEventDetailsRequest,
) -> RusotoFuture<DescribeEventDetailsResponse, DescribeEventDetailsError>;
fn describe_event_types(
&self,
input: DescribeEventTypesRequest,
) -> RusotoFuture<DescribeEventTypesResponse, DescribeEventTypesError>;
fn describe_events(
&self,
input: DescribeEventsRequest,
) -> RusotoFuture<DescribeEventsResponse, DescribeEventsError>;
}
#[derive(Clone)]
pub struct AWSHealthClient {
client: Client,
region: region::Region,
}
impl AWSHealthClient {
pub fn new(region: region::Region) -> AWSHealthClient {
AWSHealthClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> AWSHealthClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
AWSHealthClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl AWSHealth for AWSHealthClient {
fn describe_affected_entities(
&self,
input: DescribeAffectedEntitiesRequest,
) -> RusotoFuture<DescribeAffectedEntitiesResponse, DescribeAffectedEntitiesError> {
let mut request = SignedRequest::new("POST", "health", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSHealth_20160804.DescribeAffectedEntities",
);
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeAffectedEntitiesResponse, _>()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeAffectedEntitiesError::from_response(response))
}))
}
})
}
fn describe_entity_aggregates(
&self,
input: DescribeEntityAggregatesRequest,
) -> RusotoFuture<DescribeEntityAggregatesResponse, DescribeEntityAggregatesError> {
let mut request = SignedRequest::new("POST", "health", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSHealth_20160804.DescribeEntityAggregates",
);
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeEntityAggregatesResponse, _>()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeEntityAggregatesError::from_response(response))
}))
}
})
}
fn describe_event_aggregates(
&self,
input: DescribeEventAggregatesRequest,
) -> RusotoFuture<DescribeEventAggregatesResponse, DescribeEventAggregatesError> {
let mut request = SignedRequest::new("POST", "health", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSHealth_20160804.DescribeEventAggregates");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeEventAggregatesResponse, _>()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeEventAggregatesError::from_response(response))
}))
}
})
}
fn describe_event_details(
&self,
input: DescribeEventDetailsRequest,
) -> RusotoFuture<DescribeEventDetailsResponse, DescribeEventDetailsError> {
let mut request = SignedRequest::new("POST", "health", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSHealth_20160804.DescribeEventDetails");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeEventDetailsResponse, _>()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DescribeEventDetailsError::from_response(response))
}),
)
}
})
}
fn describe_event_types(
&self,
input: DescribeEventTypesRequest,
) -> RusotoFuture<DescribeEventTypesResponse, DescribeEventTypesError> {
let mut request = SignedRequest::new("POST", "health", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSHealth_20160804.DescribeEventTypes");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeEventTypesResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeEventTypesError::from_response(response))),
)
}
})
}
fn describe_events(
&self,
input: DescribeEventsRequest,
) -> RusotoFuture<DescribeEventsResponse, DescribeEventsError> {
let mut request = SignedRequest::new("POST", "health", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSHealth_20160804.DescribeEvents");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeEventsResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeEventsError::from_response(response))),
)
}
})
}
}