aws_sdk_comprehend/operation/classify_document/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::classify_document::_classify_document_output::ClassifyDocumentOutputBuilder;
3
4pub use crate::operation::classify_document::_classify_document_input::ClassifyDocumentInputBuilder;
5
6impl crate::operation::classify_document::builders::ClassifyDocumentInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(
9 self,
10 client: &crate::Client,
11 ) -> ::std::result::Result<
12 crate::operation::classify_document::ClassifyDocumentOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::classify_document::ClassifyDocumentError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.classify_document();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `ClassifyDocument`.
24///
25/// <p>Creates a classification request to analyze a single document in real-time. <code>ClassifyDocument</code> supports the following model types:</p>
26/// <ul>
27/// <li>
28/// <p>Custom classifier - a custom model that you have created and trained. For input, you can provide plain text, a single-page document (PDF, Word, or image), or Amazon Textract API output. For more information, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/how-document-classification.html">Custom classification</a> in the <i>Amazon Comprehend Developer Guide</i>.</p></li>
29/// <li>
30/// <p>Prompt safety classifier - Amazon Comprehend provides a pre-trained model for classifying input prompts for generative AI applications. For input, you provide English plain text input. For prompt safety classification, the response includes only the <code>Classes</code> field. For more information about prompt safety classifiers, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/trust-safety.html#prompt-classification">Prompt safety classification</a> in the <i>Amazon Comprehend Developer Guide</i>.</p></li>
31/// </ul>
32/// <p>If the system detects errors while processing a page in the input document, the API response includes an <code>Errors</code> field that describes the errors.</p>
33/// <p>If the system detects a document-level error in your input document, the API returns an <code>InvalidRequestException</code> error response. For details about this exception, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/idp-inputs-sync-err.html"> Errors in semi-structured documents</a> in the Comprehend Developer Guide.</p>
34#[derive(::std::clone::Clone, ::std::fmt::Debug)]
35pub struct ClassifyDocumentFluentBuilder {
36 handle: ::std::sync::Arc<crate::client::Handle>,
37 inner: crate::operation::classify_document::builders::ClassifyDocumentInputBuilder,
38 config_override: ::std::option::Option<crate::config::Builder>,
39}
40impl
41 crate::client::customize::internal::CustomizableSend<
42 crate::operation::classify_document::ClassifyDocumentOutput,
43 crate::operation::classify_document::ClassifyDocumentError,
44 > for ClassifyDocumentFluentBuilder
45{
46 fn send(
47 self,
48 config_override: crate::config::Builder,
49 ) -> crate::client::customize::internal::BoxFuture<
50 crate::client::customize::internal::SendResult<
51 crate::operation::classify_document::ClassifyDocumentOutput,
52 crate::operation::classify_document::ClassifyDocumentError,
53 >,
54 > {
55 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
56 }
57}
58impl ClassifyDocumentFluentBuilder {
59 /// Creates a new `ClassifyDocumentFluentBuilder`.
60 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
61 Self {
62 handle,
63 inner: ::std::default::Default::default(),
64 config_override: ::std::option::Option::None,
65 }
66 }
67 /// Access the ClassifyDocument as a reference.
68 pub fn as_input(&self) -> &crate::operation::classify_document::builders::ClassifyDocumentInputBuilder {
69 &self.inner
70 }
71 /// Sends the request and returns the response.
72 ///
73 /// If an error occurs, an `SdkError` will be returned with additional details that
74 /// can be matched against.
75 ///
76 /// By default, any retryable failures will be retried twice. Retry behavior
77 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
78 /// set when configuring the client.
79 pub async fn send(
80 self,
81 ) -> ::std::result::Result<
82 crate::operation::classify_document::ClassifyDocumentOutput,
83 ::aws_smithy_runtime_api::client::result::SdkError<
84 crate::operation::classify_document::ClassifyDocumentError,
85 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
86 >,
87 > {
88 let input = self
89 .inner
90 .build()
91 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
92 let runtime_plugins = crate::operation::classify_document::ClassifyDocument::operation_runtime_plugins(
93 self.handle.runtime_plugins.clone(),
94 &self.handle.conf,
95 self.config_override,
96 );
97 crate::operation::classify_document::ClassifyDocument::orchestrate(&runtime_plugins, input).await
98 }
99
100 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
101 pub fn customize(
102 self,
103 ) -> crate::client::customize::CustomizableOperation<
104 crate::operation::classify_document::ClassifyDocumentOutput,
105 crate::operation::classify_document::ClassifyDocumentError,
106 Self,
107 > {
108 crate::client::customize::CustomizableOperation::new(self)
109 }
110 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
111 self.set_config_override(::std::option::Option::Some(config_override.into()));
112 self
113 }
114
115 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
116 self.config_override = config_override;
117 self
118 }
119 /// <p>The document text to be analyzed. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
120 pub fn text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
121 self.inner = self.inner.text(input.into());
122 self
123 }
124 /// <p>The document text to be analyzed. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
125 pub fn set_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
126 self.inner = self.inner.set_text(input);
127 self
128 }
129 /// <p>The document text to be analyzed. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
130 pub fn get_text(&self) -> &::std::option::Option<::std::string::String> {
131 self.inner.get_text()
132 }
133 /// <p>The Amazon Resource Number (ARN) of the endpoint.</p>
134 /// <p>For prompt safety classification, Amazon Comprehend provides the endpoint ARN. For more information about prompt safety classifiers, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/trust-safety.html#prompt-classification">Prompt safety classification</a> in the <i>Amazon Comprehend Developer Guide</i></p>
135 /// <p>For custom classification, you create an endpoint for your custom model. For more information, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/using-endpoints.html">Using Amazon Comprehend endpoints</a>.</p>
136 pub fn endpoint_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
137 self.inner = self.inner.endpoint_arn(input.into());
138 self
139 }
140 /// <p>The Amazon Resource Number (ARN) of the endpoint.</p>
141 /// <p>For prompt safety classification, Amazon Comprehend provides the endpoint ARN. For more information about prompt safety classifiers, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/trust-safety.html#prompt-classification">Prompt safety classification</a> in the <i>Amazon Comprehend Developer Guide</i></p>
142 /// <p>For custom classification, you create an endpoint for your custom model. For more information, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/using-endpoints.html">Using Amazon Comprehend endpoints</a>.</p>
143 pub fn set_endpoint_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
144 self.inner = self.inner.set_endpoint_arn(input);
145 self
146 }
147 /// <p>The Amazon Resource Number (ARN) of the endpoint.</p>
148 /// <p>For prompt safety classification, Amazon Comprehend provides the endpoint ARN. For more information about prompt safety classifiers, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/trust-safety.html#prompt-classification">Prompt safety classification</a> in the <i>Amazon Comprehend Developer Guide</i></p>
149 /// <p>For custom classification, you create an endpoint for your custom model. For more information, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/using-endpoints.html">Using Amazon Comprehend endpoints</a>.</p>
150 pub fn get_endpoint_arn(&self) -> &::std::option::Option<::std::string::String> {
151 self.inner.get_endpoint_arn()
152 }
153 /// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file.</p>
154 /// <p>When you classify a document using a custom model, you can also use the <code>Bytes</code> parameter to input an Amazon Textract <code>DetectDocumentText</code> or <code>AnalyzeDocument</code> output file.</p>
155 /// <p>To classify a document using the prompt safety classifier, use the <code>Text</code> parameter for input.</p>
156 /// <p>Provide the input document as a sequence of base64-encoded bytes. If your code uses an Amazon Web Services SDK to classify documents, the SDK may encode the document file bytes for you.</p>
157 /// <p>The maximum length of this field depends on the input document type. For details, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/idp-inputs-sync.html"> Inputs for real-time custom analysis</a> in the Comprehend Developer Guide.</p>
158 /// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
159 pub fn bytes(mut self, input: ::aws_smithy_types::Blob) -> Self {
160 self.inner = self.inner.bytes(input);
161 self
162 }
163 /// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file.</p>
164 /// <p>When you classify a document using a custom model, you can also use the <code>Bytes</code> parameter to input an Amazon Textract <code>DetectDocumentText</code> or <code>AnalyzeDocument</code> output file.</p>
165 /// <p>To classify a document using the prompt safety classifier, use the <code>Text</code> parameter for input.</p>
166 /// <p>Provide the input document as a sequence of base64-encoded bytes. If your code uses an Amazon Web Services SDK to classify documents, the SDK may encode the document file bytes for you.</p>
167 /// <p>The maximum length of this field depends on the input document type. For details, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/idp-inputs-sync.html"> Inputs for real-time custom analysis</a> in the Comprehend Developer Guide.</p>
168 /// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
169 pub fn set_bytes(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
170 self.inner = self.inner.set_bytes(input);
171 self
172 }
173 /// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file.</p>
174 /// <p>When you classify a document using a custom model, you can also use the <code>Bytes</code> parameter to input an Amazon Textract <code>DetectDocumentText</code> or <code>AnalyzeDocument</code> output file.</p>
175 /// <p>To classify a document using the prompt safety classifier, use the <code>Text</code> parameter for input.</p>
176 /// <p>Provide the input document as a sequence of base64-encoded bytes. If your code uses an Amazon Web Services SDK to classify documents, the SDK may encode the document file bytes for you.</p>
177 /// <p>The maximum length of this field depends on the input document type. For details, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/idp-inputs-sync.html"> Inputs for real-time custom analysis</a> in the Comprehend Developer Guide.</p>
178 /// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
179 pub fn get_bytes(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
180 self.inner.get_bytes()
181 }
182 /// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
183 pub fn document_reader_config(mut self, input: crate::types::DocumentReaderConfig) -> Self {
184 self.inner = self.inner.document_reader_config(input);
185 self
186 }
187 /// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
188 pub fn set_document_reader_config(mut self, input: ::std::option::Option<crate::types::DocumentReaderConfig>) -> Self {
189 self.inner = self.inner.set_document_reader_config(input);
190 self
191 }
192 /// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
193 pub fn get_document_reader_config(&self) -> &::std::option::Option<crate::types::DocumentReaderConfig> {
194 self.inner.get_document_reader_config()
195 }
196}