aws_sdk_translate/operation/translate_document/_translate_document_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 TranslateDocumentOutput {
6 /// <p>The document containing the translated content. The document format matches the source document format.</p>
7 pub translated_document: ::std::option::Option<crate::types::TranslatedDocument>,
8 /// <p>The language code of the source document.</p>
9 pub source_language_code: ::std::string::String,
10 /// <p>The language code of the translated document.</p>
11 pub target_language_code: ::std::string::String,
12 /// <p>The names of the custom terminologies applied to the input text by Amazon Translate to produce the translated text document.</p>
13 pub applied_terminologies: ::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>>,
14 /// <p>Settings to configure your translation output. You can configure the following options:</p>
15 /// <ul>
16 /// <li>
17 /// <p>Brevity: reduces the length of the translation output for most translations. Available for <code>TranslateText</code> only.</p></li>
18 /// <li>
19 /// <p>Formality: sets the formality level of the translation output.</p></li>
20 /// <li>
21 /// <p>Profanity: masks profane words and phrases in the translation output.</p></li>
22 /// </ul>
23 pub applied_settings: ::std::option::Option<crate::types::TranslationSettings>,
24 _request_id: Option<String>,
25}
26impl TranslateDocumentOutput {
27 /// <p>The document containing the translated content. The document format matches the source document format.</p>
28 pub fn translated_document(&self) -> ::std::option::Option<&crate::types::TranslatedDocument> {
29 self.translated_document.as_ref()
30 }
31 /// <p>The language code of the source document.</p>
32 pub fn source_language_code(&self) -> &str {
33 use std::ops::Deref;
34 self.source_language_code.deref()
35 }
36 /// <p>The language code of the translated document.</p>
37 pub fn target_language_code(&self) -> &str {
38 use std::ops::Deref;
39 self.target_language_code.deref()
40 }
41 /// <p>The names of the custom terminologies applied to the input text by Amazon Translate to produce the translated text document.</p>
42 ///
43 /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.applied_terminologies.is_none()`.
44 pub fn applied_terminologies(&self) -> &[crate::types::AppliedTerminology] {
45 self.applied_terminologies.as_deref().unwrap_or_default()
46 }
47 /// <p>Settings to configure your translation output. You can configure the following options:</p>
48 /// <ul>
49 /// <li>
50 /// <p>Brevity: reduces the length of the translation output for most translations. Available for <code>TranslateText</code> only.</p></li>
51 /// <li>
52 /// <p>Formality: sets the formality level of the translation output.</p></li>
53 /// <li>
54 /// <p>Profanity: masks profane words and phrases in the translation output.</p></li>
55 /// </ul>
56 pub fn applied_settings(&self) -> ::std::option::Option<&crate::types::TranslationSettings> {
57 self.applied_settings.as_ref()
58 }
59}
60impl ::aws_types::request_id::RequestId for TranslateDocumentOutput {
61 fn request_id(&self) -> Option<&str> {
62 self._request_id.as_deref()
63 }
64}
65impl TranslateDocumentOutput {
66 /// Creates a new builder-style object to manufacture [`TranslateDocumentOutput`](crate::operation::translate_document::TranslateDocumentOutput).
67 pub fn builder() -> crate::operation::translate_document::builders::TranslateDocumentOutputBuilder {
68 crate::operation::translate_document::builders::TranslateDocumentOutputBuilder::default()
69 }
70}
71
72/// A builder for [`TranslateDocumentOutput`](crate::operation::translate_document::TranslateDocumentOutput).
73#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
74#[non_exhaustive]
75pub struct TranslateDocumentOutputBuilder {
76 pub(crate) translated_document: ::std::option::Option<crate::types::TranslatedDocument>,
77 pub(crate) source_language_code: ::std::option::Option<::std::string::String>,
78 pub(crate) target_language_code: ::std::option::Option<::std::string::String>,
79 pub(crate) applied_terminologies: ::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>>,
80 pub(crate) applied_settings: ::std::option::Option<crate::types::TranslationSettings>,
81 _request_id: Option<String>,
82}
83impl TranslateDocumentOutputBuilder {
84 /// <p>The document containing the translated content. The document format matches the source document format.</p>
85 /// This field is required.
86 pub fn translated_document(mut self, input: crate::types::TranslatedDocument) -> Self {
87 self.translated_document = ::std::option::Option::Some(input);
88 self
89 }
90 /// <p>The document containing the translated content. The document format matches the source document format.</p>
91 pub fn set_translated_document(mut self, input: ::std::option::Option<crate::types::TranslatedDocument>) -> Self {
92 self.translated_document = input;
93 self
94 }
95 /// <p>The document containing the translated content. The document format matches the source document format.</p>
96 pub fn get_translated_document(&self) -> &::std::option::Option<crate::types::TranslatedDocument> {
97 &self.translated_document
98 }
99 /// <p>The language code of the source document.</p>
100 /// This field is required.
101 pub fn source_language_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
102 self.source_language_code = ::std::option::Option::Some(input.into());
103 self
104 }
105 /// <p>The language code of the source document.</p>
106 pub fn set_source_language_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
107 self.source_language_code = input;
108 self
109 }
110 /// <p>The language code of the source document.</p>
111 pub fn get_source_language_code(&self) -> &::std::option::Option<::std::string::String> {
112 &self.source_language_code
113 }
114 /// <p>The language code of the translated document.</p>
115 /// This field is required.
116 pub fn target_language_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
117 self.target_language_code = ::std::option::Option::Some(input.into());
118 self
119 }
120 /// <p>The language code of the translated document.</p>
121 pub fn set_target_language_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
122 self.target_language_code = input;
123 self
124 }
125 /// <p>The language code of the translated document.</p>
126 pub fn get_target_language_code(&self) -> &::std::option::Option<::std::string::String> {
127 &self.target_language_code
128 }
129 /// Appends an item to `applied_terminologies`.
130 ///
131 /// To override the contents of this collection use [`set_applied_terminologies`](Self::set_applied_terminologies).
132 ///
133 /// <p>The names of the custom terminologies applied to the input text by Amazon Translate to produce the translated text document.</p>
134 pub fn applied_terminologies(mut self, input: crate::types::AppliedTerminology) -> Self {
135 let mut v = self.applied_terminologies.unwrap_or_default();
136 v.push(input);
137 self.applied_terminologies = ::std::option::Option::Some(v);
138 self
139 }
140 /// <p>The names of the custom terminologies applied to the input text by Amazon Translate to produce the translated text document.</p>
141 pub fn set_applied_terminologies(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>>) -> Self {
142 self.applied_terminologies = input;
143 self
144 }
145 /// <p>The names of the custom terminologies applied to the input text by Amazon Translate to produce the translated text document.</p>
146 pub fn get_applied_terminologies(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::AppliedTerminology>> {
147 &self.applied_terminologies
148 }
149 /// <p>Settings to configure your translation output. You can configure the following options:</p>
150 /// <ul>
151 /// <li>
152 /// <p>Brevity: reduces the length of the translation output for most translations. Available for <code>TranslateText</code> only.</p></li>
153 /// <li>
154 /// <p>Formality: sets the formality level of the translation output.</p></li>
155 /// <li>
156 /// <p>Profanity: masks profane words and phrases in the translation output.</p></li>
157 /// </ul>
158 pub fn applied_settings(mut self, input: crate::types::TranslationSettings) -> Self {
159 self.applied_settings = ::std::option::Option::Some(input);
160 self
161 }
162 /// <p>Settings to configure your translation output. You can configure the following options:</p>
163 /// <ul>
164 /// <li>
165 /// <p>Brevity: reduces the length of the translation output for most translations. Available for <code>TranslateText</code> only.</p></li>
166 /// <li>
167 /// <p>Formality: sets the formality level of the translation output.</p></li>
168 /// <li>
169 /// <p>Profanity: masks profane words and phrases in the translation output.</p></li>
170 /// </ul>
171 pub fn set_applied_settings(mut self, input: ::std::option::Option<crate::types::TranslationSettings>) -> Self {
172 self.applied_settings = input;
173 self
174 }
175 /// <p>Settings to configure your translation output. You can configure the following options:</p>
176 /// <ul>
177 /// <li>
178 /// <p>Brevity: reduces the length of the translation output for most translations. Available for <code>TranslateText</code> only.</p></li>
179 /// <li>
180 /// <p>Formality: sets the formality level of the translation output.</p></li>
181 /// <li>
182 /// <p>Profanity: masks profane words and phrases in the translation output.</p></li>
183 /// </ul>
184 pub fn get_applied_settings(&self) -> &::std::option::Option<crate::types::TranslationSettings> {
185 &self.applied_settings
186 }
187 pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
188 self._request_id = Some(request_id.into());
189 self
190 }
191
192 pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
193 self._request_id = request_id;
194 self
195 }
196 /// Consumes the builder and constructs a [`TranslateDocumentOutput`](crate::operation::translate_document::TranslateDocumentOutput).
197 /// This method will fail if any of the following fields are not set:
198 /// - [`source_language_code`](crate::operation::translate_document::builders::TranslateDocumentOutputBuilder::source_language_code)
199 /// - [`target_language_code`](crate::operation::translate_document::builders::TranslateDocumentOutputBuilder::target_language_code)
200 pub fn build(
201 self,
202 ) -> ::std::result::Result<crate::operation::translate_document::TranslateDocumentOutput, ::aws_smithy_types::error::operation::BuildError> {
203 ::std::result::Result::Ok(crate::operation::translate_document::TranslateDocumentOutput {
204 translated_document: self.translated_document,
205 source_language_code: self.source_language_code.ok_or_else(|| {
206 ::aws_smithy_types::error::operation::BuildError::missing_field(
207 "source_language_code",
208 "source_language_code was not specified but it is required when building TranslateDocumentOutput",
209 )
210 })?,
211 target_language_code: self.target_language_code.ok_or_else(|| {
212 ::aws_smithy_types::error::operation::BuildError::missing_field(
213 "target_language_code",
214 "target_language_code was not specified but it is required when building TranslateDocumentOutput",
215 )
216 })?,
217 applied_terminologies: self.applied_terminologies,
218 applied_settings: self.applied_settings,
219 _request_id: self._request_id,
220 })
221 }
222}