aws_sdk_bedrockagentruntime/operation/retrieve/
_retrieve_output.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(missing_docs)] // documentation missing in model
3#[non_exhaustive]
4#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
5pub struct RetrieveOutput {
6    /// <p>A list of results from querying the knowledge base.</p>
7    pub retrieval_results: ::std::vec::Vec<crate::types::KnowledgeBaseRetrievalResult>,
8    /// <p>Specifies if there is a guardrail intervention in the response.</p>
9    pub guardrail_action: ::std::option::Option<crate::types::GuadrailAction>,
10    /// <p>If there are more results than can fit in the response, the response returns a <code>nextToken</code>. Use this token in the <code>nextToken</code> field of another request to retrieve the next batch of results.</p>
11    pub next_token: ::std::option::Option<::std::string::String>,
12    _request_id: Option<String>,
13}
14impl RetrieveOutput {
15    /// <p>A list of results from querying the knowledge base.</p>
16    pub fn retrieval_results(&self) -> &[crate::types::KnowledgeBaseRetrievalResult] {
17        use std::ops::Deref;
18        self.retrieval_results.deref()
19    }
20    /// <p>Specifies if there is a guardrail intervention in the response.</p>
21    pub fn guardrail_action(&self) -> ::std::option::Option<&crate::types::GuadrailAction> {
22        self.guardrail_action.as_ref()
23    }
24    /// <p>If there are more results than can fit in the response, the response returns a <code>nextToken</code>. Use this token in the <code>nextToken</code> field of another request to retrieve the next batch of results.</p>
25    pub fn next_token(&self) -> ::std::option::Option<&str> {
26        self.next_token.as_deref()
27    }
28}
29impl ::std::fmt::Debug for RetrieveOutput {
30    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
31        let mut formatter = f.debug_struct("RetrieveOutput");
32        formatter.field("retrieval_results", &"*** Sensitive Data Redacted ***");
33        formatter.field("guardrail_action", &self.guardrail_action);
34        formatter.field("next_token", &self.next_token);
35        formatter.field("_request_id", &self._request_id);
36        formatter.finish()
37    }
38}
39impl ::aws_types::request_id::RequestId for RetrieveOutput {
40    fn request_id(&self) -> Option<&str> {
41        self._request_id.as_deref()
42    }
43}
44impl RetrieveOutput {
45    /// Creates a new builder-style object to manufacture [`RetrieveOutput`](crate::operation::retrieve::RetrieveOutput).
46    pub fn builder() -> crate::operation::retrieve::builders::RetrieveOutputBuilder {
47        crate::operation::retrieve::builders::RetrieveOutputBuilder::default()
48    }
49}
50
51/// A builder for [`RetrieveOutput`](crate::operation::retrieve::RetrieveOutput).
52#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
53#[non_exhaustive]
54pub struct RetrieveOutputBuilder {
55    pub(crate) retrieval_results: ::std::option::Option<::std::vec::Vec<crate::types::KnowledgeBaseRetrievalResult>>,
56    pub(crate) guardrail_action: ::std::option::Option<crate::types::GuadrailAction>,
57    pub(crate) next_token: ::std::option::Option<::std::string::String>,
58    _request_id: Option<String>,
59}
60impl RetrieveOutputBuilder {
61    /// Appends an item to `retrieval_results`.
62    ///
63    /// To override the contents of this collection use [`set_retrieval_results`](Self::set_retrieval_results).
64    ///
65    /// <p>A list of results from querying the knowledge base.</p>
66    pub fn retrieval_results(mut self, input: crate::types::KnowledgeBaseRetrievalResult) -> Self {
67        let mut v = self.retrieval_results.unwrap_or_default();
68        v.push(input);
69        self.retrieval_results = ::std::option::Option::Some(v);
70        self
71    }
72    /// <p>A list of results from querying the knowledge base.</p>
73    pub fn set_retrieval_results(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::KnowledgeBaseRetrievalResult>>) -> Self {
74        self.retrieval_results = input;
75        self
76    }
77    /// <p>A list of results from querying the knowledge base.</p>
78    pub fn get_retrieval_results(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::KnowledgeBaseRetrievalResult>> {
79        &self.retrieval_results
80    }
81    /// <p>Specifies if there is a guardrail intervention in the response.</p>
82    pub fn guardrail_action(mut self, input: crate::types::GuadrailAction) -> Self {
83        self.guardrail_action = ::std::option::Option::Some(input);
84        self
85    }
86    /// <p>Specifies if there is a guardrail intervention in the response.</p>
87    pub fn set_guardrail_action(mut self, input: ::std::option::Option<crate::types::GuadrailAction>) -> Self {
88        self.guardrail_action = input;
89        self
90    }
91    /// <p>Specifies if there is a guardrail intervention in the response.</p>
92    pub fn get_guardrail_action(&self) -> &::std::option::Option<crate::types::GuadrailAction> {
93        &self.guardrail_action
94    }
95    /// <p>If there are more results than can fit in the response, the response returns a <code>nextToken</code>. Use this token in the <code>nextToken</code> field of another request to retrieve the next batch of results.</p>
96    pub fn next_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
97        self.next_token = ::std::option::Option::Some(input.into());
98        self
99    }
100    /// <p>If there are more results than can fit in the response, the response returns a <code>nextToken</code>. Use this token in the <code>nextToken</code> field of another request to retrieve the next batch of results.</p>
101    pub fn set_next_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
102        self.next_token = input;
103        self
104    }
105    /// <p>If there are more results than can fit in the response, the response returns a <code>nextToken</code>. Use this token in the <code>nextToken</code> field of another request to retrieve the next batch of results.</p>
106    pub fn get_next_token(&self) -> &::std::option::Option<::std::string::String> {
107        &self.next_token
108    }
109    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
110        self._request_id = Some(request_id.into());
111        self
112    }
113
114    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
115        self._request_id = request_id;
116        self
117    }
118    /// Consumes the builder and constructs a [`RetrieveOutput`](crate::operation::retrieve::RetrieveOutput).
119    /// This method will fail if any of the following fields are not set:
120    /// - [`retrieval_results`](crate::operation::retrieve::builders::RetrieveOutputBuilder::retrieval_results)
121    pub fn build(self) -> ::std::result::Result<crate::operation::retrieve::RetrieveOutput, ::aws_smithy_types::error::operation::BuildError> {
122        ::std::result::Result::Ok(crate::operation::retrieve::RetrieveOutput {
123            retrieval_results: self.retrieval_results.ok_or_else(|| {
124                ::aws_smithy_types::error::operation::BuildError::missing_field(
125                    "retrieval_results",
126                    "retrieval_results was not specified but it is required when building RetrieveOutput",
127                )
128            })?,
129            guardrail_action: self.guardrail_action,
130            next_token: self.next_token,
131            _request_id: self._request_id,
132        })
133    }
134}
135impl ::std::fmt::Debug for RetrieveOutputBuilder {
136    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
137        let mut formatter = f.debug_struct("RetrieveOutputBuilder");
138        formatter.field("retrieval_results", &"*** Sensitive Data Redacted ***");
139        formatter.field("guardrail_action", &self.guardrail_action);
140        formatter.field("next_token", &self.next_token);
141        formatter.field("_request_id", &self._request_id);
142        formatter.finish()
143    }
144}