{-# 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.RDS.Types.UserAuthConfig
-- 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.RDS.Types.UserAuthConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types.AuthScheme
import Amazonka.RDS.Types.IAMAuthMode

-- | Specifies the details of authentication used by a proxy to log in as a
-- specific database user.
--
-- /See:/ 'newUserAuthConfig' smart constructor.
data UserAuthConfig = UserAuthConfig'
  { -- | Whether to require or disallow Amazon Web Services Identity and Access
    -- Management (IAM) authentication for connections to the proxy.
    UserAuthConfig -> Maybe IAMAuthMode
iAMAuth :: Prelude.Maybe IAMAuthMode,
    -- | The name of the database user to which the proxy connects.
    UserAuthConfig -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | The type of authentication that the proxy uses for connections from the
    -- proxy to the underlying database.
    UserAuthConfig -> Maybe AuthScheme
authScheme :: Prelude.Maybe AuthScheme,
    -- | The Amazon Resource Name (ARN) representing the secret that the proxy
    -- uses to authenticate to the RDS DB instance or Aurora DB cluster. These
    -- secrets are stored within Amazon Secrets Manager.
    UserAuthConfig -> Maybe Text
secretArn :: Prelude.Maybe Prelude.Text,
    -- | A user-specified description about the authentication used by a proxy to
    -- log in as a specific database user.
    UserAuthConfig -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (UserAuthConfig -> UserAuthConfig -> Bool
(UserAuthConfig -> UserAuthConfig -> Bool)
-> (UserAuthConfig -> UserAuthConfig -> Bool) -> Eq UserAuthConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserAuthConfig -> UserAuthConfig -> Bool
$c/= :: UserAuthConfig -> UserAuthConfig -> Bool
== :: UserAuthConfig -> UserAuthConfig -> Bool
$c== :: UserAuthConfig -> UserAuthConfig -> Bool
Prelude.Eq, ReadPrec [UserAuthConfig]
ReadPrec UserAuthConfig
Int -> ReadS UserAuthConfig
ReadS [UserAuthConfig]
(Int -> ReadS UserAuthConfig)
-> ReadS [UserAuthConfig]
-> ReadPrec UserAuthConfig
-> ReadPrec [UserAuthConfig]
-> Read UserAuthConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserAuthConfig]
$creadListPrec :: ReadPrec [UserAuthConfig]
readPrec :: ReadPrec UserAuthConfig
$creadPrec :: ReadPrec UserAuthConfig
readList :: ReadS [UserAuthConfig]
$creadList :: ReadS [UserAuthConfig]
readsPrec :: Int -> ReadS UserAuthConfig
$creadsPrec :: Int -> ReadS UserAuthConfig
Prelude.Read, Int -> UserAuthConfig -> ShowS
[UserAuthConfig] -> ShowS
UserAuthConfig -> String
(Int -> UserAuthConfig -> ShowS)
-> (UserAuthConfig -> String)
-> ([UserAuthConfig] -> ShowS)
-> Show UserAuthConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserAuthConfig] -> ShowS
$cshowList :: [UserAuthConfig] -> ShowS
show :: UserAuthConfig -> String
$cshow :: UserAuthConfig -> String
showsPrec :: Int -> UserAuthConfig -> ShowS
$cshowsPrec :: Int -> UserAuthConfig -> ShowS
Prelude.Show, (forall x. UserAuthConfig -> Rep UserAuthConfig x)
-> (forall x. Rep UserAuthConfig x -> UserAuthConfig)
-> Generic UserAuthConfig
forall x. Rep UserAuthConfig x -> UserAuthConfig
forall x. UserAuthConfig -> Rep UserAuthConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserAuthConfig x -> UserAuthConfig
$cfrom :: forall x. UserAuthConfig -> Rep UserAuthConfig x
Prelude.Generic)

-- |
-- Create a value of 'UserAuthConfig' 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:
--
-- 'iAMAuth', 'userAuthConfig_iAMAuth' - Whether to require or disallow Amazon Web Services Identity and Access
-- Management (IAM) authentication for connections to the proxy.
--
-- 'userName', 'userAuthConfig_userName' - The name of the database user to which the proxy connects.
--
-- 'authScheme', 'userAuthConfig_authScheme' - The type of authentication that the proxy uses for connections from the
-- proxy to the underlying database.
--
-- 'secretArn', 'userAuthConfig_secretArn' - The Amazon Resource Name (ARN) representing the secret that the proxy
-- uses to authenticate to the RDS DB instance or Aurora DB cluster. These
-- secrets are stored within Amazon Secrets Manager.
--
-- 'description', 'userAuthConfig_description' - A user-specified description about the authentication used by a proxy to
-- log in as a specific database user.
newUserAuthConfig ::
  UserAuthConfig
newUserAuthConfig :: UserAuthConfig
newUserAuthConfig =
  UserAuthConfig' :: Maybe IAMAuthMode
-> Maybe Text
-> Maybe AuthScheme
-> Maybe Text
-> Maybe Text
-> UserAuthConfig
UserAuthConfig'
    { $sel:iAMAuth:UserAuthConfig' :: Maybe IAMAuthMode
iAMAuth = Maybe IAMAuthMode
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:UserAuthConfig' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authScheme:UserAuthConfig' :: Maybe AuthScheme
authScheme = Maybe AuthScheme
forall a. Maybe a
Prelude.Nothing,
      $sel:secretArn:UserAuthConfig' :: Maybe Text
secretArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UserAuthConfig' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether to require or disallow Amazon Web Services Identity and Access
-- Management (IAM) authentication for connections to the proxy.
userAuthConfig_iAMAuth :: Lens.Lens' UserAuthConfig (Prelude.Maybe IAMAuthMode)
userAuthConfig_iAMAuth :: (Maybe IAMAuthMode -> f (Maybe IAMAuthMode))
-> UserAuthConfig -> f UserAuthConfig
userAuthConfig_iAMAuth = (UserAuthConfig -> Maybe IAMAuthMode)
-> (UserAuthConfig -> Maybe IAMAuthMode -> UserAuthConfig)
-> Lens
     UserAuthConfig
     UserAuthConfig
     (Maybe IAMAuthMode)
     (Maybe IAMAuthMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserAuthConfig' {Maybe IAMAuthMode
iAMAuth :: Maybe IAMAuthMode
$sel:iAMAuth:UserAuthConfig' :: UserAuthConfig -> Maybe IAMAuthMode
iAMAuth} -> Maybe IAMAuthMode
iAMAuth) (\s :: UserAuthConfig
s@UserAuthConfig' {} Maybe IAMAuthMode
a -> UserAuthConfig
s {$sel:iAMAuth:UserAuthConfig' :: Maybe IAMAuthMode
iAMAuth = Maybe IAMAuthMode
a} :: UserAuthConfig)

-- | The name of the database user to which the proxy connects.
userAuthConfig_userName :: Lens.Lens' UserAuthConfig (Prelude.Maybe Prelude.Text)
userAuthConfig_userName :: (Maybe Text -> f (Maybe Text))
-> UserAuthConfig -> f UserAuthConfig
userAuthConfig_userName = (UserAuthConfig -> Maybe Text)
-> (UserAuthConfig -> Maybe Text -> UserAuthConfig)
-> Lens UserAuthConfig UserAuthConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserAuthConfig' {Maybe Text
userName :: Maybe Text
$sel:userName:UserAuthConfig' :: UserAuthConfig -> Maybe Text
userName} -> Maybe Text
userName) (\s :: UserAuthConfig
s@UserAuthConfig' {} Maybe Text
a -> UserAuthConfig
s {$sel:userName:UserAuthConfig' :: Maybe Text
userName = Maybe Text
a} :: UserAuthConfig)

-- | The type of authentication that the proxy uses for connections from the
-- proxy to the underlying database.
userAuthConfig_authScheme :: Lens.Lens' UserAuthConfig (Prelude.Maybe AuthScheme)
userAuthConfig_authScheme :: (Maybe AuthScheme -> f (Maybe AuthScheme))
-> UserAuthConfig -> f UserAuthConfig
userAuthConfig_authScheme = (UserAuthConfig -> Maybe AuthScheme)
-> (UserAuthConfig -> Maybe AuthScheme -> UserAuthConfig)
-> Lens
     UserAuthConfig UserAuthConfig (Maybe AuthScheme) (Maybe AuthScheme)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserAuthConfig' {Maybe AuthScheme
authScheme :: Maybe AuthScheme
$sel:authScheme:UserAuthConfig' :: UserAuthConfig -> Maybe AuthScheme
authScheme} -> Maybe AuthScheme
authScheme) (\s :: UserAuthConfig
s@UserAuthConfig' {} Maybe AuthScheme
a -> UserAuthConfig
s {$sel:authScheme:UserAuthConfig' :: Maybe AuthScheme
authScheme = Maybe AuthScheme
a} :: UserAuthConfig)

-- | The Amazon Resource Name (ARN) representing the secret that the proxy
-- uses to authenticate to the RDS DB instance or Aurora DB cluster. These
-- secrets are stored within Amazon Secrets Manager.
userAuthConfig_secretArn :: Lens.Lens' UserAuthConfig (Prelude.Maybe Prelude.Text)
userAuthConfig_secretArn :: (Maybe Text -> f (Maybe Text))
-> UserAuthConfig -> f UserAuthConfig
userAuthConfig_secretArn = (UserAuthConfig -> Maybe Text)
-> (UserAuthConfig -> Maybe Text -> UserAuthConfig)
-> Lens UserAuthConfig UserAuthConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserAuthConfig' {Maybe Text
secretArn :: Maybe Text
$sel:secretArn:UserAuthConfig' :: UserAuthConfig -> Maybe Text
secretArn} -> Maybe Text
secretArn) (\s :: UserAuthConfig
s@UserAuthConfig' {} Maybe Text
a -> UserAuthConfig
s {$sel:secretArn:UserAuthConfig' :: Maybe Text
secretArn = Maybe Text
a} :: UserAuthConfig)

-- | A user-specified description about the authentication used by a proxy to
-- log in as a specific database user.
userAuthConfig_description :: Lens.Lens' UserAuthConfig (Prelude.Maybe Prelude.Text)
userAuthConfig_description :: (Maybe Text -> f (Maybe Text))
-> UserAuthConfig -> f UserAuthConfig
userAuthConfig_description = (UserAuthConfig -> Maybe Text)
-> (UserAuthConfig -> Maybe Text -> UserAuthConfig)
-> Lens UserAuthConfig UserAuthConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserAuthConfig' {Maybe Text
description :: Maybe Text
$sel:description:UserAuthConfig' :: UserAuthConfig -> Maybe Text
description} -> Maybe Text
description) (\s :: UserAuthConfig
s@UserAuthConfig' {} Maybe Text
a -> UserAuthConfig
s {$sel:description:UserAuthConfig' :: Maybe Text
description = Maybe Text
a} :: UserAuthConfig)

instance Prelude.Hashable UserAuthConfig

instance Prelude.NFData UserAuthConfig

instance Core.ToQuery UserAuthConfig where
  toQuery :: UserAuthConfig -> QueryString
toQuery UserAuthConfig' {Maybe Text
Maybe AuthScheme
Maybe IAMAuthMode
description :: Maybe Text
secretArn :: Maybe Text
authScheme :: Maybe AuthScheme
userName :: Maybe Text
iAMAuth :: Maybe IAMAuthMode
$sel:description:UserAuthConfig' :: UserAuthConfig -> Maybe Text
$sel:secretArn:UserAuthConfig' :: UserAuthConfig -> Maybe Text
$sel:authScheme:UserAuthConfig' :: UserAuthConfig -> Maybe AuthScheme
$sel:userName:UserAuthConfig' :: UserAuthConfig -> Maybe Text
$sel:iAMAuth:UserAuthConfig' :: UserAuthConfig -> Maybe IAMAuthMode
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"IAMAuth" ByteString -> Maybe IAMAuthMode -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe IAMAuthMode
iAMAuth,
        ByteString
"UserName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
userName,
        ByteString
"AuthScheme" ByteString -> Maybe AuthScheme -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe AuthScheme
authScheme,
        ByteString
"SecretArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
secretArn,
        ByteString
"Description" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
description
      ]