{-# 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-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)
module Amazonka.VoiceId.Types.EnrollmentJobFraudDetectionConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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,
    -- | 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
  }
  deriving (EnrollmentJobFraudDetectionConfig
-> EnrollmentJobFraudDetectionConfig -> Bool
(EnrollmentJobFraudDetectionConfig
 -> EnrollmentJobFraudDetectionConfig -> Bool)
-> (EnrollmentJobFraudDetectionConfig
    -> EnrollmentJobFraudDetectionConfig -> Bool)
-> Eq EnrollmentJobFraudDetectionConfig
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]
(Int -> ReadS EnrollmentJobFraudDetectionConfig)
-> ReadS [EnrollmentJobFraudDetectionConfig]
-> ReadPrec EnrollmentJobFraudDetectionConfig
-> ReadPrec [EnrollmentJobFraudDetectionConfig]
-> Read 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
(Int -> EnrollmentJobFraudDetectionConfig -> ShowS)
-> (EnrollmentJobFraudDetectionConfig -> String)
-> ([EnrollmentJobFraudDetectionConfig] -> ShowS)
-> Show EnrollmentJobFraudDetectionConfig
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.
 EnrollmentJobFraudDetectionConfig
 -> Rep EnrollmentJobFraudDetectionConfig x)
-> (forall x.
    Rep EnrollmentJobFraudDetectionConfig x
    -> EnrollmentJobFraudDetectionConfig)
-> Generic EnrollmentJobFraudDetectionConfig
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:
--
-- '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.
--
-- '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.
newEnrollmentJobFraudDetectionConfig ::
  EnrollmentJobFraudDetectionConfig
newEnrollmentJobFraudDetectionConfig :: EnrollmentJobFraudDetectionConfig
newEnrollmentJobFraudDetectionConfig =
  EnrollmentJobFraudDetectionConfig' :: Maybe Natural
-> Maybe FraudDetectionAction -> EnrollmentJobFraudDetectionConfig
EnrollmentJobFraudDetectionConfig'
    { $sel:riskThreshold:EnrollmentJobFraudDetectionConfig' :: Maybe Natural
riskThreshold =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:fraudDetectionAction:EnrollmentJobFraudDetectionConfig' :: Maybe FraudDetectionAction
fraudDetectionAction = Maybe FraudDetectionAction
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> EnrollmentJobFraudDetectionConfig
-> f EnrollmentJobFraudDetectionConfig
enrollmentJobFraudDetectionConfig_riskThreshold = (EnrollmentJobFraudDetectionConfig -> Maybe Natural)
-> (EnrollmentJobFraudDetectionConfig
    -> Maybe Natural -> EnrollmentJobFraudDetectionConfig)
-> Lens
     EnrollmentJobFraudDetectionConfig
     EnrollmentJobFraudDetectionConfig
     (Maybe Natural)
     (Maybe Natural)
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)

-- | 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 :: (Maybe FraudDetectionAction -> f (Maybe FraudDetectionAction))
-> EnrollmentJobFraudDetectionConfig
-> f EnrollmentJobFraudDetectionConfig
enrollmentJobFraudDetectionConfig_fraudDetectionAction = (EnrollmentJobFraudDetectionConfig -> Maybe FraudDetectionAction)
-> (EnrollmentJobFraudDetectionConfig
    -> Maybe FraudDetectionAction -> EnrollmentJobFraudDetectionConfig)
-> Lens
     EnrollmentJobFraudDetectionConfig
     EnrollmentJobFraudDetectionConfig
     (Maybe FraudDetectionAction)
     (Maybe 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)

instance
  Core.FromJSON
    EnrollmentJobFraudDetectionConfig
  where
  parseJSON :: Value -> Parser EnrollmentJobFraudDetectionConfig
parseJSON =
    String
-> (Object -> Parser EnrollmentJobFraudDetectionConfig)
-> Value
-> Parser EnrollmentJobFraudDetectionConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EnrollmentJobFraudDetectionConfig"
      ( \Object
x ->
          Maybe Natural
-> Maybe FraudDetectionAction -> EnrollmentJobFraudDetectionConfig
EnrollmentJobFraudDetectionConfig'
            (Maybe Natural
 -> Maybe FraudDetectionAction -> EnrollmentJobFraudDetectionConfig)
-> Parser (Maybe Natural)
-> Parser
     (Maybe FraudDetectionAction -> EnrollmentJobFraudDetectionConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RiskThreshold")
            Parser
  (Maybe FraudDetectionAction -> EnrollmentJobFraudDetectionConfig)
-> Parser (Maybe FraudDetectionAction)
-> Parser EnrollmentJobFraudDetectionConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FraudDetectionAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FraudDetectionAction")
      )

instance
  Prelude.Hashable
    EnrollmentJobFraudDetectionConfig

instance
  Prelude.NFData
    EnrollmentJobFraudDetectionConfig

instance
  Core.ToJSON
    EnrollmentJobFraudDetectionConfig
  where
  toJSON :: EnrollmentJobFraudDetectionConfig -> Value
toJSON EnrollmentJobFraudDetectionConfig' {Maybe Natural
Maybe FraudDetectionAction
fraudDetectionAction :: Maybe FraudDetectionAction
riskThreshold :: Maybe Natural
$sel:fraudDetectionAction:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe FraudDetectionAction
$sel:riskThreshold:EnrollmentJobFraudDetectionConfig' :: EnrollmentJobFraudDetectionConfig -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RiskThreshold" 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
riskThreshold,
            (Text
"FraudDetectionAction" Text -> FraudDetectionAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FraudDetectionAction -> Pair)
-> Maybe FraudDetectionAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FraudDetectionAction
fraudDetectionAction
          ]
      )