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

import Amazonka.CognitoIdentityProvider.Types.AccountTakeoverEventActionType
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

-- | Account takeover action type.
--
-- /See:/ 'newAccountTakeoverActionType' smart constructor.
data AccountTakeoverActionType = AccountTakeoverActionType'
  { -- | Flag specifying whether to send a notification.
    AccountTakeoverActionType -> Bool
notify :: Prelude.Bool,
    -- | The action to take in response to the account takeover action. Valid
    -- values are as follows:
    --
    -- -   @BLOCK@ Choosing this action will block the request.
    --
    -- -   @MFA_IF_CONFIGURED@ Present an MFA challenge if user has configured
    --     it, else allow the request.
    --
    -- -   @MFA_REQUIRED@ Present an MFA challenge if user has configured it,
    --     else block the request.
    --
    -- -   @NO_ACTION@ Allow the user to sign in.
    AccountTakeoverActionType -> AccountTakeoverEventActionType
eventAction :: AccountTakeoverEventActionType
  }
  deriving (AccountTakeoverActionType -> AccountTakeoverActionType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountTakeoverActionType -> AccountTakeoverActionType -> Bool
$c/= :: AccountTakeoverActionType -> AccountTakeoverActionType -> Bool
== :: AccountTakeoverActionType -> AccountTakeoverActionType -> Bool
$c== :: AccountTakeoverActionType -> AccountTakeoverActionType -> Bool
Prelude.Eq, ReadPrec [AccountTakeoverActionType]
ReadPrec AccountTakeoverActionType
Int -> ReadS AccountTakeoverActionType
ReadS [AccountTakeoverActionType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccountTakeoverActionType]
$creadListPrec :: ReadPrec [AccountTakeoverActionType]
readPrec :: ReadPrec AccountTakeoverActionType
$creadPrec :: ReadPrec AccountTakeoverActionType
readList :: ReadS [AccountTakeoverActionType]
$creadList :: ReadS [AccountTakeoverActionType]
readsPrec :: Int -> ReadS AccountTakeoverActionType
$creadsPrec :: Int -> ReadS AccountTakeoverActionType
Prelude.Read, Int -> AccountTakeoverActionType -> ShowS
[AccountTakeoverActionType] -> ShowS
AccountTakeoverActionType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountTakeoverActionType] -> ShowS
$cshowList :: [AccountTakeoverActionType] -> ShowS
show :: AccountTakeoverActionType -> String
$cshow :: AccountTakeoverActionType -> String
showsPrec :: Int -> AccountTakeoverActionType -> ShowS
$cshowsPrec :: Int -> AccountTakeoverActionType -> ShowS
Prelude.Show, forall x.
Rep AccountTakeoverActionType x -> AccountTakeoverActionType
forall x.
AccountTakeoverActionType -> Rep AccountTakeoverActionType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AccountTakeoverActionType x -> AccountTakeoverActionType
$cfrom :: forall x.
AccountTakeoverActionType -> Rep AccountTakeoverActionType x
Prelude.Generic)

-- |
-- Create a value of 'AccountTakeoverActionType' 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:
--
-- 'notify', 'accountTakeoverActionType_notify' - Flag specifying whether to send a notification.
--
-- 'eventAction', 'accountTakeoverActionType_eventAction' - The action to take in response to the account takeover action. Valid
-- values are as follows:
--
-- -   @BLOCK@ Choosing this action will block the request.
--
-- -   @MFA_IF_CONFIGURED@ Present an MFA challenge if user has configured
--     it, else allow the request.
--
-- -   @MFA_REQUIRED@ Present an MFA challenge if user has configured it,
--     else block the request.
--
-- -   @NO_ACTION@ Allow the user to sign in.
newAccountTakeoverActionType ::
  -- | 'notify'
  Prelude.Bool ->
  -- | 'eventAction'
  AccountTakeoverEventActionType ->
  AccountTakeoverActionType
newAccountTakeoverActionType :: Bool -> AccountTakeoverEventActionType -> AccountTakeoverActionType
newAccountTakeoverActionType Bool
pNotify_ AccountTakeoverEventActionType
pEventAction_ =
  AccountTakeoverActionType'
    { $sel:notify:AccountTakeoverActionType' :: Bool
notify = Bool
pNotify_,
      $sel:eventAction:AccountTakeoverActionType' :: AccountTakeoverEventActionType
eventAction = AccountTakeoverEventActionType
pEventAction_
    }

-- | Flag specifying whether to send a notification.
accountTakeoverActionType_notify :: Lens.Lens' AccountTakeoverActionType Prelude.Bool
accountTakeoverActionType_notify :: Lens' AccountTakeoverActionType Bool
accountTakeoverActionType_notify = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountTakeoverActionType' {Bool
notify :: Bool
$sel:notify:AccountTakeoverActionType' :: AccountTakeoverActionType -> Bool
notify} -> Bool
notify) (\s :: AccountTakeoverActionType
s@AccountTakeoverActionType' {} Bool
a -> AccountTakeoverActionType
s {$sel:notify:AccountTakeoverActionType' :: Bool
notify = Bool
a} :: AccountTakeoverActionType)

-- | The action to take in response to the account takeover action. Valid
-- values are as follows:
--
-- -   @BLOCK@ Choosing this action will block the request.
--
-- -   @MFA_IF_CONFIGURED@ Present an MFA challenge if user has configured
--     it, else allow the request.
--
-- -   @MFA_REQUIRED@ Present an MFA challenge if user has configured it,
--     else block the request.
--
-- -   @NO_ACTION@ Allow the user to sign in.
accountTakeoverActionType_eventAction :: Lens.Lens' AccountTakeoverActionType AccountTakeoverEventActionType
accountTakeoverActionType_eventAction :: Lens' AccountTakeoverActionType AccountTakeoverEventActionType
accountTakeoverActionType_eventAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountTakeoverActionType' {AccountTakeoverEventActionType
eventAction :: AccountTakeoverEventActionType
$sel:eventAction:AccountTakeoverActionType' :: AccountTakeoverActionType -> AccountTakeoverEventActionType
eventAction} -> AccountTakeoverEventActionType
eventAction) (\s :: AccountTakeoverActionType
s@AccountTakeoverActionType' {} AccountTakeoverEventActionType
a -> AccountTakeoverActionType
s {$sel:eventAction:AccountTakeoverActionType' :: AccountTakeoverEventActionType
eventAction = AccountTakeoverEventActionType
a} :: AccountTakeoverActionType)

instance Data.FromJSON AccountTakeoverActionType where
  parseJSON :: Value -> Parser AccountTakeoverActionType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AccountTakeoverActionType"
      ( \Object
x ->
          Bool -> AccountTakeoverEventActionType -> AccountTakeoverActionType
AccountTakeoverActionType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Notify")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EventAction")
      )

instance Prelude.Hashable AccountTakeoverActionType where
  hashWithSalt :: Int -> AccountTakeoverActionType -> Int
hashWithSalt Int
_salt AccountTakeoverActionType' {Bool
AccountTakeoverEventActionType
eventAction :: AccountTakeoverEventActionType
notify :: Bool
$sel:eventAction:AccountTakeoverActionType' :: AccountTakeoverActionType -> AccountTakeoverEventActionType
$sel:notify:AccountTakeoverActionType' :: AccountTakeoverActionType -> Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
notify
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AccountTakeoverEventActionType
eventAction

instance Prelude.NFData AccountTakeoverActionType where
  rnf :: AccountTakeoverActionType -> ()
rnf AccountTakeoverActionType' {Bool
AccountTakeoverEventActionType
eventAction :: AccountTakeoverEventActionType
notify :: Bool
$sel:eventAction:AccountTakeoverActionType' :: AccountTakeoverActionType -> AccountTakeoverEventActionType
$sel:notify:AccountTakeoverActionType' :: AccountTakeoverActionType -> Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Bool
notify
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AccountTakeoverEventActionType
eventAction

instance Data.ToJSON AccountTakeoverActionType where
  toJSON :: AccountTakeoverActionType -> Value
toJSON AccountTakeoverActionType' {Bool
AccountTakeoverEventActionType
eventAction :: AccountTakeoverEventActionType
notify :: Bool
$sel:eventAction:AccountTakeoverActionType' :: AccountTakeoverActionType -> AccountTakeoverEventActionType
$sel:notify:AccountTakeoverActionType' :: AccountTakeoverActionType -> Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Notify" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
notify),
            forall a. a -> Maybe a
Prelude.Just (Key
"EventAction" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AccountTakeoverEventActionType
eventAction)
          ]
      )