{-# 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-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.EnrollmentConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 fraud detection configuration to use for the speaker enrollment job.
    EnrollmentConfig -> Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig :: Prelude.Maybe EnrollmentJobFraudDetectionConfig,
    -- | 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
  }
  deriving (EnrollmentConfig -> EnrollmentConfig -> Bool
(EnrollmentConfig -> EnrollmentConfig -> Bool)
-> (EnrollmentConfig -> EnrollmentConfig -> Bool)
-> Eq EnrollmentConfig
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]
(Int -> ReadS EnrollmentConfig)
-> ReadS [EnrollmentConfig]
-> ReadPrec EnrollmentConfig
-> ReadPrec [EnrollmentConfig]
-> Read 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
(Int -> EnrollmentConfig -> ShowS)
-> (EnrollmentConfig -> String)
-> ([EnrollmentConfig] -> ShowS)
-> Show EnrollmentConfig
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. EnrollmentConfig -> Rep EnrollmentConfig x)
-> (forall x. Rep EnrollmentConfig x -> EnrollmentConfig)
-> Generic EnrollmentConfig
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:
--
-- 'fraudDetectionConfig', 'enrollmentConfig_fraudDetectionConfig' - The fraud detection configuration to use for the speaker enrollment job.
--
-- '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.
newEnrollmentConfig ::
  EnrollmentConfig
newEnrollmentConfig :: EnrollmentConfig
newEnrollmentConfig =
  EnrollmentConfig' :: Maybe EnrollmentJobFraudDetectionConfig
-> Maybe ExistingEnrollmentAction -> EnrollmentConfig
EnrollmentConfig'
    { $sel:fraudDetectionConfig:EnrollmentConfig' :: Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig =
        Maybe EnrollmentJobFraudDetectionConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:existingEnrollmentAction:EnrollmentConfig' :: Maybe ExistingEnrollmentAction
existingEnrollmentAction = Maybe ExistingEnrollmentAction
forall a. Maybe a
Prelude.Nothing
    }

-- | The fraud detection configuration to use for the speaker enrollment job.
enrollmentConfig_fraudDetectionConfig :: Lens.Lens' EnrollmentConfig (Prelude.Maybe EnrollmentJobFraudDetectionConfig)
enrollmentConfig_fraudDetectionConfig :: (Maybe EnrollmentJobFraudDetectionConfig
 -> f (Maybe EnrollmentJobFraudDetectionConfig))
-> EnrollmentConfig -> f EnrollmentConfig
enrollmentConfig_fraudDetectionConfig = (EnrollmentConfig -> Maybe EnrollmentJobFraudDetectionConfig)
-> (EnrollmentConfig
    -> Maybe EnrollmentJobFraudDetectionConfig -> EnrollmentConfig)
-> Lens
     EnrollmentConfig
     EnrollmentConfig
     (Maybe EnrollmentJobFraudDetectionConfig)
     (Maybe EnrollmentJobFraudDetectionConfig)
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)

-- | 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 :: (Maybe ExistingEnrollmentAction
 -> f (Maybe ExistingEnrollmentAction))
-> EnrollmentConfig -> f EnrollmentConfig
enrollmentConfig_existingEnrollmentAction = (EnrollmentConfig -> Maybe ExistingEnrollmentAction)
-> (EnrollmentConfig
    -> Maybe ExistingEnrollmentAction -> EnrollmentConfig)
-> Lens
     EnrollmentConfig
     EnrollmentConfig
     (Maybe ExistingEnrollmentAction)
     (Maybe 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)

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

instance Prelude.Hashable EnrollmentConfig

instance Prelude.NFData EnrollmentConfig

instance Core.ToJSON EnrollmentConfig where
  toJSON :: EnrollmentConfig -> Value
toJSON EnrollmentConfig' {Maybe ExistingEnrollmentAction
Maybe EnrollmentJobFraudDetectionConfig
existingEnrollmentAction :: Maybe ExistingEnrollmentAction
fraudDetectionConfig :: Maybe EnrollmentJobFraudDetectionConfig
$sel:existingEnrollmentAction:EnrollmentConfig' :: EnrollmentConfig -> Maybe ExistingEnrollmentAction
$sel:fraudDetectionConfig:EnrollmentConfig' :: EnrollmentConfig -> Maybe EnrollmentJobFraudDetectionConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FraudDetectionConfig" Text -> EnrollmentJobFraudDetectionConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EnrollmentJobFraudDetectionConfig -> Pair)
-> Maybe EnrollmentJobFraudDetectionConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EnrollmentJobFraudDetectionConfig
fraudDetectionConfig,
            (Text
"ExistingEnrollmentAction" Text -> ExistingEnrollmentAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ExistingEnrollmentAction -> Pair)
-> Maybe ExistingEnrollmentAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ExistingEnrollmentAction
existingEnrollmentAction
          ]
      )