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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MemoryDb.Types.InputAuthenticationType
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:/ 'newAuthenticationMode' smart constructor.
data AuthenticationMode = AuthenticationMode'
  { -- | The password(s) used for authentication
    AuthenticationMode -> Maybe (NonEmpty Text)
passwords :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | Indicates whether the user requires a password to authenticate. All
    -- newly-created users require a password.
    AuthenticationMode -> Maybe InputAuthenticationType
type' :: Prelude.Maybe InputAuthenticationType
  }
  deriving (AuthenticationMode -> AuthenticationMode -> Bool
(AuthenticationMode -> AuthenticationMode -> Bool)
-> (AuthenticationMode -> AuthenticationMode -> Bool)
-> Eq AuthenticationMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthenticationMode -> AuthenticationMode -> Bool
$c/= :: AuthenticationMode -> AuthenticationMode -> Bool
== :: AuthenticationMode -> AuthenticationMode -> Bool
$c== :: AuthenticationMode -> AuthenticationMode -> Bool
Prelude.Eq, ReadPrec [AuthenticationMode]
ReadPrec AuthenticationMode
Int -> ReadS AuthenticationMode
ReadS [AuthenticationMode]
(Int -> ReadS AuthenticationMode)
-> ReadS [AuthenticationMode]
-> ReadPrec AuthenticationMode
-> ReadPrec [AuthenticationMode]
-> Read AuthenticationMode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuthenticationMode]
$creadListPrec :: ReadPrec [AuthenticationMode]
readPrec :: ReadPrec AuthenticationMode
$creadPrec :: ReadPrec AuthenticationMode
readList :: ReadS [AuthenticationMode]
$creadList :: ReadS [AuthenticationMode]
readsPrec :: Int -> ReadS AuthenticationMode
$creadsPrec :: Int -> ReadS AuthenticationMode
Prelude.Read, Int -> AuthenticationMode -> ShowS
[AuthenticationMode] -> ShowS
AuthenticationMode -> String
(Int -> AuthenticationMode -> ShowS)
-> (AuthenticationMode -> String)
-> ([AuthenticationMode] -> ShowS)
-> Show AuthenticationMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthenticationMode] -> ShowS
$cshowList :: [AuthenticationMode] -> ShowS
show :: AuthenticationMode -> String
$cshow :: AuthenticationMode -> String
showsPrec :: Int -> AuthenticationMode -> ShowS
$cshowsPrec :: Int -> AuthenticationMode -> ShowS
Prelude.Show, (forall x. AuthenticationMode -> Rep AuthenticationMode x)
-> (forall x. Rep AuthenticationMode x -> AuthenticationMode)
-> Generic AuthenticationMode
forall x. Rep AuthenticationMode x -> AuthenticationMode
forall x. AuthenticationMode -> Rep AuthenticationMode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AuthenticationMode x -> AuthenticationMode
$cfrom :: forall x. AuthenticationMode -> Rep AuthenticationMode x
Prelude.Generic)

-- |
-- Create a value of 'AuthenticationMode' 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:
--
-- 'passwords', 'authenticationMode_passwords' - The password(s) used for authentication
--
-- 'type'', 'authenticationMode_type' - Indicates whether the user requires a password to authenticate. All
-- newly-created users require a password.
newAuthenticationMode ::
  AuthenticationMode
newAuthenticationMode :: AuthenticationMode
newAuthenticationMode =
  AuthenticationMode' :: Maybe (NonEmpty Text)
-> Maybe InputAuthenticationType -> AuthenticationMode
AuthenticationMode'
    { $sel:passwords:AuthenticationMode' :: Maybe (NonEmpty Text)
passwords = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:type':AuthenticationMode' :: Maybe InputAuthenticationType
type' = Maybe InputAuthenticationType
forall a. Maybe a
Prelude.Nothing
    }

-- | The password(s) used for authentication
authenticationMode_passwords :: Lens.Lens' AuthenticationMode (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
authenticationMode_passwords :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> AuthenticationMode -> f AuthenticationMode
authenticationMode_passwords = (AuthenticationMode -> Maybe (NonEmpty Text))
-> (AuthenticationMode
    -> Maybe (NonEmpty Text) -> AuthenticationMode)
-> Lens
     AuthenticationMode
     AuthenticationMode
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationMode' {Maybe (NonEmpty Text)
passwords :: Maybe (NonEmpty Text)
$sel:passwords:AuthenticationMode' :: AuthenticationMode -> Maybe (NonEmpty Text)
passwords} -> Maybe (NonEmpty Text)
passwords) (\s :: AuthenticationMode
s@AuthenticationMode' {} Maybe (NonEmpty Text)
a -> AuthenticationMode
s {$sel:passwords:AuthenticationMode' :: Maybe (NonEmpty Text)
passwords = Maybe (NonEmpty Text)
a} :: AuthenticationMode) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> AuthenticationMode -> f AuthenticationMode)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> AuthenticationMode
-> f AuthenticationMode
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates whether the user requires a password to authenticate. All
-- newly-created users require a password.
authenticationMode_type :: Lens.Lens' AuthenticationMode (Prelude.Maybe InputAuthenticationType)
authenticationMode_type :: (Maybe InputAuthenticationType
 -> f (Maybe InputAuthenticationType))
-> AuthenticationMode -> f AuthenticationMode
authenticationMode_type = (AuthenticationMode -> Maybe InputAuthenticationType)
-> (AuthenticationMode
    -> Maybe InputAuthenticationType -> AuthenticationMode)
-> Lens
     AuthenticationMode
     AuthenticationMode
     (Maybe InputAuthenticationType)
     (Maybe InputAuthenticationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationMode' {Maybe InputAuthenticationType
type' :: Maybe InputAuthenticationType
$sel:type':AuthenticationMode' :: AuthenticationMode -> Maybe InputAuthenticationType
type'} -> Maybe InputAuthenticationType
type') (\s :: AuthenticationMode
s@AuthenticationMode' {} Maybe InputAuthenticationType
a -> AuthenticationMode
s {$sel:type':AuthenticationMode' :: Maybe InputAuthenticationType
type' = Maybe InputAuthenticationType
a} :: AuthenticationMode)

instance Prelude.Hashable AuthenticationMode

instance Prelude.NFData AuthenticationMode

instance Core.ToJSON AuthenticationMode where
  toJSON :: AuthenticationMode -> Value
toJSON AuthenticationMode' {Maybe (NonEmpty Text)
Maybe InputAuthenticationType
type' :: Maybe InputAuthenticationType
passwords :: Maybe (NonEmpty Text)
$sel:type':AuthenticationMode' :: AuthenticationMode -> Maybe InputAuthenticationType
$sel:passwords:AuthenticationMode' :: AuthenticationMode -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Passwords" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
passwords,
            (Text
"Type" Text -> InputAuthenticationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (InputAuthenticationType -> Pair)
-> Maybe InputAuthenticationType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputAuthenticationType
type'
          ]
      )