{-# 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.DMS.Types.RedisSettings
-- 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.DMS.Types.RedisSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.DMS.Types.RedisAuthTypeValue
import Amazonka.DMS.Types.SslSecurityProtocolValue
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Provides information that defines a Redis target endpoint.
--
-- /See:/ 'newRedisSettings' smart constructor.
data RedisSettings = RedisSettings'
  { -- | The password provided with the @auth-role@ and @auth-token@ options of
    -- the @AuthType@ setting for a Redis target endpoint.
    RedisSettings -> Maybe (Sensitive Text)
authPassword :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The type of authentication to perform when connecting to a Redis target.
    -- Options include @none@, @auth-token@, and @auth-role@. The @auth-token@
    -- option requires an @AuthPassword@ value to be provided. The @auth-role@
    -- option requires @AuthUserName@ and @AuthPassword@ values to be provided.
    RedisSettings -> Maybe RedisAuthTypeValue
authType :: Prelude.Maybe RedisAuthTypeValue,
    -- | The user name provided with the @auth-role@ option of the @AuthType@
    -- setting for a Redis target endpoint.
    RedisSettings -> Maybe Text
authUserName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the certificate authority (CA) that
    -- DMS uses to connect to your Redis target endpoint.
    RedisSettings -> Maybe Text
sslCaCertificateArn :: Prelude.Maybe Prelude.Text,
    -- | The connection to a Redis target endpoint using Transport Layer Security
    -- (TLS). Valid values include @plaintext@ and @ssl-encryption@. The
    -- default is @ssl-encryption@. The @ssl-encryption@ option makes an
    -- encrypted connection. Optionally, you can identify an Amazon Resource
    -- Name (ARN) for an SSL certificate authority (CA) using the
    -- @SslCaCertificateArn @setting. If an ARN isn\'t given for a CA, DMS uses
    -- the Amazon root CA.
    --
    -- The @plaintext@ option doesn\'t provide Transport Layer Security (TLS)
    -- encryption for traffic between endpoint and database.
    RedisSettings -> Maybe SslSecurityProtocolValue
sslSecurityProtocol :: Prelude.Maybe SslSecurityProtocolValue,
    -- | Fully qualified domain name of the endpoint.
    RedisSettings -> Text
serverName :: Prelude.Text,
    -- | Transmission Control Protocol (TCP) port for the endpoint.
    RedisSettings -> Int
port :: Prelude.Int
  }
  deriving (RedisSettings -> RedisSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RedisSettings -> RedisSettings -> Bool
$c/= :: RedisSettings -> RedisSettings -> Bool
== :: RedisSettings -> RedisSettings -> Bool
$c== :: RedisSettings -> RedisSettings -> Bool
Prelude.Eq, Int -> RedisSettings -> ShowS
[RedisSettings] -> ShowS
RedisSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RedisSettings] -> ShowS
$cshowList :: [RedisSettings] -> ShowS
show :: RedisSettings -> String
$cshow :: RedisSettings -> String
showsPrec :: Int -> RedisSettings -> ShowS
$cshowsPrec :: Int -> RedisSettings -> ShowS
Prelude.Show, forall x. Rep RedisSettings x -> RedisSettings
forall x. RedisSettings -> Rep RedisSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RedisSettings x -> RedisSettings
$cfrom :: forall x. RedisSettings -> Rep RedisSettings x
Prelude.Generic)

-- |
-- Create a value of 'RedisSettings' 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:
--
-- 'authPassword', 'redisSettings_authPassword' - The password provided with the @auth-role@ and @auth-token@ options of
-- the @AuthType@ setting for a Redis target endpoint.
--
-- 'authType', 'redisSettings_authType' - The type of authentication to perform when connecting to a Redis target.
-- Options include @none@, @auth-token@, and @auth-role@. The @auth-token@
-- option requires an @AuthPassword@ value to be provided. The @auth-role@
-- option requires @AuthUserName@ and @AuthPassword@ values to be provided.
--
-- 'authUserName', 'redisSettings_authUserName' - The user name provided with the @auth-role@ option of the @AuthType@
-- setting for a Redis target endpoint.
--
-- 'sslCaCertificateArn', 'redisSettings_sslCaCertificateArn' - The Amazon Resource Name (ARN) for the certificate authority (CA) that
-- DMS uses to connect to your Redis target endpoint.
--
-- 'sslSecurityProtocol', 'redisSettings_sslSecurityProtocol' - The connection to a Redis target endpoint using Transport Layer Security
-- (TLS). Valid values include @plaintext@ and @ssl-encryption@. The
-- default is @ssl-encryption@. The @ssl-encryption@ option makes an
-- encrypted connection. Optionally, you can identify an Amazon Resource
-- Name (ARN) for an SSL certificate authority (CA) using the
-- @SslCaCertificateArn @setting. If an ARN isn\'t given for a CA, DMS uses
-- the Amazon root CA.
--
-- The @plaintext@ option doesn\'t provide Transport Layer Security (TLS)
-- encryption for traffic between endpoint and database.
--
-- 'serverName', 'redisSettings_serverName' - Fully qualified domain name of the endpoint.
--
-- 'port', 'redisSettings_port' - Transmission Control Protocol (TCP) port for the endpoint.
newRedisSettings ::
  -- | 'serverName'
  Prelude.Text ->
  -- | 'port'
  Prelude.Int ->
  RedisSettings
newRedisSettings :: Text -> Int -> RedisSettings
newRedisSettings Text
pServerName_ Int
pPort_ =
  RedisSettings'
    { $sel:authPassword:RedisSettings' :: Maybe (Sensitive Text)
authPassword = forall a. Maybe a
Prelude.Nothing,
      $sel:authType:RedisSettings' :: Maybe RedisAuthTypeValue
authType = forall a. Maybe a
Prelude.Nothing,
      $sel:authUserName:RedisSettings' :: Maybe Text
authUserName = forall a. Maybe a
Prelude.Nothing,
      $sel:sslCaCertificateArn:RedisSettings' :: Maybe Text
sslCaCertificateArn = forall a. Maybe a
Prelude.Nothing,
      $sel:sslSecurityProtocol:RedisSettings' :: Maybe SslSecurityProtocolValue
sslSecurityProtocol = forall a. Maybe a
Prelude.Nothing,
      $sel:serverName:RedisSettings' :: Text
serverName = Text
pServerName_,
      $sel:port:RedisSettings' :: Int
port = Int
pPort_
    }

-- | The password provided with the @auth-role@ and @auth-token@ options of
-- the @AuthType@ setting for a Redis target endpoint.
redisSettings_authPassword :: Lens.Lens' RedisSettings (Prelude.Maybe Prelude.Text)
redisSettings_authPassword :: Lens' RedisSettings (Maybe Text)
redisSettings_authPassword = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedisSettings' {Maybe (Sensitive Text)
authPassword :: Maybe (Sensitive Text)
$sel:authPassword:RedisSettings' :: RedisSettings -> Maybe (Sensitive Text)
authPassword} -> Maybe (Sensitive Text)
authPassword) (\s :: RedisSettings
s@RedisSettings' {} Maybe (Sensitive Text)
a -> RedisSettings
s {$sel:authPassword:RedisSettings' :: Maybe (Sensitive Text)
authPassword = Maybe (Sensitive Text)
a} :: RedisSettings) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | The type of authentication to perform when connecting to a Redis target.
-- Options include @none@, @auth-token@, and @auth-role@. The @auth-token@
-- option requires an @AuthPassword@ value to be provided. The @auth-role@
-- option requires @AuthUserName@ and @AuthPassword@ values to be provided.
redisSettings_authType :: Lens.Lens' RedisSettings (Prelude.Maybe RedisAuthTypeValue)
redisSettings_authType :: Lens' RedisSettings (Maybe RedisAuthTypeValue)
redisSettings_authType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedisSettings' {Maybe RedisAuthTypeValue
authType :: Maybe RedisAuthTypeValue
$sel:authType:RedisSettings' :: RedisSettings -> Maybe RedisAuthTypeValue
authType} -> Maybe RedisAuthTypeValue
authType) (\s :: RedisSettings
s@RedisSettings' {} Maybe RedisAuthTypeValue
a -> RedisSettings
s {$sel:authType:RedisSettings' :: Maybe RedisAuthTypeValue
authType = Maybe RedisAuthTypeValue
a} :: RedisSettings)

-- | The user name provided with the @auth-role@ option of the @AuthType@
-- setting for a Redis target endpoint.
redisSettings_authUserName :: Lens.Lens' RedisSettings (Prelude.Maybe Prelude.Text)
redisSettings_authUserName :: Lens' RedisSettings (Maybe Text)
redisSettings_authUserName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedisSettings' {Maybe Text
authUserName :: Maybe Text
$sel:authUserName:RedisSettings' :: RedisSettings -> Maybe Text
authUserName} -> Maybe Text
authUserName) (\s :: RedisSettings
s@RedisSettings' {} Maybe Text
a -> RedisSettings
s {$sel:authUserName:RedisSettings' :: Maybe Text
authUserName = Maybe Text
a} :: RedisSettings)

-- | The Amazon Resource Name (ARN) for the certificate authority (CA) that
-- DMS uses to connect to your Redis target endpoint.
redisSettings_sslCaCertificateArn :: Lens.Lens' RedisSettings (Prelude.Maybe Prelude.Text)
redisSettings_sslCaCertificateArn :: Lens' RedisSettings (Maybe Text)
redisSettings_sslCaCertificateArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedisSettings' {Maybe Text
sslCaCertificateArn :: Maybe Text
$sel:sslCaCertificateArn:RedisSettings' :: RedisSettings -> Maybe Text
sslCaCertificateArn} -> Maybe Text
sslCaCertificateArn) (\s :: RedisSettings
s@RedisSettings' {} Maybe Text
a -> RedisSettings
s {$sel:sslCaCertificateArn:RedisSettings' :: Maybe Text
sslCaCertificateArn = Maybe Text
a} :: RedisSettings)

-- | The connection to a Redis target endpoint using Transport Layer Security
-- (TLS). Valid values include @plaintext@ and @ssl-encryption@. The
-- default is @ssl-encryption@. The @ssl-encryption@ option makes an
-- encrypted connection. Optionally, you can identify an Amazon Resource
-- Name (ARN) for an SSL certificate authority (CA) using the
-- @SslCaCertificateArn @setting. If an ARN isn\'t given for a CA, DMS uses
-- the Amazon root CA.
--
-- The @plaintext@ option doesn\'t provide Transport Layer Security (TLS)
-- encryption for traffic between endpoint and database.
redisSettings_sslSecurityProtocol :: Lens.Lens' RedisSettings (Prelude.Maybe SslSecurityProtocolValue)
redisSettings_sslSecurityProtocol :: Lens' RedisSettings (Maybe SslSecurityProtocolValue)
redisSettings_sslSecurityProtocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedisSettings' {Maybe SslSecurityProtocolValue
sslSecurityProtocol :: Maybe SslSecurityProtocolValue
$sel:sslSecurityProtocol:RedisSettings' :: RedisSettings -> Maybe SslSecurityProtocolValue
sslSecurityProtocol} -> Maybe SslSecurityProtocolValue
sslSecurityProtocol) (\s :: RedisSettings
s@RedisSettings' {} Maybe SslSecurityProtocolValue
a -> RedisSettings
s {$sel:sslSecurityProtocol:RedisSettings' :: Maybe SslSecurityProtocolValue
sslSecurityProtocol = Maybe SslSecurityProtocolValue
a} :: RedisSettings)

-- | Fully qualified domain name of the endpoint.
redisSettings_serverName :: Lens.Lens' RedisSettings Prelude.Text
redisSettings_serverName :: Lens' RedisSettings Text
redisSettings_serverName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedisSettings' {Text
serverName :: Text
$sel:serverName:RedisSettings' :: RedisSettings -> Text
serverName} -> Text
serverName) (\s :: RedisSettings
s@RedisSettings' {} Text
a -> RedisSettings
s {$sel:serverName:RedisSettings' :: Text
serverName = Text
a} :: RedisSettings)

-- | Transmission Control Protocol (TCP) port for the endpoint.
redisSettings_port :: Lens.Lens' RedisSettings Prelude.Int
redisSettings_port :: Lens' RedisSettings Int
redisSettings_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedisSettings' {Int
port :: Int
$sel:port:RedisSettings' :: RedisSettings -> Int
port} -> Int
port) (\s :: RedisSettings
s@RedisSettings' {} Int
a -> RedisSettings
s {$sel:port:RedisSettings' :: Int
port = Int
a} :: RedisSettings)

instance Data.FromJSON RedisSettings where
  parseJSON :: Value -> Parser RedisSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RedisSettings"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Maybe RedisAuthTypeValue
-> Maybe Text
-> Maybe Text
-> Maybe SslSecurityProtocolValue
-> Text
-> Int
-> RedisSettings
RedisSettings'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AuthPassword")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AuthType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AuthUserName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SslCaCertificateArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SslSecurityProtocol")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ServerName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Port")
      )

instance Prelude.Hashable RedisSettings where
  hashWithSalt :: Int -> RedisSettings -> Int
hashWithSalt Int
_salt RedisSettings' {Int
Maybe Text
Maybe (Sensitive Text)
Maybe RedisAuthTypeValue
Maybe SslSecurityProtocolValue
Text
port :: Int
serverName :: Text
sslSecurityProtocol :: Maybe SslSecurityProtocolValue
sslCaCertificateArn :: Maybe Text
authUserName :: Maybe Text
authType :: Maybe RedisAuthTypeValue
authPassword :: Maybe (Sensitive Text)
$sel:port:RedisSettings' :: RedisSettings -> Int
$sel:serverName:RedisSettings' :: RedisSettings -> Text
$sel:sslSecurityProtocol:RedisSettings' :: RedisSettings -> Maybe SslSecurityProtocolValue
$sel:sslCaCertificateArn:RedisSettings' :: RedisSettings -> Maybe Text
$sel:authUserName:RedisSettings' :: RedisSettings -> Maybe Text
$sel:authType:RedisSettings' :: RedisSettings -> Maybe RedisAuthTypeValue
$sel:authPassword:RedisSettings' :: RedisSettings -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
authPassword
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RedisAuthTypeValue
authType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
authUserName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sslCaCertificateArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SslSecurityProtocolValue
sslSecurityProtocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serverName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
port

instance Prelude.NFData RedisSettings where
  rnf :: RedisSettings -> ()
rnf RedisSettings' {Int
Maybe Text
Maybe (Sensitive Text)
Maybe RedisAuthTypeValue
Maybe SslSecurityProtocolValue
Text
port :: Int
serverName :: Text
sslSecurityProtocol :: Maybe SslSecurityProtocolValue
sslCaCertificateArn :: Maybe Text
authUserName :: Maybe Text
authType :: Maybe RedisAuthTypeValue
authPassword :: Maybe (Sensitive Text)
$sel:port:RedisSettings' :: RedisSettings -> Int
$sel:serverName:RedisSettings' :: RedisSettings -> Text
$sel:sslSecurityProtocol:RedisSettings' :: RedisSettings -> Maybe SslSecurityProtocolValue
$sel:sslCaCertificateArn:RedisSettings' :: RedisSettings -> Maybe Text
$sel:authUserName:RedisSettings' :: RedisSettings -> Maybe Text
$sel:authType:RedisSettings' :: RedisSettings -> Maybe RedisAuthTypeValue
$sel:authPassword:RedisSettings' :: RedisSettings -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
authPassword
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RedisAuthTypeValue
authType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
authUserName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sslCaCertificateArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SslSecurityProtocolValue
sslSecurityProtocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serverName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
port

instance Data.ToJSON RedisSettings where
  toJSON :: RedisSettings -> Value
toJSON RedisSettings' {Int
Maybe Text
Maybe (Sensitive Text)
Maybe RedisAuthTypeValue
Maybe SslSecurityProtocolValue
Text
port :: Int
serverName :: Text
sslSecurityProtocol :: Maybe SslSecurityProtocolValue
sslCaCertificateArn :: Maybe Text
authUserName :: Maybe Text
authType :: Maybe RedisAuthTypeValue
authPassword :: Maybe (Sensitive Text)
$sel:port:RedisSettings' :: RedisSettings -> Int
$sel:serverName:RedisSettings' :: RedisSettings -> Text
$sel:sslSecurityProtocol:RedisSettings' :: RedisSettings -> Maybe SslSecurityProtocolValue
$sel:sslCaCertificateArn:RedisSettings' :: RedisSettings -> Maybe Text
$sel:authUserName:RedisSettings' :: RedisSettings -> Maybe Text
$sel:authType:RedisSettings' :: RedisSettings -> Maybe RedisAuthTypeValue
$sel:authPassword:RedisSettings' :: RedisSettings -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AuthPassword" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
authPassword,
            (Key
"AuthType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RedisAuthTypeValue
authType,
            (Key
"AuthUserName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
authUserName,
            (Key
"SslCaCertificateArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sslCaCertificateArn,
            (Key
"SslSecurityProtocol" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SslSecurityProtocolValue
sslSecurityProtocol,
            forall a. a -> Maybe a
Prelude.Just (Key
"ServerName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
serverName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Port" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
port)
          ]
      )