aws_sdk_bedrockruntime/operation/apply_guardrail/
_apply_guardrail_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, ::std::fmt::Debug)]
5pub struct ApplyGuardrailOutput {
6    /// <p>The usage details in the response from the guardrail.</p>
7    pub usage: ::std::option::Option<crate::types::GuardrailUsage>,
8    /// <p>The action taken in the response from the guardrail.</p>
9    pub action: crate::types::GuardrailAction,
10    /// <p>The reason for the action taken when harmful content is detected.</p>
11    pub action_reason: ::std::option::Option<::std::string::String>,
12    /// <p>The output details in the response from the guardrail.</p>
13    pub outputs: ::std::vec::Vec<crate::types::GuardrailOutputContent>,
14    /// <p>The assessment details in the response from the guardrail.</p>
15    pub assessments: ::std::vec::Vec<crate::types::GuardrailAssessment>,
16    /// <p>The guardrail coverage details in the apply guardrail response.</p>
17    pub guardrail_coverage: ::std::option::Option<crate::types::GuardrailCoverage>,
18    _request_id: Option<String>,
19}
20impl ApplyGuardrailOutput {
21    /// <p>The usage details in the response from the guardrail.</p>
22    pub fn usage(&self) -> ::std::option::Option<&crate::types::GuardrailUsage> {
23        self.usage.as_ref()
24    }
25    /// <p>The action taken in the response from the guardrail.</p>
26    pub fn action(&self) -> &crate::types::GuardrailAction {
27        &self.action
28    }
29    /// <p>The reason for the action taken when harmful content is detected.</p>
30    pub fn action_reason(&self) -> ::std::option::Option<&str> {
31        self.action_reason.as_deref()
32    }
33    /// <p>The output details in the response from the guardrail.</p>
34    pub fn outputs(&self) -> &[crate::types::GuardrailOutputContent] {
35        use std::ops::Deref;
36        self.outputs.deref()
37    }
38    /// <p>The assessment details in the response from the guardrail.</p>
39    pub fn assessments(&self) -> &[crate::types::GuardrailAssessment] {
40        use std::ops::Deref;
41        self.assessments.deref()
42    }
43    /// <p>The guardrail coverage details in the apply guardrail response.</p>
44    pub fn guardrail_coverage(&self) -> ::std::option::Option<&crate::types::GuardrailCoverage> {
45        self.guardrail_coverage.as_ref()
46    }
47}
48impl ::aws_types::request_id::RequestId for ApplyGuardrailOutput {
49    fn request_id(&self) -> Option<&str> {
50        self._request_id.as_deref()
51    }
52}
53impl ApplyGuardrailOutput {
54    /// Creates a new builder-style object to manufacture [`ApplyGuardrailOutput`](crate::operation::apply_guardrail::ApplyGuardrailOutput).
55    pub fn builder() -> crate::operation::apply_guardrail::builders::ApplyGuardrailOutputBuilder {
56        crate::operation::apply_guardrail::builders::ApplyGuardrailOutputBuilder::default()
57    }
58}
59
60/// A builder for [`ApplyGuardrailOutput`](crate::operation::apply_guardrail::ApplyGuardrailOutput).
61#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
62#[non_exhaustive]
63pub struct ApplyGuardrailOutputBuilder {
64    pub(crate) usage: ::std::option::Option<crate::types::GuardrailUsage>,
65    pub(crate) action: ::std::option::Option<crate::types::GuardrailAction>,
66    pub(crate) action_reason: ::std::option::Option<::std::string::String>,
67    pub(crate) outputs: ::std::option::Option<::std::vec::Vec<crate::types::GuardrailOutputContent>>,
68    pub(crate) assessments: ::std::option::Option<::std::vec::Vec<crate::types::GuardrailAssessment>>,
69    pub(crate) guardrail_coverage: ::std::option::Option<crate::types::GuardrailCoverage>,
70    _request_id: Option<String>,
71}
72impl ApplyGuardrailOutputBuilder {
73    /// <p>The usage details in the response from the guardrail.</p>
74    /// This field is required.
75    pub fn usage(mut self, input: crate::types::GuardrailUsage) -> Self {
76        self.usage = ::std::option::Option::Some(input);
77        self
78    }
79    /// <p>The usage details in the response from the guardrail.</p>
80    pub fn set_usage(mut self, input: ::std::option::Option<crate::types::GuardrailUsage>) -> Self {
81        self.usage = input;
82        self
83    }
84    /// <p>The usage details in the response from the guardrail.</p>
85    pub fn get_usage(&self) -> &::std::option::Option<crate::types::GuardrailUsage> {
86        &self.usage
87    }
88    /// <p>The action taken in the response from the guardrail.</p>
89    /// This field is required.
90    pub fn action(mut self, input: crate::types::GuardrailAction) -> Self {
91        self.action = ::std::option::Option::Some(input);
92        self
93    }
94    /// <p>The action taken in the response from the guardrail.</p>
95    pub fn set_action(mut self, input: ::std::option::Option<crate::types::GuardrailAction>) -> Self {
96        self.action = input;
97        self
98    }
99    /// <p>The action taken in the response from the guardrail.</p>
100    pub fn get_action(&self) -> &::std::option::Option<crate::types::GuardrailAction> {
101        &self.action
102    }
103    /// <p>The reason for the action taken when harmful content is detected.</p>
104    pub fn action_reason(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
105        self.action_reason = ::std::option::Option::Some(input.into());
106        self
107    }
108    /// <p>The reason for the action taken when harmful content is detected.</p>
109    pub fn set_action_reason(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
110        self.action_reason = input;
111        self
112    }
113    /// <p>The reason for the action taken when harmful content is detected.</p>
114    pub fn get_action_reason(&self) -> &::std::option::Option<::std::string::String> {
115        &self.action_reason
116    }
117    /// Appends an item to `outputs`.
118    ///
119    /// To override the contents of this collection use [`set_outputs`](Self::set_outputs).
120    ///
121    /// <p>The output details in the response from the guardrail.</p>
122    pub fn outputs(mut self, input: crate::types::GuardrailOutputContent) -> Self {
123        let mut v = self.outputs.unwrap_or_default();
124        v.push(input);
125        self.outputs = ::std::option::Option::Some(v);
126        self
127    }
128    /// <p>The output details in the response from the guardrail.</p>
129    pub fn set_outputs(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::GuardrailOutputContent>>) -> Self {
130        self.outputs = input;
131        self
132    }
133    /// <p>The output details in the response from the guardrail.</p>
134    pub fn get_outputs(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::GuardrailOutputContent>> {
135        &self.outputs
136    }
137    /// Appends an item to `assessments`.
138    ///
139    /// To override the contents of this collection use [`set_assessments`](Self::set_assessments).
140    ///
141    /// <p>The assessment details in the response from the guardrail.</p>
142    pub fn assessments(mut self, input: crate::types::GuardrailAssessment) -> Self {
143        let mut v = self.assessments.unwrap_or_default();
144        v.push(input);
145        self.assessments = ::std::option::Option::Some(v);
146        self
147    }
148    /// <p>The assessment details in the response from the guardrail.</p>
149    pub fn set_assessments(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::GuardrailAssessment>>) -> Self {
150        self.assessments = input;
151        self
152    }
153    /// <p>The assessment details in the response from the guardrail.</p>
154    pub fn get_assessments(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::GuardrailAssessment>> {
155        &self.assessments
156    }
157    /// <p>The guardrail coverage details in the apply guardrail response.</p>
158    pub fn guardrail_coverage(mut self, input: crate::types::GuardrailCoverage) -> Self {
159        self.guardrail_coverage = ::std::option::Option::Some(input);
160        self
161    }
162    /// <p>The guardrail coverage details in the apply guardrail response.</p>
163    pub fn set_guardrail_coverage(mut self, input: ::std::option::Option<crate::types::GuardrailCoverage>) -> Self {
164        self.guardrail_coverage = input;
165        self
166    }
167    /// <p>The guardrail coverage details in the apply guardrail response.</p>
168    pub fn get_guardrail_coverage(&self) -> &::std::option::Option<crate::types::GuardrailCoverage> {
169        &self.guardrail_coverage
170    }
171    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
172        self._request_id = Some(request_id.into());
173        self
174    }
175
176    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
177        self._request_id = request_id;
178        self
179    }
180    /// Consumes the builder and constructs a [`ApplyGuardrailOutput`](crate::operation::apply_guardrail::ApplyGuardrailOutput).
181    /// This method will fail if any of the following fields are not set:
182    /// - [`action`](crate::operation::apply_guardrail::builders::ApplyGuardrailOutputBuilder::action)
183    /// - [`outputs`](crate::operation::apply_guardrail::builders::ApplyGuardrailOutputBuilder::outputs)
184    /// - [`assessments`](crate::operation::apply_guardrail::builders::ApplyGuardrailOutputBuilder::assessments)
185    pub fn build(
186        self,
187    ) -> ::std::result::Result<crate::operation::apply_guardrail::ApplyGuardrailOutput, ::aws_smithy_types::error::operation::BuildError> {
188        ::std::result::Result::Ok(crate::operation::apply_guardrail::ApplyGuardrailOutput {
189            usage: self.usage,
190            action: self.action.ok_or_else(|| {
191                ::aws_smithy_types::error::operation::BuildError::missing_field(
192                    "action",
193                    "action was not specified but it is required when building ApplyGuardrailOutput",
194                )
195            })?,
196            action_reason: self.action_reason,
197            outputs: self.outputs.ok_or_else(|| {
198                ::aws_smithy_types::error::operation::BuildError::missing_field(
199                    "outputs",
200                    "outputs was not specified but it is required when building ApplyGuardrailOutput",
201                )
202            })?,
203            assessments: self.assessments.ok_or_else(|| {
204                ::aws_smithy_types::error::operation::BuildError::missing_field(
205                    "assessments",
206                    "assessments was not specified but it is required when building ApplyGuardrailOutput",
207                )
208            })?,
209            guardrail_coverage: self.guardrail_coverage,
210            _request_id: self._request_id,
211        })
212    }
213}