// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>A search result block that enables natural citations with proper source attribution for retrieved content.</p><note>
/// <p>This field is only supported by Anthropic Claude Opus 4.1, Opus 4, Sonnet 4.5, Sonnet 4, Sonnet 3.7, and 3.5 Haiku models.</p>
/// </note>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct SearchResultBlock {
    /// <p>The source URL or identifier for the content.</p>
    pub source: ::std::string::String,
    /// <p>A descriptive title for the search result.</p>
    pub title: ::std::string::String,
    /// <p>An array of search result content block.</p>
    pub content: ::std::vec::Vec<crate::types::SearchResultContentBlock>,
    /// <p>Configuration setting for citations</p>
    pub citations: ::std::option::Option<crate::types::CitationsConfig>,
}
impl SearchResultBlock {
    /// <p>The source URL or identifier for the content.</p>
    pub fn source(&self) -> &str {
        use std::ops::Deref;
        self.source.deref()
    }
    /// <p>A descriptive title for the search result.</p>
    pub fn title(&self) -> &str {
        use std::ops::Deref;
        self.title.deref()
    }
    /// <p>An array of search result content block.</p>
    pub fn content(&self) -> &[crate::types::SearchResultContentBlock] {
        use std::ops::Deref;
        self.content.deref()
    }
    /// <p>Configuration setting for citations</p>
    pub fn citations(&self) -> ::std::option::Option<&crate::types::CitationsConfig> {
        self.citations.as_ref()
    }
}
impl SearchResultBlock {
    /// Creates a new builder-style object to manufacture [`SearchResultBlock`](crate::types::SearchResultBlock).
    pub fn builder() -> crate::types::builders::SearchResultBlockBuilder {
        crate::types::builders::SearchResultBlockBuilder::default()
    }
}

/// A builder for [`SearchResultBlock`](crate::types::SearchResultBlock).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct SearchResultBlockBuilder {
    pub(crate) source: ::std::option::Option<::std::string::String>,
    pub(crate) title: ::std::option::Option<::std::string::String>,
    pub(crate) content: ::std::option::Option<::std::vec::Vec<crate::types::SearchResultContentBlock>>,
    pub(crate) citations: ::std::option::Option<crate::types::CitationsConfig>,
}
impl SearchResultBlockBuilder {
    /// <p>The source URL or identifier for the content.</p>
    /// This field is required.
    pub fn source(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.source = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The source URL or identifier for the content.</p>
    pub fn set_source(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.source = input;
        self
    }
    /// <p>The source URL or identifier for the content.</p>
    pub fn get_source(&self) -> &::std::option::Option<::std::string::String> {
        &self.source
    }
    /// <p>A descriptive title for the search result.</p>
    /// This field is required.
    pub fn title(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.title = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>A descriptive title for the search result.</p>
    pub fn set_title(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.title = input;
        self
    }
    /// <p>A descriptive title for the search result.</p>
    pub fn get_title(&self) -> &::std::option::Option<::std::string::String> {
        &self.title
    }
    /// Appends an item to `content`.
    ///
    /// To override the contents of this collection use [`set_content`](Self::set_content).
    ///
    /// <p>An array of search result content block.</p>
    pub fn content(mut self, input: crate::types::SearchResultContentBlock) -> Self {
        let mut v = self.content.unwrap_or_default();
        v.push(input);
        self.content = ::std::option::Option::Some(v);
        self
    }
    /// <p>An array of search result content block.</p>
    pub fn set_content(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::SearchResultContentBlock>>) -> Self {
        self.content = input;
        self
    }
    /// <p>An array of search result content block.</p>
    pub fn get_content(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::SearchResultContentBlock>> {
        &self.content
    }
    /// <p>Configuration setting for citations</p>
    pub fn citations(mut self, input: crate::types::CitationsConfig) -> Self {
        self.citations = ::std::option::Option::Some(input);
        self
    }
    /// <p>Configuration setting for citations</p>
    pub fn set_citations(mut self, input: ::std::option::Option<crate::types::CitationsConfig>) -> Self {
        self.citations = input;
        self
    }
    /// <p>Configuration setting for citations</p>
    pub fn get_citations(&self) -> &::std::option::Option<crate::types::CitationsConfig> {
        &self.citations
    }
    /// Consumes the builder and constructs a [`SearchResultBlock`](crate::types::SearchResultBlock).
    /// This method will fail if any of the following fields are not set:
    /// - [`source`](crate::types::builders::SearchResultBlockBuilder::source)
    /// - [`title`](crate::types::builders::SearchResultBlockBuilder::title)
    /// - [`content`](crate::types::builders::SearchResultBlockBuilder::content)
    pub fn build(self) -> ::std::result::Result<crate::types::SearchResultBlock, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::SearchResultBlock {
            source: self.source.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "source",
                    "source was not specified but it is required when building SearchResultBlock",
                )
            })?,
            title: self.title.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "title",
                    "title was not specified but it is required when building SearchResultBlock",
                )
            })?,
            content: self.content.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "content",
                    "content was not specified but it is required when building SearchResultBlock",
                )
            })?,
            citations: self.citations,
        })
    }
}
