{-# 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.CloudWatchEvents.Types.RedshiftDataParameters
-- 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.CloudWatchEvents.Types.RedshiftDataParameters where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | These are custom parameters to be used when the target is a Amazon
-- Redshift cluster to invoke the Amazon Redshift Data API ExecuteStatement
-- based on EventBridge events.
--
-- /See:/ 'newRedshiftDataParameters' smart constructor.
data RedshiftDataParameters = RedshiftDataParameters'
  { -- | The database user name. Required when authenticating using temporary
    -- credentials.
    RedshiftDataParameters -> Maybe Text
dbUser :: Prelude.Maybe Prelude.Text,
    -- | The name or ARN of the secret that enables access to the database.
    -- Required when authenticating using Amazon Web Services Secrets Manager.
    RedshiftDataParameters -> Maybe Text
secretManagerArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the SQL statement. You can name the SQL statement when you
    -- create it to identify the query.
    RedshiftDataParameters -> Maybe Text
statementName :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether to send an event back to EventBridge after the SQL
    -- statement runs.
    RedshiftDataParameters -> Maybe Bool
withEvent :: Prelude.Maybe Prelude.Bool,
    -- | The name of the database. Required when authenticating using temporary
    -- credentials.
    RedshiftDataParameters -> Text
database :: Prelude.Text,
    -- | The SQL statement text to run.
    RedshiftDataParameters -> Text
sql :: Prelude.Text
  }
  deriving (RedshiftDataParameters -> RedshiftDataParameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RedshiftDataParameters -> RedshiftDataParameters -> Bool
$c/= :: RedshiftDataParameters -> RedshiftDataParameters -> Bool
== :: RedshiftDataParameters -> RedshiftDataParameters -> Bool
$c== :: RedshiftDataParameters -> RedshiftDataParameters -> Bool
Prelude.Eq, ReadPrec [RedshiftDataParameters]
ReadPrec RedshiftDataParameters
Int -> ReadS RedshiftDataParameters
ReadS [RedshiftDataParameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RedshiftDataParameters]
$creadListPrec :: ReadPrec [RedshiftDataParameters]
readPrec :: ReadPrec RedshiftDataParameters
$creadPrec :: ReadPrec RedshiftDataParameters
readList :: ReadS [RedshiftDataParameters]
$creadList :: ReadS [RedshiftDataParameters]
readsPrec :: Int -> ReadS RedshiftDataParameters
$creadsPrec :: Int -> ReadS RedshiftDataParameters
Prelude.Read, Int -> RedshiftDataParameters -> ShowS
[RedshiftDataParameters] -> ShowS
RedshiftDataParameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RedshiftDataParameters] -> ShowS
$cshowList :: [RedshiftDataParameters] -> ShowS
show :: RedshiftDataParameters -> String
$cshow :: RedshiftDataParameters -> String
showsPrec :: Int -> RedshiftDataParameters -> ShowS
$cshowsPrec :: Int -> RedshiftDataParameters -> ShowS
Prelude.Show, forall x. Rep RedshiftDataParameters x -> RedshiftDataParameters
forall x. RedshiftDataParameters -> Rep RedshiftDataParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RedshiftDataParameters x -> RedshiftDataParameters
$cfrom :: forall x. RedshiftDataParameters -> Rep RedshiftDataParameters x
Prelude.Generic)

-- |
-- Create a value of 'RedshiftDataParameters' 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:
--
-- 'dbUser', 'redshiftDataParameters_dbUser' - The database user name. Required when authenticating using temporary
-- credentials.
--
-- 'secretManagerArn', 'redshiftDataParameters_secretManagerArn' - The name or ARN of the secret that enables access to the database.
-- Required when authenticating using Amazon Web Services Secrets Manager.
--
-- 'statementName', 'redshiftDataParameters_statementName' - The name of the SQL statement. You can name the SQL statement when you
-- create it to identify the query.
--
-- 'withEvent', 'redshiftDataParameters_withEvent' - Indicates whether to send an event back to EventBridge after the SQL
-- statement runs.
--
-- 'database', 'redshiftDataParameters_database' - The name of the database. Required when authenticating using temporary
-- credentials.
--
-- 'sql', 'redshiftDataParameters_sql' - The SQL statement text to run.
newRedshiftDataParameters ::
  -- | 'database'
  Prelude.Text ->
  -- | 'sql'
  Prelude.Text ->
  RedshiftDataParameters
newRedshiftDataParameters :: Text -> Text -> RedshiftDataParameters
newRedshiftDataParameters Text
pDatabase_ Text
pSql_ =
  RedshiftDataParameters'
    { $sel:dbUser:RedshiftDataParameters' :: Maybe Text
dbUser = forall a. Maybe a
Prelude.Nothing,
      $sel:secretManagerArn:RedshiftDataParameters' :: Maybe Text
secretManagerArn = forall a. Maybe a
Prelude.Nothing,
      $sel:statementName:RedshiftDataParameters' :: Maybe Text
statementName = forall a. Maybe a
Prelude.Nothing,
      $sel:withEvent:RedshiftDataParameters' :: Maybe Bool
withEvent = forall a. Maybe a
Prelude.Nothing,
      $sel:database:RedshiftDataParameters' :: Text
database = Text
pDatabase_,
      $sel:sql:RedshiftDataParameters' :: Text
sql = Text
pSql_
    }

-- | The database user name. Required when authenticating using temporary
-- credentials.
redshiftDataParameters_dbUser :: Lens.Lens' RedshiftDataParameters (Prelude.Maybe Prelude.Text)
redshiftDataParameters_dbUser :: Lens' RedshiftDataParameters (Maybe Text)
redshiftDataParameters_dbUser = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDataParameters' {Maybe Text
dbUser :: Maybe Text
$sel:dbUser:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
dbUser} -> Maybe Text
dbUser) (\s :: RedshiftDataParameters
s@RedshiftDataParameters' {} Maybe Text
a -> RedshiftDataParameters
s {$sel:dbUser:RedshiftDataParameters' :: Maybe Text
dbUser = Maybe Text
a} :: RedshiftDataParameters)

-- | The name or ARN of the secret that enables access to the database.
-- Required when authenticating using Amazon Web Services Secrets Manager.
redshiftDataParameters_secretManagerArn :: Lens.Lens' RedshiftDataParameters (Prelude.Maybe Prelude.Text)
redshiftDataParameters_secretManagerArn :: Lens' RedshiftDataParameters (Maybe Text)
redshiftDataParameters_secretManagerArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDataParameters' {Maybe Text
secretManagerArn :: Maybe Text
$sel:secretManagerArn:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
secretManagerArn} -> Maybe Text
secretManagerArn) (\s :: RedshiftDataParameters
s@RedshiftDataParameters' {} Maybe Text
a -> RedshiftDataParameters
s {$sel:secretManagerArn:RedshiftDataParameters' :: Maybe Text
secretManagerArn = Maybe Text
a} :: RedshiftDataParameters)

-- | The name of the SQL statement. You can name the SQL statement when you
-- create it to identify the query.
redshiftDataParameters_statementName :: Lens.Lens' RedshiftDataParameters (Prelude.Maybe Prelude.Text)
redshiftDataParameters_statementName :: Lens' RedshiftDataParameters (Maybe Text)
redshiftDataParameters_statementName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDataParameters' {Maybe Text
statementName :: Maybe Text
$sel:statementName:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
statementName} -> Maybe Text
statementName) (\s :: RedshiftDataParameters
s@RedshiftDataParameters' {} Maybe Text
a -> RedshiftDataParameters
s {$sel:statementName:RedshiftDataParameters' :: Maybe Text
statementName = Maybe Text
a} :: RedshiftDataParameters)

-- | Indicates whether to send an event back to EventBridge after the SQL
-- statement runs.
redshiftDataParameters_withEvent :: Lens.Lens' RedshiftDataParameters (Prelude.Maybe Prelude.Bool)
redshiftDataParameters_withEvent :: Lens' RedshiftDataParameters (Maybe Bool)
redshiftDataParameters_withEvent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDataParameters' {Maybe Bool
withEvent :: Maybe Bool
$sel:withEvent:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Bool
withEvent} -> Maybe Bool
withEvent) (\s :: RedshiftDataParameters
s@RedshiftDataParameters' {} Maybe Bool
a -> RedshiftDataParameters
s {$sel:withEvent:RedshiftDataParameters' :: Maybe Bool
withEvent = Maybe Bool
a} :: RedshiftDataParameters)

-- | The name of the database. Required when authenticating using temporary
-- credentials.
redshiftDataParameters_database :: Lens.Lens' RedshiftDataParameters Prelude.Text
redshiftDataParameters_database :: Lens' RedshiftDataParameters Text
redshiftDataParameters_database = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDataParameters' {Text
database :: Text
$sel:database:RedshiftDataParameters' :: RedshiftDataParameters -> Text
database} -> Text
database) (\s :: RedshiftDataParameters
s@RedshiftDataParameters' {} Text
a -> RedshiftDataParameters
s {$sel:database:RedshiftDataParameters' :: Text
database = Text
a} :: RedshiftDataParameters)

-- | The SQL statement text to run.
redshiftDataParameters_sql :: Lens.Lens' RedshiftDataParameters Prelude.Text
redshiftDataParameters_sql :: Lens' RedshiftDataParameters Text
redshiftDataParameters_sql = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDataParameters' {Text
sql :: Text
$sel:sql:RedshiftDataParameters' :: RedshiftDataParameters -> Text
sql} -> Text
sql) (\s :: RedshiftDataParameters
s@RedshiftDataParameters' {} Text
a -> RedshiftDataParameters
s {$sel:sql:RedshiftDataParameters' :: Text
sql = Text
a} :: RedshiftDataParameters)

instance Data.FromJSON RedshiftDataParameters where
  parseJSON :: Value -> Parser RedshiftDataParameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RedshiftDataParameters"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Text
-> Text
-> RedshiftDataParameters
RedshiftDataParameters'
            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
"DbUser")
            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
"SecretManagerArn")
            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
"StatementName")
            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
"WithEvent")
            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
"Database")
            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
"Sql")
      )

instance Prelude.Hashable RedshiftDataParameters where
  hashWithSalt :: Int -> RedshiftDataParameters -> Int
hashWithSalt Int
_salt RedshiftDataParameters' {Maybe Bool
Maybe Text
Text
sql :: Text
database :: Text
withEvent :: Maybe Bool
statementName :: Maybe Text
secretManagerArn :: Maybe Text
dbUser :: Maybe Text
$sel:sql:RedshiftDataParameters' :: RedshiftDataParameters -> Text
$sel:database:RedshiftDataParameters' :: RedshiftDataParameters -> Text
$sel:withEvent:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Bool
$sel:statementName:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
$sel:secretManagerArn:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
$sel:dbUser:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dbUser
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
secretManagerArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statementName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
withEvent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
database
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sql

instance Prelude.NFData RedshiftDataParameters where
  rnf :: RedshiftDataParameters -> ()
rnf RedshiftDataParameters' {Maybe Bool
Maybe Text
Text
sql :: Text
database :: Text
withEvent :: Maybe Bool
statementName :: Maybe Text
secretManagerArn :: Maybe Text
dbUser :: Maybe Text
$sel:sql:RedshiftDataParameters' :: RedshiftDataParameters -> Text
$sel:database:RedshiftDataParameters' :: RedshiftDataParameters -> Text
$sel:withEvent:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Bool
$sel:statementName:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
$sel:secretManagerArn:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
$sel:dbUser:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dbUser
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
secretManagerArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statementName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
withEvent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
database
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sql

instance Data.ToJSON RedshiftDataParameters where
  toJSON :: RedshiftDataParameters -> Value
toJSON RedshiftDataParameters' {Maybe Bool
Maybe Text
Text
sql :: Text
database :: Text
withEvent :: Maybe Bool
statementName :: Maybe Text
secretManagerArn :: Maybe Text
dbUser :: Maybe Text
$sel:sql:RedshiftDataParameters' :: RedshiftDataParameters -> Text
$sel:database:RedshiftDataParameters' :: RedshiftDataParameters -> Text
$sel:withEvent:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Bool
$sel:statementName:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
$sel:secretManagerArn:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
$sel:dbUser:RedshiftDataParameters' :: RedshiftDataParameters -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DbUser" 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
dbUser,
            (Key
"SecretManagerArn" 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
secretManagerArn,
            (Key
"StatementName" 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
statementName,
            (Key
"WithEvent" 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 Bool
withEvent,
            forall a. a -> Maybe a
Prelude.Just (Key
"Database" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
database),
            forall a. a -> Maybe a
Prelude.Just (Key
"Sql" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sql)
          ]
      )