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

import Amazonka.CognitoIdentityProvider.Types.NotifyEmailType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The notify configuration type.
--
-- /See:/ 'newNotifyConfigurationType' smart constructor.
data NotifyConfigurationType = NotifyConfigurationType'
  { -- | The email template used when a detected risk event is allowed.
    NotifyConfigurationType -> Maybe NotifyEmailType
noActionEmail :: Prelude.Maybe NotifyEmailType,
    -- | The email address that is sending the email. It must be either
    -- individually verified with Amazon SES, or from a domain that has been
    -- verified with Amazon SES.
    NotifyConfigurationType -> Maybe Text
from :: Prelude.Maybe Prelude.Text,
    -- | The destination to which the receiver of an email should reply to.
    NotifyConfigurationType -> Maybe Text
replyTo :: Prelude.Maybe Prelude.Text,
    -- | Email template used when a detected risk event is blocked.
    NotifyConfigurationType -> Maybe NotifyEmailType
blockEmail :: Prelude.Maybe NotifyEmailType,
    -- | The MFA email template used when MFA is challenged as part of a detected
    -- risk.
    NotifyConfigurationType -> Maybe NotifyEmailType
mfaEmail :: Prelude.Maybe NotifyEmailType,
    -- | The Amazon Resource Name (ARN) of the identity that is associated with
    -- the sending authorization policy. It permits Amazon Cognito to send for
    -- the email address specified in the @From@ parameter.
    NotifyConfigurationType -> Text
sourceArn :: Prelude.Text
  }
  deriving (NotifyConfigurationType -> NotifyConfigurationType -> Bool
(NotifyConfigurationType -> NotifyConfigurationType -> Bool)
-> (NotifyConfigurationType -> NotifyConfigurationType -> Bool)
-> Eq NotifyConfigurationType
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]
(Int -> ReadS NotifyConfigurationType)
-> ReadS [NotifyConfigurationType]
-> ReadPrec NotifyConfigurationType
-> ReadPrec [NotifyConfigurationType]
-> Read 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
(Int -> NotifyConfigurationType -> ShowS)
-> (NotifyConfigurationType -> String)
-> ([NotifyConfigurationType] -> ShowS)
-> Show NotifyConfigurationType
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.
 NotifyConfigurationType -> Rep NotifyConfigurationType x)
-> (forall x.
    Rep NotifyConfigurationType x -> NotifyConfigurationType)
-> Generic NotifyConfigurationType
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:
--
-- 'noActionEmail', 'notifyConfigurationType_noActionEmail' - The email template used when a detected risk event is allowed.
--
-- 'from', 'notifyConfigurationType_from' - The email address that is sending the email. It must be either
-- individually verified with Amazon SES, or from a domain that has been
-- verified with Amazon SES.
--
-- 'replyTo', 'notifyConfigurationType_replyTo' - The destination to which the receiver of an email should reply to.
--
-- 'blockEmail', 'notifyConfigurationType_blockEmail' - Email template used when a detected risk event is blocked.
--
-- 'mfaEmail', 'notifyConfigurationType_mfaEmail' - The MFA email template used when MFA is challenged as part of a detected
-- risk.
--
-- 'sourceArn', 'notifyConfigurationType_sourceArn' - The Amazon Resource Name (ARN) of the identity that is associated with
-- the sending authorization policy. It 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' :: Maybe NotifyEmailType
-> Maybe Text
-> Maybe Text
-> Maybe NotifyEmailType
-> Maybe NotifyEmailType
-> Text
-> NotifyConfigurationType
NotifyConfigurationType'
    { $sel:noActionEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
noActionEmail =
        Maybe NotifyEmailType
forall a. Maybe a
Prelude.Nothing,
      $sel:from:NotifyConfigurationType' :: Maybe Text
from = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:replyTo:NotifyConfigurationType' :: Maybe Text
replyTo = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:blockEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
blockEmail = Maybe NotifyEmailType
forall a. Maybe a
Prelude.Nothing,
      $sel:mfaEmail:NotifyConfigurationType' :: Maybe NotifyEmailType
mfaEmail = Maybe NotifyEmailType
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceArn:NotifyConfigurationType' :: Text
sourceArn = Text
pSourceArn_
    }

-- | The email template used when a detected risk event is allowed.
notifyConfigurationType_noActionEmail :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe NotifyEmailType)
notifyConfigurationType_noActionEmail :: (Maybe NotifyEmailType -> f (Maybe NotifyEmailType))
-> NotifyConfigurationType -> f NotifyConfigurationType
notifyConfigurationType_noActionEmail = (NotifyConfigurationType -> Maybe NotifyEmailType)
-> (NotifyConfigurationType
    -> Maybe NotifyEmailType -> NotifyConfigurationType)
-> Lens
     NotifyConfigurationType
     NotifyConfigurationType
     (Maybe NotifyEmailType)
     (Maybe NotifyEmailType)
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 email address that is sending the email. It must be either
-- individually verified with Amazon SES, or from a domain that has been
-- verified with Amazon SES.
notifyConfigurationType_from :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe Prelude.Text)
notifyConfigurationType_from :: (Maybe Text -> f (Maybe Text))
-> NotifyConfigurationType -> f NotifyConfigurationType
notifyConfigurationType_from = (NotifyConfigurationType -> Maybe Text)
-> (NotifyConfigurationType
    -> Maybe Text -> NotifyConfigurationType)
-> Lens
     NotifyConfigurationType
     NotifyConfigurationType
     (Maybe Text)
     (Maybe Text)
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 destination to which the receiver of an email should reply to.
notifyConfigurationType_replyTo :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe Prelude.Text)
notifyConfigurationType_replyTo :: (Maybe Text -> f (Maybe Text))
-> NotifyConfigurationType -> f NotifyConfigurationType
notifyConfigurationType_replyTo = (NotifyConfigurationType -> Maybe Text)
-> (NotifyConfigurationType
    -> Maybe Text -> NotifyConfigurationType)
-> Lens
     NotifyConfigurationType
     NotifyConfigurationType
     (Maybe Text)
     (Maybe Text)
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)

-- | Email template used when a detected risk event is blocked.
notifyConfigurationType_blockEmail :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe NotifyEmailType)
notifyConfigurationType_blockEmail :: (Maybe NotifyEmailType -> f (Maybe NotifyEmailType))
-> NotifyConfigurationType -> f NotifyConfigurationType
notifyConfigurationType_blockEmail = (NotifyConfigurationType -> Maybe NotifyEmailType)
-> (NotifyConfigurationType
    -> Maybe NotifyEmailType -> NotifyConfigurationType)
-> Lens
     NotifyConfigurationType
     NotifyConfigurationType
     (Maybe NotifyEmailType)
     (Maybe NotifyEmailType)
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 MFA email template used when MFA is challenged as part of a detected
-- risk.
notifyConfigurationType_mfaEmail :: Lens.Lens' NotifyConfigurationType (Prelude.Maybe NotifyEmailType)
notifyConfigurationType_mfaEmail :: (Maybe NotifyEmailType -> f (Maybe NotifyEmailType))
-> NotifyConfigurationType -> f NotifyConfigurationType
notifyConfigurationType_mfaEmail = (NotifyConfigurationType -> Maybe NotifyEmailType)
-> (NotifyConfigurationType
    -> Maybe NotifyEmailType -> NotifyConfigurationType)
-> Lens
     NotifyConfigurationType
     NotifyConfigurationType
     (Maybe NotifyEmailType)
     (Maybe NotifyEmailType)
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 Amazon Resource Name (ARN) of the identity that is associated with
-- the sending authorization policy. It permits Amazon Cognito to send for
-- the email address specified in the @From@ parameter.
notifyConfigurationType_sourceArn :: Lens.Lens' NotifyConfigurationType Prelude.Text
notifyConfigurationType_sourceArn :: (Text -> f Text)
-> NotifyConfigurationType -> f NotifyConfigurationType
notifyConfigurationType_sourceArn = (NotifyConfigurationType -> Text)
-> (NotifyConfigurationType -> Text -> NotifyConfigurationType)
-> Lens NotifyConfigurationType NotifyConfigurationType Text Text
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 Core.FromJSON NotifyConfigurationType where
  parseJSON :: Value -> Parser NotifyConfigurationType
parseJSON =
    String
-> (Object -> Parser NotifyConfigurationType)
-> Value
-> Parser NotifyConfigurationType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NotifyConfigurationType"
      ( \Object
x ->
          Maybe NotifyEmailType
-> Maybe Text
-> Maybe Text
-> Maybe NotifyEmailType
-> Maybe NotifyEmailType
-> Text
-> NotifyConfigurationType
NotifyConfigurationType'
            (Maybe NotifyEmailType
 -> Maybe Text
 -> Maybe Text
 -> Maybe NotifyEmailType
 -> Maybe NotifyEmailType
 -> Text
 -> NotifyConfigurationType)
-> Parser (Maybe NotifyEmailType)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe NotifyEmailType
      -> Maybe NotifyEmailType
      -> Text
      -> NotifyConfigurationType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe NotifyEmailType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NoActionEmail")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe NotifyEmailType
   -> Maybe NotifyEmailType
   -> Text
   -> NotifyConfigurationType)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe NotifyEmailType
      -> Maybe NotifyEmailType
      -> Text
      -> NotifyConfigurationType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"From")
            Parser
  (Maybe Text
   -> Maybe NotifyEmailType
   -> Maybe NotifyEmailType
   -> Text
   -> NotifyConfigurationType)
-> Parser (Maybe Text)
-> Parser
     (Maybe NotifyEmailType
      -> Maybe NotifyEmailType -> Text -> NotifyConfigurationType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReplyTo")
            Parser
  (Maybe NotifyEmailType
   -> Maybe NotifyEmailType -> Text -> NotifyConfigurationType)
-> Parser (Maybe NotifyEmailType)
-> Parser
     (Maybe NotifyEmailType -> Text -> NotifyConfigurationType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NotifyEmailType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BlockEmail")
            Parser (Maybe NotifyEmailType -> Text -> NotifyConfigurationType)
-> Parser (Maybe NotifyEmailType)
-> Parser (Text -> NotifyConfigurationType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NotifyEmailType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MfaEmail")
            Parser (Text -> NotifyConfigurationType)
-> Parser Text -> Parser NotifyConfigurationType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SourceArn")
      )

instance Prelude.Hashable NotifyConfigurationType

instance Prelude.NFData NotifyConfigurationType

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