{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Rekognition.SearchFacesByImage
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- For a given input image, first detects the largest face in the image,
-- and then searches the specified collection for matching faces. The
-- operation compares the features of the input face with faces in the
-- specified collection.
--
-- To search for all faces in an input image, you might first call the
-- IndexFaces operation, and then use the face IDs returned in subsequent
-- calls to the SearchFaces operation.
--
-- You can also call the @DetectFaces@ operation and use the bounding boxes
-- in the response to make face crops, which then you can pass in to the
-- @SearchFacesByImage@ operation.
--
-- You pass the input image either 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.
--
-- The response returns an array of faces that match, ordered by similarity
-- score with the highest similarity first. More specifically, it is an
-- array of metadata for each face match found. Along with the metadata,
-- the response also includes a @similarity@ indicating how similar the
-- face is to the input face. In the response, the operation also returns
-- the bounding box (and a confidence level that the bounding box contains
-- a face) of the face that Amazon Rekognition used for the input image.
--
-- If no faces are detected in the input image, @SearchFacesByImage@
-- returns an @InvalidParameterException@ error.
--
-- For an example, Searching for a Face Using an Image in the Amazon
-- Rekognition Developer Guide.
--
-- The @QualityFilter@ input parameter allows you to filter out detected
-- faces that don’t meet a required quality bar. The quality bar is based
-- on a variety of common use cases. Use @QualityFilter@ to set the quality
-- bar for filtering by specifying @LOW@, @MEDIUM@, or @HIGH@. If you do
-- not want to filter detected faces, specify @NONE@. The default value is
-- @NONE@.
--
-- To use quality filtering, you need a collection associated with version
-- 3 of the face model or higher. To get the version of the face model
-- associated with a collection, call DescribeCollection.
--
-- This operation requires permissions to perform the
-- @rekognition:SearchFacesByImage@ action.
module Amazonka.Rekognition.SearchFacesByImage
  ( -- * Creating a Request
    SearchFacesByImage (..),
    newSearchFacesByImage,

    -- * Request Lenses
    searchFacesByImage_faceMatchThreshold,
    searchFacesByImage_maxFaces,
    searchFacesByImage_qualityFilter,
    searchFacesByImage_collectionId,
    searchFacesByImage_image,

    -- * Destructuring the Response
    SearchFacesByImageResponse (..),
    newSearchFacesByImageResponse,

    -- * Response Lenses
    searchFacesByImageResponse_faceMatches,
    searchFacesByImageResponse_faceModelVersion,
    searchFacesByImageResponse_searchedFaceBoundingBox,
    searchFacesByImageResponse_searchedFaceConfidence,
    searchFacesByImageResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newSearchFacesByImage' smart constructor.
data SearchFacesByImage = SearchFacesByImage'
  { -- | (Optional) Specifies the minimum confidence in the face match to return.
    -- For example, don\'t return any matches where confidence in matches is
    -- less than 70%. The default value is 80%.
    SearchFacesByImage -> Maybe Double
faceMatchThreshold :: Prelude.Maybe Prelude.Double,
    -- | Maximum number of faces to return. The operation returns the maximum
    -- number of faces with the highest confidence in the match.
    SearchFacesByImage -> Maybe Natural
maxFaces :: Prelude.Maybe Prelude.Natural,
    -- | A filter that specifies a quality bar for how much filtering is done to
    -- identify faces. Filtered faces aren\'t searched for in the collection.
    -- If you specify @AUTO@, Amazon Rekognition chooses the quality bar. If
    -- you specify @LOW@, @MEDIUM@, or @HIGH@, filtering removes all faces that
    -- don’t meet the chosen quality bar. The quality bar is based on a variety
    -- of common use cases. Low-quality detections can occur for a number of
    -- reasons. Some examples are an object that\'s misidentified as a face, a
    -- face that\'s too blurry, or a face with a pose that\'s too extreme to
    -- use. If you specify @NONE@, no filtering is performed. The default value
    -- is @NONE@.
    --
    -- To use quality filtering, the collection you are using must be
    -- associated with version 3 of the face model or higher.
    SearchFacesByImage -> Maybe QualityFilter
qualityFilter :: Prelude.Maybe QualityFilter,
    -- | ID of the collection to search.
    SearchFacesByImage -> Text
collectionId :: Prelude.Text,
    -- | The input image as base64-encoded bytes or an S3 object. If you use the
    -- AWS CLI to call Amazon Rekognition operations, passing base64-encoded
    -- image bytes is not supported.
    --
    -- If you are using an AWS SDK to call Amazon Rekognition, you might not
    -- need to base64-encode image bytes passed using the @Bytes@ field. For
    -- more information, see Images in the Amazon Rekognition developer guide.
    SearchFacesByImage -> Image
image :: Image
  }
  deriving (SearchFacesByImage -> SearchFacesByImage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchFacesByImage -> SearchFacesByImage -> Bool
$c/= :: SearchFacesByImage -> SearchFacesByImage -> Bool
== :: SearchFacesByImage -> SearchFacesByImage -> Bool
$c== :: SearchFacesByImage -> SearchFacesByImage -> Bool
Prelude.Eq, ReadPrec [SearchFacesByImage]
ReadPrec SearchFacesByImage
Int -> ReadS SearchFacesByImage
ReadS [SearchFacesByImage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchFacesByImage]
$creadListPrec :: ReadPrec [SearchFacesByImage]
readPrec :: ReadPrec SearchFacesByImage
$creadPrec :: ReadPrec SearchFacesByImage
readList :: ReadS [SearchFacesByImage]
$creadList :: ReadS [SearchFacesByImage]
readsPrec :: Int -> ReadS SearchFacesByImage
$creadsPrec :: Int -> ReadS SearchFacesByImage
Prelude.Read, Int -> SearchFacesByImage -> ShowS
[SearchFacesByImage] -> ShowS
SearchFacesByImage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchFacesByImage] -> ShowS
$cshowList :: [SearchFacesByImage] -> ShowS
show :: SearchFacesByImage -> String
$cshow :: SearchFacesByImage -> String
showsPrec :: Int -> SearchFacesByImage -> ShowS
$cshowsPrec :: Int -> SearchFacesByImage -> ShowS
Prelude.Show, forall x. Rep SearchFacesByImage x -> SearchFacesByImage
forall x. SearchFacesByImage -> Rep SearchFacesByImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchFacesByImage x -> SearchFacesByImage
$cfrom :: forall x. SearchFacesByImage -> Rep SearchFacesByImage x
Prelude.Generic)

-- |
-- Create a value of 'SearchFacesByImage' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'faceMatchThreshold', 'searchFacesByImage_faceMatchThreshold' - (Optional) Specifies the minimum confidence in the face match to return.
-- For example, don\'t return any matches where confidence in matches is
-- less than 70%. The default value is 80%.
--
-- 'maxFaces', 'searchFacesByImage_maxFaces' - Maximum number of faces to return. The operation returns the maximum
-- number of faces with the highest confidence in the match.
--
-- 'qualityFilter', 'searchFacesByImage_qualityFilter' - A filter that specifies a quality bar for how much filtering is done to
-- identify faces. Filtered faces aren\'t searched for in the collection.
-- If you specify @AUTO@, Amazon Rekognition chooses the quality bar. If
-- you specify @LOW@, @MEDIUM@, or @HIGH@, filtering removes all faces that
-- don’t meet the chosen quality bar. The quality bar is based on a variety
-- of common use cases. Low-quality detections can occur for a number of
-- reasons. Some examples are an object that\'s misidentified as a face, a
-- face that\'s too blurry, or a face with a pose that\'s too extreme to
-- use. If you specify @NONE@, no filtering is performed. The default value
-- is @NONE@.
--
-- To use quality filtering, the collection you are using must be
-- associated with version 3 of the face model or higher.
--
-- 'collectionId', 'searchFacesByImage_collectionId' - ID of the collection to search.
--
-- 'image', 'searchFacesByImage_image' - The input image as base64-encoded bytes or an S3 object. If you use the
-- AWS CLI to call Amazon Rekognition operations, passing base64-encoded
-- image bytes is not supported.
--
-- If you are using an AWS SDK to call Amazon Rekognition, you might not
-- need to base64-encode image bytes passed using the @Bytes@ field. For
-- more information, see Images in the Amazon Rekognition developer guide.
newSearchFacesByImage ::
  -- | 'collectionId'
  Prelude.Text ->
  -- | 'image'
  Image ->
  SearchFacesByImage
newSearchFacesByImage :: Text -> Image -> SearchFacesByImage
newSearchFacesByImage Text
pCollectionId_ Image
pImage_ =
  SearchFacesByImage'
    { $sel:faceMatchThreshold:SearchFacesByImage' :: Maybe Double
faceMatchThreshold =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxFaces:SearchFacesByImage' :: Maybe Natural
maxFaces = forall a. Maybe a
Prelude.Nothing,
      $sel:qualityFilter:SearchFacesByImage' :: Maybe QualityFilter
qualityFilter = forall a. Maybe a
Prelude.Nothing,
      $sel:collectionId:SearchFacesByImage' :: Text
collectionId = Text
pCollectionId_,
      $sel:image:SearchFacesByImage' :: Image
image = Image
pImage_
    }

-- | (Optional) Specifies the minimum confidence in the face match to return.
-- For example, don\'t return any matches where confidence in matches is
-- less than 70%. The default value is 80%.
searchFacesByImage_faceMatchThreshold :: Lens.Lens' SearchFacesByImage (Prelude.Maybe Prelude.Double)
searchFacesByImage_faceMatchThreshold :: Lens' SearchFacesByImage (Maybe Double)
searchFacesByImage_faceMatchThreshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImage' {Maybe Double
faceMatchThreshold :: Maybe Double
$sel:faceMatchThreshold:SearchFacesByImage' :: SearchFacesByImage -> Maybe Double
faceMatchThreshold} -> Maybe Double
faceMatchThreshold) (\s :: SearchFacesByImage
s@SearchFacesByImage' {} Maybe Double
a -> SearchFacesByImage
s {$sel:faceMatchThreshold:SearchFacesByImage' :: Maybe Double
faceMatchThreshold = Maybe Double
a} :: SearchFacesByImage)

-- | Maximum number of faces to return. The operation returns the maximum
-- number of faces with the highest confidence in the match.
searchFacesByImage_maxFaces :: Lens.Lens' SearchFacesByImage (Prelude.Maybe Prelude.Natural)
searchFacesByImage_maxFaces :: Lens' SearchFacesByImage (Maybe Natural)
searchFacesByImage_maxFaces = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImage' {Maybe Natural
maxFaces :: Maybe Natural
$sel:maxFaces:SearchFacesByImage' :: SearchFacesByImage -> Maybe Natural
maxFaces} -> Maybe Natural
maxFaces) (\s :: SearchFacesByImage
s@SearchFacesByImage' {} Maybe Natural
a -> SearchFacesByImage
s {$sel:maxFaces:SearchFacesByImage' :: Maybe Natural
maxFaces = Maybe Natural
a} :: SearchFacesByImage)

-- | A filter that specifies a quality bar for how much filtering is done to
-- identify faces. Filtered faces aren\'t searched for in the collection.
-- If you specify @AUTO@, Amazon Rekognition chooses the quality bar. If
-- you specify @LOW@, @MEDIUM@, or @HIGH@, filtering removes all faces that
-- don’t meet the chosen quality bar. The quality bar is based on a variety
-- of common use cases. Low-quality detections can occur for a number of
-- reasons. Some examples are an object that\'s misidentified as a face, a
-- face that\'s too blurry, or a face with a pose that\'s too extreme to
-- use. If you specify @NONE@, no filtering is performed. The default value
-- is @NONE@.
--
-- To use quality filtering, the collection you are using must be
-- associated with version 3 of the face model or higher.
searchFacesByImage_qualityFilter :: Lens.Lens' SearchFacesByImage (Prelude.Maybe QualityFilter)
searchFacesByImage_qualityFilter :: Lens' SearchFacesByImage (Maybe QualityFilter)
searchFacesByImage_qualityFilter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImage' {Maybe QualityFilter
qualityFilter :: Maybe QualityFilter
$sel:qualityFilter:SearchFacesByImage' :: SearchFacesByImage -> Maybe QualityFilter
qualityFilter} -> Maybe QualityFilter
qualityFilter) (\s :: SearchFacesByImage
s@SearchFacesByImage' {} Maybe QualityFilter
a -> SearchFacesByImage
s {$sel:qualityFilter:SearchFacesByImage' :: Maybe QualityFilter
qualityFilter = Maybe QualityFilter
a} :: SearchFacesByImage)

-- | ID of the collection to search.
searchFacesByImage_collectionId :: Lens.Lens' SearchFacesByImage Prelude.Text
searchFacesByImage_collectionId :: Lens' SearchFacesByImage Text
searchFacesByImage_collectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImage' {Text
collectionId :: Text
$sel:collectionId:SearchFacesByImage' :: SearchFacesByImage -> Text
collectionId} -> Text
collectionId) (\s :: SearchFacesByImage
s@SearchFacesByImage' {} Text
a -> SearchFacesByImage
s {$sel:collectionId:SearchFacesByImage' :: Text
collectionId = Text
a} :: SearchFacesByImage)

-- | The input image as base64-encoded bytes or an S3 object. If you use the
-- AWS CLI to call Amazon Rekognition operations, passing base64-encoded
-- image bytes is not supported.
--
-- If you are using an AWS SDK to call Amazon Rekognition, you might not
-- need to base64-encode image bytes passed using the @Bytes@ field. For
-- more information, see Images in the Amazon Rekognition developer guide.
searchFacesByImage_image :: Lens.Lens' SearchFacesByImage Image
searchFacesByImage_image :: Lens' SearchFacesByImage Image
searchFacesByImage_image = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImage' {Image
image :: Image
$sel:image:SearchFacesByImage' :: SearchFacesByImage -> Image
image} -> Image
image) (\s :: SearchFacesByImage
s@SearchFacesByImage' {} Image
a -> SearchFacesByImage
s {$sel:image:SearchFacesByImage' :: Image
image = Image
a} :: SearchFacesByImage)

instance Core.AWSRequest SearchFacesByImage where
  type
    AWSResponse SearchFacesByImage =
      SearchFacesByImageResponse
  request :: (Service -> Service)
-> SearchFacesByImage -> Request SearchFacesByImage
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SearchFacesByImage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SearchFacesByImage)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [FaceMatch]
-> Maybe Text
-> Maybe BoundingBox
-> Maybe Double
-> Int
-> SearchFacesByImageResponse
SearchFacesByImageResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"FaceMatches" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"FaceModelVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"SearchedFaceBoundingBox")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"SearchedFaceConfidence")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable SearchFacesByImage where
  hashWithSalt :: Int -> SearchFacesByImage -> Int
hashWithSalt Int
_salt SearchFacesByImage' {Maybe Double
Maybe Natural
Maybe QualityFilter
Text
Image
image :: Image
collectionId :: Text
qualityFilter :: Maybe QualityFilter
maxFaces :: Maybe Natural
faceMatchThreshold :: Maybe Double
$sel:image:SearchFacesByImage' :: SearchFacesByImage -> Image
$sel:collectionId:SearchFacesByImage' :: SearchFacesByImage -> Text
$sel:qualityFilter:SearchFacesByImage' :: SearchFacesByImage -> Maybe QualityFilter
$sel:maxFaces:SearchFacesByImage' :: SearchFacesByImage -> Maybe Natural
$sel:faceMatchThreshold:SearchFacesByImage' :: SearchFacesByImage -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
faceMatchThreshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxFaces
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QualityFilter
qualityFilter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
collectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Image
image

instance Prelude.NFData SearchFacesByImage where
  rnf :: SearchFacesByImage -> ()
rnf SearchFacesByImage' {Maybe Double
Maybe Natural
Maybe QualityFilter
Text
Image
image :: Image
collectionId :: Text
qualityFilter :: Maybe QualityFilter
maxFaces :: Maybe Natural
faceMatchThreshold :: Maybe Double
$sel:image:SearchFacesByImage' :: SearchFacesByImage -> Image
$sel:collectionId:SearchFacesByImage' :: SearchFacesByImage -> Text
$sel:qualityFilter:SearchFacesByImage' :: SearchFacesByImage -> Maybe QualityFilter
$sel:maxFaces:SearchFacesByImage' :: SearchFacesByImage -> Maybe Natural
$sel:faceMatchThreshold:SearchFacesByImage' :: SearchFacesByImage -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
faceMatchThreshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxFaces
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QualityFilter
qualityFilter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
collectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Image
image

instance Data.ToHeaders SearchFacesByImage where
  toHeaders :: SearchFacesByImage -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"RekognitionService.SearchFacesByImage" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON SearchFacesByImage where
  toJSON :: SearchFacesByImage -> Value
toJSON SearchFacesByImage' {Maybe Double
Maybe Natural
Maybe QualityFilter
Text
Image
image :: Image
collectionId :: Text
qualityFilter :: Maybe QualityFilter
maxFaces :: Maybe Natural
faceMatchThreshold :: Maybe Double
$sel:image:SearchFacesByImage' :: SearchFacesByImage -> Image
$sel:collectionId:SearchFacesByImage' :: SearchFacesByImage -> Text
$sel:qualityFilter:SearchFacesByImage' :: SearchFacesByImage -> Maybe QualityFilter
$sel:maxFaces:SearchFacesByImage' :: SearchFacesByImage -> Maybe Natural
$sel:faceMatchThreshold:SearchFacesByImage' :: SearchFacesByImage -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FaceMatchThreshold" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
faceMatchThreshold,
            (Key
"MaxFaces" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxFaces,
            (Key
"QualityFilter" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe QualityFilter
qualityFilter,
            forall a. a -> Maybe a
Prelude.Just (Key
"CollectionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
collectionId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Image" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Image
image)
          ]
      )

instance Data.ToPath SearchFacesByImage where
  toPath :: SearchFacesByImage -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery SearchFacesByImage where
  toQuery :: SearchFacesByImage -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newSearchFacesByImageResponse' smart constructor.
data SearchFacesByImageResponse = SearchFacesByImageResponse'
  { -- | An array of faces that match the input face, along with the confidence
    -- in the match.
    SearchFacesByImageResponse -> Maybe [FaceMatch]
faceMatches :: Prelude.Maybe [FaceMatch],
    -- | Version number of the face detection model associated with the input
    -- collection (@CollectionId@).
    SearchFacesByImageResponse -> Maybe Text
faceModelVersion :: Prelude.Maybe Prelude.Text,
    -- | The bounding box around the face in the input image that Amazon
    -- Rekognition used for the search.
    SearchFacesByImageResponse -> Maybe BoundingBox
searchedFaceBoundingBox :: Prelude.Maybe BoundingBox,
    -- | The level of confidence that the @searchedFaceBoundingBox@, contains a
    -- face.
    SearchFacesByImageResponse -> Maybe Double
searchedFaceConfidence :: Prelude.Maybe Prelude.Double,
    -- | The response's http status code.
    SearchFacesByImageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchFacesByImageResponse -> SearchFacesByImageResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchFacesByImageResponse -> SearchFacesByImageResponse -> Bool
$c/= :: SearchFacesByImageResponse -> SearchFacesByImageResponse -> Bool
== :: SearchFacesByImageResponse -> SearchFacesByImageResponse -> Bool
$c== :: SearchFacesByImageResponse -> SearchFacesByImageResponse -> Bool
Prelude.Eq, ReadPrec [SearchFacesByImageResponse]
ReadPrec SearchFacesByImageResponse
Int -> ReadS SearchFacesByImageResponse
ReadS [SearchFacesByImageResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchFacesByImageResponse]
$creadListPrec :: ReadPrec [SearchFacesByImageResponse]
readPrec :: ReadPrec SearchFacesByImageResponse
$creadPrec :: ReadPrec SearchFacesByImageResponse
readList :: ReadS [SearchFacesByImageResponse]
$creadList :: ReadS [SearchFacesByImageResponse]
readsPrec :: Int -> ReadS SearchFacesByImageResponse
$creadsPrec :: Int -> ReadS SearchFacesByImageResponse
Prelude.Read, Int -> SearchFacesByImageResponse -> ShowS
[SearchFacesByImageResponse] -> ShowS
SearchFacesByImageResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchFacesByImageResponse] -> ShowS
$cshowList :: [SearchFacesByImageResponse] -> ShowS
show :: SearchFacesByImageResponse -> String
$cshow :: SearchFacesByImageResponse -> String
showsPrec :: Int -> SearchFacesByImageResponse -> ShowS
$cshowsPrec :: Int -> SearchFacesByImageResponse -> ShowS
Prelude.Show, forall x.
Rep SearchFacesByImageResponse x -> SearchFacesByImageResponse
forall x.
SearchFacesByImageResponse -> Rep SearchFacesByImageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SearchFacesByImageResponse x -> SearchFacesByImageResponse
$cfrom :: forall x.
SearchFacesByImageResponse -> Rep SearchFacesByImageResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchFacesByImageResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'faceMatches', 'searchFacesByImageResponse_faceMatches' - An array of faces that match the input face, along with the confidence
-- in the match.
--
-- 'faceModelVersion', 'searchFacesByImageResponse_faceModelVersion' - Version number of the face detection model associated with the input
-- collection (@CollectionId@).
--
-- 'searchedFaceBoundingBox', 'searchFacesByImageResponse_searchedFaceBoundingBox' - The bounding box around the face in the input image that Amazon
-- Rekognition used for the search.
--
-- 'searchedFaceConfidence', 'searchFacesByImageResponse_searchedFaceConfidence' - The level of confidence that the @searchedFaceBoundingBox@, contains a
-- face.
--
-- 'httpStatus', 'searchFacesByImageResponse_httpStatus' - The response's http status code.
newSearchFacesByImageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchFacesByImageResponse
newSearchFacesByImageResponse :: Int -> SearchFacesByImageResponse
newSearchFacesByImageResponse Int
pHttpStatus_ =
  SearchFacesByImageResponse'
    { $sel:faceMatches:SearchFacesByImageResponse' :: Maybe [FaceMatch]
faceMatches =
        forall a. Maybe a
Prelude.Nothing,
      $sel:faceModelVersion:SearchFacesByImageResponse' :: Maybe Text
faceModelVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:searchedFaceBoundingBox:SearchFacesByImageResponse' :: Maybe BoundingBox
searchedFaceBoundingBox = forall a. Maybe a
Prelude.Nothing,
      $sel:searchedFaceConfidence:SearchFacesByImageResponse' :: Maybe Double
searchedFaceConfidence = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchFacesByImageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of faces that match the input face, along with the confidence
-- in the match.
searchFacesByImageResponse_faceMatches :: Lens.Lens' SearchFacesByImageResponse (Prelude.Maybe [FaceMatch])
searchFacesByImageResponse_faceMatches :: Lens' SearchFacesByImageResponse (Maybe [FaceMatch])
searchFacesByImageResponse_faceMatches = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImageResponse' {Maybe [FaceMatch]
faceMatches :: Maybe [FaceMatch]
$sel:faceMatches:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Maybe [FaceMatch]
faceMatches} -> Maybe [FaceMatch]
faceMatches) (\s :: SearchFacesByImageResponse
s@SearchFacesByImageResponse' {} Maybe [FaceMatch]
a -> SearchFacesByImageResponse
s {$sel:faceMatches:SearchFacesByImageResponse' :: Maybe [FaceMatch]
faceMatches = Maybe [FaceMatch]
a} :: SearchFacesByImageResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Version number of the face detection model associated with the input
-- collection (@CollectionId@).
searchFacesByImageResponse_faceModelVersion :: Lens.Lens' SearchFacesByImageResponse (Prelude.Maybe Prelude.Text)
searchFacesByImageResponse_faceModelVersion :: Lens' SearchFacesByImageResponse (Maybe Text)
searchFacesByImageResponse_faceModelVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImageResponse' {Maybe Text
faceModelVersion :: Maybe Text
$sel:faceModelVersion:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Maybe Text
faceModelVersion} -> Maybe Text
faceModelVersion) (\s :: SearchFacesByImageResponse
s@SearchFacesByImageResponse' {} Maybe Text
a -> SearchFacesByImageResponse
s {$sel:faceModelVersion:SearchFacesByImageResponse' :: Maybe Text
faceModelVersion = Maybe Text
a} :: SearchFacesByImageResponse)

-- | The bounding box around the face in the input image that Amazon
-- Rekognition used for the search.
searchFacesByImageResponse_searchedFaceBoundingBox :: Lens.Lens' SearchFacesByImageResponse (Prelude.Maybe BoundingBox)
searchFacesByImageResponse_searchedFaceBoundingBox :: Lens' SearchFacesByImageResponse (Maybe BoundingBox)
searchFacesByImageResponse_searchedFaceBoundingBox = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImageResponse' {Maybe BoundingBox
searchedFaceBoundingBox :: Maybe BoundingBox
$sel:searchedFaceBoundingBox:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Maybe BoundingBox
searchedFaceBoundingBox} -> Maybe BoundingBox
searchedFaceBoundingBox) (\s :: SearchFacesByImageResponse
s@SearchFacesByImageResponse' {} Maybe BoundingBox
a -> SearchFacesByImageResponse
s {$sel:searchedFaceBoundingBox:SearchFacesByImageResponse' :: Maybe BoundingBox
searchedFaceBoundingBox = Maybe BoundingBox
a} :: SearchFacesByImageResponse)

-- | The level of confidence that the @searchedFaceBoundingBox@, contains a
-- face.
searchFacesByImageResponse_searchedFaceConfidence :: Lens.Lens' SearchFacesByImageResponse (Prelude.Maybe Prelude.Double)
searchFacesByImageResponse_searchedFaceConfidence :: Lens' SearchFacesByImageResponse (Maybe Double)
searchFacesByImageResponse_searchedFaceConfidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImageResponse' {Maybe Double
searchedFaceConfidence :: Maybe Double
$sel:searchedFaceConfidence:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Maybe Double
searchedFaceConfidence} -> Maybe Double
searchedFaceConfidence) (\s :: SearchFacesByImageResponse
s@SearchFacesByImageResponse' {} Maybe Double
a -> SearchFacesByImageResponse
s {$sel:searchedFaceConfidence:SearchFacesByImageResponse' :: Maybe Double
searchedFaceConfidence = Maybe Double
a} :: SearchFacesByImageResponse)

-- | The response's http status code.
searchFacesByImageResponse_httpStatus :: Lens.Lens' SearchFacesByImageResponse Prelude.Int
searchFacesByImageResponse_httpStatus :: Lens' SearchFacesByImageResponse Int
searchFacesByImageResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchFacesByImageResponse' {Int
httpStatus :: Int
$sel:httpStatus:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SearchFacesByImageResponse
s@SearchFacesByImageResponse' {} Int
a -> SearchFacesByImageResponse
s {$sel:httpStatus:SearchFacesByImageResponse' :: Int
httpStatus = Int
a} :: SearchFacesByImageResponse)

instance Prelude.NFData SearchFacesByImageResponse where
  rnf :: SearchFacesByImageResponse -> ()
rnf SearchFacesByImageResponse' {Int
Maybe Double
Maybe [FaceMatch]
Maybe Text
Maybe BoundingBox
httpStatus :: Int
searchedFaceConfidence :: Maybe Double
searchedFaceBoundingBox :: Maybe BoundingBox
faceModelVersion :: Maybe Text
faceMatches :: Maybe [FaceMatch]
$sel:httpStatus:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Int
$sel:searchedFaceConfidence:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Maybe Double
$sel:searchedFaceBoundingBox:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Maybe BoundingBox
$sel:faceModelVersion:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Maybe Text
$sel:faceMatches:SearchFacesByImageResponse' :: SearchFacesByImageResponse -> Maybe [FaceMatch]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FaceMatch]
faceMatches
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
faceModelVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BoundingBox
searchedFaceBoundingBox
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
searchedFaceConfidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus