{-# 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.ElastiCache.Types.Authentication
-- 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.ElastiCache.Types.Authentication where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElastiCache.Types.AuthenticationType
import qualified Amazonka.Prelude as Prelude

-- | Indicates whether the user requires a password to authenticate.
--
-- /See:/ 'newAuthentication' smart constructor.
data Authentication = Authentication'
  { -- | The number of passwords belonging to the user. The maximum is two.
    Authentication -> Maybe Int
passwordCount :: Prelude.Maybe Prelude.Int,
    -- | Indicates whether the user requires a password to authenticate.
    Authentication -> Maybe AuthenticationType
type' :: Prelude.Maybe AuthenticationType
  }
  deriving (Authentication -> Authentication -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Authentication -> Authentication -> Bool
$c/= :: Authentication -> Authentication -> Bool
== :: Authentication -> Authentication -> Bool
$c== :: Authentication -> Authentication -> Bool
Prelude.Eq, ReadPrec [Authentication]
ReadPrec Authentication
Int -> ReadS Authentication
ReadS [Authentication]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Authentication]
$creadListPrec :: ReadPrec [Authentication]
readPrec :: ReadPrec Authentication
$creadPrec :: ReadPrec Authentication
readList :: ReadS [Authentication]
$creadList :: ReadS [Authentication]
readsPrec :: Int -> ReadS Authentication
$creadsPrec :: Int -> ReadS Authentication
Prelude.Read, Int -> Authentication -> ShowS
[Authentication] -> ShowS
Authentication -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Authentication] -> ShowS
$cshowList :: [Authentication] -> ShowS
show :: Authentication -> String
$cshow :: Authentication -> String
showsPrec :: Int -> Authentication -> ShowS
$cshowsPrec :: Int -> Authentication -> ShowS
Prelude.Show, forall x. Rep Authentication x -> Authentication
forall x. Authentication -> Rep Authentication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Authentication x -> Authentication
$cfrom :: forall x. Authentication -> Rep Authentication x
Prelude.Generic)

-- |
-- Create a value of 'Authentication' 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:
--
-- 'passwordCount', 'authentication_passwordCount' - The number of passwords belonging to the user. The maximum is two.
--
-- 'type'', 'authentication_type' - Indicates whether the user requires a password to authenticate.
newAuthentication ::
  Authentication
newAuthentication :: Authentication
newAuthentication =
  Authentication'
    { $sel:passwordCount:Authentication' :: Maybe Int
passwordCount = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Authentication' :: Maybe AuthenticationType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of passwords belonging to the user. The maximum is two.
authentication_passwordCount :: Lens.Lens' Authentication (Prelude.Maybe Prelude.Int)
authentication_passwordCount :: Lens' Authentication (Maybe Int)
authentication_passwordCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Authentication' {Maybe Int
passwordCount :: Maybe Int
$sel:passwordCount:Authentication' :: Authentication -> Maybe Int
passwordCount} -> Maybe Int
passwordCount) (\s :: Authentication
s@Authentication' {} Maybe Int
a -> Authentication
s {$sel:passwordCount:Authentication' :: Maybe Int
passwordCount = Maybe Int
a} :: Authentication)

-- | Indicates whether the user requires a password to authenticate.
authentication_type :: Lens.Lens' Authentication (Prelude.Maybe AuthenticationType)
authentication_type :: Lens' Authentication (Maybe AuthenticationType)
authentication_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Authentication' {Maybe AuthenticationType
type' :: Maybe AuthenticationType
$sel:type':Authentication' :: Authentication -> Maybe AuthenticationType
type'} -> Maybe AuthenticationType
type') (\s :: Authentication
s@Authentication' {} Maybe AuthenticationType
a -> Authentication
s {$sel:type':Authentication' :: Maybe AuthenticationType
type' = Maybe AuthenticationType
a} :: Authentication)

instance Data.FromXML Authentication where
  parseXML :: [Node] -> Either String Authentication
parseXML [Node]
x =
    Maybe Int -> Maybe AuthenticationType -> Authentication
Authentication'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"PasswordCount")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Type")

instance Prelude.Hashable Authentication where
  hashWithSalt :: Int -> Authentication -> Int
hashWithSalt Int
_salt Authentication' {Maybe Int
Maybe AuthenticationType
type' :: Maybe AuthenticationType
passwordCount :: Maybe Int
$sel:type':Authentication' :: Authentication -> Maybe AuthenticationType
$sel:passwordCount:Authentication' :: Authentication -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
passwordCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AuthenticationType
type'

instance Prelude.NFData Authentication where
  rnf :: Authentication -> ()
rnf Authentication' {Maybe Int
Maybe AuthenticationType
type' :: Maybe AuthenticationType
passwordCount :: Maybe Int
$sel:type':Authentication' :: Authentication -> Maybe AuthenticationType
$sel:passwordCount:Authentication' :: Authentication -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
passwordCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AuthenticationType
type'