{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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_qualityFilter,
    searchFacesByImage_faceMatchThreshold,
    searchFacesByImage_maxFaces,
    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.Lens as Lens
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'
  { -- | 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,
    -- | (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,
    -- | 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
(SearchFacesByImage -> SearchFacesByImage -> Bool)
-> (SearchFacesByImage -> SearchFacesByImage -> Bool)
-> Eq SearchFacesByImage
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]
(Int -> ReadS SearchFacesByImage)
-> ReadS [SearchFacesByImage]
-> ReadPrec SearchFacesByImage
-> ReadPrec [SearchFacesByImage]
-> Read 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
(Int -> SearchFacesByImage -> ShowS)
-> (SearchFacesByImage -> String)
-> ([SearchFacesByImage] -> ShowS)
-> Show SearchFacesByImage
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. SearchFacesByImage -> Rep SearchFacesByImage x)
-> (forall x. Rep SearchFacesByImage x -> SearchFacesByImage)
-> Generic SearchFacesByImage
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:
--
-- '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.
--
-- '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.
--
-- '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' :: Maybe QualityFilter
-> Maybe Double
-> Maybe Natural
-> Text
-> Image
-> SearchFacesByImage
SearchFacesByImage'
    { $sel:qualityFilter:SearchFacesByImage' :: Maybe QualityFilter
qualityFilter =
        Maybe QualityFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:faceMatchThreshold:SearchFacesByImage' :: Maybe Double
faceMatchThreshold = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:maxFaces:SearchFacesByImage' :: Maybe Natural
maxFaces = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:collectionId:SearchFacesByImage' :: Text
collectionId = Text
pCollectionId_,
      $sel:image:SearchFacesByImage' :: Image
image = Image
pImage_
    }

-- | 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 :: (Maybe QualityFilter -> f (Maybe QualityFilter))
-> SearchFacesByImage -> f SearchFacesByImage
searchFacesByImage_qualityFilter = (SearchFacesByImage -> Maybe QualityFilter)
-> (SearchFacesByImage
    -> Maybe QualityFilter -> SearchFacesByImage)
-> Lens
     SearchFacesByImage
     SearchFacesByImage
     (Maybe QualityFilter)
     (Maybe 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)

-- | (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 :: (Maybe Double -> f (Maybe Double))
-> SearchFacesByImage -> f SearchFacesByImage
searchFacesByImage_faceMatchThreshold = (SearchFacesByImage -> Maybe Double)
-> (SearchFacesByImage -> Maybe Double -> SearchFacesByImage)
-> Lens
     SearchFacesByImage SearchFacesByImage (Maybe Double) (Maybe Double)
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 :: (Maybe Natural -> f (Maybe Natural))
-> SearchFacesByImage -> f SearchFacesByImage
searchFacesByImage_maxFaces = (SearchFacesByImage -> Maybe Natural)
-> (SearchFacesByImage -> Maybe Natural -> SearchFacesByImage)
-> Lens
     SearchFacesByImage
     SearchFacesByImage
     (Maybe Natural)
     (Maybe Natural)
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)

-- | ID of the collection to search.
searchFacesByImage_collectionId :: Lens.Lens' SearchFacesByImage Prelude.Text
searchFacesByImage_collectionId :: (Text -> f Text) -> SearchFacesByImage -> f SearchFacesByImage
searchFacesByImage_collectionId = (SearchFacesByImage -> Text)
-> (SearchFacesByImage -> Text -> SearchFacesByImage)
-> Lens SearchFacesByImage SearchFacesByImage Text Text
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 :: (Image -> f Image) -> SearchFacesByImage -> f SearchFacesByImage
searchFacesByImage_image = (SearchFacesByImage -> Image)
-> (SearchFacesByImage -> Image -> SearchFacesByImage)
-> Lens SearchFacesByImage SearchFacesByImage Image 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 :: SearchFacesByImage -> Request SearchFacesByImage
request = Service -> SearchFacesByImage -> Request SearchFacesByImage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SearchFacesByImage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SearchFacesByImage)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse SearchFacesByImage))
-> Logger
-> Service
-> Proxy SearchFacesByImage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SearchFacesByImage)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe [FaceMatch]
 -> Maybe Text
 -> Maybe BoundingBox
 -> Maybe Double
 -> Int
 -> SearchFacesByImageResponse)
-> Either String (Maybe [FaceMatch])
-> Either
     String
     (Maybe Text
      -> Maybe BoundingBox
      -> Maybe Double
      -> Int
      -> SearchFacesByImageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [FaceMatch]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FaceMatches" Either String (Maybe (Maybe [FaceMatch]))
-> Maybe [FaceMatch] -> Either String (Maybe [FaceMatch])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [FaceMatch]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe Text
   -> Maybe BoundingBox
   -> Maybe Double
   -> Int
   -> SearchFacesByImageResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe BoundingBox
      -> Maybe Double -> Int -> SearchFacesByImageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FaceModelVersion")
            Either
  String
  (Maybe BoundingBox
   -> Maybe Double -> Int -> SearchFacesByImageResponse)
-> Either String (Maybe BoundingBox)
-> Either
     String (Maybe Double -> Int -> SearchFacesByImageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe BoundingBox)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"SearchedFaceBoundingBox")
            Either String (Maybe Double -> Int -> SearchFacesByImageResponse)
-> Either String (Maybe Double)
-> Either String (Int -> SearchFacesByImageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Double)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"SearchedFaceConfidence")
            Either String (Int -> SearchFacesByImageResponse)
-> Either String Int -> Either String SearchFacesByImageResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable SearchFacesByImage

instance Prelude.NFData SearchFacesByImage

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

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

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

instance Core.ToQuery SearchFacesByImage where
  toQuery :: SearchFacesByImage -> QueryString
toQuery = QueryString -> SearchFacesByImage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(SearchFacesByImageResponse -> SearchFacesByImageResponse -> Bool)
-> (SearchFacesByImageResponse
    -> SearchFacesByImageResponse -> Bool)
-> Eq SearchFacesByImageResponse
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]
(Int -> ReadS SearchFacesByImageResponse)
-> ReadS [SearchFacesByImageResponse]
-> ReadPrec SearchFacesByImageResponse
-> ReadPrec [SearchFacesByImageResponse]
-> Read 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
(Int -> SearchFacesByImageResponse -> ShowS)
-> (SearchFacesByImageResponse -> String)
-> ([SearchFacesByImageResponse] -> ShowS)
-> Show SearchFacesByImageResponse
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.
 SearchFacesByImageResponse -> Rep SearchFacesByImageResponse x)
-> (forall x.
    Rep SearchFacesByImageResponse x -> SearchFacesByImageResponse)
-> Generic SearchFacesByImageResponse
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' :: Maybe [FaceMatch]
-> Maybe Text
-> Maybe BoundingBox
-> Maybe Double
-> Int
-> SearchFacesByImageResponse
SearchFacesByImageResponse'
    { $sel:faceMatches:SearchFacesByImageResponse' :: Maybe [FaceMatch]
faceMatches =
        Maybe [FaceMatch]
forall a. Maybe a
Prelude.Nothing,
      $sel:faceModelVersion:SearchFacesByImageResponse' :: Maybe Text
faceModelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:searchedFaceBoundingBox:SearchFacesByImageResponse' :: Maybe BoundingBox
searchedFaceBoundingBox = Maybe BoundingBox
forall a. Maybe a
Prelude.Nothing,
      $sel:searchedFaceConfidence:SearchFacesByImageResponse' :: Maybe Double
searchedFaceConfidence = Maybe Double
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 :: (Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
-> SearchFacesByImageResponse -> f SearchFacesByImageResponse
searchFacesByImageResponse_faceMatches = (SearchFacesByImageResponse -> Maybe [FaceMatch])
-> (SearchFacesByImageResponse
    -> Maybe [FaceMatch] -> SearchFacesByImageResponse)
-> Lens
     SearchFacesByImageResponse
     SearchFacesByImageResponse
     (Maybe [FaceMatch])
     (Maybe [FaceMatch])
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) ((Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
 -> SearchFacesByImageResponse -> f SearchFacesByImageResponse)
-> ((Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
    -> Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
-> (Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
-> SearchFacesByImageResponse
-> f SearchFacesByImageResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [FaceMatch] [FaceMatch] [FaceMatch] [FaceMatch]
-> Iso
     (Maybe [FaceMatch])
     (Maybe [FaceMatch])
     (Maybe [FaceMatch])
     (Maybe [FaceMatch])
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 AnIso [FaceMatch] [FaceMatch] [FaceMatch] [FaceMatch]
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 :: (Maybe Text -> f (Maybe Text))
-> SearchFacesByImageResponse -> f SearchFacesByImageResponse
searchFacesByImageResponse_faceModelVersion = (SearchFacesByImageResponse -> Maybe Text)
-> (SearchFacesByImageResponse
    -> Maybe Text -> SearchFacesByImageResponse)
-> Lens
     SearchFacesByImageResponse
     SearchFacesByImageResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe BoundingBox -> f (Maybe BoundingBox))
-> SearchFacesByImageResponse -> f SearchFacesByImageResponse
searchFacesByImageResponse_searchedFaceBoundingBox = (SearchFacesByImageResponse -> Maybe BoundingBox)
-> (SearchFacesByImageResponse
    -> Maybe BoundingBox -> SearchFacesByImageResponse)
-> Lens
     SearchFacesByImageResponse
     SearchFacesByImageResponse
     (Maybe BoundingBox)
     (Maybe BoundingBox)
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 :: (Maybe Double -> f (Maybe Double))
-> SearchFacesByImageResponse -> f SearchFacesByImageResponse
searchFacesByImageResponse_searchedFaceConfidence = (SearchFacesByImageResponse -> Maybe Double)
-> (SearchFacesByImageResponse
    -> Maybe Double -> SearchFacesByImageResponse)
-> Lens
     SearchFacesByImageResponse
     SearchFacesByImageResponse
     (Maybe Double)
     (Maybe Double)
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 :: (Int -> f Int)
-> SearchFacesByImageResponse -> f SearchFacesByImageResponse
searchFacesByImageResponse_httpStatus = (SearchFacesByImageResponse -> Int)
-> (SearchFacesByImageResponse
    -> Int -> SearchFacesByImageResponse)
-> Lens
     SearchFacesByImageResponse SearchFacesByImageResponse Int Int
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