aws_sdk_rekognition/operation/detect_custom_labels/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::detect_custom_labels::_detect_custom_labels_output::DetectCustomLabelsOutputBuilder;
3
4pub use crate::operation::detect_custom_labels::_detect_custom_labels_input::DetectCustomLabelsInputBuilder;
5
6impl crate::operation::detect_custom_labels::builders::DetectCustomLabelsInputBuilder {
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_custom_labels::DetectCustomLabelsOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::detect_custom_labels::DetectCustomLabelsError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.detect_custom_labels();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `DetectCustomLabels`.
24///
25/// <note>
26/// <p>This operation applies only to Amazon Rekognition Custom Labels.</p>
27/// </note>
28/// <p>Detects custom labels in a supplied image by using an Amazon Rekognition Custom Labels model.</p>
29/// <p>You specify which version of a model version to use by using the <code>ProjectVersionArn</code> input parameter.</p>
30/// <p>You pass the input image as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file.</p>
31/// <p>For each object that the model version detects on an image, the API returns a (<code>CustomLabel</code>) object in an array (<code>CustomLabels</code>). Each <code>CustomLabel</code> object provides the label name (<code>Name</code>), the level of confidence that the image contains the object (<code>Confidence</code>), and object location information, if it exists, for the label on the image (<code>Geometry</code>).</p>
32/// <p>To filter labels that are returned, specify a value for <code>MinConfidence</code>. <code>DetectCustomLabelsLabels</code> only returns labels with a confidence that's higher than the specified value. The value of <code>MinConfidence</code> maps to the assumed threshold values created during training. For more information, see <i>Assumed threshold</i> in the Amazon Rekognition Custom Labels Developer Guide. Amazon Rekognition Custom Labels metrics expresses an assumed threshold as a floating point value between 0-1. The range of <code>MinConfidence</code> normalizes the threshold value to a percentage value (0-100). Confidence responses from <code>DetectCustomLabels</code> are also returned as a percentage. You can use <code>MinConfidence</code> to change the precision and recall or your model. For more information, see <i>Analyzing an image</i> in the Amazon Rekognition Custom Labels Developer Guide.</p>
33/// <p>If you don't specify a value for <code>MinConfidence</code>, <code>DetectCustomLabels</code> returns labels based on the assumed threshold of each label.</p>
34/// <p>This is a stateless API operation. That is, the operation does not persist any data.</p>
35/// <p>This operation requires permissions to perform the <code>rekognition:DetectCustomLabels</code> action.</p>
36/// <p>For more information, see <i>Analyzing an image</i> in the Amazon Rekognition Custom Labels Developer Guide.</p>
37#[derive(::std::clone::Clone, ::std::fmt::Debug)]
38pub struct DetectCustomLabelsFluentBuilder {
39    handle: ::std::sync::Arc<crate::client::Handle>,
40    inner: crate::operation::detect_custom_labels::builders::DetectCustomLabelsInputBuilder,
41    config_override: ::std::option::Option<crate::config::Builder>,
42}
43impl
44    crate::client::customize::internal::CustomizableSend<
45        crate::operation::detect_custom_labels::DetectCustomLabelsOutput,
46        crate::operation::detect_custom_labels::DetectCustomLabelsError,
47    > for DetectCustomLabelsFluentBuilder
48{
49    fn send(
50        self,
51        config_override: crate::config::Builder,
52    ) -> crate::client::customize::internal::BoxFuture<
53        crate::client::customize::internal::SendResult<
54            crate::operation::detect_custom_labels::DetectCustomLabelsOutput,
55            crate::operation::detect_custom_labels::DetectCustomLabelsError,
56        >,
57    > {
58        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
59    }
60}
61impl DetectCustomLabelsFluentBuilder {
62    /// Creates a new `DetectCustomLabelsFluentBuilder`.
63    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
64        Self {
65            handle,
66            inner: ::std::default::Default::default(),
67            config_override: ::std::option::Option::None,
68        }
69    }
70    /// Access the DetectCustomLabels as a reference.
71    pub fn as_input(&self) -> &crate::operation::detect_custom_labels::builders::DetectCustomLabelsInputBuilder {
72        &self.inner
73    }
74    /// Sends the request and returns the response.
75    ///
76    /// If an error occurs, an `SdkError` will be returned with additional details that
77    /// can be matched against.
78    ///
79    /// By default, any retryable failures will be retried twice. Retry behavior
80    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
81    /// set when configuring the client.
82    pub async fn send(
83        self,
84    ) -> ::std::result::Result<
85        crate::operation::detect_custom_labels::DetectCustomLabelsOutput,
86        ::aws_smithy_runtime_api::client::result::SdkError<
87            crate::operation::detect_custom_labels::DetectCustomLabelsError,
88            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
89        >,
90    > {
91        let input = self
92            .inner
93            .build()
94            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
95        let runtime_plugins = crate::operation::detect_custom_labels::DetectCustomLabels::operation_runtime_plugins(
96            self.handle.runtime_plugins.clone(),
97            &self.handle.conf,
98            self.config_override,
99        );
100        crate::operation::detect_custom_labels::DetectCustomLabels::orchestrate(&runtime_plugins, input).await
101    }
102
103    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
104    pub fn customize(
105        self,
106    ) -> crate::client::customize::CustomizableOperation<
107        crate::operation::detect_custom_labels::DetectCustomLabelsOutput,
108        crate::operation::detect_custom_labels::DetectCustomLabelsError,
109        Self,
110    > {
111        crate::client::customize::CustomizableOperation::new(self)
112    }
113    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
114        self.set_config_override(::std::option::Option::Some(config_override.into()));
115        self
116    }
117
118    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
119        self.config_override = config_override;
120        self
121    }
122    /// <p>The ARN of the model version that you want to use. Only models associated with Custom Labels projects accepted by the operation. If a provided ARN refers to a model version associated with a project for a different feature type, then an InvalidParameterException is returned.</p>
123    pub fn project_version_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
124        self.inner = self.inner.project_version_arn(input.into());
125        self
126    }
127    /// <p>The ARN of the model version that you want to use. Only models associated with Custom Labels projects accepted by the operation. If a provided ARN refers to a model version associated with a project for a different feature type, then an InvalidParameterException is returned.</p>
128    pub fn set_project_version_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
129        self.inner = self.inner.set_project_version_arn(input);
130        self
131    }
132    /// <p>The ARN of the model version that you want to use. Only models associated with Custom Labels projects accepted by the operation. If a provided ARN refers to a model version associated with a project for a different feature type, then an InvalidParameterException is returned.</p>
133    pub fn get_project_version_arn(&self) -> &::std::option::Option<::std::string::String> {
134        self.inner.get_project_version_arn()
135    }
136    /// <p>Provides the input image either as bytes or an S3 object.</p>
137    /// <p>You pass image bytes to an Amazon Rekognition API operation by using the <code>Bytes</code> property. For example, you would use the <code>Bytes</code> property to pass an image loaded from a local file system. Image bytes passed by using the <code>Bytes</code> property must be base64-encoded. Your code may not need to encode image bytes if you are using an AWS SDK to call Amazon Rekognition API operations.</p>
138    /// <p>For more information, see Analyzing an Image Loaded from a Local File System in the Amazon Rekognition Developer Guide.</p>
139    /// <p>You pass images stored in an S3 bucket to an Amazon Rekognition API operation by using the <code>S3Object</code> property. Images stored in an S3 bucket do not need to be base64-encoded.</p>
140    /// <p>The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.</p>
141    /// <p>If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes using the Bytes property is not supported. You must first upload the image to an Amazon S3 bucket and then call the operation using the S3Object property.</p>
142    /// <p>For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see How Amazon Rekognition works with IAM in the Amazon Rekognition Developer Guide.</p>
143    pub fn image(mut self, input: crate::types::Image) -> Self {
144        self.inner = self.inner.image(input);
145        self
146    }
147    /// <p>Provides the input image either as bytes or an S3 object.</p>
148    /// <p>You pass image bytes to an Amazon Rekognition API operation by using the <code>Bytes</code> property. For example, you would use the <code>Bytes</code> property to pass an image loaded from a local file system. Image bytes passed by using the <code>Bytes</code> property must be base64-encoded. Your code may not need to encode image bytes if you are using an AWS SDK to call Amazon Rekognition API operations.</p>
149    /// <p>For more information, see Analyzing an Image Loaded from a Local File System in the Amazon Rekognition Developer Guide.</p>
150    /// <p>You pass images stored in an S3 bucket to an Amazon Rekognition API operation by using the <code>S3Object</code> property. Images stored in an S3 bucket do not need to be base64-encoded.</p>
151    /// <p>The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.</p>
152    /// <p>If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes using the Bytes property is not supported. You must first upload the image to an Amazon S3 bucket and then call the operation using the S3Object property.</p>
153    /// <p>For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see How Amazon Rekognition works with IAM in the Amazon Rekognition Developer Guide.</p>
154    pub fn set_image(mut self, input: ::std::option::Option<crate::types::Image>) -> Self {
155        self.inner = self.inner.set_image(input);
156        self
157    }
158    /// <p>Provides the input image either as bytes or an S3 object.</p>
159    /// <p>You pass image bytes to an Amazon Rekognition API operation by using the <code>Bytes</code> property. For example, you would use the <code>Bytes</code> property to pass an image loaded from a local file system. Image bytes passed by using the <code>Bytes</code> property must be base64-encoded. Your code may not need to encode image bytes if you are using an AWS SDK to call Amazon Rekognition API operations.</p>
160    /// <p>For more information, see Analyzing an Image Loaded from a Local File System in the Amazon Rekognition Developer Guide.</p>
161    /// <p>You pass images stored in an S3 bucket to an Amazon Rekognition API operation by using the <code>S3Object</code> property. Images stored in an S3 bucket do not need to be base64-encoded.</p>
162    /// <p>The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.</p>
163    /// <p>If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes using the Bytes property is not supported. You must first upload the image to an Amazon S3 bucket and then call the operation using the S3Object property.</p>
164    /// <p>For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see How Amazon Rekognition works with IAM in the Amazon Rekognition Developer Guide.</p>
165    pub fn get_image(&self) -> &::std::option::Option<crate::types::Image> {
166        self.inner.get_image()
167    }
168    /// <p>Maximum number of results you want the service to return in the response. The service returns the specified number of highest confidence labels ranked from highest confidence to lowest.</p>
169    pub fn max_results(mut self, input: i32) -> Self {
170        self.inner = self.inner.max_results(input);
171        self
172    }
173    /// <p>Maximum number of results you want the service to return in the response. The service returns the specified number of highest confidence labels ranked from highest confidence to lowest.</p>
174    pub fn set_max_results(mut self, input: ::std::option::Option<i32>) -> Self {
175        self.inner = self.inner.set_max_results(input);
176        self
177    }
178    /// <p>Maximum number of results you want the service to return in the response. The service returns the specified number of highest confidence labels ranked from highest confidence to lowest.</p>
179    pub fn get_max_results(&self) -> &::std::option::Option<i32> {
180        self.inner.get_max_results()
181    }
182    /// <p>Specifies the minimum confidence level for the labels to return. <code>DetectCustomLabels</code> doesn't return any labels with a confidence value that's lower than this specified value. If you specify a value of 0, <code>DetectCustomLabels</code> returns all labels, regardless of the assumed threshold applied to each label. If you don't specify a value for <code>MinConfidence</code>, <code>DetectCustomLabels</code> returns labels based on the assumed threshold of each label.</p>
183    pub fn min_confidence(mut self, input: f32) -> Self {
184        self.inner = self.inner.min_confidence(input);
185        self
186    }
187    /// <p>Specifies the minimum confidence level for the labels to return. <code>DetectCustomLabels</code> doesn't return any labels with a confidence value that's lower than this specified value. If you specify a value of 0, <code>DetectCustomLabels</code> returns all labels, regardless of the assumed threshold applied to each label. If you don't specify a value for <code>MinConfidence</code>, <code>DetectCustomLabels</code> returns labels based on the assumed threshold of each label.</p>
188    pub fn set_min_confidence(mut self, input: ::std::option::Option<f32>) -> Self {
189        self.inner = self.inner.set_min_confidence(input);
190        self
191    }
192    /// <p>Specifies the minimum confidence level for the labels to return. <code>DetectCustomLabels</code> doesn't return any labels with a confidence value that's lower than this specified value. If you specify a value of 0, <code>DetectCustomLabels</code> returns all labels, regardless of the assumed threshold applied to each label. If you don't specify a value for <code>MinConfidence</code>, <code>DetectCustomLabels</code> returns labels based on the assumed threshold of each label.</p>
193    pub fn get_min_confidence(&self) -> &::std::option::Option<f32> {
194        self.inner.get_min_confidence()
195    }
196}