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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MemoryDb.Types.AuthenticationType
import qualified Amazonka.Prelude as Prelude

-- | Denotes the user\'s authentication properties, such as whether it
-- requires a password to authenticate. Used in output responses.
--
-- /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
(Authentication -> Authentication -> Bool)
-> (Authentication -> Authentication -> Bool) -> Eq Authentication
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]
(Int -> ReadS Authentication)
-> ReadS [Authentication]
-> ReadPrec Authentication
-> ReadPrec [Authentication]
-> Read 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
(Int -> Authentication -> ShowS)
-> (Authentication -> String)
-> ([Authentication] -> ShowS)
-> Show Authentication
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. Authentication -> Rep Authentication x)
-> (forall x. Rep Authentication x -> Authentication)
-> Generic Authentication
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' :: Maybe Int -> Maybe AuthenticationType -> Authentication
Authentication'
    { $sel:passwordCount:Authentication' :: Maybe Int
passwordCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Authentication' :: Maybe AuthenticationType
type' = Maybe AuthenticationType
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 :: (Maybe Int -> f (Maybe Int)) -> Authentication -> f Authentication
authentication_passwordCount = (Authentication -> Maybe Int)
-> (Authentication -> Maybe Int -> Authentication)
-> Lens Authentication Authentication (Maybe Int) (Maybe Int)
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 :: (Maybe AuthenticationType -> f (Maybe AuthenticationType))
-> Authentication -> f Authentication
authentication_type = (Authentication -> Maybe AuthenticationType)
-> (Authentication -> Maybe AuthenticationType -> Authentication)
-> Lens
     Authentication
     Authentication
     (Maybe AuthenticationType)
     (Maybe AuthenticationType)
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 Core.FromJSON Authentication where
  parseJSON :: Value -> Parser Authentication
parseJSON =
    String
-> (Object -> Parser Authentication)
-> Value
-> Parser Authentication
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Authentication"
      ( \Object
x ->
          Maybe Int -> Maybe AuthenticationType -> Authentication
Authentication'
            (Maybe Int -> Maybe AuthenticationType -> Authentication)
-> Parser (Maybe Int)
-> Parser (Maybe AuthenticationType -> Authentication)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PasswordCount")
            Parser (Maybe AuthenticationType -> Authentication)
-> Parser (Maybe AuthenticationType) -> Parser Authentication
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AuthenticationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable Authentication

instance Prelude.NFData Authentication