use std::error::Error;
use std::fmt;
use async_trait::async_trait;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError};
use rusoto_core::param::{Params, ServiceParams};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
use serde_json;
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct CallInstructionsMessageType {
#[serde(rename = "Text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct CloudWatchLogsDestination {
#[serde(rename = "IamRoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub iam_role_arn: Option<String>,
#[serde(rename = "LogGroupArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub log_group_arn: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct CreateConfigurationSetEventDestinationRequest {
#[serde(rename = "ConfigurationSetName")]
pub configuration_set_name: String,
#[serde(rename = "EventDestination")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_destination: Option<EventDestinationDefinition>,
#[serde(rename = "EventDestinationName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_destination_name: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct CreateConfigurationSetEventDestinationResponse {}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct CreateConfigurationSetRequest {
#[serde(rename = "ConfigurationSetName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_set_name: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct CreateConfigurationSetResponse {}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DeleteConfigurationSetEventDestinationRequest {
#[serde(rename = "ConfigurationSetName")]
pub configuration_set_name: String,
#[serde(rename = "EventDestinationName")]
pub event_destination_name: String,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct DeleteConfigurationSetEventDestinationResponse {}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DeleteConfigurationSetRequest {
#[serde(rename = "ConfigurationSetName")]
pub configuration_set_name: String,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct DeleteConfigurationSetResponse {}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct EventDestination {
#[serde(rename = "CloudWatchLogsDestination")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cloud_watch_logs_destination: Option<CloudWatchLogsDestination>,
#[serde(rename = "Enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
#[serde(rename = "KinesisFirehoseDestination")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kinesis_firehose_destination: Option<KinesisFirehoseDestination>,
#[serde(rename = "MatchingEventTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub matching_event_types: Option<Vec<String>>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "SnsDestination")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sns_destination: Option<SnsDestination>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct EventDestinationDefinition {
#[serde(rename = "CloudWatchLogsDestination")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cloud_watch_logs_destination: Option<CloudWatchLogsDestination>,
#[serde(rename = "Enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
#[serde(rename = "KinesisFirehoseDestination")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kinesis_firehose_destination: Option<KinesisFirehoseDestination>,
#[serde(rename = "MatchingEventTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub matching_event_types: Option<Vec<String>>,
#[serde(rename = "SnsDestination")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sns_destination: Option<SnsDestination>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct GetConfigurationSetEventDestinationsRequest {
#[serde(rename = "ConfigurationSetName")]
pub configuration_set_name: String,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct GetConfigurationSetEventDestinationsResponse {
#[serde(rename = "EventDestinations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_destinations: Option<Vec<EventDestination>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct KinesisFirehoseDestination {
#[serde(rename = "DeliveryStreamArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub delivery_stream_arn: Option<String>,
#[serde(rename = "IamRoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub iam_role_arn: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ListConfigurationSetsRequest {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "PageSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub page_size: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ListConfigurationSetsResponse {
#[serde(rename = "ConfigurationSets")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_sets: Option<Vec<String>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct PlainTextMessageType {
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "Text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(rename = "VoiceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_id: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct SSMLMessageType {
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "Text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(rename = "VoiceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_id: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct SendVoiceMessageRequest {
#[serde(rename = "CallerId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub caller_id: Option<String>,
#[serde(rename = "ConfigurationSetName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_set_name: Option<String>,
#[serde(rename = "Content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<VoiceMessageContent>,
#[serde(rename = "DestinationPhoneNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub destination_phone_number: Option<String>,
#[serde(rename = "OriginationPhoneNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub origination_phone_number: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SendVoiceMessageResponse {
#[serde(rename = "MessageId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message_id: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct SnsDestination {
#[serde(rename = "TopicArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub topic_arn: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct UpdateConfigurationSetEventDestinationRequest {
#[serde(rename = "ConfigurationSetName")]
pub configuration_set_name: String,
#[serde(rename = "EventDestination")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_destination: Option<EventDestinationDefinition>,
#[serde(rename = "EventDestinationName")]
pub event_destination_name: String,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct UpdateConfigurationSetEventDestinationResponse {}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct VoiceMessageContent {
#[serde(rename = "CallInstructionsMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub call_instructions_message: Option<CallInstructionsMessageType>,
#[serde(rename = "PlainTextMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plain_text_message: Option<PlainTextMessageType>,
#[serde(rename = "SSMLMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ssml_message: Option<SSMLMessageType>,
}
#[derive(Debug, PartialEq)]
pub enum CreateConfigurationSetError {
AlreadyExists(String),
BadRequest(String),
InternalServiceError(String),
LimitExceeded(String),
TooManyRequests(String),
}
impl CreateConfigurationSetError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateConfigurationSetError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"AlreadyExistsException" => {
return RusotoError::Service(CreateConfigurationSetError::AlreadyExists(
err.msg,
))
}
"BadRequestException" => {
return RusotoError::Service(CreateConfigurationSetError::BadRequest(err.msg))
}
"InternalServiceErrorException" => {
return RusotoError::Service(CreateConfigurationSetError::InternalServiceError(
err.msg,
))
}
"LimitExceededException" => {
return RusotoError::Service(CreateConfigurationSetError::LimitExceeded(
err.msg,
))
}
"TooManyRequestsException" => {
return RusotoError::Service(CreateConfigurationSetError::TooManyRequests(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for CreateConfigurationSetError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
CreateConfigurationSetError::AlreadyExists(ref cause) => write!(f, "{}", cause),
CreateConfigurationSetError::BadRequest(ref cause) => write!(f, "{}", cause),
CreateConfigurationSetError::InternalServiceError(ref cause) => write!(f, "{}", cause),
CreateConfigurationSetError::LimitExceeded(ref cause) => write!(f, "{}", cause),
CreateConfigurationSetError::TooManyRequests(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for CreateConfigurationSetError {}
#[derive(Debug, PartialEq)]
pub enum CreateConfigurationSetEventDestinationError {
AlreadyExists(String),
BadRequest(String),
InternalServiceError(String),
LimitExceeded(String),
NotFound(String),
TooManyRequests(String),
}
impl CreateConfigurationSetEventDestinationError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<CreateConfigurationSetEventDestinationError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"AlreadyExistsException" => {
return RusotoError::Service(
CreateConfigurationSetEventDestinationError::AlreadyExists(err.msg),
)
}
"BadRequestException" => {
return RusotoError::Service(
CreateConfigurationSetEventDestinationError::BadRequest(err.msg),
)
}
"InternalServiceErrorException" => {
return RusotoError::Service(
CreateConfigurationSetEventDestinationError::InternalServiceError(err.msg),
)
}
"LimitExceededException" => {
return RusotoError::Service(
CreateConfigurationSetEventDestinationError::LimitExceeded(err.msg),
)
}
"NotFoundException" => {
return RusotoError::Service(
CreateConfigurationSetEventDestinationError::NotFound(err.msg),
)
}
"TooManyRequestsException" => {
return RusotoError::Service(
CreateConfigurationSetEventDestinationError::TooManyRequests(err.msg),
)
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for CreateConfigurationSetEventDestinationError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
CreateConfigurationSetEventDestinationError::AlreadyExists(ref cause) => {
write!(f, "{}", cause)
}
CreateConfigurationSetEventDestinationError::BadRequest(ref cause) => {
write!(f, "{}", cause)
}
CreateConfigurationSetEventDestinationError::InternalServiceError(ref cause) => {
write!(f, "{}", cause)
}
CreateConfigurationSetEventDestinationError::LimitExceeded(ref cause) => {
write!(f, "{}", cause)
}
CreateConfigurationSetEventDestinationError::NotFound(ref cause) => {
write!(f, "{}", cause)
}
CreateConfigurationSetEventDestinationError::TooManyRequests(ref cause) => {
write!(f, "{}", cause)
}
}
}
}
impl Error for CreateConfigurationSetEventDestinationError {}
#[derive(Debug, PartialEq)]
pub enum DeleteConfigurationSetError {
BadRequest(String),
InternalServiceError(String),
NotFound(String),
TooManyRequests(String),
}
impl DeleteConfigurationSetError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteConfigurationSetError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(DeleteConfigurationSetError::BadRequest(err.msg))
}
"InternalServiceErrorException" => {
return RusotoError::Service(DeleteConfigurationSetError::InternalServiceError(
err.msg,
))
}
"NotFoundException" => {
return RusotoError::Service(DeleteConfigurationSetError::NotFound(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(DeleteConfigurationSetError::TooManyRequests(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DeleteConfigurationSetError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DeleteConfigurationSetError::BadRequest(ref cause) => write!(f, "{}", cause),
DeleteConfigurationSetError::InternalServiceError(ref cause) => write!(f, "{}", cause),
DeleteConfigurationSetError::NotFound(ref cause) => write!(f, "{}", cause),
DeleteConfigurationSetError::TooManyRequests(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DeleteConfigurationSetError {}
#[derive(Debug, PartialEq)]
pub enum DeleteConfigurationSetEventDestinationError {
BadRequest(String),
InternalServiceError(String),
NotFound(String),
TooManyRequests(String),
}
impl DeleteConfigurationSetEventDestinationError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<DeleteConfigurationSetEventDestinationError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(
DeleteConfigurationSetEventDestinationError::BadRequest(err.msg),
)
}
"InternalServiceErrorException" => {
return RusotoError::Service(
DeleteConfigurationSetEventDestinationError::InternalServiceError(err.msg),
)
}
"NotFoundException" => {
return RusotoError::Service(
DeleteConfigurationSetEventDestinationError::NotFound(err.msg),
)
}
"TooManyRequestsException" => {
return RusotoError::Service(
DeleteConfigurationSetEventDestinationError::TooManyRequests(err.msg),
)
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DeleteConfigurationSetEventDestinationError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DeleteConfigurationSetEventDestinationError::BadRequest(ref cause) => {
write!(f, "{}", cause)
}
DeleteConfigurationSetEventDestinationError::InternalServiceError(ref cause) => {
write!(f, "{}", cause)
}
DeleteConfigurationSetEventDestinationError::NotFound(ref cause) => {
write!(f, "{}", cause)
}
DeleteConfigurationSetEventDestinationError::TooManyRequests(ref cause) => {
write!(f, "{}", cause)
}
}
}
}
impl Error for DeleteConfigurationSetEventDestinationError {}
#[derive(Debug, PartialEq)]
pub enum GetConfigurationSetEventDestinationsError {
BadRequest(String),
InternalServiceError(String),
NotFound(String),
TooManyRequests(String),
}
impl GetConfigurationSetEventDestinationsError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<GetConfigurationSetEventDestinationsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(
GetConfigurationSetEventDestinationsError::BadRequest(err.msg),
)
}
"InternalServiceErrorException" => {
return RusotoError::Service(
GetConfigurationSetEventDestinationsError::InternalServiceError(err.msg),
)
}
"NotFoundException" => {
return RusotoError::Service(
GetConfigurationSetEventDestinationsError::NotFound(err.msg),
)
}
"TooManyRequestsException" => {
return RusotoError::Service(
GetConfigurationSetEventDestinationsError::TooManyRequests(err.msg),
)
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for GetConfigurationSetEventDestinationsError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
GetConfigurationSetEventDestinationsError::BadRequest(ref cause) => {
write!(f, "{}", cause)
}
GetConfigurationSetEventDestinationsError::InternalServiceError(ref cause) => {
write!(f, "{}", cause)
}
GetConfigurationSetEventDestinationsError::NotFound(ref cause) => {
write!(f, "{}", cause)
}
GetConfigurationSetEventDestinationsError::TooManyRequests(ref cause) => {
write!(f, "{}", cause)
}
}
}
}
impl Error for GetConfigurationSetEventDestinationsError {}
#[derive(Debug, PartialEq)]
pub enum ListConfigurationSetsError {
BadRequest(String),
InternalServiceError(String),
TooManyRequests(String),
}
impl ListConfigurationSetsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListConfigurationSetsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ListConfigurationSetsError::BadRequest(err.msg))
}
"InternalServiceErrorException" => {
return RusotoError::Service(ListConfigurationSetsError::InternalServiceError(
err.msg,
))
}
"TooManyRequestsException" => {
return RusotoError::Service(ListConfigurationSetsError::TooManyRequests(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for ListConfigurationSetsError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ListConfigurationSetsError::BadRequest(ref cause) => write!(f, "{}", cause),
ListConfigurationSetsError::InternalServiceError(ref cause) => write!(f, "{}", cause),
ListConfigurationSetsError::TooManyRequests(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for ListConfigurationSetsError {}
#[derive(Debug, PartialEq)]
pub enum SendVoiceMessageError {
BadRequest(String),
InternalServiceError(String),
TooManyRequests(String),
}
impl SendVoiceMessageError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<SendVoiceMessageError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(SendVoiceMessageError::BadRequest(err.msg))
}
"InternalServiceErrorException" => {
return RusotoError::Service(SendVoiceMessageError::InternalServiceError(
err.msg,
))
}
"TooManyRequestsException" => {
return RusotoError::Service(SendVoiceMessageError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for SendVoiceMessageError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
SendVoiceMessageError::BadRequest(ref cause) => write!(f, "{}", cause),
SendVoiceMessageError::InternalServiceError(ref cause) => write!(f, "{}", cause),
SendVoiceMessageError::TooManyRequests(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for SendVoiceMessageError {}
#[derive(Debug, PartialEq)]
pub enum UpdateConfigurationSetEventDestinationError {
BadRequest(String),
InternalServiceError(String),
NotFound(String),
TooManyRequests(String),
}
impl UpdateConfigurationSetEventDestinationError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<UpdateConfigurationSetEventDestinationError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(
UpdateConfigurationSetEventDestinationError::BadRequest(err.msg),
)
}
"InternalServiceErrorException" => {
return RusotoError::Service(
UpdateConfigurationSetEventDestinationError::InternalServiceError(err.msg),
)
}
"NotFoundException" => {
return RusotoError::Service(
UpdateConfigurationSetEventDestinationError::NotFound(err.msg),
)
}
"TooManyRequestsException" => {
return RusotoError::Service(
UpdateConfigurationSetEventDestinationError::TooManyRequests(err.msg),
)
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for UpdateConfigurationSetEventDestinationError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
UpdateConfigurationSetEventDestinationError::BadRequest(ref cause) => {
write!(f, "{}", cause)
}
UpdateConfigurationSetEventDestinationError::InternalServiceError(ref cause) => {
write!(f, "{}", cause)
}
UpdateConfigurationSetEventDestinationError::NotFound(ref cause) => {
write!(f, "{}", cause)
}
UpdateConfigurationSetEventDestinationError::TooManyRequests(ref cause) => {
write!(f, "{}", cause)
}
}
}
}
impl Error for UpdateConfigurationSetEventDestinationError {}
#[async_trait]
pub trait SmsVoice {
async fn create_configuration_set(
&self,
input: CreateConfigurationSetRequest,
) -> Result<CreateConfigurationSetResponse, RusotoError<CreateConfigurationSetError>>;
async fn create_configuration_set_event_destination(
&self,
input: CreateConfigurationSetEventDestinationRequest,
) -> Result<
CreateConfigurationSetEventDestinationResponse,
RusotoError<CreateConfigurationSetEventDestinationError>,
>;
async fn delete_configuration_set(
&self,
input: DeleteConfigurationSetRequest,
) -> Result<DeleteConfigurationSetResponse, RusotoError<DeleteConfigurationSetError>>;
async fn delete_configuration_set_event_destination(
&self,
input: DeleteConfigurationSetEventDestinationRequest,
) -> Result<
DeleteConfigurationSetEventDestinationResponse,
RusotoError<DeleteConfigurationSetEventDestinationError>,
>;
async fn get_configuration_set_event_destinations(
&self,
input: GetConfigurationSetEventDestinationsRequest,
) -> Result<
GetConfigurationSetEventDestinationsResponse,
RusotoError<GetConfigurationSetEventDestinationsError>,
>;
async fn list_configuration_sets(
&self,
input: ListConfigurationSetsRequest,
) -> Result<ListConfigurationSetsResponse, RusotoError<ListConfigurationSetsError>>;
async fn send_voice_message(
&self,
input: SendVoiceMessageRequest,
) -> Result<SendVoiceMessageResponse, RusotoError<SendVoiceMessageError>>;
async fn update_configuration_set_event_destination(
&self,
input: UpdateConfigurationSetEventDestinationRequest,
) -> Result<
UpdateConfigurationSetEventDestinationResponse,
RusotoError<UpdateConfigurationSetEventDestinationError>,
>;
}
#[derive(Clone)]
pub struct SmsVoiceClient {
client: Client,
region: region::Region,
}
impl SmsVoiceClient {
pub fn new(region: region::Region) -> SmsVoiceClient {
SmsVoiceClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> SmsVoiceClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
D: DispatchSignedRequest + Send + Sync + 'static,
{
SmsVoiceClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
pub fn new_with_client(client: Client, region: region::Region) -> SmsVoiceClient {
SmsVoiceClient { client, region }
}
}
#[async_trait]
impl SmsVoice for SmsVoiceClient {
#[allow(unused_mut)]
async fn create_configuration_set(
&self,
input: CreateConfigurationSetRequest,
) -> Result<CreateConfigurationSetResponse, RusotoError<CreateConfigurationSetError>> {
let request_uri = "/v1/sms-voice/configuration-sets";
let mut request = SignedRequest::new("POST", "sms-voice", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("sms-voice.pinpoint".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.as_u16() == 200 {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<CreateConfigurationSetResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(CreateConfigurationSetError::from_response(response))
}
}
#[allow(unused_mut)]
async fn create_configuration_set_event_destination(
&self,
input: CreateConfigurationSetEventDestinationRequest,
) -> Result<
CreateConfigurationSetEventDestinationResponse,
RusotoError<CreateConfigurationSetEventDestinationError>,
> {
let request_uri = format!(
"/v1/sms-voice/configuration-sets/{configuration_set_name}/event-destinations",
configuration_set_name = input.configuration_set_name
);
let mut request = SignedRequest::new("POST", "sms-voice", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("sms-voice.pinpoint".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.as_u16() == 200 {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<CreateConfigurationSetEventDestinationResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(CreateConfigurationSetEventDestinationError::from_response(
response,
))
}
}
#[allow(unused_mut)]
async fn delete_configuration_set(
&self,
input: DeleteConfigurationSetRequest,
) -> Result<DeleteConfigurationSetResponse, RusotoError<DeleteConfigurationSetError>> {
let request_uri = format!(
"/v1/sms-voice/configuration-sets/{configuration_set_name}",
configuration_set_name = input.configuration_set_name
);
let mut request = SignedRequest::new("DELETE", "sms-voice", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("sms-voice.pinpoint".to_string());
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.as_u16() == 200 {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteConfigurationSetResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DeleteConfigurationSetError::from_response(response))
}
}
#[allow(unused_mut)]
async fn delete_configuration_set_event_destination(
&self,
input: DeleteConfigurationSetEventDestinationRequest,
) -> Result<
DeleteConfigurationSetEventDestinationResponse,
RusotoError<DeleteConfigurationSetEventDestinationError>,
> {
let request_uri = format!("/v1/sms-voice/configuration-sets/{configuration_set_name}/event-destinations/{event_destination_name}", configuration_set_name = input.configuration_set_name, event_destination_name = input.event_destination_name);
let mut request = SignedRequest::new("DELETE", "sms-voice", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("sms-voice.pinpoint".to_string());
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.as_u16() == 200 {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteConfigurationSetEventDestinationResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DeleteConfigurationSetEventDestinationError::from_response(
response,
))
}
}
#[allow(unused_mut)]
async fn get_configuration_set_event_destinations(
&self,
input: GetConfigurationSetEventDestinationsRequest,
) -> Result<
GetConfigurationSetEventDestinationsResponse,
RusotoError<GetConfigurationSetEventDestinationsError>,
> {
let request_uri = format!(
"/v1/sms-voice/configuration-sets/{configuration_set_name}/event-destinations",
configuration_set_name = input.configuration_set_name
);
let mut request = SignedRequest::new("GET", "sms-voice", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("sms-voice.pinpoint".to_string());
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.as_u16() == 200 {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<GetConfigurationSetEventDestinationsResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(GetConfigurationSetEventDestinationsError::from_response(
response,
))
}
}
#[allow(unused_mut)]
async fn list_configuration_sets(
&self,
input: ListConfigurationSetsRequest,
) -> Result<ListConfigurationSetsResponse, RusotoError<ListConfigurationSetsError>> {
let request_uri = "/v1/sms-voice/configuration-sets";
let mut request = SignedRequest::new("GET", "sms-voice", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("sms-voice.pinpoint".to_string());
let mut params = Params::new();
if let Some(ref x) = input.next_token {
params.put("NextToken", x);
}
if let Some(ref x) = input.page_size {
params.put("PageSize", x);
}
request.set_params(params);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.as_u16() == 200 {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListConfigurationSetsResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(ListConfigurationSetsError::from_response(response))
}
}
#[allow(unused_mut)]
async fn send_voice_message(
&self,
input: SendVoiceMessageRequest,
) -> Result<SendVoiceMessageResponse, RusotoError<SendVoiceMessageError>> {
let request_uri = "/v1/sms-voice/voice/message";
let mut request = SignedRequest::new("POST", "sms-voice", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("sms-voice.pinpoint".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.as_u16() == 200 {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<SendVoiceMessageResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(SendVoiceMessageError::from_response(response))
}
}
#[allow(unused_mut)]
async fn update_configuration_set_event_destination(
&self,
input: UpdateConfigurationSetEventDestinationRequest,
) -> Result<
UpdateConfigurationSetEventDestinationResponse,
RusotoError<UpdateConfigurationSetEventDestinationError>,
> {
let request_uri = format!("/v1/sms-voice/configuration-sets/{configuration_set_name}/event-destinations/{event_destination_name}", configuration_set_name = input.configuration_set_name, event_destination_name = input.event_destination_name);
let mut request = SignedRequest::new("PUT", "sms-voice", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("sms-voice.pinpoint".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.as_u16() == 200 {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<UpdateConfigurationSetEventDestinationResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(UpdateConfigurationSetEventDestinationError::from_response(
response,
))
}
}
}