{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.FaceSearchSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rekognition.Types.FaceSearchSettings 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

-- | Input face recognition parameters for an Amazon Rekognition stream
-- processor. Includes the collection to use for face recognition and the
-- face attributes to detect. Defining the settings is required in the
-- request parameter for CreateStreamProcessor.
--
-- /See:/ 'newFaceSearchSettings' smart constructor.
data FaceSearchSettings = FaceSearchSettings'
  { -- | The ID of a collection that contains faces that you want to search for.
    FaceSearchSettings -> Maybe Text
collectionId :: Prelude.Maybe Prelude.Text,
    -- | Minimum face match confidence score that must be met to return a result
    -- for a recognized face. The default is 80. 0 is the lowest confidence.
    -- 100 is the highest confidence. Values between 0 and 100 are accepted,
    -- and values lower than 80 are set to 80.
    FaceSearchSettings -> Maybe Double
faceMatchThreshold :: Prelude.Maybe Prelude.Double
  }
  deriving (FaceSearchSettings -> FaceSearchSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FaceSearchSettings -> FaceSearchSettings -> Bool
$c/= :: FaceSearchSettings -> FaceSearchSettings -> Bool
== :: FaceSearchSettings -> FaceSearchSettings -> Bool
$c== :: FaceSearchSettings -> FaceSearchSettings -> Bool
Prelude.Eq, ReadPrec [FaceSearchSettings]
ReadPrec FaceSearchSettings
Int -> ReadS FaceSearchSettings
ReadS [FaceSearchSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FaceSearchSettings]
$creadListPrec :: ReadPrec [FaceSearchSettings]
readPrec :: ReadPrec FaceSearchSettings
$creadPrec :: ReadPrec FaceSearchSettings
readList :: ReadS [FaceSearchSettings]
$creadList :: ReadS [FaceSearchSettings]
readsPrec :: Int -> ReadS FaceSearchSettings
$creadsPrec :: Int -> ReadS FaceSearchSettings
Prelude.Read, Int -> FaceSearchSettings -> ShowS
[FaceSearchSettings] -> ShowS
FaceSearchSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FaceSearchSettings] -> ShowS
$cshowList :: [FaceSearchSettings] -> ShowS
show :: FaceSearchSettings -> String
$cshow :: FaceSearchSettings -> String
showsPrec :: Int -> FaceSearchSettings -> ShowS
$cshowsPrec :: Int -> FaceSearchSettings -> ShowS
Prelude.Show, forall x. Rep FaceSearchSettings x -> FaceSearchSettings
forall x. FaceSearchSettings -> Rep FaceSearchSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FaceSearchSettings x -> FaceSearchSettings
$cfrom :: forall x. FaceSearchSettings -> Rep FaceSearchSettings x
Prelude.Generic)

-- |
-- Create a value of 'FaceSearchSettings' 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:
--
-- 'collectionId', 'faceSearchSettings_collectionId' - The ID of a collection that contains faces that you want to search for.
--
-- 'faceMatchThreshold', 'faceSearchSettings_faceMatchThreshold' - Minimum face match confidence score that must be met to return a result
-- for a recognized face. The default is 80. 0 is the lowest confidence.
-- 100 is the highest confidence. Values between 0 and 100 are accepted,
-- and values lower than 80 are set to 80.
newFaceSearchSettings ::
  FaceSearchSettings
newFaceSearchSettings :: FaceSearchSettings
newFaceSearchSettings =
  FaceSearchSettings'
    { $sel:collectionId:FaceSearchSettings' :: Maybe Text
collectionId = forall a. Maybe a
Prelude.Nothing,
      $sel:faceMatchThreshold:FaceSearchSettings' :: Maybe Double
faceMatchThreshold = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of a collection that contains faces that you want to search for.
faceSearchSettings_collectionId :: Lens.Lens' FaceSearchSettings (Prelude.Maybe Prelude.Text)
faceSearchSettings_collectionId :: Lens' FaceSearchSettings (Maybe Text)
faceSearchSettings_collectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceSearchSettings' {Maybe Text
collectionId :: Maybe Text
$sel:collectionId:FaceSearchSettings' :: FaceSearchSettings -> Maybe Text
collectionId} -> Maybe Text
collectionId) (\s :: FaceSearchSettings
s@FaceSearchSettings' {} Maybe Text
a -> FaceSearchSettings
s {$sel:collectionId:FaceSearchSettings' :: Maybe Text
collectionId = Maybe Text
a} :: FaceSearchSettings)

-- | Minimum face match confidence score that must be met to return a result
-- for a recognized face. The default is 80. 0 is the lowest confidence.
-- 100 is the highest confidence. Values between 0 and 100 are accepted,
-- and values lower than 80 are set to 80.
faceSearchSettings_faceMatchThreshold :: Lens.Lens' FaceSearchSettings (Prelude.Maybe Prelude.Double)
faceSearchSettings_faceMatchThreshold :: Lens' FaceSearchSettings (Maybe Double)
faceSearchSettings_faceMatchThreshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceSearchSettings' {Maybe Double
faceMatchThreshold :: Maybe Double
$sel:faceMatchThreshold:FaceSearchSettings' :: FaceSearchSettings -> Maybe Double
faceMatchThreshold} -> Maybe Double
faceMatchThreshold) (\s :: FaceSearchSettings
s@FaceSearchSettings' {} Maybe Double
a -> FaceSearchSettings
s {$sel:faceMatchThreshold:FaceSearchSettings' :: Maybe Double
faceMatchThreshold = Maybe Double
a} :: FaceSearchSettings)

instance Data.FromJSON FaceSearchSettings where
  parseJSON :: Value -> Parser FaceSearchSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FaceSearchSettings"
      ( \Object
x ->
          Maybe Text -> Maybe Double -> FaceSearchSettings
FaceSearchSettings'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CollectionId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"FaceMatchThreshold")
      )

instance Prelude.Hashable FaceSearchSettings where
  hashWithSalt :: Int -> FaceSearchSettings -> Int
hashWithSalt Int
_salt FaceSearchSettings' {Maybe Double
Maybe Text
faceMatchThreshold :: Maybe Double
collectionId :: Maybe Text
$sel:faceMatchThreshold:FaceSearchSettings' :: FaceSearchSettings -> Maybe Double
$sel:collectionId:FaceSearchSettings' :: FaceSearchSettings -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
collectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
faceMatchThreshold

instance Prelude.NFData FaceSearchSettings where
  rnf :: FaceSearchSettings -> ()
rnf FaceSearchSettings' {Maybe Double
Maybe Text
faceMatchThreshold :: Maybe Double
collectionId :: Maybe Text
$sel:faceMatchThreshold:FaceSearchSettings' :: FaceSearchSettings -> Maybe Double
$sel:collectionId:FaceSearchSettings' :: FaceSearchSettings -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
collectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
faceMatchThreshold

instance Data.ToJSON FaceSearchSettings where
  toJSON :: FaceSearchSettings -> Value
toJSON FaceSearchSettings' {Maybe Double
Maybe Text
faceMatchThreshold :: Maybe Double
collectionId :: Maybe Text
$sel:faceMatchThreshold:FaceSearchSettings' :: FaceSearchSettings -> Maybe Double
$sel:collectionId:FaceSearchSettings' :: FaceSearchSettings -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CollectionId" 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 Text
collectionId,
            (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
          ]
      )