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

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

-- | The SMS text message multi-factor authentication (MFA) configuration
-- type.
--
-- /See:/ 'newSmsMfaConfigType' smart constructor.
data SmsMfaConfigType = SmsMfaConfigType'
  { -- | The SMS authentication message that will be sent to users with the code
    -- they need to sign in. The message must contain the ‘{####}’ placeholder,
    -- which will be replaced with the code. If the message is not included,
    -- and default message will be used.
    SmsMfaConfigType -> Maybe Text
smsAuthenticationMessage :: Prelude.Maybe Prelude.Text,
    -- | The SMS configuration.
    SmsMfaConfigType -> Maybe SmsConfigurationType
smsConfiguration :: Prelude.Maybe SmsConfigurationType
  }
  deriving (SmsMfaConfigType -> SmsMfaConfigType -> Bool
(SmsMfaConfigType -> SmsMfaConfigType -> Bool)
-> (SmsMfaConfigType -> SmsMfaConfigType -> Bool)
-> Eq SmsMfaConfigType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SmsMfaConfigType -> SmsMfaConfigType -> Bool
$c/= :: SmsMfaConfigType -> SmsMfaConfigType -> Bool
== :: SmsMfaConfigType -> SmsMfaConfigType -> Bool
$c== :: SmsMfaConfigType -> SmsMfaConfigType -> Bool
Prelude.Eq, ReadPrec [SmsMfaConfigType]
ReadPrec SmsMfaConfigType
Int -> ReadS SmsMfaConfigType
ReadS [SmsMfaConfigType]
(Int -> ReadS SmsMfaConfigType)
-> ReadS [SmsMfaConfigType]
-> ReadPrec SmsMfaConfigType
-> ReadPrec [SmsMfaConfigType]
-> Read SmsMfaConfigType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SmsMfaConfigType]
$creadListPrec :: ReadPrec [SmsMfaConfigType]
readPrec :: ReadPrec SmsMfaConfigType
$creadPrec :: ReadPrec SmsMfaConfigType
readList :: ReadS [SmsMfaConfigType]
$creadList :: ReadS [SmsMfaConfigType]
readsPrec :: Int -> ReadS SmsMfaConfigType
$creadsPrec :: Int -> ReadS SmsMfaConfigType
Prelude.Read, Int -> SmsMfaConfigType -> ShowS
[SmsMfaConfigType] -> ShowS
SmsMfaConfigType -> String
(Int -> SmsMfaConfigType -> ShowS)
-> (SmsMfaConfigType -> String)
-> ([SmsMfaConfigType] -> ShowS)
-> Show SmsMfaConfigType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SmsMfaConfigType] -> ShowS
$cshowList :: [SmsMfaConfigType] -> ShowS
show :: SmsMfaConfigType -> String
$cshow :: SmsMfaConfigType -> String
showsPrec :: Int -> SmsMfaConfigType -> ShowS
$cshowsPrec :: Int -> SmsMfaConfigType -> ShowS
Prelude.Show, (forall x. SmsMfaConfigType -> Rep SmsMfaConfigType x)
-> (forall x. Rep SmsMfaConfigType x -> SmsMfaConfigType)
-> Generic SmsMfaConfigType
forall x. Rep SmsMfaConfigType x -> SmsMfaConfigType
forall x. SmsMfaConfigType -> Rep SmsMfaConfigType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SmsMfaConfigType x -> SmsMfaConfigType
$cfrom :: forall x. SmsMfaConfigType -> Rep SmsMfaConfigType x
Prelude.Generic)

-- |
-- Create a value of 'SmsMfaConfigType' 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:
--
-- 'smsAuthenticationMessage', 'smsMfaConfigType_smsAuthenticationMessage' - The SMS authentication message that will be sent to users with the code
-- they need to sign in. The message must contain the ‘{####}’ placeholder,
-- which will be replaced with the code. If the message is not included,
-- and default message will be used.
--
-- 'smsConfiguration', 'smsMfaConfigType_smsConfiguration' - The SMS configuration.
newSmsMfaConfigType ::
  SmsMfaConfigType
newSmsMfaConfigType :: SmsMfaConfigType
newSmsMfaConfigType =
  SmsMfaConfigType' :: Maybe Text -> Maybe SmsConfigurationType -> SmsMfaConfigType
SmsMfaConfigType'
    { $sel:smsAuthenticationMessage:SmsMfaConfigType' :: Maybe Text
smsAuthenticationMessage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:smsConfiguration:SmsMfaConfigType' :: Maybe SmsConfigurationType
smsConfiguration = Maybe SmsConfigurationType
forall a. Maybe a
Prelude.Nothing
    }

-- | The SMS authentication message that will be sent to users with the code
-- they need to sign in. The message must contain the ‘{####}’ placeholder,
-- which will be replaced with the code. If the message is not included,
-- and default message will be used.
smsMfaConfigType_smsAuthenticationMessage :: Lens.Lens' SmsMfaConfigType (Prelude.Maybe Prelude.Text)
smsMfaConfigType_smsAuthenticationMessage :: (Maybe Text -> f (Maybe Text))
-> SmsMfaConfigType -> f SmsMfaConfigType
smsMfaConfigType_smsAuthenticationMessage = (SmsMfaConfigType -> Maybe Text)
-> (SmsMfaConfigType -> Maybe Text -> SmsMfaConfigType)
-> Lens SmsMfaConfigType SmsMfaConfigType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SmsMfaConfigType' {Maybe Text
smsAuthenticationMessage :: Maybe Text
$sel:smsAuthenticationMessage:SmsMfaConfigType' :: SmsMfaConfigType -> Maybe Text
smsAuthenticationMessage} -> Maybe Text
smsAuthenticationMessage) (\s :: SmsMfaConfigType
s@SmsMfaConfigType' {} Maybe Text
a -> SmsMfaConfigType
s {$sel:smsAuthenticationMessage:SmsMfaConfigType' :: Maybe Text
smsAuthenticationMessage = Maybe Text
a} :: SmsMfaConfigType)

-- | The SMS configuration.
smsMfaConfigType_smsConfiguration :: Lens.Lens' SmsMfaConfigType (Prelude.Maybe SmsConfigurationType)
smsMfaConfigType_smsConfiguration :: (Maybe SmsConfigurationType -> f (Maybe SmsConfigurationType))
-> SmsMfaConfigType -> f SmsMfaConfigType
smsMfaConfigType_smsConfiguration = (SmsMfaConfigType -> Maybe SmsConfigurationType)
-> (SmsMfaConfigType
    -> Maybe SmsConfigurationType -> SmsMfaConfigType)
-> Lens
     SmsMfaConfigType
     SmsMfaConfigType
     (Maybe SmsConfigurationType)
     (Maybe SmsConfigurationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SmsMfaConfigType' {Maybe SmsConfigurationType
smsConfiguration :: Maybe SmsConfigurationType
$sel:smsConfiguration:SmsMfaConfigType' :: SmsMfaConfigType -> Maybe SmsConfigurationType
smsConfiguration} -> Maybe SmsConfigurationType
smsConfiguration) (\s :: SmsMfaConfigType
s@SmsMfaConfigType' {} Maybe SmsConfigurationType
a -> SmsMfaConfigType
s {$sel:smsConfiguration:SmsMfaConfigType' :: Maybe SmsConfigurationType
smsConfiguration = Maybe SmsConfigurationType
a} :: SmsMfaConfigType)

instance Core.FromJSON SmsMfaConfigType where
  parseJSON :: Value -> Parser SmsMfaConfigType
parseJSON =
    String
-> (Object -> Parser SmsMfaConfigType)
-> Value
-> Parser SmsMfaConfigType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SmsMfaConfigType"
      ( \Object
x ->
          Maybe Text -> Maybe SmsConfigurationType -> SmsMfaConfigType
SmsMfaConfigType'
            (Maybe Text -> Maybe SmsConfigurationType -> SmsMfaConfigType)
-> Parser (Maybe Text)
-> Parser (Maybe SmsConfigurationType -> SmsMfaConfigType)
forall (f :: * -> *) a b. Functor 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
"SmsAuthenticationMessage")
            Parser (Maybe SmsConfigurationType -> SmsMfaConfigType)
-> Parser (Maybe SmsConfigurationType) -> Parser SmsMfaConfigType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SmsConfigurationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SmsConfiguration")
      )

instance Prelude.Hashable SmsMfaConfigType

instance Prelude.NFData SmsMfaConfigType

instance Core.ToJSON SmsMfaConfigType where
  toJSON :: SmsMfaConfigType -> Value
toJSON SmsMfaConfigType' {Maybe Text
Maybe SmsConfigurationType
smsConfiguration :: Maybe SmsConfigurationType
smsAuthenticationMessage :: Maybe Text
$sel:smsConfiguration:SmsMfaConfigType' :: SmsMfaConfigType -> Maybe SmsConfigurationType
$sel:smsAuthenticationMessage:SmsMfaConfigType' :: SmsMfaConfigType -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SmsAuthenticationMessage" 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
smsAuthenticationMessage,
            (Text
"SmsConfiguration" Text -> SmsConfigurationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SmsConfigurationType -> Pair)
-> Maybe SmsConfigurationType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SmsConfigurationType
smsConfiguration
          ]
      )