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

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

-- | The data type for @AccountRecoverySetting@.
--
-- /See:/ 'newAccountRecoverySettingType' smart constructor.
data AccountRecoverySettingType = AccountRecoverySettingType'
  { -- | The list of @RecoveryOptionTypes@.
    AccountRecoverySettingType -> Maybe (NonEmpty RecoveryOptionType)
recoveryMechanisms :: Prelude.Maybe (Prelude.NonEmpty RecoveryOptionType)
  }
  deriving (AccountRecoverySettingType -> AccountRecoverySettingType -> Bool
(AccountRecoverySettingType -> AccountRecoverySettingType -> Bool)
-> (AccountRecoverySettingType
    -> AccountRecoverySettingType -> Bool)
-> Eq AccountRecoverySettingType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountRecoverySettingType -> AccountRecoverySettingType -> Bool
$c/= :: AccountRecoverySettingType -> AccountRecoverySettingType -> Bool
== :: AccountRecoverySettingType -> AccountRecoverySettingType -> Bool
$c== :: AccountRecoverySettingType -> AccountRecoverySettingType -> Bool
Prelude.Eq, ReadPrec [AccountRecoverySettingType]
ReadPrec AccountRecoverySettingType
Int -> ReadS AccountRecoverySettingType
ReadS [AccountRecoverySettingType]
(Int -> ReadS AccountRecoverySettingType)
-> ReadS [AccountRecoverySettingType]
-> ReadPrec AccountRecoverySettingType
-> ReadPrec [AccountRecoverySettingType]
-> Read AccountRecoverySettingType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccountRecoverySettingType]
$creadListPrec :: ReadPrec [AccountRecoverySettingType]
readPrec :: ReadPrec AccountRecoverySettingType
$creadPrec :: ReadPrec AccountRecoverySettingType
readList :: ReadS [AccountRecoverySettingType]
$creadList :: ReadS [AccountRecoverySettingType]
readsPrec :: Int -> ReadS AccountRecoverySettingType
$creadsPrec :: Int -> ReadS AccountRecoverySettingType
Prelude.Read, Int -> AccountRecoverySettingType -> ShowS
[AccountRecoverySettingType] -> ShowS
AccountRecoverySettingType -> String
(Int -> AccountRecoverySettingType -> ShowS)
-> (AccountRecoverySettingType -> String)
-> ([AccountRecoverySettingType] -> ShowS)
-> Show AccountRecoverySettingType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountRecoverySettingType] -> ShowS
$cshowList :: [AccountRecoverySettingType] -> ShowS
show :: AccountRecoverySettingType -> String
$cshow :: AccountRecoverySettingType -> String
showsPrec :: Int -> AccountRecoverySettingType -> ShowS
$cshowsPrec :: Int -> AccountRecoverySettingType -> ShowS
Prelude.Show, (forall x.
 AccountRecoverySettingType -> Rep AccountRecoverySettingType x)
-> (forall x.
    Rep AccountRecoverySettingType x -> AccountRecoverySettingType)
-> Generic AccountRecoverySettingType
forall x.
Rep AccountRecoverySettingType x -> AccountRecoverySettingType
forall x.
AccountRecoverySettingType -> Rep AccountRecoverySettingType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AccountRecoverySettingType x -> AccountRecoverySettingType
$cfrom :: forall x.
AccountRecoverySettingType -> Rep AccountRecoverySettingType x
Prelude.Generic)

-- |
-- Create a value of 'AccountRecoverySettingType' 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:
--
-- 'recoveryMechanisms', 'accountRecoverySettingType_recoveryMechanisms' - The list of @RecoveryOptionTypes@.
newAccountRecoverySettingType ::
  AccountRecoverySettingType
newAccountRecoverySettingType :: AccountRecoverySettingType
newAccountRecoverySettingType =
  AccountRecoverySettingType' :: Maybe (NonEmpty RecoveryOptionType) -> AccountRecoverySettingType
AccountRecoverySettingType'
    { $sel:recoveryMechanisms:AccountRecoverySettingType' :: Maybe (NonEmpty RecoveryOptionType)
recoveryMechanisms =
        Maybe (NonEmpty RecoveryOptionType)
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of @RecoveryOptionTypes@.
accountRecoverySettingType_recoveryMechanisms :: Lens.Lens' AccountRecoverySettingType (Prelude.Maybe (Prelude.NonEmpty RecoveryOptionType))
accountRecoverySettingType_recoveryMechanisms :: (Maybe (NonEmpty RecoveryOptionType)
 -> f (Maybe (NonEmpty RecoveryOptionType)))
-> AccountRecoverySettingType -> f AccountRecoverySettingType
accountRecoverySettingType_recoveryMechanisms = (AccountRecoverySettingType -> Maybe (NonEmpty RecoveryOptionType))
-> (AccountRecoverySettingType
    -> Maybe (NonEmpty RecoveryOptionType)
    -> AccountRecoverySettingType)
-> Lens
     AccountRecoverySettingType
     AccountRecoverySettingType
     (Maybe (NonEmpty RecoveryOptionType))
     (Maybe (NonEmpty RecoveryOptionType))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountRecoverySettingType' {Maybe (NonEmpty RecoveryOptionType)
recoveryMechanisms :: Maybe (NonEmpty RecoveryOptionType)
$sel:recoveryMechanisms:AccountRecoverySettingType' :: AccountRecoverySettingType -> Maybe (NonEmpty RecoveryOptionType)
recoveryMechanisms} -> Maybe (NonEmpty RecoveryOptionType)
recoveryMechanisms) (\s :: AccountRecoverySettingType
s@AccountRecoverySettingType' {} Maybe (NonEmpty RecoveryOptionType)
a -> AccountRecoverySettingType
s {$sel:recoveryMechanisms:AccountRecoverySettingType' :: Maybe (NonEmpty RecoveryOptionType)
recoveryMechanisms = Maybe (NonEmpty RecoveryOptionType)
a} :: AccountRecoverySettingType) ((Maybe (NonEmpty RecoveryOptionType)
  -> f (Maybe (NonEmpty RecoveryOptionType)))
 -> AccountRecoverySettingType -> f AccountRecoverySettingType)
-> ((Maybe (NonEmpty RecoveryOptionType)
     -> f (Maybe (NonEmpty RecoveryOptionType)))
    -> Maybe (NonEmpty RecoveryOptionType)
    -> f (Maybe (NonEmpty RecoveryOptionType)))
-> (Maybe (NonEmpty RecoveryOptionType)
    -> f (Maybe (NonEmpty RecoveryOptionType)))
-> AccountRecoverySettingType
-> f AccountRecoverySettingType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty RecoveryOptionType)
  (NonEmpty RecoveryOptionType)
  (NonEmpty RecoveryOptionType)
  (NonEmpty RecoveryOptionType)
-> Iso
     (Maybe (NonEmpty RecoveryOptionType))
     (Maybe (NonEmpty RecoveryOptionType))
     (Maybe (NonEmpty RecoveryOptionType))
     (Maybe (NonEmpty RecoveryOptionType))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty RecoveryOptionType)
  (NonEmpty RecoveryOptionType)
  (NonEmpty RecoveryOptionType)
  (NonEmpty RecoveryOptionType)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AccountRecoverySettingType where
  parseJSON :: Value -> Parser AccountRecoverySettingType
parseJSON =
    String
-> (Object -> Parser AccountRecoverySettingType)
-> Value
-> Parser AccountRecoverySettingType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccountRecoverySettingType"
      ( \Object
x ->
          Maybe (NonEmpty RecoveryOptionType) -> AccountRecoverySettingType
AccountRecoverySettingType'
            (Maybe (NonEmpty RecoveryOptionType) -> AccountRecoverySettingType)
-> Parser (Maybe (NonEmpty RecoveryOptionType))
-> Parser AccountRecoverySettingType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty RecoveryOptionType))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RecoveryMechanisms")
      )

instance Prelude.Hashable AccountRecoverySettingType

instance Prelude.NFData AccountRecoverySettingType

instance Core.ToJSON AccountRecoverySettingType where
  toJSON :: AccountRecoverySettingType -> Value
toJSON AccountRecoverySettingType' {Maybe (NonEmpty RecoveryOptionType)
recoveryMechanisms :: Maybe (NonEmpty RecoveryOptionType)
$sel:recoveryMechanisms:AccountRecoverySettingType' :: AccountRecoverySettingType -> Maybe (NonEmpty RecoveryOptionType)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RecoveryMechanisms" Text -> NonEmpty RecoveryOptionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty RecoveryOptionType -> Pair)
-> Maybe (NonEmpty RecoveryOptionType) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty RecoveryOptionType)
recoveryMechanisms
          ]
      )