use std::fmt::Write;
pub mod delete_lexicon_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) name: std::option::Option<std::string::String>,
}
impl Builder {
pub fn name(mut self, input: impl Into<std::string::String>) -> Self {
self.name = Some(input.into());
self
}
pub fn set_name(mut self, input: std::option::Option<std::string::String>) -> Self {
self.name = input;
self
}
pub fn build(
self,
) -> Result<crate::input::DeleteLexiconInput, aws_smithy_http::operation::error::BuildError>
{
Ok(crate::input::DeleteLexiconInput { name: self.name })
}
}
}
impl DeleteLexiconInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::DeleteLexicon,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::DeleteLexiconInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let input_1 = &_input.name;
let input_1 = input_1.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"name",
"cannot be empty or unset",
)
})?;
let name = aws_smithy_http::label::fmt_string(
input_1,
aws_smithy_http::label::EncodingStrategy::Default,
);
if name.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"name",
"cannot be empty or unset",
),
);
}
write!(output, "/v1/lexicons/{Name}", Name = name)
.expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::DeleteLexiconInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("DELETE").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::DeleteLexicon::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"DeleteLexicon",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::delete_lexicon_input::Builder {
crate::input::delete_lexicon_input::Builder::default()
}
}
pub mod describe_voices_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) engine: std::option::Option<crate::model::Engine>,
pub(crate) language_code: std::option::Option<crate::model::LanguageCode>,
pub(crate) include_additional_language_codes: std::option::Option<bool>,
pub(crate) next_token: std::option::Option<std::string::String>,
}
impl Builder {
pub fn engine(mut self, input: crate::model::Engine) -> Self {
self.engine = Some(input);
self
}
pub fn set_engine(mut self, input: std::option::Option<crate::model::Engine>) -> Self {
self.engine = input;
self
}
pub fn language_code(mut self, input: crate::model::LanguageCode) -> Self {
self.language_code = Some(input);
self
}
pub fn set_language_code(
mut self,
input: std::option::Option<crate::model::LanguageCode>,
) -> Self {
self.language_code = input;
self
}
pub fn include_additional_language_codes(mut self, input: bool) -> Self {
self.include_additional_language_codes = Some(input);
self
}
pub fn set_include_additional_language_codes(
mut self,
input: std::option::Option<bool>,
) -> Self {
self.include_additional_language_codes = input;
self
}
pub fn next_token(mut self, input: impl Into<std::string::String>) -> Self {
self.next_token = Some(input.into());
self
}
pub fn set_next_token(mut self, input: std::option::Option<std::string::String>) -> Self {
self.next_token = input;
self
}
pub fn build(
self,
) -> Result<crate::input::DescribeVoicesInput, aws_smithy_http::operation::error::BuildError>
{
Ok(crate::input::DescribeVoicesInput {
engine: self.engine,
language_code: self.language_code,
include_additional_language_codes: self
.include_additional_language_codes
.unwrap_or_default(),
next_token: self.next_token,
})
}
}
}
impl DescribeVoicesInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::DescribeVoices,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::DescribeVoicesInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/v1/voices").expect("formatting should succeed");
Ok(())
}
fn uri_query(
_input: &crate::input::DescribeVoicesInput,
mut output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let mut query = aws_smithy_http::query::Writer::new(&mut output);
if let Some(inner_2) = &_input.engine {
{
query.push_kv("Engine", &aws_smithy_http::query::fmt_string(&inner_2));
}
}
if let Some(inner_3) = &_input.language_code {
{
query.push_kv(
"LanguageCode",
&aws_smithy_http::query::fmt_string(&inner_3),
);
}
}
if _input.include_additional_language_codes {
query.push_kv(
"IncludeAdditionalLanguageCodes",
aws_smithy_types::primitive::Encoder::from(
_input.include_additional_language_codes,
)
.encode(),
);
}
if let Some(inner_4) = &_input.next_token {
{
query.push_kv("NextToken", &aws_smithy_http::query::fmt_string(&inner_4));
}
}
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::DescribeVoicesInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
uri_query(input, &mut uri)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::DescribeVoices::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"DescribeVoices",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::describe_voices_input::Builder {
crate::input::describe_voices_input::Builder::default()
}
}
pub mod get_lexicon_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) name: std::option::Option<std::string::String>,
}
impl Builder {
pub fn name(mut self, input: impl Into<std::string::String>) -> Self {
self.name = Some(input.into());
self
}
pub fn set_name(mut self, input: std::option::Option<std::string::String>) -> Self {
self.name = input;
self
}
pub fn build(
self,
) -> Result<crate::input::GetLexiconInput, aws_smithy_http::operation::error::BuildError>
{
Ok(crate::input::GetLexiconInput { name: self.name })
}
}
}
impl GetLexiconInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::GetLexicon,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::GetLexiconInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let input_5 = &_input.name;
let input_5 = input_5.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"name",
"cannot be empty or unset",
)
})?;
let name = aws_smithy_http::label::fmt_string(
input_5,
aws_smithy_http::label::EncodingStrategy::Default,
);
if name.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"name",
"cannot be empty or unset",
),
);
}
write!(output, "/v1/lexicons/{Name}", Name = name)
.expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::GetLexiconInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::GetLexicon::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"GetLexicon",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::get_lexicon_input::Builder {
crate::input::get_lexicon_input::Builder::default()
}
}
pub mod get_speech_synthesis_task_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) task_id: std::option::Option<std::string::String>,
}
impl Builder {
pub fn task_id(mut self, input: impl Into<std::string::String>) -> Self {
self.task_id = Some(input.into());
self
}
pub fn set_task_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.task_id = input;
self
}
pub fn build(
self,
) -> Result<
crate::input::GetSpeechSynthesisTaskInput,
aws_smithy_http::operation::error::BuildError,
> {
Ok(crate::input::GetSpeechSynthesisTaskInput {
task_id: self.task_id,
})
}
}
}
impl GetSpeechSynthesisTaskInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::GetSpeechSynthesisTask,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::GetSpeechSynthesisTaskInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let input_6 = &_input.task_id;
let input_6 = input_6.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"task_id",
"cannot be empty or unset",
)
})?;
let task_id = aws_smithy_http::label::fmt_string(
input_6,
aws_smithy_http::label::EncodingStrategy::Default,
);
if task_id.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"task_id",
"cannot be empty or unset",
),
);
}
write!(output, "/v1/synthesisTasks/{TaskId}", TaskId = task_id)
.expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::GetSpeechSynthesisTaskInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::GetSpeechSynthesisTask::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"GetSpeechSynthesisTask",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::get_speech_synthesis_task_input::Builder {
crate::input::get_speech_synthesis_task_input::Builder::default()
}
}
pub mod list_lexicons_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) next_token: std::option::Option<std::string::String>,
}
impl Builder {
pub fn next_token(mut self, input: impl Into<std::string::String>) -> Self {
self.next_token = Some(input.into());
self
}
pub fn set_next_token(mut self, input: std::option::Option<std::string::String>) -> Self {
self.next_token = input;
self
}
pub fn build(
self,
) -> Result<crate::input::ListLexiconsInput, aws_smithy_http::operation::error::BuildError>
{
Ok(crate::input::ListLexiconsInput {
next_token: self.next_token,
})
}
}
}
impl ListLexiconsInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::ListLexicons,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::ListLexiconsInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/v1/lexicons").expect("formatting should succeed");
Ok(())
}
fn uri_query(
_input: &crate::input::ListLexiconsInput,
mut output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let mut query = aws_smithy_http::query::Writer::new(&mut output);
if let Some(inner_7) = &_input.next_token {
{
query.push_kv("NextToken", &aws_smithy_http::query::fmt_string(&inner_7));
}
}
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::ListLexiconsInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
uri_query(input, &mut uri)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::ListLexicons::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"ListLexicons",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::list_lexicons_input::Builder {
crate::input::list_lexicons_input::Builder::default()
}
}
pub mod list_speech_synthesis_tasks_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) max_results: std::option::Option<i32>,
pub(crate) next_token: std::option::Option<std::string::String>,
pub(crate) status: std::option::Option<crate::model::TaskStatus>,
}
impl Builder {
pub fn max_results(mut self, input: i32) -> Self {
self.max_results = Some(input);
self
}
pub fn set_max_results(mut self, input: std::option::Option<i32>) -> Self {
self.max_results = input;
self
}
pub fn next_token(mut self, input: impl Into<std::string::String>) -> Self {
self.next_token = Some(input.into());
self
}
pub fn set_next_token(mut self, input: std::option::Option<std::string::String>) -> Self {
self.next_token = input;
self
}
pub fn status(mut self, input: crate::model::TaskStatus) -> Self {
self.status = Some(input);
self
}
pub fn set_status(mut self, input: std::option::Option<crate::model::TaskStatus>) -> Self {
self.status = input;
self
}
pub fn build(
self,
) -> Result<
crate::input::ListSpeechSynthesisTasksInput,
aws_smithy_http::operation::error::BuildError,
> {
Ok(crate::input::ListSpeechSynthesisTasksInput {
max_results: self.max_results,
next_token: self.next_token,
status: self.status,
})
}
}
}
impl ListSpeechSynthesisTasksInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::ListSpeechSynthesisTasks,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::ListSpeechSynthesisTasksInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/v1/synthesisTasks").expect("formatting should succeed");
Ok(())
}
fn uri_query(
_input: &crate::input::ListSpeechSynthesisTasksInput,
mut output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let mut query = aws_smithy_http::query::Writer::new(&mut output);
if let Some(inner_8) = &_input.max_results {
if *inner_8 != 0 {
query.push_kv(
"MaxResults",
aws_smithy_types::primitive::Encoder::from(*inner_8).encode(),
);
}
}
if let Some(inner_9) = &_input.next_token {
{
query.push_kv("NextToken", &aws_smithy_http::query::fmt_string(&inner_9));
}
}
if let Some(inner_10) = &_input.status {
{
query.push_kv("Status", &aws_smithy_http::query::fmt_string(&inner_10));
}
}
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::ListSpeechSynthesisTasksInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
uri_query(input, &mut uri)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::ListSpeechSynthesisTasks::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"ListSpeechSynthesisTasks",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::list_speech_synthesis_tasks_input::Builder {
crate::input::list_speech_synthesis_tasks_input::Builder::default()
}
}
pub mod put_lexicon_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default)]
pub struct Builder {
pub(crate) name: std::option::Option<std::string::String>,
pub(crate) content: std::option::Option<std::string::String>,
}
impl Builder {
pub fn name(mut self, input: impl Into<std::string::String>) -> Self {
self.name = Some(input.into());
self
}
pub fn set_name(mut self, input: std::option::Option<std::string::String>) -> Self {
self.name = input;
self
}
pub fn content(mut self, input: impl Into<std::string::String>) -> Self {
self.content = Some(input.into());
self
}
pub fn set_content(mut self, input: std::option::Option<std::string::String>) -> Self {
self.content = input;
self
}
pub fn build(
self,
) -> Result<crate::input::PutLexiconInput, aws_smithy_http::operation::error::BuildError>
{
Ok(crate::input::PutLexiconInput {
name: self.name,
content: self.content,
})
}
}
impl std::fmt::Debug for Builder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut formatter = f.debug_struct("Builder");
formatter.field("name", &self.name);
formatter.field("content", &"*** Sensitive Data Redacted ***");
formatter.finish()
}
}
}
impl PutLexiconInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::PutLexicon,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::PutLexiconInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let input_11 = &_input.name;
let input_11 = input_11.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"name",
"cannot be empty or unset",
)
})?;
let name = aws_smithy_http::label::fmt_string(
input_11,
aws_smithy_http::label::EncodingStrategy::Default,
);
if name.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"name",
"cannot be empty or unset",
),
);
}
write!(output, "/v1/lexicons/{Name}", Name = name)
.expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::PutLexiconInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("PUT").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder = aws_smithy_http::header::set_request_header_if_absent(
builder,
http::header::CONTENT_TYPE,
"application/json",
);
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from(
crate::operation_ser::serialize_operation_crate_operation_put_lexicon(&self)?,
);
if let Some(content_length) = body.content_length() {
request = aws_smithy_http::header::set_request_header_if_absent(
request,
http::header::CONTENT_LENGTH,
content_length,
);
}
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::PutLexicon::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"PutLexicon",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::put_lexicon_input::Builder {
crate::input::put_lexicon_input::Builder::default()
}
}
pub mod start_speech_synthesis_task_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) engine: std::option::Option<crate::model::Engine>,
pub(crate) language_code: std::option::Option<crate::model::LanguageCode>,
pub(crate) lexicon_names: std::option::Option<std::vec::Vec<std::string::String>>,
pub(crate) output_format: std::option::Option<crate::model::OutputFormat>,
pub(crate) output_s3_bucket_name: std::option::Option<std::string::String>,
pub(crate) output_s3_key_prefix: std::option::Option<std::string::String>,
pub(crate) sample_rate: std::option::Option<std::string::String>,
pub(crate) sns_topic_arn: std::option::Option<std::string::String>,
pub(crate) speech_mark_types:
std::option::Option<std::vec::Vec<crate::model::SpeechMarkType>>,
pub(crate) text: std::option::Option<std::string::String>,
pub(crate) text_type: std::option::Option<crate::model::TextType>,
pub(crate) voice_id: std::option::Option<crate::model::VoiceId>,
}
impl Builder {
pub fn engine(mut self, input: crate::model::Engine) -> Self {
self.engine = Some(input);
self
}
pub fn set_engine(mut self, input: std::option::Option<crate::model::Engine>) -> Self {
self.engine = input;
self
}
pub fn language_code(mut self, input: crate::model::LanguageCode) -> Self {
self.language_code = Some(input);
self
}
pub fn set_language_code(
mut self,
input: std::option::Option<crate::model::LanguageCode>,
) -> Self {
self.language_code = input;
self
}
pub fn lexicon_names(mut self, input: impl Into<std::string::String>) -> Self {
let mut v = self.lexicon_names.unwrap_or_default();
v.push(input.into());
self.lexicon_names = Some(v);
self
}
pub fn set_lexicon_names(
mut self,
input: std::option::Option<std::vec::Vec<std::string::String>>,
) -> Self {
self.lexicon_names = input;
self
}
pub fn output_format(mut self, input: crate::model::OutputFormat) -> Self {
self.output_format = Some(input);
self
}
pub fn set_output_format(
mut self,
input: std::option::Option<crate::model::OutputFormat>,
) -> Self {
self.output_format = input;
self
}
pub fn output_s3_bucket_name(mut self, input: impl Into<std::string::String>) -> Self {
self.output_s3_bucket_name = Some(input.into());
self
}
pub fn set_output_s3_bucket_name(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.output_s3_bucket_name = input;
self
}
pub fn output_s3_key_prefix(mut self, input: impl Into<std::string::String>) -> Self {
self.output_s3_key_prefix = Some(input.into());
self
}
pub fn set_output_s3_key_prefix(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.output_s3_key_prefix = input;
self
}
pub fn sample_rate(mut self, input: impl Into<std::string::String>) -> Self {
self.sample_rate = Some(input.into());
self
}
pub fn set_sample_rate(mut self, input: std::option::Option<std::string::String>) -> Self {
self.sample_rate = input;
self
}
pub fn sns_topic_arn(mut self, input: impl Into<std::string::String>) -> Self {
self.sns_topic_arn = Some(input.into());
self
}
pub fn set_sns_topic_arn(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.sns_topic_arn = input;
self
}
pub fn speech_mark_types(mut self, input: crate::model::SpeechMarkType) -> Self {
let mut v = self.speech_mark_types.unwrap_or_default();
v.push(input);
self.speech_mark_types = Some(v);
self
}
pub fn set_speech_mark_types(
mut self,
input: std::option::Option<std::vec::Vec<crate::model::SpeechMarkType>>,
) -> Self {
self.speech_mark_types = input;
self
}
pub fn text(mut self, input: impl Into<std::string::String>) -> Self {
self.text = Some(input.into());
self
}
pub fn set_text(mut self, input: std::option::Option<std::string::String>) -> Self {
self.text = input;
self
}
pub fn text_type(mut self, input: crate::model::TextType) -> Self {
self.text_type = Some(input);
self
}
pub fn set_text_type(mut self, input: std::option::Option<crate::model::TextType>) -> Self {
self.text_type = input;
self
}
pub fn voice_id(mut self, input: crate::model::VoiceId) -> Self {
self.voice_id = Some(input);
self
}
pub fn set_voice_id(mut self, input: std::option::Option<crate::model::VoiceId>) -> Self {
self.voice_id = input;
self
}
pub fn build(
self,
) -> Result<
crate::input::StartSpeechSynthesisTaskInput,
aws_smithy_http::operation::error::BuildError,
> {
Ok(crate::input::StartSpeechSynthesisTaskInput {
engine: self.engine,
language_code: self.language_code,
lexicon_names: self.lexicon_names,
output_format: self.output_format,
output_s3_bucket_name: self.output_s3_bucket_name,
output_s3_key_prefix: self.output_s3_key_prefix,
sample_rate: self.sample_rate,
sns_topic_arn: self.sns_topic_arn,
speech_mark_types: self.speech_mark_types,
text: self.text,
text_type: self.text_type,
voice_id: self.voice_id,
})
}
}
}
impl StartSpeechSynthesisTaskInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::StartSpeechSynthesisTask,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::StartSpeechSynthesisTaskInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/v1/synthesisTasks").expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::StartSpeechSynthesisTaskInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("POST").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder = aws_smithy_http::header::set_request_header_if_absent(
builder,
http::header::CONTENT_TYPE,
"application/json",
);
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from(
crate::operation_ser::serialize_operation_crate_operation_start_speech_synthesis_task(
&self,
)?,
);
if let Some(content_length) = body.content_length() {
request = aws_smithy_http::header::set_request_header_if_absent(
request,
http::header::CONTENT_LENGTH,
content_length,
);
}
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::StartSpeechSynthesisTask::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"StartSpeechSynthesisTask",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::start_speech_synthesis_task_input::Builder {
crate::input::start_speech_synthesis_task_input::Builder::default()
}
}
pub mod synthesize_speech_input {
#[derive(std::clone::Clone, std::cmp::PartialEq, std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) engine: std::option::Option<crate::model::Engine>,
pub(crate) language_code: std::option::Option<crate::model::LanguageCode>,
pub(crate) lexicon_names: std::option::Option<std::vec::Vec<std::string::String>>,
pub(crate) output_format: std::option::Option<crate::model::OutputFormat>,
pub(crate) sample_rate: std::option::Option<std::string::String>,
pub(crate) speech_mark_types:
std::option::Option<std::vec::Vec<crate::model::SpeechMarkType>>,
pub(crate) text: std::option::Option<std::string::String>,
pub(crate) text_type: std::option::Option<crate::model::TextType>,
pub(crate) voice_id: std::option::Option<crate::model::VoiceId>,
}
impl Builder {
pub fn engine(mut self, input: crate::model::Engine) -> Self {
self.engine = Some(input);
self
}
pub fn set_engine(mut self, input: std::option::Option<crate::model::Engine>) -> Self {
self.engine = input;
self
}
pub fn language_code(mut self, input: crate::model::LanguageCode) -> Self {
self.language_code = Some(input);
self
}
pub fn set_language_code(
mut self,
input: std::option::Option<crate::model::LanguageCode>,
) -> Self {
self.language_code = input;
self
}
pub fn lexicon_names(mut self, input: impl Into<std::string::String>) -> Self {
let mut v = self.lexicon_names.unwrap_or_default();
v.push(input.into());
self.lexicon_names = Some(v);
self
}
pub fn set_lexicon_names(
mut self,
input: std::option::Option<std::vec::Vec<std::string::String>>,
) -> Self {
self.lexicon_names = input;
self
}
pub fn output_format(mut self, input: crate::model::OutputFormat) -> Self {
self.output_format = Some(input);
self
}
pub fn set_output_format(
mut self,
input: std::option::Option<crate::model::OutputFormat>,
) -> Self {
self.output_format = input;
self
}
pub fn sample_rate(mut self, input: impl Into<std::string::String>) -> Self {
self.sample_rate = Some(input.into());
self
}
pub fn set_sample_rate(mut self, input: std::option::Option<std::string::String>) -> Self {
self.sample_rate = input;
self
}
pub fn speech_mark_types(mut self, input: crate::model::SpeechMarkType) -> Self {
let mut v = self.speech_mark_types.unwrap_or_default();
v.push(input);
self.speech_mark_types = Some(v);
self
}
pub fn set_speech_mark_types(
mut self,
input: std::option::Option<std::vec::Vec<crate::model::SpeechMarkType>>,
) -> Self {
self.speech_mark_types = input;
self
}
pub fn text(mut self, input: impl Into<std::string::String>) -> Self {
self.text = Some(input.into());
self
}
pub fn set_text(mut self, input: std::option::Option<std::string::String>) -> Self {
self.text = input;
self
}
pub fn text_type(mut self, input: crate::model::TextType) -> Self {
self.text_type = Some(input);
self
}
pub fn set_text_type(mut self, input: std::option::Option<crate::model::TextType>) -> Self {
self.text_type = input;
self
}
pub fn voice_id(mut self, input: crate::model::VoiceId) -> Self {
self.voice_id = Some(input);
self
}
pub fn set_voice_id(mut self, input: std::option::Option<crate::model::VoiceId>) -> Self {
self.voice_id = input;
self
}
pub fn build(
self,
) -> Result<
crate::input::SynthesizeSpeechInput,
aws_smithy_http::operation::error::BuildError,
> {
Ok(crate::input::SynthesizeSpeechInput {
engine: self.engine,
language_code: self.language_code,
lexicon_names: self.lexicon_names,
output_format: self.output_format,
sample_rate: self.sample_rate,
speech_mark_types: self.speech_mark_types,
text: self.text,
text_type: self.text_type,
voice_id: self.voice_id,
})
}
}
}
impl SynthesizeSpeechInput {
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
async fn _make_presigned_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::SynthesizeSpeech,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::SynthesizeSpeechInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/v1/speech").expect("formatting should succeed");
Ok(())
}
fn uri_query(
_input: &crate::input::SynthesizeSpeechInput,
mut output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let mut query = aws_smithy_http::query::Writer::new(&mut output);
if let Some(inner_12) = &_input.engine {
{
query.push_kv("Engine", &aws_smithy_http::query::fmt_string(&inner_12));
}
}
if let Some(inner_13) = &_input.language_code {
{
query.push_kv(
"LanguageCode",
&aws_smithy_http::query::fmt_string(&inner_13),
);
}
}
if let Some(inner_14) = &_input.lexicon_names {
{
for inner_15 in inner_14 {
query.push_kv(
"LexiconNames",
&aws_smithy_http::query::fmt_string(&inner_15),
);
}
}
}
let inner_16 = &_input.output_format;
let inner_16 = inner_16.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"output_format",
"cannot be empty or unset",
)
})?;
query.push_kv(
"OutputFormat",
&aws_smithy_http::query::fmt_string(&inner_16),
);
if let Some(inner_17) = &_input.sample_rate {
{
query.push_kv("SampleRate", &aws_smithy_http::query::fmt_string(&inner_17));
}
}
if let Some(inner_18) = &_input.speech_mark_types {
{
for inner_19 in inner_18 {
query.push_kv(
"SpeechMarkTypes",
&aws_smithy_http::query::fmt_string(&inner_19),
);
}
}
}
let inner_20 = &_input.text;
let inner_20 = inner_20.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"text",
"cannot be empty or unset",
)
})?;
if inner_20.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"text",
"cannot be empty or unset",
),
);
}
query.push_kv("Text", &aws_smithy_http::query::fmt_string(&inner_20));
if let Some(inner_21) = &_input.text_type {
{
query.push_kv("TextType", &aws_smithy_http::query::fmt_string(&inner_21));
}
}
let inner_22 = &_input.voice_id;
let inner_22 = inner_22.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"voice_id",
"cannot be empty or unset",
)
})?;
query.push_kv("VoiceId", &aws_smithy_http::query::fmt_string(&inner_22));
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::SynthesizeSpeechInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
uri_query(input, &mut uri)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::SynthesizeSpeech::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"SynthesizeSpeech",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub async fn presigned(
self,
config: &crate::config::Config,
presigning_config: crate::presigning::config::PresigningConfig,
) -> Result<
crate::presigning::request::PresignedRequest,
aws_smithy_http::result::SdkError<crate::error::SynthesizeSpeechError>,
> {
let (mut request, _) = self
._make_presigned_operation(config)
.await
.map_err(aws_smithy_http::result::SdkError::construction_failure)?
.into_request_response();
{
let mut props = request.properties_mut();
props.insert(presigning_config.start_time());
props.insert(aws_sigv4::http_request::SignableBody::Bytes(b""));
let mut config = props
.get_mut::<aws_sig_auth::signer::OperationSigningConfig>()
.expect("signing config added by make_operation()");
config.signature_type = aws_sig_auth::signer::HttpSignatureType::HttpRequestQueryParams;
config.expires_in = Some(presigning_config.expires());
}
let middleware = crate::middleware::DefaultMiddleware::default();
let mut svc = tower::builder::ServiceBuilder::new()
.layer(&middleware)
.service(crate::presigning::service::PresignedRequestService::new());
use tower::{Service, ServiceExt};
Ok(svc.ready().await?.call(request).await?)
}
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::SynthesizeSpeech,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let params_result = crate::endpoint::Params::builder()
.set_region(_config.region.as_ref().map(|r| r.as_ref().to_owned()))
.set_use_dual_stack(_config.use_dual_stack)
.set_use_fips(_config.use_fips)
.set_endpoint(_config.endpoint_url.clone())
.build()
.map_err(|err| {
aws_smithy_http::endpoint::ResolveEndpointError::from_source(
"could not construct endpoint parameters",
err,
)
});
let (endpoint_result, params) = match params_result {
Ok(params) => (
_config.endpoint_resolver.resolve_endpoint(¶ms),
Some(params),
),
Err(e) => (Err(e), None),
};
let mut request = {
fn uri_base(
_input: &crate::input::SynthesizeSpeechInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
write!(output, "/v1/speech").expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::SynthesizeSpeechInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("POST").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder = aws_smithy_http::header::set_request_header_if_absent(
builder,
http::header::CONTENT_TYPE,
"application/json",
);
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from(
crate::operation_ser::serialize_operation_crate_operation_synthesize_speech(&self)?,
);
if let Some(content_length) = body.content_length() {
request = aws_smithy_http::header::set_request_header_if_absent(
request,
http::header::CONTENT_LENGTH,
content_length,
);
}
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request.properties_mut().insert(endpoint_result);
if let Some(params) = params {
request.properties_mut().insert(params);
}
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_credentials_cache(
&mut request.properties_mut(),
_config.credentials_cache.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::SynthesizeSpeech::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"SynthesizeSpeech",
"polly",
));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
pub fn builder() -> crate::input::synthesize_speech_input::Builder {
crate::input::synthesize_speech_input::Builder::default()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct SynthesizeSpeechInput {
#[doc(hidden)]
pub engine: std::option::Option<crate::model::Engine>,
#[doc(hidden)]
pub language_code: std::option::Option<crate::model::LanguageCode>,
#[doc(hidden)]
pub lexicon_names: std::option::Option<std::vec::Vec<std::string::String>>,
#[doc(hidden)]
pub output_format: std::option::Option<crate::model::OutputFormat>,
#[doc(hidden)]
pub sample_rate: std::option::Option<std::string::String>,
#[doc(hidden)]
pub speech_mark_types: std::option::Option<std::vec::Vec<crate::model::SpeechMarkType>>,
#[doc(hidden)]
pub text: std::option::Option<std::string::String>,
#[doc(hidden)]
pub text_type: std::option::Option<crate::model::TextType>,
#[doc(hidden)]
pub voice_id: std::option::Option<crate::model::VoiceId>,
}
impl SynthesizeSpeechInput {
pub fn engine(&self) -> std::option::Option<&crate::model::Engine> {
self.engine.as_ref()
}
pub fn language_code(&self) -> std::option::Option<&crate::model::LanguageCode> {
self.language_code.as_ref()
}
pub fn lexicon_names(&self) -> std::option::Option<&[std::string::String]> {
self.lexicon_names.as_deref()
}
pub fn output_format(&self) -> std::option::Option<&crate::model::OutputFormat> {
self.output_format.as_ref()
}
pub fn sample_rate(&self) -> std::option::Option<&str> {
self.sample_rate.as_deref()
}
pub fn speech_mark_types(&self) -> std::option::Option<&[crate::model::SpeechMarkType]> {
self.speech_mark_types.as_deref()
}
pub fn text(&self) -> std::option::Option<&str> {
self.text.as_deref()
}
pub fn text_type(&self) -> std::option::Option<&crate::model::TextType> {
self.text_type.as_ref()
}
pub fn voice_id(&self) -> std::option::Option<&crate::model::VoiceId> {
self.voice_id.as_ref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct StartSpeechSynthesisTaskInput {
#[doc(hidden)]
pub engine: std::option::Option<crate::model::Engine>,
#[doc(hidden)]
pub language_code: std::option::Option<crate::model::LanguageCode>,
#[doc(hidden)]
pub lexicon_names: std::option::Option<std::vec::Vec<std::string::String>>,
#[doc(hidden)]
pub output_format: std::option::Option<crate::model::OutputFormat>,
#[doc(hidden)]
pub output_s3_bucket_name: std::option::Option<std::string::String>,
#[doc(hidden)]
pub output_s3_key_prefix: std::option::Option<std::string::String>,
#[doc(hidden)]
pub sample_rate: std::option::Option<std::string::String>,
#[doc(hidden)]
pub sns_topic_arn: std::option::Option<std::string::String>,
#[doc(hidden)]
pub speech_mark_types: std::option::Option<std::vec::Vec<crate::model::SpeechMarkType>>,
#[doc(hidden)]
pub text: std::option::Option<std::string::String>,
#[doc(hidden)]
pub text_type: std::option::Option<crate::model::TextType>,
#[doc(hidden)]
pub voice_id: std::option::Option<crate::model::VoiceId>,
}
impl StartSpeechSynthesisTaskInput {
pub fn engine(&self) -> std::option::Option<&crate::model::Engine> {
self.engine.as_ref()
}
pub fn language_code(&self) -> std::option::Option<&crate::model::LanguageCode> {
self.language_code.as_ref()
}
pub fn lexicon_names(&self) -> std::option::Option<&[std::string::String]> {
self.lexicon_names.as_deref()
}
pub fn output_format(&self) -> std::option::Option<&crate::model::OutputFormat> {
self.output_format.as_ref()
}
pub fn output_s3_bucket_name(&self) -> std::option::Option<&str> {
self.output_s3_bucket_name.as_deref()
}
pub fn output_s3_key_prefix(&self) -> std::option::Option<&str> {
self.output_s3_key_prefix.as_deref()
}
pub fn sample_rate(&self) -> std::option::Option<&str> {
self.sample_rate.as_deref()
}
pub fn sns_topic_arn(&self) -> std::option::Option<&str> {
self.sns_topic_arn.as_deref()
}
pub fn speech_mark_types(&self) -> std::option::Option<&[crate::model::SpeechMarkType]> {
self.speech_mark_types.as_deref()
}
pub fn text(&self) -> std::option::Option<&str> {
self.text.as_deref()
}
pub fn text_type(&self) -> std::option::Option<&crate::model::TextType> {
self.text_type.as_ref()
}
pub fn voice_id(&self) -> std::option::Option<&crate::model::VoiceId> {
self.voice_id.as_ref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq)]
pub struct PutLexiconInput {
#[doc(hidden)]
pub name: std::option::Option<std::string::String>,
#[doc(hidden)]
pub content: std::option::Option<std::string::String>,
}
impl PutLexiconInput {
pub fn name(&self) -> std::option::Option<&str> {
self.name.as_deref()
}
pub fn content(&self) -> std::option::Option<&str> {
self.content.as_deref()
}
}
impl std::fmt::Debug for PutLexiconInput {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut formatter = f.debug_struct("PutLexiconInput");
formatter.field("name", &self.name);
formatter.field("content", &"*** Sensitive Data Redacted ***");
formatter.finish()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct ListSpeechSynthesisTasksInput {
#[doc(hidden)]
pub max_results: std::option::Option<i32>,
#[doc(hidden)]
pub next_token: std::option::Option<std::string::String>,
#[doc(hidden)]
pub status: std::option::Option<crate::model::TaskStatus>,
}
impl ListSpeechSynthesisTasksInput {
pub fn max_results(&self) -> std::option::Option<i32> {
self.max_results
}
pub fn next_token(&self) -> std::option::Option<&str> {
self.next_token.as_deref()
}
pub fn status(&self) -> std::option::Option<&crate::model::TaskStatus> {
self.status.as_ref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct ListLexiconsInput {
#[doc(hidden)]
pub next_token: std::option::Option<std::string::String>,
}
impl ListLexiconsInput {
pub fn next_token(&self) -> std::option::Option<&str> {
self.next_token.as_deref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct GetSpeechSynthesisTaskInput {
#[doc(hidden)]
pub task_id: std::option::Option<std::string::String>,
}
impl GetSpeechSynthesisTaskInput {
pub fn task_id(&self) -> std::option::Option<&str> {
self.task_id.as_deref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct GetLexiconInput {
#[doc(hidden)]
pub name: std::option::Option<std::string::String>,
}
impl GetLexiconInput {
pub fn name(&self) -> std::option::Option<&str> {
self.name.as_deref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct DescribeVoicesInput {
#[doc(hidden)]
pub engine: std::option::Option<crate::model::Engine>,
#[doc(hidden)]
pub language_code: std::option::Option<crate::model::LanguageCode>,
#[doc(hidden)]
pub include_additional_language_codes: bool,
#[doc(hidden)]
pub next_token: std::option::Option<std::string::String>,
}
impl DescribeVoicesInput {
pub fn engine(&self) -> std::option::Option<&crate::model::Engine> {
self.engine.as_ref()
}
pub fn language_code(&self) -> std::option::Option<&crate::model::LanguageCode> {
self.language_code.as_ref()
}
pub fn include_additional_language_codes(&self) -> bool {
self.include_additional_language_codes
}
pub fn next_token(&self) -> std::option::Option<&str> {
self.next_token.as_deref()
}
}
#[allow(missing_docs)] #[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct DeleteLexiconInput {
#[doc(hidden)]
pub name: std::option::Option<std::string::String>,
}
impl DeleteLexiconInput {
pub fn name(&self) -> std::option::Option<&str> {
self.name.as_deref()
}
}