// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::classify_document::_classify_document_input::ClassifyDocumentInputBuilder;
pub use crate::operation::classify_document::_classify_document_output::ClassifyDocumentOutputBuilder;
impl crate::operation::classify_document::builders::ClassifyDocumentInputBuilder {
/// Sends a request with this input using the given client.
pub async fn send_with(
self,
client: &crate::Client,
) -> ::std::result::Result<
crate::operation::classify_document::ClassifyDocumentOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::classify_document::ClassifyDocumentError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let mut fluent_builder = client.classify_document();
fluent_builder.inner = self;
fluent_builder.send().await
}
}
/// Fluent builder constructing a request to `ClassifyDocument`.
///
/// <p>Creates a classification request to analyze a single document in real-time. <code>ClassifyDocument</code> supports the following model types:</p>
/// <ul>
/// <li>
/// <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>
/// <li>
/// <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>
/// </ul>
/// <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>
/// <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>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct ClassifyDocumentFluentBuilder {
handle: ::std::sync::Arc<crate::client::Handle>,
inner: crate::operation::classify_document::builders::ClassifyDocumentInputBuilder,
config_override: ::std::option::Option<crate::config::Builder>,
}
impl
crate::client::customize::internal::CustomizableSend<
crate::operation::classify_document::ClassifyDocumentOutput,
crate::operation::classify_document::ClassifyDocumentError,
> for ClassifyDocumentFluentBuilder
{
fn send(
self,
config_override: crate::config::Builder,
) -> crate::client::customize::internal::BoxFuture<
crate::client::customize::internal::SendResult<
crate::operation::classify_document::ClassifyDocumentOutput,
crate::operation::classify_document::ClassifyDocumentError,
>,
> {
::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
}
}
impl ClassifyDocumentFluentBuilder {
/// Creates a new `ClassifyDocumentFluentBuilder`.
pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
Self {
handle,
inner: ::std::default::Default::default(),
config_override: ::std::option::Option::None,
}
}
/// Access the ClassifyDocument as a reference.
pub fn as_input(&self) -> &crate::operation::classify_document::builders::ClassifyDocumentInputBuilder {
&self.inner
}
/// Sends the request and returns the response.
///
/// If an error occurs, an `SdkError` will be returned with additional details that
/// can be matched against.
///
/// By default, any retryable failures will be retried twice. Retry behavior
/// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
/// set when configuring the client.
pub async fn send(
self,
) -> ::std::result::Result<
crate::operation::classify_document::ClassifyDocumentOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::classify_document::ClassifyDocumentError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let input = self
.inner
.build()
.map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
let runtime_plugins = crate::operation::classify_document::ClassifyDocument::operation_runtime_plugins(
self.handle.runtime_plugins.clone(),
&self.handle.conf,
self.config_override,
);
crate::operation::classify_document::ClassifyDocument::orchestrate(&runtime_plugins, input).await
}
/// Consumes this builder, creating a customizable operation that can be modified before being sent.
pub fn customize(
self,
) -> crate::client::customize::CustomizableOperation<
crate::operation::classify_document::ClassifyDocumentOutput,
crate::operation::classify_document::ClassifyDocumentError,
Self,
> {
crate::client::customize::CustomizableOperation::new(self)
}
pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
self.set_config_override(::std::option::Option::Some(config_override.into()));
self
}
pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
self.config_override = config_override;
self
}
/// <p>The document text to be analyzed. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
pub fn text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.text(input.into());
self
}
/// <p>The document text to be analyzed. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
pub fn set_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_text(input);
self
}
/// <p>The document text to be analyzed. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
pub fn get_text(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_text()
}
/// <p>The Amazon Resource Number (ARN) of the endpoint.</p>
/// <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>
/// <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>
pub fn endpoint_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.endpoint_arn(input.into());
self
}
/// <p>The Amazon Resource Number (ARN) of the endpoint.</p>
/// <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>
/// <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>
pub fn set_endpoint_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_endpoint_arn(input);
self
}
/// <p>The Amazon Resource Number (ARN) of the endpoint.</p>
/// <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>
/// <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>
pub fn get_endpoint_arn(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_endpoint_arn()
}
/// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file.</p>
/// <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>
/// <p>To classify a document using the prompt safety classifier, use the <code>Text</code> parameter for input.</p>
/// <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>
/// <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>
/// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
pub fn bytes(mut self, input: ::aws_smithy_types::Blob) -> Self {
self.inner = self.inner.bytes(input);
self
}
/// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file.</p>
/// <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>
/// <p>To classify a document using the prompt safety classifier, use the <code>Text</code> parameter for input.</p>
/// <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>
/// <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>
/// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
pub fn set_bytes(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
self.inner = self.inner.set_bytes(input);
self
}
/// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file.</p>
/// <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>
/// <p>To classify a document using the prompt safety classifier, use the <code>Text</code> parameter for input.</p>
/// <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>
/// <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>
/// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
pub fn get_bytes(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
self.inner.get_bytes()
}
/// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
pub fn document_reader_config(mut self, input: crate::types::DocumentReaderConfig) -> Self {
self.inner = self.inner.document_reader_config(input);
self
}
/// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
pub fn set_document_reader_config(mut self, input: ::std::option::Option<crate::types::DocumentReaderConfig>) -> Self {
self.inner = self.inner.set_document_reader_config(input);
self
}
/// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
pub fn get_document_reader_config(&self) -> &::std::option::Option<crate::types::DocumentReaderConfig> {
self.inner.get_document_reader_config()
}
}