{-# 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.EnrollmentConfig
-- 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.EnrollmentConfig 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.EnrollmentJobFraudDetectionConfig
import Amazonka.VoiceId.Types.ExistingEnrollmentAction

-- | Contains configurations defining enrollment behavior for the batch job.
--
-- /See:/ 'newEnrollmentConfig' smart constructor.
data EnrollmentConfig = EnrollmentConfig'
  { -- | The action to take when the specified speaker is already enrolled in the
    -- specified domain. The default value is @SKIP@, which skips the
    -- enrollment for the existing speaker. Setting the value to @OVERWRITE@
    -- replaces the existing voice prints and enrollment audio stored for that
    -- speaker with new data generated from the latest audio.
    EnrollmentConfig -> Maybe ExistingEnrollmentAction
existingEnrollmentAction :: Prelude.Maybe ExistingEnrollmentAction,
    -- | The fraud detection configuration to use for the speaker enrollment job.
    EnrollmentConfig -> Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig :: Prelude.Maybe EnrollmentJobFraudDetectionConfig
  }
  deriving (EnrollmentConfig -> EnrollmentConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnrollmentConfig -> EnrollmentConfig -> Bool
$c/= :: EnrollmentConfig -> EnrollmentConfig -> Bool
== :: EnrollmentConfig -> EnrollmentConfig -> Bool
$c== :: EnrollmentConfig -> EnrollmentConfig -> Bool
Prelude.Eq, ReadPrec [EnrollmentConfig]
ReadPrec EnrollmentConfig
Int -> ReadS EnrollmentConfig
ReadS [EnrollmentConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnrollmentConfig]
$creadListPrec :: ReadPrec [EnrollmentConfig]
readPrec :: ReadPrec EnrollmentConfig
$creadPrec :: ReadPrec EnrollmentConfig
readList :: ReadS [EnrollmentConfig]
$creadList :: ReadS [EnrollmentConfig]
readsPrec :: Int -> ReadS EnrollmentConfig
$creadsPrec :: Int -> ReadS EnrollmentConfig
Prelude.Read, Int -> EnrollmentConfig -> ShowS
[EnrollmentConfig] -> ShowS
EnrollmentConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnrollmentConfig] -> ShowS
$cshowList :: [EnrollmentConfig] -> ShowS
show :: EnrollmentConfig -> String
$cshow :: EnrollmentConfig -> String
showsPrec :: Int -> EnrollmentConfig -> ShowS
$cshowsPrec :: Int -> EnrollmentConfig -> ShowS
Prelude.Show, forall x. Rep EnrollmentConfig x -> EnrollmentConfig
forall x. EnrollmentConfig -> Rep EnrollmentConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnrollmentConfig x -> EnrollmentConfig
$cfrom :: forall x. EnrollmentConfig -> Rep EnrollmentConfig x
Prelude.Generic)

-- |
-- Create a value of 'EnrollmentConfig' 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:
--
-- 'existingEnrollmentAction', 'enrollmentConfig_existingEnrollmentAction' - The action to take when the specified speaker is already enrolled in the
-- specified domain. The default value is @SKIP@, which skips the
-- enrollment for the existing speaker. Setting the value to @OVERWRITE@
-- replaces the existing voice prints and enrollment audio stored for that
-- speaker with new data generated from the latest audio.
--
-- 'fraudDetectionConfig', 'enrollmentConfig_fraudDetectionConfig' - The fraud detection configuration to use for the speaker enrollment job.
newEnrollmentConfig ::
  EnrollmentConfig
newEnrollmentConfig :: EnrollmentConfig
newEnrollmentConfig =
  EnrollmentConfig'
    { $sel:existingEnrollmentAction:EnrollmentConfig' :: Maybe ExistingEnrollmentAction
existingEnrollmentAction =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fraudDetectionConfig:EnrollmentConfig' :: Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig = forall a. Maybe a
Prelude.Nothing
    }

-- | The action to take when the specified speaker is already enrolled in the
-- specified domain. The default value is @SKIP@, which skips the
-- enrollment for the existing speaker. Setting the value to @OVERWRITE@
-- replaces the existing voice prints and enrollment audio stored for that
-- speaker with new data generated from the latest audio.
enrollmentConfig_existingEnrollmentAction :: Lens.Lens' EnrollmentConfig (Prelude.Maybe ExistingEnrollmentAction)
enrollmentConfig_existingEnrollmentAction :: Lens' EnrollmentConfig (Maybe ExistingEnrollmentAction)
enrollmentConfig_existingEnrollmentAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnrollmentConfig' {Maybe ExistingEnrollmentAction
existingEnrollmentAction :: Maybe ExistingEnrollmentAction
$sel:existingEnrollmentAction:EnrollmentConfig' :: EnrollmentConfig -> Maybe ExistingEnrollmentAction
existingEnrollmentAction} -> Maybe ExistingEnrollmentAction
existingEnrollmentAction) (\s :: EnrollmentConfig
s@EnrollmentConfig' {} Maybe ExistingEnrollmentAction
a -> EnrollmentConfig
s {$sel:existingEnrollmentAction:EnrollmentConfig' :: Maybe ExistingEnrollmentAction
existingEnrollmentAction = Maybe ExistingEnrollmentAction
a} :: EnrollmentConfig)

-- | The fraud detection configuration to use for the speaker enrollment job.
enrollmentConfig_fraudDetectionConfig :: Lens.Lens' EnrollmentConfig (Prelude.Maybe EnrollmentJobFraudDetectionConfig)
enrollmentConfig_fraudDetectionConfig :: Lens' EnrollmentConfig (Maybe EnrollmentJobFraudDetectionConfig)
enrollmentConfig_fraudDetectionConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnrollmentConfig' {Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig :: Maybe EnrollmentJobFraudDetectionConfig
$sel:fraudDetectionConfig:EnrollmentConfig' :: EnrollmentConfig -> Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig} -> Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig) (\s :: EnrollmentConfig
s@EnrollmentConfig' {} Maybe EnrollmentJobFraudDetectionConfig
a -> EnrollmentConfig
s {$sel:fraudDetectionConfig:EnrollmentConfig' :: Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig = Maybe EnrollmentJobFraudDetectionConfig
a} :: EnrollmentConfig)

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

instance Prelude.Hashable EnrollmentConfig where
  hashWithSalt :: Int -> EnrollmentConfig -> Int
hashWithSalt Int
_salt EnrollmentConfig' {Maybe ExistingEnrollmentAction
Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig :: Maybe EnrollmentJobFraudDetectionConfig
existingEnrollmentAction :: Maybe ExistingEnrollmentAction
$sel:fraudDetectionConfig:EnrollmentConfig' :: EnrollmentConfig -> Maybe EnrollmentJobFraudDetectionConfig
$sel:existingEnrollmentAction:EnrollmentConfig' :: EnrollmentConfig -> Maybe ExistingEnrollmentAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExistingEnrollmentAction
existingEnrollmentAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig

instance Prelude.NFData EnrollmentConfig where
  rnf :: EnrollmentConfig -> ()
rnf EnrollmentConfig' {Maybe ExistingEnrollmentAction
Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig :: Maybe EnrollmentJobFraudDetectionConfig
existingEnrollmentAction :: Maybe ExistingEnrollmentAction
$sel:fraudDetectionConfig:EnrollmentConfig' :: EnrollmentConfig -> Maybe EnrollmentJobFraudDetectionConfig
$sel:existingEnrollmentAction:EnrollmentConfig' :: EnrollmentConfig -> Maybe ExistingEnrollmentAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ExistingEnrollmentAction
existingEnrollmentAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig

instance Data.ToJSON EnrollmentConfig where
  toJSON :: EnrollmentConfig -> Value
toJSON EnrollmentConfig' {Maybe ExistingEnrollmentAction
Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig :: Maybe EnrollmentJobFraudDetectionConfig
existingEnrollmentAction :: Maybe ExistingEnrollmentAction
$sel:fraudDetectionConfig:EnrollmentConfig' :: EnrollmentConfig -> Maybe EnrollmentJobFraudDetectionConfig
$sel:existingEnrollmentAction:EnrollmentConfig' :: EnrollmentConfig -> Maybe ExistingEnrollmentAction
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ExistingEnrollmentAction" 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 ExistingEnrollmentAction
existingEnrollmentAction,
            (Key
"FraudDetectionConfig" 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 EnrollmentJobFraudDetectionConfig
fraudDetectionConfig
          ]
      )