{-# 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.VoiceId.Types.EnrollmentJobFraudDetectionConfig
-- 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.VoiceId.Types.EnrollmentJobFraudDetectionConfig 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.VoiceId.Types.FraudDetectionAction

-- | The configuration defining the action to take when a speaker is flagged
-- by the fraud detection system during a batch speaker enrollment job, and
-- the risk threshold to use for identification.
--
-- /See:/ 'newEnrollmentJobFraudDetectionConfig' smart constructor.
data EnrollmentJobFraudDetectionConfig = EnrollmentJobFraudDetectionConfig'
  { -- | The action to take when the given speaker is flagged by the fraud
    -- detection system. The default value is @FAIL@, which fails the speaker
    -- enrollment. Changing this value to @IGNORE@ results in the speaker being
    -- enrolled even if they are flagged by the fraud detection system.
    EnrollmentJobFraudDetectionConfig -> Maybe FraudDetectionAction
fraudDetectionAction :: Prelude.Maybe FraudDetectionAction,
    -- | Threshold value for determining whether the speaker is a high risk to be
    -- fraudulent. If the detected risk score calculated by Voice ID is greater
    -- than or equal to the threshold, the speaker is considered a fraudster.
    EnrollmentJobFraudDetectionConfig -> Maybe Natural
riskThreshold :: Prelude.Maybe Prelude.Natural
  }
  deriving (EnrollmentJobFraudDetectionConfig
-> EnrollmentJobFraudDetectionConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnrollmentJobFraudDetectionConfig
-> EnrollmentJobFraudDetectionConfig -> Bool
$c/= :: EnrollmentJobFraudDetectionConfig
-> EnrollmentJobFraudDetectionConfig -> Bool
== :: EnrollmentJobFraudDetectionConfig
-> EnrollmentJobFraudDetectionConfig -> Bool
$c== :: EnrollmentJobFraudDetectionConfig
-> EnrollmentJobFraudDetectionConfig -> Bool
Prelude.Eq, ReadPrec [EnrollmentJobFraudDetectionConfig]
ReadPrec EnrollmentJobFraudDetectionConfig
Int -> ReadS EnrollmentJobFraudDetectionConfig
ReadS [EnrollmentJobFraudDetectionConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnrollmentJobFraudDetectionConfig]
$creadListPrec :: ReadPrec [EnrollmentJobFraudDetectionConfig]
readPrec :: ReadPrec EnrollmentJobFraudDetectionConfig
$creadPrec :: ReadPrec EnrollmentJobFraudDetectionConfig
readList :: ReadS [EnrollmentJobFraudDetectionConfig]
$creadList :: ReadS [EnrollmentJobFraudDetectionConfig]
readsPrec :: Int -> ReadS EnrollmentJobFraudDetectionConfig
$creadsPrec :: Int -> ReadS EnrollmentJobFraudDetectionConfig
Prelude.Read, Int -> EnrollmentJobFraudDetectionConfig -> ShowS
[EnrollmentJobFraudDetectionConfig] -> ShowS
EnrollmentJobFraudDetectionConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnrollmentJobFraudDetectionConfig] -> ShowS
$cshowList :: [EnrollmentJobFraudDetectionConfig] -> ShowS
show :: EnrollmentJobFraudDetectionConfig -> String
$cshow :: EnrollmentJobFraudDetectionConfig -> String
showsPrec :: Int -> EnrollmentJobFraudDetectionConfig -> ShowS
$cshowsPrec :: Int -> EnrollmentJobFraudDetectionConfig -> ShowS
Prelude.Show, forall x.
Rep EnrollmentJobFraudDetectionConfig x
-> EnrollmentJobFraudDetectionConfig
forall x.
EnrollmentJobFraudDetectionConfig
-> Rep EnrollmentJobFraudDetectionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnrollmentJobFraudDetectionConfig x
-> EnrollmentJobFraudDetectionConfig
$cfrom :: forall x.
EnrollmentJobFraudDetectionConfig
-> Rep EnrollmentJobFraudDetectionConfig x
Prelude.Generic)

-- |
-- Create a value of 'EnrollmentJobFraudDetectionConfig' 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:
--
-- 'fraudDetectionAction', 'enrollmentJobFraudDetectionConfig_fraudDetectionAction' - The action to take when the given speaker is flagged by the fraud
-- detection system. The default value is @FAIL@, which fails the speaker
-- enrollment. Changing this value to @IGNORE@ results in the speaker being
-- enrolled even if they are flagged by the fraud detection system.
--
-- 'riskThreshold', 'enrollmentJobFraudDetectionConfig_riskThreshold' - Threshold value for determining whether the speaker is a high risk to be
-- fraudulent. If the detected risk score calculated by Voice ID is greater
-- than or equal to the threshold, the speaker is considered a fraudster.
newEnrollmentJobFraudDetectionConfig ::
  EnrollmentJobFraudDetectionConfig
newEnrollmentJobFraudDetectionConfig :: EnrollmentJobFraudDetectionConfig
newEnrollmentJobFraudDetectionConfig =
  EnrollmentJobFraudDetectionConfig'
    { $sel:fraudDetectionAction:EnrollmentJobFraudDetectionConfig' :: Maybe FraudDetectionAction
fraudDetectionAction =
        forall a. Maybe a
Prelude.Nothing,
      $sel:riskThreshold:EnrollmentJobFraudDetectionConfig' :: Maybe Natural
riskThreshold = forall a. Maybe a
Prelude.Nothing
    }

-- | The action to take when the given speaker is flagged by the fraud
-- detection system. The default value is @FAIL@, which fails the speaker
-- enrollment. Changing this value to @IGNORE@ results in the speaker being
-- enrolled even if they are flagged by the fraud detection system.
enrollmentJobFraudDetectionConfig_fraudDetectionAction :: Lens.Lens' EnrollmentJobFraudDetectionConfig (Prelude.Maybe FraudDetectionAction)
enrollmentJobFraudDetectionConfig_fraudDetectionAction :: Lens'
  EnrollmentJobFraudDetectionConfig (Maybe FraudDetectionAction)
enrollmentJobFraudDetectionConfig_fraudDetectionAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnrollmentJobFraudDetectionConfig' {Maybe FraudDetectionAction
fraudDetectionAction :: Maybe FraudDetectionAction
$sel:fraudDetectionAction:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe FraudDetectionAction
fraudDetectionAction} -> Maybe FraudDetectionAction
fraudDetectionAction) (\s :: EnrollmentJobFraudDetectionConfig
s@EnrollmentJobFraudDetectionConfig' {} Maybe FraudDetectionAction
a -> EnrollmentJobFraudDetectionConfig
s {$sel:fraudDetectionAction:EnrollmentJobFraudDetectionConfig' :: Maybe FraudDetectionAction
fraudDetectionAction = Maybe FraudDetectionAction
a} :: EnrollmentJobFraudDetectionConfig)

-- | Threshold value for determining whether the speaker is a high risk to be
-- fraudulent. If the detected risk score calculated by Voice ID is greater
-- than or equal to the threshold, the speaker is considered a fraudster.
enrollmentJobFraudDetectionConfig_riskThreshold :: Lens.Lens' EnrollmentJobFraudDetectionConfig (Prelude.Maybe Prelude.Natural)
enrollmentJobFraudDetectionConfig_riskThreshold :: Lens' EnrollmentJobFraudDetectionConfig (Maybe Natural)
enrollmentJobFraudDetectionConfig_riskThreshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnrollmentJobFraudDetectionConfig' {Maybe Natural
riskThreshold :: Maybe Natural
$sel:riskThreshold:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe Natural
riskThreshold} -> Maybe Natural
riskThreshold) (\s :: EnrollmentJobFraudDetectionConfig
s@EnrollmentJobFraudDetectionConfig' {} Maybe Natural
a -> EnrollmentJobFraudDetectionConfig
s {$sel:riskThreshold:EnrollmentJobFraudDetectionConfig' :: Maybe Natural
riskThreshold = Maybe Natural
a} :: EnrollmentJobFraudDetectionConfig)

instance
  Data.FromJSON
    EnrollmentJobFraudDetectionConfig
  where
  parseJSON :: Value -> Parser EnrollmentJobFraudDetectionConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EnrollmentJobFraudDetectionConfig"
      ( \Object
x ->
          Maybe FraudDetectionAction
-> Maybe Natural -> EnrollmentJobFraudDetectionConfig
EnrollmentJobFraudDetectionConfig'
            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
"FraudDetectionAction")
            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
"RiskThreshold")
      )

instance
  Prelude.Hashable
    EnrollmentJobFraudDetectionConfig
  where
  hashWithSalt :: Int -> EnrollmentJobFraudDetectionConfig -> Int
hashWithSalt
    Int
_salt
    EnrollmentJobFraudDetectionConfig' {Maybe Natural
Maybe FraudDetectionAction
riskThreshold :: Maybe Natural
fraudDetectionAction :: Maybe FraudDetectionAction
$sel:riskThreshold:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe Natural
$sel:fraudDetectionAction:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe FraudDetectionAction
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FraudDetectionAction
fraudDetectionAction
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
riskThreshold

instance
  Prelude.NFData
    EnrollmentJobFraudDetectionConfig
  where
  rnf :: EnrollmentJobFraudDetectionConfig -> ()
rnf EnrollmentJobFraudDetectionConfig' {Maybe Natural
Maybe FraudDetectionAction
riskThreshold :: Maybe Natural
fraudDetectionAction :: Maybe FraudDetectionAction
$sel:riskThreshold:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe Natural
$sel:fraudDetectionAction:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe FraudDetectionAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FraudDetectionAction
fraudDetectionAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
riskThreshold

instance
  Data.ToJSON
    EnrollmentJobFraudDetectionConfig
  where
  toJSON :: EnrollmentJobFraudDetectionConfig -> Value
toJSON EnrollmentJobFraudDetectionConfig' {Maybe Natural
Maybe FraudDetectionAction
riskThreshold :: Maybe Natural
fraudDetectionAction :: Maybe FraudDetectionAction
$sel:riskThreshold:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe Natural
$sel:fraudDetectionAction:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe FraudDetectionAction
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FraudDetectionAction" 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 FraudDetectionAction
fraudDetectionAction,
            (Key
"RiskThreshold" 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
riskThreshold
          ]
      )