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

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

-- | The notify configuration type.
--
-- /See:/ 'newNotifyConfigurationType' smart constructor.
data NotifyConfigurationType = NotifyConfigurationType'
  { -- | Email template used when a detected risk event is blocked.
    NotifyConfigurationType -> Maybe NotifyEmailType
blockEmail :: Prelude.Maybe NotifyEmailType,
    -- | The email address that is sending the email. The address must be either
    -- individually verified with Amazon Simple Email Service, or from a domain
    -- that has been verified with Amazon SES.
    NotifyConfigurationType -> Maybe Text
from :: Prelude.Maybe Prelude.Text,
    -- | The multi-factor authentication (MFA) email template used when MFA is
    -- challenged as part of a detected risk.
    NotifyConfigurationType -> Maybe NotifyEmailType
mfaEmail :: Prelude.Maybe NotifyEmailType,
    -- | The email template used when a detected risk event is allowed.
    NotifyConfigurationType -> Maybe NotifyEmailType
noActionEmail :: Prelude.Maybe NotifyEmailType,
    -- | The destination to which the receiver of an email should reply to.
    NotifyConfigurationType -> Maybe Text
replyTo :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the identity that is associated with
    -- the sending authorization policy. This identity permits Amazon Cognito
    -- to send for the email address specified in the @From@ parameter.
    NotifyConfigurationType -> Text
sourceArn :: Prelude.Text
  }
  deriving (NotifyConfigurationType -> NotifyConfigurationType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotifyConfigurationType -> NotifyConfigurationType -> Bool
$c/= :: NotifyConfigurationType -> NotifyConfigurationType -> Bool
== :: NotifyConfigurationType -> NotifyConfigurationType -> Bool
$c== :: NotifyConfigurationType -> NotifyConfigurationType -> Bool
Prelude.Eq, ReadPrec [NotifyConfigurationType]
ReadPrec NotifyConfigurationType
Int -> ReadS NotifyConfigurationType
ReadS [NotifyConfigurationType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotifyConfigurationType]
$creadListPrec :: ReadPrec [NotifyConfigurationType]
readPrec :: ReadPrec NotifyConfigurationType
$creadPrec :: ReadPrec NotifyConfigurationType
readList :: ReadS [NotifyConfigurationType]
$creadList :: ReadS [NotifyConfigurationType]
readsPrec :: Int -> ReadS NotifyConfigurationType
$creadsPrec :: Int -> ReadS NotifyConfigurationType
Prelude.Read, Int -> NotifyConfigurationType -> ShowS
[NotifyConfigurationType] -> ShowS
NotifyConfigurationType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotifyConfigurationType] -> ShowS
$cshowList :: [NotifyConfigurationType] -> ShowS
show :: NotifyConfigurationType -> String
$cshow :: NotifyConfigurationType -> String
showsPrec :: Int -> NotifyConfigurationType -> ShowS
$cshowsPrec :: Int -> NotifyConfigurationType -> ShowS
Prelude.Show, forall x. Rep NotifyConfigurationType x -> NotifyConfigurationType
forall x. NotifyConfigurationType -> Rep NotifyConfigurationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NotifyConfigurationType x -> NotifyConfigurationType
$cfrom :: forall x. NotifyConfigurationType -> Rep NotifyConfigurationType x
Prelude.Generic)

-- |
-- Create a value of 'NotifyConfigurationType' 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:
--
-- 'blockEmail', 'notifyConfigurationType_blockEmail' - Email template used when a detected risk event is blocked.
--
-- 'from', 'notifyConfigurationType_from' - The email address that is sending the email. The address must be either
-- individually verified with Amazon Simple Email Service, or from a domain
-- that has been verified with Amazon SES.
--
-- 'mfaEmail', 'notifyConfigurationType_mfaEmail' - The multi-factor authentication (MFA) email template used when MFA is
-- challenged as part of a detected risk.
--
-- 'noActionEmail', 'notifyConfigurationType_noActionEmail' - The email template used when a detected risk event is allowed.
--
-- 'replyTo', 'notifyConfigurationType_replyTo' - The destination to which the receiver of an email should reply to.
--
-- 'sourceArn', 'notifyConfigurationType_sourceArn' - The Amazon Resource Name (ARN) of the identity that is associated with
-- the sending authorization policy. This identity permits Amazon Cognito
-- to send for the email address specified in the @From@ parameter.
newNotifyConfigurationType ::
  -- | 'sourceArn'
  Prelude.Text ->
  NotifyConfigurationType
newNotifyConfigurationType :: Text -> NotifyConfigurationType
newNotifyConfigurationType Text
pSourceArn_ =
  NotifyConfigurationType'
    { $sel:blockEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
blockEmail =
        forall a. Maybe a
Prelude.Nothing,
      $sel:from:NotifyConfigurationType' :: Maybe Text
from = forall a. Maybe a
Prelude.Nothing,
      $sel:mfaEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
mfaEmail = forall a. Maybe a
Prelude.Nothing,
      $sel:noActionEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
noActionEmail = forall a. Maybe a
Prelude.Nothing,
      $sel:replyTo:NotifyConfigurationType' :: Maybe Text
replyTo = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceArn:NotifyConfigurationType' :: Text
sourceArn = Text
pSourceArn_
    }

-- | Email template used when a detected risk event is blocked.
notifyConfigurationType_blockEmail :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe NotifyEmailType)
notifyConfigurationType_blockEmail :: Lens' NotifyConfigurationType (Maybe NotifyEmailType)
notifyConfigurationType_blockEmail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyConfigurationType' {Maybe NotifyEmailType
blockEmail :: Maybe NotifyEmailType
$sel:blockEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
blockEmail} -> Maybe NotifyEmailType
blockEmail) (\s :: NotifyConfigurationType
s@NotifyConfigurationType' {} Maybe NotifyEmailType
a -> NotifyConfigurationType
s {$sel:blockEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
blockEmail = Maybe NotifyEmailType
a} :: NotifyConfigurationType)

-- | The email address that is sending the email. The address must be either
-- individually verified with Amazon Simple Email Service, or from a domain
-- that has been verified with Amazon SES.
notifyConfigurationType_from :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe Prelude.Text)
notifyConfigurationType_from :: Lens' NotifyConfigurationType (Maybe Text)
notifyConfigurationType_from = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyConfigurationType' {Maybe Text
from :: Maybe Text
$sel:from:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe Text
from} -> Maybe Text
from) (\s :: NotifyConfigurationType
s@NotifyConfigurationType' {} Maybe Text
a -> NotifyConfigurationType
s {$sel:from:NotifyConfigurationType' :: Maybe Text
from = Maybe Text
a} :: NotifyConfigurationType)

-- | The multi-factor authentication (MFA) email template used when MFA is
-- challenged as part of a detected risk.
notifyConfigurationType_mfaEmail :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe NotifyEmailType)
notifyConfigurationType_mfaEmail :: Lens' NotifyConfigurationType (Maybe NotifyEmailType)
notifyConfigurationType_mfaEmail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyConfigurationType' {Maybe NotifyEmailType
mfaEmail :: Maybe NotifyEmailType
$sel:mfaEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
mfaEmail} -> Maybe NotifyEmailType
mfaEmail) (\s :: NotifyConfigurationType
s@NotifyConfigurationType' {} Maybe NotifyEmailType
a -> NotifyConfigurationType
s {$sel:mfaEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
mfaEmail = Maybe NotifyEmailType
a} :: NotifyConfigurationType)

-- | The email template used when a detected risk event is allowed.
notifyConfigurationType_noActionEmail :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe NotifyEmailType)
notifyConfigurationType_noActionEmail :: Lens' NotifyConfigurationType (Maybe NotifyEmailType)
notifyConfigurationType_noActionEmail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyConfigurationType' {Maybe NotifyEmailType
noActionEmail :: Maybe NotifyEmailType
$sel:noActionEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
noActionEmail} -> Maybe NotifyEmailType
noActionEmail) (\s :: NotifyConfigurationType
s@NotifyConfigurationType' {} Maybe NotifyEmailType
a -> NotifyConfigurationType
s {$sel:noActionEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
noActionEmail = Maybe NotifyEmailType
a} :: NotifyConfigurationType)

-- | The destination to which the receiver of an email should reply to.
notifyConfigurationType_replyTo :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe Prelude.Text)
notifyConfigurationType_replyTo :: Lens' NotifyConfigurationType (Maybe Text)
notifyConfigurationType_replyTo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyConfigurationType' {Maybe Text
replyTo :: Maybe Text
$sel:replyTo:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe Text
replyTo} -> Maybe Text
replyTo) (\s :: NotifyConfigurationType
s@NotifyConfigurationType' {} Maybe Text
a -> NotifyConfigurationType
s {$sel:replyTo:NotifyConfigurationType' :: Maybe Text
replyTo = Maybe Text
a} :: NotifyConfigurationType)

-- | The Amazon Resource Name (ARN) of the identity that is associated with
-- the sending authorization policy. This identity permits Amazon Cognito
-- to send for the email address specified in the @From@ parameter.
notifyConfigurationType_sourceArn :: Lens.Lens' NotifyConfigurationType Prelude.Text
notifyConfigurationType_sourceArn :: Lens' NotifyConfigurationType Text
notifyConfigurationType_sourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyConfigurationType' {Text
sourceArn :: Text
$sel:sourceArn:NotifyConfigurationType' :: NotifyConfigurationType -> Text
sourceArn} -> Text
sourceArn) (\s :: NotifyConfigurationType
s@NotifyConfigurationType' {} Text
a -> NotifyConfigurationType
s {$sel:sourceArn:NotifyConfigurationType' :: Text
sourceArn = Text
a} :: NotifyConfigurationType)

instance Data.FromJSON NotifyConfigurationType where
  parseJSON :: Value -> Parser NotifyConfigurationType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NotifyConfigurationType"
      ( \Object
x ->
          Maybe NotifyEmailType
-> Maybe Text
-> Maybe NotifyEmailType
-> Maybe NotifyEmailType
-> Maybe Text
-> Text
-> NotifyConfigurationType
NotifyConfigurationType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"BlockEmail")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"From")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MfaEmail")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NoActionEmail")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ReplyTo")
            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
"SourceArn")
      )

instance Prelude.Hashable NotifyConfigurationType where
  hashWithSalt :: Int -> NotifyConfigurationType -> Int
hashWithSalt Int
_salt NotifyConfigurationType' {Maybe Text
Maybe NotifyEmailType
Text
sourceArn :: Text
replyTo :: Maybe Text
noActionEmail :: Maybe NotifyEmailType
mfaEmail :: Maybe NotifyEmailType
from :: Maybe Text
blockEmail :: Maybe NotifyEmailType
$sel:sourceArn:NotifyConfigurationType' :: NotifyConfigurationType -> Text
$sel:replyTo:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe Text
$sel:noActionEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
$sel:mfaEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
$sel:from:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe Text
$sel:blockEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NotifyEmailType
blockEmail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
from
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NotifyEmailType
mfaEmail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NotifyEmailType
noActionEmail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
replyTo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceArn

instance Prelude.NFData NotifyConfigurationType where
  rnf :: NotifyConfigurationType -> ()
rnf NotifyConfigurationType' {Maybe Text
Maybe NotifyEmailType
Text
sourceArn :: Text
replyTo :: Maybe Text
noActionEmail :: Maybe NotifyEmailType
mfaEmail :: Maybe NotifyEmailType
from :: Maybe Text
blockEmail :: Maybe NotifyEmailType
$sel:sourceArn:NotifyConfigurationType' :: NotifyConfigurationType -> Text
$sel:replyTo:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe Text
$sel:noActionEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
$sel:mfaEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
$sel:from:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe Text
$sel:blockEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe NotifyEmailType
blockEmail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
from
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NotifyEmailType
mfaEmail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NotifyEmailType
noActionEmail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
replyTo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sourceArn

instance Data.ToJSON NotifyConfigurationType where
  toJSON :: NotifyConfigurationType -> Value
toJSON NotifyConfigurationType' {Maybe Text
Maybe NotifyEmailType
Text
sourceArn :: Text
replyTo :: Maybe Text
noActionEmail :: Maybe NotifyEmailType
mfaEmail :: Maybe NotifyEmailType
from :: Maybe Text
blockEmail :: Maybe NotifyEmailType
$sel:sourceArn:NotifyConfigurationType' :: NotifyConfigurationType -> Text
$sel:replyTo:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe Text
$sel:noActionEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
$sel:mfaEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
$sel:from:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe Text
$sel:blockEmail:NotifyConfigurationType' :: NotifyConfigurationType -> Maybe NotifyEmailType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BlockEmail" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NotifyEmailType
blockEmail,
            (Key
"From" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
from,
            (Key
"MfaEmail" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NotifyEmailType
mfaEmail,
            (Key
"NoActionEmail" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NotifyEmailType
noActionEmail,
            (Key
"ReplyTo" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
replyTo,
            forall a. a -> Maybe a
Prelude.Just (Key
"SourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sourceArn)
          ]
      )