{-# 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.UserAuthConfigInfo
-- 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.UserAuthConfigInfo 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

-- | Returns the details of authentication used by a proxy to log in as a
-- specific database user.
--
-- /See:/ 'newUserAuthConfigInfo' smart constructor.
data UserAuthConfigInfo = UserAuthConfigInfo'
  { -- | Whether to require or disallow Amazon Web Services Identity and Access
    -- Management (IAM) authentication for connections to the proxy.
    UserAuthConfigInfo -> Maybe IAMAuthMode
iAMAuth :: Prelude.Maybe IAMAuthMode,
    -- | The name of the database user to which the proxy connects.
    UserAuthConfigInfo -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | The type of authentication that the proxy uses for connections from the
    -- proxy to the underlying database.
    UserAuthConfigInfo -> 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.
    UserAuthConfigInfo -> 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.
    UserAuthConfigInfo -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (UserAuthConfigInfo -> UserAuthConfigInfo -> Bool
(UserAuthConfigInfo -> UserAuthConfigInfo -> Bool)
-> (UserAuthConfigInfo -> UserAuthConfigInfo -> Bool)
-> Eq UserAuthConfigInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserAuthConfigInfo -> UserAuthConfigInfo -> Bool
$c/= :: UserAuthConfigInfo -> UserAuthConfigInfo -> Bool
== :: UserAuthConfigInfo -> UserAuthConfigInfo -> Bool
$c== :: UserAuthConfigInfo -> UserAuthConfigInfo -> Bool
Prelude.Eq, ReadPrec [UserAuthConfigInfo]
ReadPrec UserAuthConfigInfo
Int -> ReadS UserAuthConfigInfo
ReadS [UserAuthConfigInfo]
(Int -> ReadS UserAuthConfigInfo)
-> ReadS [UserAuthConfigInfo]
-> ReadPrec UserAuthConfigInfo
-> ReadPrec [UserAuthConfigInfo]
-> Read UserAuthConfigInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserAuthConfigInfo]
$creadListPrec :: ReadPrec [UserAuthConfigInfo]
readPrec :: ReadPrec UserAuthConfigInfo
$creadPrec :: ReadPrec UserAuthConfigInfo
readList :: ReadS [UserAuthConfigInfo]
$creadList :: ReadS [UserAuthConfigInfo]
readsPrec :: Int -> ReadS UserAuthConfigInfo
$creadsPrec :: Int -> ReadS UserAuthConfigInfo
Prelude.Read, Int -> UserAuthConfigInfo -> ShowS
[UserAuthConfigInfo] -> ShowS
UserAuthConfigInfo -> String
(Int -> UserAuthConfigInfo -> ShowS)
-> (UserAuthConfigInfo -> String)
-> ([UserAuthConfigInfo] -> ShowS)
-> Show UserAuthConfigInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserAuthConfigInfo] -> ShowS
$cshowList :: [UserAuthConfigInfo] -> ShowS
show :: UserAuthConfigInfo -> String
$cshow :: UserAuthConfigInfo -> String
showsPrec :: Int -> UserAuthConfigInfo -> ShowS
$cshowsPrec :: Int -> UserAuthConfigInfo -> ShowS
Prelude.Show, (forall x. UserAuthConfigInfo -> Rep UserAuthConfigInfo x)
-> (forall x. Rep UserAuthConfigInfo x -> UserAuthConfigInfo)
-> Generic UserAuthConfigInfo
forall x. Rep UserAuthConfigInfo x -> UserAuthConfigInfo
forall x. UserAuthConfigInfo -> Rep UserAuthConfigInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserAuthConfigInfo x -> UserAuthConfigInfo
$cfrom :: forall x. UserAuthConfigInfo -> Rep UserAuthConfigInfo x
Prelude.Generic)

-- |
-- Create a value of 'UserAuthConfigInfo' 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', 'userAuthConfigInfo_iAMAuth' - Whether to require or disallow Amazon Web Services Identity and Access
-- Management (IAM) authentication for connections to the proxy.
--
-- 'userName', 'userAuthConfigInfo_userName' - The name of the database user to which the proxy connects.
--
-- 'authScheme', 'userAuthConfigInfo_authScheme' - The type of authentication that the proxy uses for connections from the
-- proxy to the underlying database.
--
-- 'secretArn', 'userAuthConfigInfo_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', 'userAuthConfigInfo_description' - A user-specified description about the authentication used by a proxy to
-- log in as a specific database user.
newUserAuthConfigInfo ::
  UserAuthConfigInfo
newUserAuthConfigInfo :: UserAuthConfigInfo
newUserAuthConfigInfo =
  UserAuthConfigInfo' :: Maybe IAMAuthMode
-> Maybe Text
-> Maybe AuthScheme
-> Maybe Text
-> Maybe Text
-> UserAuthConfigInfo
UserAuthConfigInfo'
    { $sel:iAMAuth:UserAuthConfigInfo' :: Maybe IAMAuthMode
iAMAuth = Maybe IAMAuthMode
forall a. Maybe a
Prelude.Nothing,
      $sel:userName:UserAuthConfigInfo' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authScheme:UserAuthConfigInfo' :: Maybe AuthScheme
authScheme = Maybe AuthScheme
forall a. Maybe a
Prelude.Nothing,
      $sel:secretArn:UserAuthConfigInfo' :: Maybe Text
secretArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UserAuthConfigInfo' :: 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.
userAuthConfigInfo_iAMAuth :: Lens.Lens' UserAuthConfigInfo (Prelude.Maybe IAMAuthMode)
userAuthConfigInfo_iAMAuth :: (Maybe IAMAuthMode -> f (Maybe IAMAuthMode))
-> UserAuthConfigInfo -> f UserAuthConfigInfo
userAuthConfigInfo_iAMAuth = (UserAuthConfigInfo -> Maybe IAMAuthMode)
-> (UserAuthConfigInfo -> Maybe IAMAuthMode -> UserAuthConfigInfo)
-> Lens
     UserAuthConfigInfo
     UserAuthConfigInfo
     (Maybe IAMAuthMode)
     (Maybe IAMAuthMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserAuthConfigInfo' {Maybe IAMAuthMode
iAMAuth :: Maybe IAMAuthMode
$sel:iAMAuth:UserAuthConfigInfo' :: UserAuthConfigInfo -> Maybe IAMAuthMode
iAMAuth} -> Maybe IAMAuthMode
iAMAuth) (\s :: UserAuthConfigInfo
s@UserAuthConfigInfo' {} Maybe IAMAuthMode
a -> UserAuthConfigInfo
s {$sel:iAMAuth:UserAuthConfigInfo' :: Maybe IAMAuthMode
iAMAuth = Maybe IAMAuthMode
a} :: UserAuthConfigInfo)

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

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

-- | 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.
userAuthConfigInfo_secretArn :: Lens.Lens' UserAuthConfigInfo (Prelude.Maybe Prelude.Text)
userAuthConfigInfo_secretArn :: (Maybe Text -> f (Maybe Text))
-> UserAuthConfigInfo -> f UserAuthConfigInfo
userAuthConfigInfo_secretArn = (UserAuthConfigInfo -> Maybe Text)
-> (UserAuthConfigInfo -> Maybe Text -> UserAuthConfigInfo)
-> Lens
     UserAuthConfigInfo UserAuthConfigInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserAuthConfigInfo' {Maybe Text
secretArn :: Maybe Text
$sel:secretArn:UserAuthConfigInfo' :: UserAuthConfigInfo -> Maybe Text
secretArn} -> Maybe Text
secretArn) (\s :: UserAuthConfigInfo
s@UserAuthConfigInfo' {} Maybe Text
a -> UserAuthConfigInfo
s {$sel:secretArn:UserAuthConfigInfo' :: Maybe Text
secretArn = Maybe Text
a} :: UserAuthConfigInfo)

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

instance Core.FromXML UserAuthConfigInfo where
  parseXML :: [Node] -> Either String UserAuthConfigInfo
parseXML [Node]
x =
    Maybe IAMAuthMode
-> Maybe Text
-> Maybe AuthScheme
-> Maybe Text
-> Maybe Text
-> UserAuthConfigInfo
UserAuthConfigInfo'
      (Maybe IAMAuthMode
 -> Maybe Text
 -> Maybe AuthScheme
 -> Maybe Text
 -> Maybe Text
 -> UserAuthConfigInfo)
-> Either String (Maybe IAMAuthMode)
-> Either
     String
     (Maybe Text
      -> Maybe AuthScheme
      -> Maybe Text
      -> Maybe Text
      -> UserAuthConfigInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe IAMAuthMode)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IAMAuth")
      Either
  String
  (Maybe Text
   -> Maybe AuthScheme
   -> Maybe Text
   -> Maybe Text
   -> UserAuthConfigInfo)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe AuthScheme
      -> Maybe Text -> Maybe Text -> UserAuthConfigInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"UserName")
      Either
  String
  (Maybe AuthScheme
   -> Maybe Text -> Maybe Text -> UserAuthConfigInfo)
-> Either String (Maybe AuthScheme)
-> Either String (Maybe Text -> Maybe Text -> UserAuthConfigInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe AuthScheme)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AuthScheme")
      Either String (Maybe Text -> Maybe Text -> UserAuthConfigInfo)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> UserAuthConfigInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SecretArn")
      Either String (Maybe Text -> UserAuthConfigInfo)
-> Either String (Maybe Text) -> Either String UserAuthConfigInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Description")

instance Prelude.Hashable UserAuthConfigInfo

instance Prelude.NFData UserAuthConfigInfo