{-# 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.CognitoIdentityProvider.Types.AccountTakeoverRiskConfigurationType
-- 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.CognitoIdentityProvider.Types.AccountTakeoverRiskConfigurationType where

import Amazonka.CognitoIdentityProvider.Types.AccountTakeoverActionsType
import Amazonka.CognitoIdentityProvider.Types.NotifyConfigurationType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration for mitigation actions and notification for different
-- levels of risk detected for a potential account takeover.
--
-- /See:/ 'newAccountTakeoverRiskConfigurationType' smart constructor.
data AccountTakeoverRiskConfigurationType = AccountTakeoverRiskConfigurationType'
  { -- | The notify configuration used to construct email notifications.
    AccountTakeoverRiskConfigurationType
-> Maybe NotifyConfigurationType
notifyConfiguration :: Prelude.Maybe NotifyConfigurationType,
    -- | Account takeover risk configuration actions
    AccountTakeoverRiskConfigurationType -> AccountTakeoverActionsType
actions :: AccountTakeoverActionsType
  }
  deriving (AccountTakeoverRiskConfigurationType
-> AccountTakeoverRiskConfigurationType -> Bool
(AccountTakeoverRiskConfigurationType
 -> AccountTakeoverRiskConfigurationType -> Bool)
-> (AccountTakeoverRiskConfigurationType
    -> AccountTakeoverRiskConfigurationType -> Bool)
-> Eq AccountTakeoverRiskConfigurationType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountTakeoverRiskConfigurationType
-> AccountTakeoverRiskConfigurationType -> Bool
$c/= :: AccountTakeoverRiskConfigurationType
-> AccountTakeoverRiskConfigurationType -> Bool
== :: AccountTakeoverRiskConfigurationType
-> AccountTakeoverRiskConfigurationType -> Bool
$c== :: AccountTakeoverRiskConfigurationType
-> AccountTakeoverRiskConfigurationType -> Bool
Prelude.Eq, ReadPrec [AccountTakeoverRiskConfigurationType]
ReadPrec AccountTakeoverRiskConfigurationType
Int -> ReadS AccountTakeoverRiskConfigurationType
ReadS [AccountTakeoverRiskConfigurationType]
(Int -> ReadS AccountTakeoverRiskConfigurationType)
-> ReadS [AccountTakeoverRiskConfigurationType]
-> ReadPrec AccountTakeoverRiskConfigurationType
-> ReadPrec [AccountTakeoverRiskConfigurationType]
-> Read AccountTakeoverRiskConfigurationType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccountTakeoverRiskConfigurationType]
$creadListPrec :: ReadPrec [AccountTakeoverRiskConfigurationType]
readPrec :: ReadPrec AccountTakeoverRiskConfigurationType
$creadPrec :: ReadPrec AccountTakeoverRiskConfigurationType
readList :: ReadS [AccountTakeoverRiskConfigurationType]
$creadList :: ReadS [AccountTakeoverRiskConfigurationType]
readsPrec :: Int -> ReadS AccountTakeoverRiskConfigurationType
$creadsPrec :: Int -> ReadS AccountTakeoverRiskConfigurationType
Prelude.Read, Int -> AccountTakeoverRiskConfigurationType -> ShowS
[AccountTakeoverRiskConfigurationType] -> ShowS
AccountTakeoverRiskConfigurationType -> String
(Int -> AccountTakeoverRiskConfigurationType -> ShowS)
-> (AccountTakeoverRiskConfigurationType -> String)
-> ([AccountTakeoverRiskConfigurationType] -> ShowS)
-> Show AccountTakeoverRiskConfigurationType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountTakeoverRiskConfigurationType] -> ShowS
$cshowList :: [AccountTakeoverRiskConfigurationType] -> ShowS
show :: AccountTakeoverRiskConfigurationType -> String
$cshow :: AccountTakeoverRiskConfigurationType -> String
showsPrec :: Int -> AccountTakeoverRiskConfigurationType -> ShowS
$cshowsPrec :: Int -> AccountTakeoverRiskConfigurationType -> ShowS
Prelude.Show, (forall x.
 AccountTakeoverRiskConfigurationType
 -> Rep AccountTakeoverRiskConfigurationType x)
-> (forall x.
    Rep AccountTakeoverRiskConfigurationType x
    -> AccountTakeoverRiskConfigurationType)
-> Generic AccountTakeoverRiskConfigurationType
forall x.
Rep AccountTakeoverRiskConfigurationType x
-> AccountTakeoverRiskConfigurationType
forall x.
AccountTakeoverRiskConfigurationType
-> Rep AccountTakeoverRiskConfigurationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AccountTakeoverRiskConfigurationType x
-> AccountTakeoverRiskConfigurationType
$cfrom :: forall x.
AccountTakeoverRiskConfigurationType
-> Rep AccountTakeoverRiskConfigurationType x
Prelude.Generic)

-- |
-- Create a value of 'AccountTakeoverRiskConfigurationType' 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:
--
-- 'notifyConfiguration', 'accountTakeoverRiskConfigurationType_notifyConfiguration' - The notify configuration used to construct email notifications.
--
-- 'actions', 'accountTakeoverRiskConfigurationType_actions' - Account takeover risk configuration actions
newAccountTakeoverRiskConfigurationType ::
  -- | 'actions'
  AccountTakeoverActionsType ->
  AccountTakeoverRiskConfigurationType
newAccountTakeoverRiskConfigurationType :: AccountTakeoverActionsType -> AccountTakeoverRiskConfigurationType
newAccountTakeoverRiskConfigurationType AccountTakeoverActionsType
pActions_ =
  AccountTakeoverRiskConfigurationType' :: Maybe NotifyConfigurationType
-> AccountTakeoverActionsType
-> AccountTakeoverRiskConfigurationType
AccountTakeoverRiskConfigurationType'
    { $sel:notifyConfiguration:AccountTakeoverRiskConfigurationType' :: Maybe NotifyConfigurationType
notifyConfiguration =
        Maybe NotifyConfigurationType
forall a. Maybe a
Prelude.Nothing,
      $sel:actions:AccountTakeoverRiskConfigurationType' :: AccountTakeoverActionsType
actions = AccountTakeoverActionsType
pActions_
    }

-- | The notify configuration used to construct email notifications.
accountTakeoverRiskConfigurationType_notifyConfiguration :: Lens.Lens' AccountTakeoverRiskConfigurationType (Prelude.Maybe NotifyConfigurationType)
accountTakeoverRiskConfigurationType_notifyConfiguration :: (Maybe NotifyConfigurationType
 -> f (Maybe NotifyConfigurationType))
-> AccountTakeoverRiskConfigurationType
-> f AccountTakeoverRiskConfigurationType
accountTakeoverRiskConfigurationType_notifyConfiguration = (AccountTakeoverRiskConfigurationType
 -> Maybe NotifyConfigurationType)
-> (AccountTakeoverRiskConfigurationType
    -> Maybe NotifyConfigurationType
    -> AccountTakeoverRiskConfigurationType)
-> Lens
     AccountTakeoverRiskConfigurationType
     AccountTakeoverRiskConfigurationType
     (Maybe NotifyConfigurationType)
     (Maybe NotifyConfigurationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountTakeoverRiskConfigurationType' {Maybe NotifyConfigurationType
notifyConfiguration :: Maybe NotifyConfigurationType
$sel:notifyConfiguration:AccountTakeoverRiskConfigurationType' :: AccountTakeoverRiskConfigurationType
-> Maybe NotifyConfigurationType
notifyConfiguration} -> Maybe NotifyConfigurationType
notifyConfiguration) (\s :: AccountTakeoverRiskConfigurationType
s@AccountTakeoverRiskConfigurationType' {} Maybe NotifyConfigurationType
a -> AccountTakeoverRiskConfigurationType
s {$sel:notifyConfiguration:AccountTakeoverRiskConfigurationType' :: Maybe NotifyConfigurationType
notifyConfiguration = Maybe NotifyConfigurationType
a} :: AccountTakeoverRiskConfigurationType)

-- | Account takeover risk configuration actions
accountTakeoverRiskConfigurationType_actions :: Lens.Lens' AccountTakeoverRiskConfigurationType AccountTakeoverActionsType
accountTakeoverRiskConfigurationType_actions :: (AccountTakeoverActionsType -> f AccountTakeoverActionsType)
-> AccountTakeoverRiskConfigurationType
-> f AccountTakeoverRiskConfigurationType
accountTakeoverRiskConfigurationType_actions = (AccountTakeoverRiskConfigurationType
 -> AccountTakeoverActionsType)
-> (AccountTakeoverRiskConfigurationType
    -> AccountTakeoverActionsType
    -> AccountTakeoverRiskConfigurationType)
-> Lens
     AccountTakeoverRiskConfigurationType
     AccountTakeoverRiskConfigurationType
     AccountTakeoverActionsType
     AccountTakeoverActionsType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountTakeoverRiskConfigurationType' {AccountTakeoverActionsType
actions :: AccountTakeoverActionsType
$sel:actions:AccountTakeoverRiskConfigurationType' :: AccountTakeoverRiskConfigurationType -> AccountTakeoverActionsType
actions} -> AccountTakeoverActionsType
actions) (\s :: AccountTakeoverRiskConfigurationType
s@AccountTakeoverRiskConfigurationType' {} AccountTakeoverActionsType
a -> AccountTakeoverRiskConfigurationType
s {$sel:actions:AccountTakeoverRiskConfigurationType' :: AccountTakeoverActionsType
actions = AccountTakeoverActionsType
a} :: AccountTakeoverRiskConfigurationType)

instance
  Core.FromJSON
    AccountTakeoverRiskConfigurationType
  where
  parseJSON :: Value -> Parser AccountTakeoverRiskConfigurationType
parseJSON =
    String
-> (Object -> Parser AccountTakeoverRiskConfigurationType)
-> Value
-> Parser AccountTakeoverRiskConfigurationType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccountTakeoverRiskConfigurationType"
      ( \Object
x ->
          Maybe NotifyConfigurationType
-> AccountTakeoverActionsType
-> AccountTakeoverRiskConfigurationType
AccountTakeoverRiskConfigurationType'
            (Maybe NotifyConfigurationType
 -> AccountTakeoverActionsType
 -> AccountTakeoverRiskConfigurationType)
-> Parser (Maybe NotifyConfigurationType)
-> Parser
     (AccountTakeoverActionsType
      -> AccountTakeoverRiskConfigurationType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe NotifyConfigurationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NotifyConfiguration")
            Parser
  (AccountTakeoverActionsType
   -> AccountTakeoverRiskConfigurationType)
-> Parser AccountTakeoverActionsType
-> Parser AccountTakeoverRiskConfigurationType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AccountTakeoverActionsType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Actions")
      )

instance
  Prelude.Hashable
    AccountTakeoverRiskConfigurationType

instance
  Prelude.NFData
    AccountTakeoverRiskConfigurationType

instance
  Core.ToJSON
    AccountTakeoverRiskConfigurationType
  where
  toJSON :: AccountTakeoverRiskConfigurationType -> Value
toJSON AccountTakeoverRiskConfigurationType' {Maybe NotifyConfigurationType
AccountTakeoverActionsType
actions :: AccountTakeoverActionsType
notifyConfiguration :: Maybe NotifyConfigurationType
$sel:actions:AccountTakeoverRiskConfigurationType' :: AccountTakeoverRiskConfigurationType -> AccountTakeoverActionsType
$sel:notifyConfiguration:AccountTakeoverRiskConfigurationType' :: AccountTakeoverRiskConfigurationType
-> Maybe NotifyConfigurationType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NotifyConfiguration" Text -> NotifyConfigurationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NotifyConfigurationType -> Pair)
-> Maybe NotifyConfigurationType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NotifyConfigurationType
notifyConfiguration,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Actions" Text -> AccountTakeoverActionsType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AccountTakeoverActionsType
actions)
          ]
      )