aws-sdk-context 1.0.0

AWS SDK for AWS Context
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// The result of a retrieval. `retrievedContext` is always present. A response that only asks for authorization carries `authorizationRequired` beside an empty `retrievedContext`.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
pub struct AgenticRetrieveOutput {
    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
    pub retrieved_context: ::std::vec::Vec<crate::types::RetrievedContext>,
    /// The synthesized natural-language answer, when one was generated.
    pub answer: ::std::option::Option<::std::string::String>,
    /// Maps spans of answer to the supporting entities, when an answer was generated.
    pub citations: ::std::option::Option<::std::vec::Vec<crate::types::Citation>>,
    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
    pub authorization_required: ::std::option::Option<crate::types::AuthorizationRequired>,
    _request_id: Option<String>,
}
impl AgenticRetrieveOutput {
    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
    pub fn retrieved_context(&self) -> &[crate::types::RetrievedContext] {
        use std::ops::Deref;
        self.retrieved_context.deref()
    }
    /// The synthesized natural-language answer, when one was generated.
    pub fn answer(&self) -> ::std::option::Option<&str> {
        self.answer.as_deref()
    }
    /// Maps spans of answer to the supporting entities, when an answer was generated.
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.citations.is_none()`.
    pub fn citations(&self) -> &[crate::types::Citation] {
        self.citations.as_deref().unwrap_or_default()
    }
    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
    pub fn authorization_required(&self) -> ::std::option::Option<&crate::types::AuthorizationRequired> {
        self.authorization_required.as_ref()
    }
}
impl ::std::fmt::Debug for AgenticRetrieveOutput {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        let mut formatter = f.debug_struct("AgenticRetrieveOutput");
        formatter.field("retrieved_context", &self.retrieved_context);
        formatter.field("answer", &"*** Sensitive Data Redacted ***");
        formatter.field("citations", &self.citations);
        formatter.field("authorization_required", &self.authorization_required);
        formatter.field("_request_id", &self._request_id);
        formatter.finish()
    }
}
impl ::aws_types::request_id::RequestId for AgenticRetrieveOutput {
    fn request_id(&self) -> Option<&str> {
        self._request_id.as_deref()
    }
}
impl AgenticRetrieveOutput {
    /// Creates a new builder-style object to manufacture [`AgenticRetrieveOutput`](crate::operation::agentic_retrieve::AgenticRetrieveOutput).
    pub fn builder() -> crate::operation::agentic_retrieve::builders::AgenticRetrieveOutputBuilder {
        crate::operation::agentic_retrieve::builders::AgenticRetrieveOutputBuilder::default()
    }
}

/// A builder for [`AgenticRetrieveOutput`](crate::operation::agentic_retrieve::AgenticRetrieveOutput).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
#[non_exhaustive]
pub struct AgenticRetrieveOutputBuilder {
    pub(crate) retrieved_context: ::std::option::Option<::std::vec::Vec<crate::types::RetrievedContext>>,
    pub(crate) answer: ::std::option::Option<::std::string::String>,
    pub(crate) citations: ::std::option::Option<::std::vec::Vec<crate::types::Citation>>,
    pub(crate) authorization_required: ::std::option::Option<crate::types::AuthorizationRequired>,
    _request_id: Option<String>,
}
impl AgenticRetrieveOutputBuilder {
    /// Appends an item to `retrieved_context`.
    ///
    /// To override the contents of this collection use [`set_retrieved_context`](Self::set_retrieved_context).
    ///
    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
    pub fn retrieved_context(mut self, input: crate::types::RetrievedContext) -> Self {
        let mut v = self.retrieved_context.unwrap_or_default();
        v.push(input);
        self.retrieved_context = ::std::option::Option::Some(v);
        self
    }
    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
    pub fn set_retrieved_context(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::RetrievedContext>>) -> Self {
        self.retrieved_context = input;
        self
    }
    /// The ranked, structured context that the agent assembled across all iterations, without duplicates. Always present. Each entry is a graph node, a graph edge, or a document.
    pub fn get_retrieved_context(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::RetrievedContext>> {
        &self.retrieved_context
    }
    /// The synthesized natural-language answer, when one was generated.
    pub fn answer(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.answer = ::std::option::Option::Some(input.into());
        self
    }
    /// The synthesized natural-language answer, when one was generated.
    pub fn set_answer(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.answer = input;
        self
    }
    /// The synthesized natural-language answer, when one was generated.
    pub fn get_answer(&self) -> &::std::option::Option<::std::string::String> {
        &self.answer
    }
    /// Appends an item to `citations`.
    ///
    /// To override the contents of this collection use [`set_citations`](Self::set_citations).
    ///
    /// Maps spans of answer to the supporting entities, when an answer was generated.
    pub fn citations(mut self, input: crate::types::Citation) -> Self {
        let mut v = self.citations.unwrap_or_default();
        v.push(input);
        self.citations = ::std::option::Option::Some(v);
        self
    }
    /// Maps spans of answer to the supporting entities, when an answer was generated.
    pub fn set_citations(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Citation>>) -> Self {
        self.citations = input;
        self
    }
    /// Maps spans of answer to the supporting entities, when an answer was generated.
    pub fn get_citations(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Citation>> {
        &self.citations
    }
    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
    pub fn authorization_required(mut self, input: crate::types::AuthorizationRequired) -> Self {
        self.authorization_required = ::std::option::Option::Some(input);
        self
    }
    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
    pub fn set_authorization_required(mut self, input: ::std::option::Option<crate::types::AuthorizationRequired>) -> Self {
        self.authorization_required = input;
        self
    }
    /// Present when you must authorize access to a third-party resource. If `retrievedContext` is empty, no result was retrieved. Otherwise, the result leaves out one or more resources that you have not authorized. Show `authorizationUrl` to the user and retry after they consent.
    pub fn get_authorization_required(&self) -> &::std::option::Option<crate::types::AuthorizationRequired> {
        &self.authorization_required
    }
    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
        self._request_id = Some(request_id.into());
        self
    }

    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
        self._request_id = request_id;
        self
    }
    /// Consumes the builder and constructs a [`AgenticRetrieveOutput`](crate::operation::agentic_retrieve::AgenticRetrieveOutput).
    /// This method will fail if any of the following fields are not set:
    /// - [`retrieved_context`](crate::operation::agentic_retrieve::builders::AgenticRetrieveOutputBuilder::retrieved_context)
    pub fn build(
        self,
    ) -> ::std::result::Result<crate::operation::agentic_retrieve::AgenticRetrieveOutput, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::operation::agentic_retrieve::AgenticRetrieveOutput {
            retrieved_context: self.retrieved_context.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "retrieved_context",
                    "retrieved_context was not specified but it is required when building AgenticRetrieveOutput",
                )
            })?,
            answer: self.answer,
            citations: self.citations,
            authorization_required: self.authorization_required,
            _request_id: self._request_id,
        })
    }
}
impl ::std::fmt::Debug for AgenticRetrieveOutputBuilder {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        let mut formatter = f.debug_struct("AgenticRetrieveOutputBuilder");
        formatter.field("retrieved_context", &self.retrieved_context);
        formatter.field("answer", &"*** Sensitive Data Redacted ***");
        formatter.field("citations", &self.citations);
        formatter.field("authorization_required", &self.authorization_required);
        formatter.field("_request_id", &self._request_id);
        formatter.finish()
    }
}