aws-sdk-lexmodelbuilding 1.99.0

AWS SDK for Amazon Lex Model Building Service
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>Obtains information from the user. To define a prompt, provide one or more messages and specify the number of attempts to get information from the user. If you provide more than one message, Amazon Lex chooses one of the messages to use to prompt the user. For more information, see <code>how-it-works</code>.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Prompt {
    /// <p>An array of objects, each of which provides a message string and its type. You can specify the message string in plain text or in Speech Synthesis Markup Language (SSML).</p>
    pub messages: ::std::vec::Vec<crate::types::Message>,
    /// <p>The number of times to prompt the user for information.</p>
    pub max_attempts: i32,
    /// <p>A response card. Amazon Lex uses this prompt at runtime, in the <code>PostText</code> API response. It substitutes session attributes and slot values for placeholders in the response card. For more information, see <code>ex-resp-card</code>.</p>
    pub response_card: ::std::option::Option<::std::string::String>,
}
impl Prompt {
    /// <p>An array of objects, each of which provides a message string and its type. You can specify the message string in plain text or in Speech Synthesis Markup Language (SSML).</p>
    pub fn messages(&self) -> &[crate::types::Message] {
        use std::ops::Deref;
        self.messages.deref()
    }
    /// <p>The number of times to prompt the user for information.</p>
    pub fn max_attempts(&self) -> i32 {
        self.max_attempts
    }
    /// <p>A response card. Amazon Lex uses this prompt at runtime, in the <code>PostText</code> API response. It substitutes session attributes and slot values for placeholders in the response card. For more information, see <code>ex-resp-card</code>.</p>
    pub fn response_card(&self) -> ::std::option::Option<&str> {
        self.response_card.as_deref()
    }
}
impl Prompt {
    /// Creates a new builder-style object to manufacture [`Prompt`](crate::types::Prompt).
    pub fn builder() -> crate::types::builders::PromptBuilder {
        crate::types::builders::PromptBuilder::default()
    }
}

/// A builder for [`Prompt`](crate::types::Prompt).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct PromptBuilder {
    pub(crate) messages: ::std::option::Option<::std::vec::Vec<crate::types::Message>>,
    pub(crate) max_attempts: ::std::option::Option<i32>,
    pub(crate) response_card: ::std::option::Option<::std::string::String>,
}
impl PromptBuilder {
    /// Appends an item to `messages`.
    ///
    /// To override the contents of this collection use [`set_messages`](Self::set_messages).
    ///
    /// <p>An array of objects, each of which provides a message string and its type. You can specify the message string in plain text or in Speech Synthesis Markup Language (SSML).</p>
    pub fn messages(mut self, input: crate::types::Message) -> Self {
        let mut v = self.messages.unwrap_or_default();
        v.push(input);
        self.messages = ::std::option::Option::Some(v);
        self
    }
    /// <p>An array of objects, each of which provides a message string and its type. You can specify the message string in plain text or in Speech Synthesis Markup Language (SSML).</p>
    pub fn set_messages(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Message>>) -> Self {
        self.messages = input;
        self
    }
    /// <p>An array of objects, each of which provides a message string and its type. You can specify the message string in plain text or in Speech Synthesis Markup Language (SSML).</p>
    pub fn get_messages(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Message>> {
        &self.messages
    }
    /// <p>The number of times to prompt the user for information.</p>
    /// This field is required.
    pub fn max_attempts(mut self, input: i32) -> Self {
        self.max_attempts = ::std::option::Option::Some(input);
        self
    }
    /// <p>The number of times to prompt the user for information.</p>
    pub fn set_max_attempts(mut self, input: ::std::option::Option<i32>) -> Self {
        self.max_attempts = input;
        self
    }
    /// <p>The number of times to prompt the user for information.</p>
    pub fn get_max_attempts(&self) -> &::std::option::Option<i32> {
        &self.max_attempts
    }
    /// <p>A response card. Amazon Lex uses this prompt at runtime, in the <code>PostText</code> API response. It substitutes session attributes and slot values for placeholders in the response card. For more information, see <code>ex-resp-card</code>.</p>
    pub fn response_card(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.response_card = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>A response card. Amazon Lex uses this prompt at runtime, in the <code>PostText</code> API response. It substitutes session attributes and slot values for placeholders in the response card. For more information, see <code>ex-resp-card</code>.</p>
    pub fn set_response_card(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.response_card = input;
        self
    }
    /// <p>A response card. Amazon Lex uses this prompt at runtime, in the <code>PostText</code> API response. It substitutes session attributes and slot values for placeholders in the response card. For more information, see <code>ex-resp-card</code>.</p>
    pub fn get_response_card(&self) -> &::std::option::Option<::std::string::String> {
        &self.response_card
    }
    /// Consumes the builder and constructs a [`Prompt`](crate::types::Prompt).
    /// This method will fail if any of the following fields are not set:
    /// - [`messages`](crate::types::builders::PromptBuilder::messages)
    /// - [`max_attempts`](crate::types::builders::PromptBuilder::max_attempts)
    pub fn build(self) -> ::std::result::Result<crate::types::Prompt, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Prompt {
            messages: self.messages.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "messages",
                    "messages was not specified but it is required when building Prompt",
                )
            })?,
            max_attempts: self.max_attempts.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "max_attempts",
                    "max_attempts was not specified but it is required when building Prompt",
                )
            })?,
            response_card: self.response_card,
        })
    }
}