aws_sdk_comprehend/operation/detect_entities/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::detect_entities::_detect_entities_output::DetectEntitiesOutputBuilder;
3
4pub use crate::operation::detect_entities::_detect_entities_input::DetectEntitiesInputBuilder;
5
6impl crate::operation::detect_entities::builders::DetectEntitiesInputBuilder {
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::detect_entities::DetectEntitiesOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::detect_entities::DetectEntitiesError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.detect_entities();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `DetectEntities`.
24///
25/// <p>Detects named entities in input text when you use the pre-trained model. Detects custom entities if you have a custom entity recognition model.</p>
26/// <p>When detecting named entities using the pre-trained model, use plain text as the input. For more information about named entities, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/how-entities.html">Entities</a> in the Comprehend Developer Guide.</p>
27/// <p>When you use a custom entity recognition model, you can input plain text or you can upload a single-page input document (text, PDF, Word, or image).</p>
28/// <p>If the system detects errors while processing a page in the input document, the API response includes an entry in <code>Errors</code> for each error.</p>
29/// <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>
30#[derive(::std::clone::Clone, ::std::fmt::Debug)]
31pub struct DetectEntitiesFluentBuilder {
32    handle: ::std::sync::Arc<crate::client::Handle>,
33    inner: crate::operation::detect_entities::builders::DetectEntitiesInputBuilder,
34    config_override: ::std::option::Option<crate::config::Builder>,
35}
36impl
37    crate::client::customize::internal::CustomizableSend<
38        crate::operation::detect_entities::DetectEntitiesOutput,
39        crate::operation::detect_entities::DetectEntitiesError,
40    > for DetectEntitiesFluentBuilder
41{
42    fn send(
43        self,
44        config_override: crate::config::Builder,
45    ) -> crate::client::customize::internal::BoxFuture<
46        crate::client::customize::internal::SendResult<
47            crate::operation::detect_entities::DetectEntitiesOutput,
48            crate::operation::detect_entities::DetectEntitiesError,
49        >,
50    > {
51        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
52    }
53}
54impl DetectEntitiesFluentBuilder {
55    /// Creates a new `DetectEntitiesFluentBuilder`.
56    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
57        Self {
58            handle,
59            inner: ::std::default::Default::default(),
60            config_override: ::std::option::Option::None,
61        }
62    }
63    /// Access the DetectEntities as a reference.
64    pub fn as_input(&self) -> &crate::operation::detect_entities::builders::DetectEntitiesInputBuilder {
65        &self.inner
66    }
67    /// Sends the request and returns the response.
68    ///
69    /// If an error occurs, an `SdkError` will be returned with additional details that
70    /// can be matched against.
71    ///
72    /// By default, any retryable failures will be retried twice. Retry behavior
73    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
74    /// set when configuring the client.
75    pub async fn send(
76        self,
77    ) -> ::std::result::Result<
78        crate::operation::detect_entities::DetectEntitiesOutput,
79        ::aws_smithy_runtime_api::client::result::SdkError<
80            crate::operation::detect_entities::DetectEntitiesError,
81            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
82        >,
83    > {
84        let input = self
85            .inner
86            .build()
87            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
88        let runtime_plugins = crate::operation::detect_entities::DetectEntities::operation_runtime_plugins(
89            self.handle.runtime_plugins.clone(),
90            &self.handle.conf,
91            self.config_override,
92        );
93        crate::operation::detect_entities::DetectEntities::orchestrate(&runtime_plugins, input).await
94    }
95
96    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
97    pub fn customize(
98        self,
99    ) -> crate::client::customize::CustomizableOperation<
100        crate::operation::detect_entities::DetectEntitiesOutput,
101        crate::operation::detect_entities::DetectEntitiesError,
102        Self,
103    > {
104        crate::client::customize::CustomizableOperation::new(self)
105    }
106    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
107        self.set_config_override(::std::option::Option::Some(config_override.into()));
108        self
109    }
110
111    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
112        self.config_override = config_override;
113        self
114    }
115    /// <p>A UTF-8 text string. The maximum string size is 100 KB. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
116    pub fn text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
117        self.inner = self.inner.text(input.into());
118        self
119    }
120    /// <p>A UTF-8 text string. The maximum string size is 100 KB. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
121    pub fn set_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
122        self.inner = self.inner.set_text(input);
123        self
124    }
125    /// <p>A UTF-8 text string. The maximum string size is 100 KB. If you enter text using this parameter, do not use the <code>Bytes</code> parameter.</p>
126    pub fn get_text(&self) -> &::std::option::Option<::std::string::String> {
127        self.inner.get_text()
128    }
129    /// <p>The language of the input documents. You can specify any of the primary languages supported by Amazon Comprehend. If your request includes the endpoint for a custom entity recognition model, Amazon Comprehend uses the language of your custom model, and it ignores any language code that you specify here.</p>
130    /// <p>All input documents must be in the same language.</p>
131    pub fn language_code(mut self, input: crate::types::LanguageCode) -> Self {
132        self.inner = self.inner.language_code(input);
133        self
134    }
135    /// <p>The language of the input documents. You can specify any of the primary languages supported by Amazon Comprehend. If your request includes the endpoint for a custom entity recognition model, Amazon Comprehend uses the language of your custom model, and it ignores any language code that you specify here.</p>
136    /// <p>All input documents must be in the same language.</p>
137    pub fn set_language_code(mut self, input: ::std::option::Option<crate::types::LanguageCode>) -> Self {
138        self.inner = self.inner.set_language_code(input);
139        self
140    }
141    /// <p>The language of the input documents. You can specify any of the primary languages supported by Amazon Comprehend. If your request includes the endpoint for a custom entity recognition model, Amazon Comprehend uses the language of your custom model, and it ignores any language code that you specify here.</p>
142    /// <p>All input documents must be in the same language.</p>
143    pub fn get_language_code(&self) -> &::std::option::Option<crate::types::LanguageCode> {
144        self.inner.get_language_code()
145    }
146    /// <p>The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model. Provide an endpoint if you want to detect entities by using your own custom model instead of the default model that is used by Amazon Comprehend.</p>
147    /// <p>If you specify an endpoint, Amazon Comprehend uses the language of your custom model, and it ignores any language code that you provide in your request.</p>
148    /// <p>For information about endpoints, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/manage-endpoints.html">Managing endpoints</a>.</p>
149    pub fn endpoint_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
150        self.inner = self.inner.endpoint_arn(input.into());
151        self
152    }
153    /// <p>The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model. Provide an endpoint if you want to detect entities by using your own custom model instead of the default model that is used by Amazon Comprehend.</p>
154    /// <p>If you specify an endpoint, Amazon Comprehend uses the language of your custom model, and it ignores any language code that you provide in your request.</p>
155    /// <p>For information about endpoints, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/manage-endpoints.html">Managing endpoints</a>.</p>
156    pub fn set_endpoint_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
157        self.inner = self.inner.set_endpoint_arn(input);
158        self
159    }
160    /// <p>The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model. Provide an endpoint if you want to detect entities by using your own custom model instead of the default model that is used by Amazon Comprehend.</p>
161    /// <p>If you specify an endpoint, Amazon Comprehend uses the language of your custom model, and it ignores any language code that you provide in your request.</p>
162    /// <p>For information about endpoints, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/manage-endpoints.html">Managing endpoints</a>.</p>
163    pub fn get_endpoint_arn(&self) -> &::std::option::Option<::std::string::String> {
164        self.inner.get_endpoint_arn()
165    }
166    /// <p>This field applies only when you use a custom entity recognition model that was trained with PDF annotations. For other cases, enter your text input in the <code>Text</code> field.</p>
167    /// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file. Using a plain-text file in the <code>Bytes</code> parameter is equivelent to using the <code>Text</code> parameter (the <code>Entities</code> field in the response is identical).</p>
168    /// <p>You can also use the <code>Bytes</code> parameter to input an Amazon Textract <code>DetectDocumentText</code> or <code>AnalyzeDocument</code> output file.</p>
169    /// <p>Provide the input document as a sequence of base64-encoded bytes. If your code uses an Amazon Web Services SDK to detect entities, the SDK may encode the document file bytes for you.</p>
170    /// <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>
171    /// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
172    pub fn bytes(mut self, input: ::aws_smithy_types::Blob) -> Self {
173        self.inner = self.inner.bytes(input);
174        self
175    }
176    /// <p>This field applies only when you use a custom entity recognition model that was trained with PDF annotations. For other cases, enter your text input in the <code>Text</code> field.</p>
177    /// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file. Using a plain-text file in the <code>Bytes</code> parameter is equivelent to using the <code>Text</code> parameter (the <code>Entities</code> field in the response is identical).</p>
178    /// <p>You can also use the <code>Bytes</code> parameter to input an Amazon Textract <code>DetectDocumentText</code> or <code>AnalyzeDocument</code> output file.</p>
179    /// <p>Provide the input document as a sequence of base64-encoded bytes. If your code uses an Amazon Web Services SDK to detect entities, the SDK may encode the document file bytes for you.</p>
180    /// <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>
181    /// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
182    pub fn set_bytes(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
183        self.inner = self.inner.set_bytes(input);
184        self
185    }
186    /// <p>This field applies only when you use a custom entity recognition model that was trained with PDF annotations. For other cases, enter your text input in the <code>Text</code> field.</p>
187    /// <p>Use the <code>Bytes</code> parameter to input a text, PDF, Word or image file. Using a plain-text file in the <code>Bytes</code> parameter is equivelent to using the <code>Text</code> parameter (the <code>Entities</code> field in the response is identical).</p>
188    /// <p>You can also use the <code>Bytes</code> parameter to input an Amazon Textract <code>DetectDocumentText</code> or <code>AnalyzeDocument</code> output file.</p>
189    /// <p>Provide the input document as a sequence of base64-encoded bytes. If your code uses an Amazon Web Services SDK to detect entities, the SDK may encode the document file bytes for you.</p>
190    /// <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>
191    /// <p>If you use the <code>Bytes</code> parameter, do not use the <code>Text</code> parameter.</p>
192    pub fn get_bytes(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
193        self.inner.get_bytes()
194    }
195    /// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
196    pub fn document_reader_config(mut self, input: crate::types::DocumentReaderConfig) -> Self {
197        self.inner = self.inner.document_reader_config(input);
198        self
199    }
200    /// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
201    pub fn set_document_reader_config(mut self, input: ::std::option::Option<crate::types::DocumentReaderConfig>) -> Self {
202        self.inner = self.inner.set_document_reader_config(input);
203        self
204    }
205    /// <p>Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.</p>
206    pub fn get_document_reader_config(&self) -> &::std::option::Option<crate::types::DocumentReaderConfig> {
207        self.inner.get_document_reader_config()
208    }
209}