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, Serialize)]
pub struct CreateVocabularyRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "Phrases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub phrases: Option<Vec<String>>,
#[serde(rename = "VocabularyFileUri")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_file_uri: Option<String>,
#[serde(rename = "VocabularyName")]
pub vocabulary_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateVocabularyResponse {
#[serde(rename = "FailureReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_reason: Option<String>,
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "LastModifiedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_time: Option<f64>,
#[serde(rename = "VocabularyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_name: Option<String>,
#[serde(rename = "VocabularyState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_state: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteTranscriptionJobRequest {
#[serde(rename = "TranscriptionJobName")]
pub transcription_job_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteVocabularyRequest {
#[serde(rename = "VocabularyName")]
pub vocabulary_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetTranscriptionJobRequest {
#[serde(rename = "TranscriptionJobName")]
pub transcription_job_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetTranscriptionJobResponse {
#[serde(rename = "TranscriptionJob")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcription_job: Option<TranscriptionJob>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetVocabularyRequest {
#[serde(rename = "VocabularyName")]
pub vocabulary_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetVocabularyResponse {
#[serde(rename = "DownloadUri")]
#[serde(skip_serializing_if = "Option::is_none")]
pub download_uri: Option<String>,
#[serde(rename = "FailureReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_reason: Option<String>,
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "LastModifiedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_time: Option<f64>,
#[serde(rename = "VocabularyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_name: Option<String>,
#[serde(rename = "VocabularyState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_state: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListTranscriptionJobsRequest {
#[serde(rename = "JobNameContains")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_name_contains: 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>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListTranscriptionJobsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "TranscriptionJobSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcription_job_summaries: Option<Vec<TranscriptionJobSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListVocabulariesRequest {
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NameContains")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name_contains: Option<String>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "StateEquals")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state_equals: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListVocabulariesResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "Vocabularies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabularies: Option<Vec<VocabularyInfo>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Media {
#[serde(rename = "MediaFileUri")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_file_uri: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Settings {
#[serde(rename = "ChannelIdentification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_identification: Option<bool>,
#[serde(rename = "MaxSpeakerLabels")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_speaker_labels: Option<i64>,
#[serde(rename = "ShowSpeakerLabels")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_speaker_labels: Option<bool>,
#[serde(rename = "VocabularyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartTranscriptionJobRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "Media")]
pub media: Media,
#[serde(rename = "MediaFormat")]
pub media_format: String,
#[serde(rename = "MediaSampleRateHertz")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_sample_rate_hertz: Option<i64>,
#[serde(rename = "OutputBucketName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_bucket_name: Option<String>,
#[serde(rename = "Settings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<Settings>,
#[serde(rename = "TranscriptionJobName")]
pub transcription_job_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartTranscriptionJobResponse {
#[serde(rename = "TranscriptionJob")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcription_job: Option<TranscriptionJob>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Transcript {
#[serde(rename = "TranscriptFileUri")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcript_file_uri: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TranscriptionJob {
#[serde(rename = "CompletionTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub completion_time: Option<f64>,
#[serde(rename = "CreationTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creation_time: Option<f64>,
#[serde(rename = "FailureReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_reason: Option<String>,
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "Media")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media: Option<Media>,
#[serde(rename = "MediaFormat")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_format: Option<String>,
#[serde(rename = "MediaSampleRateHertz")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_sample_rate_hertz: Option<i64>,
#[serde(rename = "Settings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<Settings>,
#[serde(rename = "Transcript")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcript: Option<Transcript>,
#[serde(rename = "TranscriptionJobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcription_job_name: Option<String>,
#[serde(rename = "TranscriptionJobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcription_job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TranscriptionJobSummary {
#[serde(rename = "CompletionTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub completion_time: Option<f64>,
#[serde(rename = "CreationTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creation_time: Option<f64>,
#[serde(rename = "FailureReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_reason: Option<String>,
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "OutputLocationType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub output_location_type: Option<String>,
#[serde(rename = "TranscriptionJobName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcription_job_name: Option<String>,
#[serde(rename = "TranscriptionJobStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcription_job_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateVocabularyRequest {
#[serde(rename = "LanguageCode")]
pub language_code: String,
#[serde(rename = "Phrases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub phrases: Option<Vec<String>>,
#[serde(rename = "VocabularyFileUri")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_file_uri: Option<String>,
#[serde(rename = "VocabularyName")]
pub vocabulary_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateVocabularyResponse {
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "LastModifiedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_time: Option<f64>,
#[serde(rename = "VocabularyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_name: Option<String>,
#[serde(rename = "VocabularyState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_state: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct VocabularyInfo {
#[serde(rename = "LanguageCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
#[serde(rename = "LastModifiedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_time: Option<f64>,
#[serde(rename = "VocabularyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_name: Option<String>,
#[serde(rename = "VocabularyState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vocabulary_state: Option<String>,
}
#[derive(Debug, PartialEq)]
pub enum CreateVocabularyError {
BadRequest(String),
Conflict(String),
InternalFailure(String),
LimitExceeded(String),
}
impl CreateVocabularyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateVocabularyError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(CreateVocabularyError::BadRequest(err.msg))
}
"ConflictException" => {
return RusotoError::Service(CreateVocabularyError::Conflict(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(CreateVocabularyError::InternalFailure(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(CreateVocabularyError::LimitExceeded(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CreateVocabularyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateVocabularyError {
fn description(&self) -> &str {
match *self {
CreateVocabularyError::BadRequest(ref cause) => cause,
CreateVocabularyError::Conflict(ref cause) => cause,
CreateVocabularyError::InternalFailure(ref cause) => cause,
CreateVocabularyError::LimitExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteTranscriptionJobError {
BadRequest(String),
InternalFailure(String),
LimitExceeded(String),
}
impl DeleteTranscriptionJobError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteTranscriptionJobError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(DeleteTranscriptionJobError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(DeleteTranscriptionJobError::InternalFailure(
err.msg,
))
}
"LimitExceededException" => {
return RusotoError::Service(DeleteTranscriptionJobError::LimitExceeded(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteTranscriptionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteTranscriptionJobError {
fn description(&self) -> &str {
match *self {
DeleteTranscriptionJobError::BadRequest(ref cause) => cause,
DeleteTranscriptionJobError::InternalFailure(ref cause) => cause,
DeleteTranscriptionJobError::LimitExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteVocabularyError {
BadRequest(String),
InternalFailure(String),
LimitExceeded(String),
NotFound(String),
}
impl DeleteVocabularyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteVocabularyError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(DeleteVocabularyError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(DeleteVocabularyError::InternalFailure(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(DeleteVocabularyError::LimitExceeded(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(DeleteVocabularyError::NotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteVocabularyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteVocabularyError {
fn description(&self) -> &str {
match *self {
DeleteVocabularyError::BadRequest(ref cause) => cause,
DeleteVocabularyError::InternalFailure(ref cause) => cause,
DeleteVocabularyError::LimitExceeded(ref cause) => cause,
DeleteVocabularyError::NotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetTranscriptionJobError {
BadRequest(String),
InternalFailure(String),
LimitExceeded(String),
NotFound(String),
}
impl GetTranscriptionJobError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetTranscriptionJobError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(GetTranscriptionJobError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(GetTranscriptionJobError::InternalFailure(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(GetTranscriptionJobError::LimitExceeded(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(GetTranscriptionJobError::NotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetTranscriptionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetTranscriptionJobError {
fn description(&self) -> &str {
match *self {
GetTranscriptionJobError::BadRequest(ref cause) => cause,
GetTranscriptionJobError::InternalFailure(ref cause) => cause,
GetTranscriptionJobError::LimitExceeded(ref cause) => cause,
GetTranscriptionJobError::NotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetVocabularyError {
BadRequest(String),
InternalFailure(String),
LimitExceeded(String),
NotFound(String),
}
impl GetVocabularyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetVocabularyError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(GetVocabularyError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(GetVocabularyError::InternalFailure(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(GetVocabularyError::LimitExceeded(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(GetVocabularyError::NotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetVocabularyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetVocabularyError {
fn description(&self) -> &str {
match *self {
GetVocabularyError::BadRequest(ref cause) => cause,
GetVocabularyError::InternalFailure(ref cause) => cause,
GetVocabularyError::LimitExceeded(ref cause) => cause,
GetVocabularyError::NotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListTranscriptionJobsError {
BadRequest(String),
InternalFailure(String),
LimitExceeded(String),
}
impl ListTranscriptionJobsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListTranscriptionJobsError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ListTranscriptionJobsError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(ListTranscriptionJobsError::InternalFailure(
err.msg,
))
}
"LimitExceededException" => {
return RusotoError::Service(ListTranscriptionJobsError::LimitExceeded(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListTranscriptionJobsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListTranscriptionJobsError {
fn description(&self) -> &str {
match *self {
ListTranscriptionJobsError::BadRequest(ref cause) => cause,
ListTranscriptionJobsError::InternalFailure(ref cause) => cause,
ListTranscriptionJobsError::LimitExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListVocabulariesError {
BadRequest(String),
InternalFailure(String),
LimitExceeded(String),
}
impl ListVocabulariesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListVocabulariesError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ListVocabulariesError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(ListVocabulariesError::InternalFailure(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(ListVocabulariesError::LimitExceeded(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListVocabulariesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListVocabulariesError {
fn description(&self) -> &str {
match *self {
ListVocabulariesError::BadRequest(ref cause) => cause,
ListVocabulariesError::InternalFailure(ref cause) => cause,
ListVocabulariesError::LimitExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartTranscriptionJobError {
BadRequest(String),
Conflict(String),
InternalFailure(String),
LimitExceeded(String),
}
impl StartTranscriptionJobError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<StartTranscriptionJobError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(StartTranscriptionJobError::BadRequest(err.msg))
}
"ConflictException" => {
return RusotoError::Service(StartTranscriptionJobError::Conflict(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(StartTranscriptionJobError::InternalFailure(
err.msg,
))
}
"LimitExceededException" => {
return RusotoError::Service(StartTranscriptionJobError::LimitExceeded(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for StartTranscriptionJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartTranscriptionJobError {
fn description(&self) -> &str {
match *self {
StartTranscriptionJobError::BadRequest(ref cause) => cause,
StartTranscriptionJobError::Conflict(ref cause) => cause,
StartTranscriptionJobError::InternalFailure(ref cause) => cause,
StartTranscriptionJobError::LimitExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateVocabularyError {
BadRequest(String),
Conflict(String),
InternalFailure(String),
LimitExceeded(String),
NotFound(String),
}
impl UpdateVocabularyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UpdateVocabularyError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(UpdateVocabularyError::BadRequest(err.msg))
}
"ConflictException" => {
return RusotoError::Service(UpdateVocabularyError::Conflict(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(UpdateVocabularyError::InternalFailure(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(UpdateVocabularyError::LimitExceeded(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(UpdateVocabularyError::NotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UpdateVocabularyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateVocabularyError {
fn description(&self) -> &str {
match *self {
UpdateVocabularyError::BadRequest(ref cause) => cause,
UpdateVocabularyError::Conflict(ref cause) => cause,
UpdateVocabularyError::InternalFailure(ref cause) => cause,
UpdateVocabularyError::LimitExceeded(ref cause) => cause,
UpdateVocabularyError::NotFound(ref cause) => cause,
}
}
}
pub trait Transcribe {
fn create_vocabulary(
&self,
input: CreateVocabularyRequest,
) -> RusotoFuture<CreateVocabularyResponse, CreateVocabularyError>;
fn delete_transcription_job(
&self,
input: DeleteTranscriptionJobRequest,
) -> RusotoFuture<(), DeleteTranscriptionJobError>;
fn delete_vocabulary(
&self,
input: DeleteVocabularyRequest,
) -> RusotoFuture<(), DeleteVocabularyError>;
fn get_transcription_job(
&self,
input: GetTranscriptionJobRequest,
) -> RusotoFuture<GetTranscriptionJobResponse, GetTranscriptionJobError>;
fn get_vocabulary(
&self,
input: GetVocabularyRequest,
) -> RusotoFuture<GetVocabularyResponse, GetVocabularyError>;
fn list_transcription_jobs(
&self,
input: ListTranscriptionJobsRequest,
) -> RusotoFuture<ListTranscriptionJobsResponse, ListTranscriptionJobsError>;
fn list_vocabularies(
&self,
input: ListVocabulariesRequest,
) -> RusotoFuture<ListVocabulariesResponse, ListVocabulariesError>;
fn start_transcription_job(
&self,
input: StartTranscriptionJobRequest,
) -> RusotoFuture<StartTranscriptionJobResponse, StartTranscriptionJobError>;
fn update_vocabulary(
&self,
input: UpdateVocabularyRequest,
) -> RusotoFuture<UpdateVocabularyResponse, UpdateVocabularyError>;
}
#[derive(Clone)]
pub struct TranscribeClient {
client: Client,
region: region::Region,
}
impl TranscribeClient {
pub fn new(region: region::Region) -> TranscribeClient {
TranscribeClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> TranscribeClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
TranscribeClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl Transcribe for TranscribeClient {
fn create_vocabulary(
&self,
input: CreateVocabularyRequest,
) -> RusotoFuture<CreateVocabularyResponse, CreateVocabularyError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.CreateVocabulary");
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::<CreateVocabularyResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateVocabularyError::from_response(response))),
)
}
})
}
fn delete_transcription_job(
&self,
input: DeleteTranscriptionJobRequest,
) -> RusotoFuture<(), DeleteTranscriptionJobError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.DeleteTranscriptionJob");
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(future::ok(::std::mem::drop(response)))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DeleteTranscriptionJobError::from_response(response))
}),
)
}
})
}
fn delete_vocabulary(
&self,
input: DeleteVocabularyRequest,
) -> RusotoFuture<(), DeleteVocabularyError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.DeleteVocabulary");
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(future::ok(::std::mem::drop(response)))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteVocabularyError::from_response(response))),
)
}
})
}
fn get_transcription_job(
&self,
input: GetTranscriptionJobRequest,
) -> RusotoFuture<GetTranscriptionJobResponse, GetTranscriptionJobError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.GetTranscriptionJob");
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::<GetTranscriptionJobResponse, _>()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetTranscriptionJobError::from_response(response))
}),
)
}
})
}
fn get_vocabulary(
&self,
input: GetVocabularyRequest,
) -> RusotoFuture<GetVocabularyResponse, GetVocabularyError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.GetVocabulary");
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::<GetVocabularyResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetVocabularyError::from_response(response))),
)
}
})
}
fn list_transcription_jobs(
&self,
input: ListTranscriptionJobsRequest,
) -> RusotoFuture<ListTranscriptionJobsResponse, ListTranscriptionJobsError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.ListTranscriptionJobs");
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::<ListTranscriptionJobsResponse, _>()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListTranscriptionJobsError::from_response(response))
}),
)
}
})
}
fn list_vocabularies(
&self,
input: ListVocabulariesRequest,
) -> RusotoFuture<ListVocabulariesResponse, ListVocabulariesError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.ListVocabularies");
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::<ListVocabulariesResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListVocabulariesError::from_response(response))),
)
}
})
}
fn start_transcription_job(
&self,
input: StartTranscriptionJobRequest,
) -> RusotoFuture<StartTranscriptionJobResponse, StartTranscriptionJobError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.StartTranscriptionJob");
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::<StartTranscriptionJobResponse, _>()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(StartTranscriptionJobError::from_response(response))
}),
)
}
})
}
fn update_vocabulary(
&self,
input: UpdateVocabularyRequest,
) -> RusotoFuture<UpdateVocabularyResponse, UpdateVocabularyError> {
let mut request = SignedRequest::new("POST", "transcribe", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "Transcribe.UpdateVocabulary");
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::<UpdateVocabularyResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateVocabularyError::from_response(response))),
)
}
})
}
}