{-# 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.AuthenticationMode
-- 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.AuthenticationMode 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.InputAuthenticationType
import qualified Amazonka.Prelude as Prelude

-- | Specifies the authentication mode to use.
--
-- /See:/ 'newAuthenticationMode' smart constructor.
data AuthenticationMode = AuthenticationMode'
  { -- | Specifies the passwords to use for authentication if @Type@ is set to
    -- @password@.
    AuthenticationMode -> Maybe (NonEmpty Text)
passwords :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | Specifies the authentication type. Possible options are IAM
    -- authentication, password and no password.
    AuthenticationMode -> Maybe InputAuthenticationType
type' :: Prelude.Maybe InputAuthenticationType
  }
  deriving (AuthenticationMode -> AuthenticationMode -> Bool
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]
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
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. 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' - Specifies the passwords to use for authentication if @Type@ is set to
-- @password@.
--
-- 'type'', 'authenticationMode_type' - Specifies the authentication type. Possible options are IAM
-- authentication, password and no password.
newAuthenticationMode ::
  AuthenticationMode
newAuthenticationMode :: AuthenticationMode
newAuthenticationMode =
  AuthenticationMode'
    { $sel:passwords:AuthenticationMode' :: Maybe (NonEmpty Text)
passwords = forall a. Maybe a
Prelude.Nothing,
      $sel:type':AuthenticationMode' :: Maybe InputAuthenticationType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the passwords to use for authentication if @Type@ is set to
-- @password@.
authenticationMode_passwords :: Lens.Lens' AuthenticationMode (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
authenticationMode_passwords :: Lens' AuthenticationMode (Maybe (NonEmpty Text))
authenticationMode_passwords = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the authentication type. Possible options are IAM
-- authentication, password and no password.
authenticationMode_type :: Lens.Lens' AuthenticationMode (Prelude.Maybe InputAuthenticationType)
authenticationMode_type :: Lens' AuthenticationMode (Maybe InputAuthenticationType)
authenticationMode_type = 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 where
  hashWithSalt :: Int -> AuthenticationMode -> Int
hashWithSalt Int
_salt 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)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
passwords
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputAuthenticationType
type'

instance Prelude.NFData AuthenticationMode where
  rnf :: AuthenticationMode -> ()
rnf 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)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
passwords
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InputAuthenticationType
type'

instance Data.ToQuery AuthenticationMode where
  toQuery :: AuthenticationMode -> QueryString
toQuery 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)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Passwords"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
passwords),
        ByteString
"Type" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe InputAuthenticationType
type'
      ]