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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.VoiceId.Types.DuplicateRegistrationAction

-- | The configuration definining the action to take when a duplicate
-- fraudster is detected, and the similarity threshold to use for detecting
-- a duplicate fraudster during a batch fraudster registration job.
--
-- /See:/ 'newRegistrationConfig' smart constructor.
data RegistrationConfig = RegistrationConfig'
  { -- | The action to take when a fraudster is identified as a duplicate. The
    -- default action is @SKIP@, which skips registering the duplicate
    -- fraudster. Setting the value to @REGISTER_AS_NEW@ always registers a new
    -- fraudster into the specified domain.
    RegistrationConfig -> Maybe DuplicateRegistrationAction
duplicateRegistrationAction :: Prelude.Maybe DuplicateRegistrationAction,
    -- | The minimum similarity score between the new and old fraudsters in order
    -- to consider the new fraudster a duplicate.
    RegistrationConfig -> Maybe Natural
fraudsterSimilarityThreshold :: Prelude.Maybe Prelude.Natural
  }
  deriving (RegistrationConfig -> RegistrationConfig -> Bool
(RegistrationConfig -> RegistrationConfig -> Bool)
-> (RegistrationConfig -> RegistrationConfig -> Bool)
-> Eq RegistrationConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegistrationConfig -> RegistrationConfig -> Bool
$c/= :: RegistrationConfig -> RegistrationConfig -> Bool
== :: RegistrationConfig -> RegistrationConfig -> Bool
$c== :: RegistrationConfig -> RegistrationConfig -> Bool
Prelude.Eq, ReadPrec [RegistrationConfig]
ReadPrec RegistrationConfig
Int -> ReadS RegistrationConfig
ReadS [RegistrationConfig]
(Int -> ReadS RegistrationConfig)
-> ReadS [RegistrationConfig]
-> ReadPrec RegistrationConfig
-> ReadPrec [RegistrationConfig]
-> Read RegistrationConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegistrationConfig]
$creadListPrec :: ReadPrec [RegistrationConfig]
readPrec :: ReadPrec RegistrationConfig
$creadPrec :: ReadPrec RegistrationConfig
readList :: ReadS [RegistrationConfig]
$creadList :: ReadS [RegistrationConfig]
readsPrec :: Int -> ReadS RegistrationConfig
$creadsPrec :: Int -> ReadS RegistrationConfig
Prelude.Read, Int -> RegistrationConfig -> ShowS
[RegistrationConfig] -> ShowS
RegistrationConfig -> String
(Int -> RegistrationConfig -> ShowS)
-> (RegistrationConfig -> String)
-> ([RegistrationConfig] -> ShowS)
-> Show RegistrationConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegistrationConfig] -> ShowS
$cshowList :: [RegistrationConfig] -> ShowS
show :: RegistrationConfig -> String
$cshow :: RegistrationConfig -> String
showsPrec :: Int -> RegistrationConfig -> ShowS
$cshowsPrec :: Int -> RegistrationConfig -> ShowS
Prelude.Show, (forall x. RegistrationConfig -> Rep RegistrationConfig x)
-> (forall x. Rep RegistrationConfig x -> RegistrationConfig)
-> Generic RegistrationConfig
forall x. Rep RegistrationConfig x -> RegistrationConfig
forall x. RegistrationConfig -> Rep RegistrationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegistrationConfig x -> RegistrationConfig
$cfrom :: forall x. RegistrationConfig -> Rep RegistrationConfig x
Prelude.Generic)

-- |
-- Create a value of 'RegistrationConfig' 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:
--
-- 'duplicateRegistrationAction', 'registrationConfig_duplicateRegistrationAction' - The action to take when a fraudster is identified as a duplicate. The
-- default action is @SKIP@, which skips registering the duplicate
-- fraudster. Setting the value to @REGISTER_AS_NEW@ always registers a new
-- fraudster into the specified domain.
--
-- 'fraudsterSimilarityThreshold', 'registrationConfig_fraudsterSimilarityThreshold' - The minimum similarity score between the new and old fraudsters in order
-- to consider the new fraudster a duplicate.
newRegistrationConfig ::
  RegistrationConfig
newRegistrationConfig :: RegistrationConfig
newRegistrationConfig =
  RegistrationConfig' :: Maybe DuplicateRegistrationAction
-> Maybe Natural -> RegistrationConfig
RegistrationConfig'
    { $sel:duplicateRegistrationAction:RegistrationConfig' :: Maybe DuplicateRegistrationAction
duplicateRegistrationAction =
        Maybe DuplicateRegistrationAction
forall a. Maybe a
Prelude.Nothing,
      $sel:fraudsterSimilarityThreshold:RegistrationConfig' :: Maybe Natural
fraudsterSimilarityThreshold = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The action to take when a fraudster is identified as a duplicate. The
-- default action is @SKIP@, which skips registering the duplicate
-- fraudster. Setting the value to @REGISTER_AS_NEW@ always registers a new
-- fraudster into the specified domain.
registrationConfig_duplicateRegistrationAction :: Lens.Lens' RegistrationConfig (Prelude.Maybe DuplicateRegistrationAction)
registrationConfig_duplicateRegistrationAction :: (Maybe DuplicateRegistrationAction
 -> f (Maybe DuplicateRegistrationAction))
-> RegistrationConfig -> f RegistrationConfig
registrationConfig_duplicateRegistrationAction = (RegistrationConfig -> Maybe DuplicateRegistrationAction)
-> (RegistrationConfig
    -> Maybe DuplicateRegistrationAction -> RegistrationConfig)
-> Lens
     RegistrationConfig
     RegistrationConfig
     (Maybe DuplicateRegistrationAction)
     (Maybe DuplicateRegistrationAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistrationConfig' {Maybe DuplicateRegistrationAction
duplicateRegistrationAction :: Maybe DuplicateRegistrationAction
$sel:duplicateRegistrationAction:RegistrationConfig' :: RegistrationConfig -> Maybe DuplicateRegistrationAction
duplicateRegistrationAction} -> Maybe DuplicateRegistrationAction
duplicateRegistrationAction) (\s :: RegistrationConfig
s@RegistrationConfig' {} Maybe DuplicateRegistrationAction
a -> RegistrationConfig
s {$sel:duplicateRegistrationAction:RegistrationConfig' :: Maybe DuplicateRegistrationAction
duplicateRegistrationAction = Maybe DuplicateRegistrationAction
a} :: RegistrationConfig)

-- | The minimum similarity score between the new and old fraudsters in order
-- to consider the new fraudster a duplicate.
registrationConfig_fraudsterSimilarityThreshold :: Lens.Lens' RegistrationConfig (Prelude.Maybe Prelude.Natural)
registrationConfig_fraudsterSimilarityThreshold :: (Maybe Natural -> f (Maybe Natural))
-> RegistrationConfig -> f RegistrationConfig
registrationConfig_fraudsterSimilarityThreshold = (RegistrationConfig -> Maybe Natural)
-> (RegistrationConfig -> Maybe Natural -> RegistrationConfig)
-> Lens
     RegistrationConfig
     RegistrationConfig
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistrationConfig' {Maybe Natural
fraudsterSimilarityThreshold :: Maybe Natural
$sel:fraudsterSimilarityThreshold:RegistrationConfig' :: RegistrationConfig -> Maybe Natural
fraudsterSimilarityThreshold} -> Maybe Natural
fraudsterSimilarityThreshold) (\s :: RegistrationConfig
s@RegistrationConfig' {} Maybe Natural
a -> RegistrationConfig
s {$sel:fraudsterSimilarityThreshold:RegistrationConfig' :: Maybe Natural
fraudsterSimilarityThreshold = Maybe Natural
a} :: RegistrationConfig)

instance Core.FromJSON RegistrationConfig where
  parseJSON :: Value -> Parser RegistrationConfig
parseJSON =
    String
-> (Object -> Parser RegistrationConfig)
-> Value
-> Parser RegistrationConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RegistrationConfig"
      ( \Object
x ->
          Maybe DuplicateRegistrationAction
-> Maybe Natural -> RegistrationConfig
RegistrationConfig'
            (Maybe DuplicateRegistrationAction
 -> Maybe Natural -> RegistrationConfig)
-> Parser (Maybe DuplicateRegistrationAction)
-> Parser (Maybe Natural -> RegistrationConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DuplicateRegistrationAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DuplicateRegistrationAction")
            Parser (Maybe Natural -> RegistrationConfig)
-> Parser (Maybe Natural) -> Parser RegistrationConfig
forall (f :: * -> *) a b. Applicative f => 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
"FraudsterSimilarityThreshold")
      )

instance Prelude.Hashable RegistrationConfig

instance Prelude.NFData RegistrationConfig

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