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

import Amazonka.CognitoIdentityProvider.Types.AccountTakeoverEventActionType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 event action.
    --
    -- -   @BLOCK@ Choosing this action will block the request.
    --
    -- -   @MFA_IF_CONFIGURED@ Throw MFA challenge if user has configured it,
    --     else allow the request.
    --
    -- -   @MFA_REQUIRED@ Throw MFA challenge if user has configured it, else
    --     block the request.
    --
    -- -   @NO_ACTION@ Allow the user sign-in.
    AccountTakeoverActionType -> AccountTakeoverEventActionType
eventAction :: AccountTakeoverEventActionType
  }
  deriving (AccountTakeoverActionType -> AccountTakeoverActionType -> Bool
(AccountTakeoverActionType -> AccountTakeoverActionType -> Bool)
-> (AccountTakeoverActionType -> AccountTakeoverActionType -> Bool)
-> Eq AccountTakeoverActionType
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]
(Int -> ReadS AccountTakeoverActionType)
-> ReadS [AccountTakeoverActionType]
-> ReadPrec AccountTakeoverActionType
-> ReadPrec [AccountTakeoverActionType]
-> Read 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
(Int -> AccountTakeoverActionType -> ShowS)
-> (AccountTakeoverActionType -> String)
-> ([AccountTakeoverActionType] -> ShowS)
-> Show AccountTakeoverActionType
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.
 AccountTakeoverActionType -> Rep AccountTakeoverActionType x)
-> (forall x.
    Rep AccountTakeoverActionType x -> AccountTakeoverActionType)
-> Generic AccountTakeoverActionType
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 event action.
--
-- -   @BLOCK@ Choosing this action will block the request.
--
-- -   @MFA_IF_CONFIGURED@ Throw MFA challenge if user has configured it,
--     else allow the request.
--
-- -   @MFA_REQUIRED@ Throw MFA challenge if user has configured it, else
--     block the request.
--
-- -   @NO_ACTION@ Allow the user sign-in.
newAccountTakeoverActionType ::
  -- | 'notify'
  Prelude.Bool ->
  -- | 'eventAction'
  AccountTakeoverEventActionType ->
  AccountTakeoverActionType
newAccountTakeoverActionType :: Bool -> AccountTakeoverEventActionType -> AccountTakeoverActionType
newAccountTakeoverActionType Bool
pNotify_ AccountTakeoverEventActionType
pEventAction_ =
  AccountTakeoverActionType' :: Bool -> AccountTakeoverEventActionType -> AccountTakeoverActionType
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 :: (Bool -> f Bool)
-> AccountTakeoverActionType -> f AccountTakeoverActionType
accountTakeoverActionType_notify = (AccountTakeoverActionType -> Bool)
-> (AccountTakeoverActionType -> Bool -> AccountTakeoverActionType)
-> Lens
     AccountTakeoverActionType AccountTakeoverActionType Bool Bool
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 event action.
--
-- -   @BLOCK@ Choosing this action will block the request.
--
-- -   @MFA_IF_CONFIGURED@ Throw MFA challenge if user has configured it,
--     else allow the request.
--
-- -   @MFA_REQUIRED@ Throw MFA challenge if user has configured it, else
--     block the request.
--
-- -   @NO_ACTION@ Allow the user sign-in.
accountTakeoverActionType_eventAction :: Lens.Lens' AccountTakeoverActionType AccountTakeoverEventActionType
accountTakeoverActionType_eventAction :: (AccountTakeoverEventActionType
 -> f AccountTakeoverEventActionType)
-> AccountTakeoverActionType -> f AccountTakeoverActionType
accountTakeoverActionType_eventAction = (AccountTakeoverActionType -> AccountTakeoverEventActionType)
-> (AccountTakeoverActionType
    -> AccountTakeoverEventActionType -> AccountTakeoverActionType)
-> Lens
     AccountTakeoverActionType
     AccountTakeoverActionType
     AccountTakeoverEventActionType
     AccountTakeoverEventActionType
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 Core.FromJSON AccountTakeoverActionType where
  parseJSON :: Value -> Parser AccountTakeoverActionType
parseJSON =
    String
-> (Object -> Parser AccountTakeoverActionType)
-> Value
-> Parser AccountTakeoverActionType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccountTakeoverActionType"
      ( \Object
x ->
          Bool -> AccountTakeoverEventActionType -> AccountTakeoverActionType
AccountTakeoverActionType'
            (Bool
 -> AccountTakeoverEventActionType -> AccountTakeoverActionType)
-> Parser Bool
-> Parser
     (AccountTakeoverEventActionType -> AccountTakeoverActionType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Notify")
            Parser
  (AccountTakeoverEventActionType -> AccountTakeoverActionType)
-> Parser AccountTakeoverEventActionType
-> Parser AccountTakeoverActionType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AccountTakeoverEventActionType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EventAction")
      )

instance Prelude.Hashable AccountTakeoverActionType

instance Prelude.NFData AccountTakeoverActionType

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Notify" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
notify),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EventAction" Text -> AccountTakeoverEventActionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AccountTakeoverEventActionType
eventAction)
          ]
      )