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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(RedshiftDataParameters -> RedshiftDataParameters -> Bool)
-> (RedshiftDataParameters -> RedshiftDataParameters -> Bool)
-> Eq RedshiftDataParameters
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]
(Int -> ReadS RedshiftDataParameters)
-> ReadS [RedshiftDataParameters]
-> ReadPrec RedshiftDataParameters
-> ReadPrec [RedshiftDataParameters]
-> Read 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
(Int -> RedshiftDataParameters -> ShowS)
-> (RedshiftDataParameters -> String)
-> ([RedshiftDataParameters] -> ShowS)
-> Show RedshiftDataParameters
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. RedshiftDataParameters -> Rep RedshiftDataParameters x)
-> (forall x.
    Rep RedshiftDataParameters x -> RedshiftDataParameters)
-> Generic RedshiftDataParameters
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' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Text
-> Text
-> RedshiftDataParameters
RedshiftDataParameters'
    { $sel:dbUser:RedshiftDataParameters' :: Maybe Text
dbUser = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretManagerArn:RedshiftDataParameters' :: Maybe Text
secretManagerArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statementName:RedshiftDataParameters' :: Maybe Text
statementName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:withEvent:RedshiftDataParameters' :: Maybe Bool
withEvent = Maybe Bool
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 :: (Maybe Text -> f (Maybe Text))
-> RedshiftDataParameters -> f RedshiftDataParameters
redshiftDataParameters_dbUser = (RedshiftDataParameters -> Maybe Text)
-> (RedshiftDataParameters -> Maybe Text -> RedshiftDataParameters)
-> Lens
     RedshiftDataParameters
     RedshiftDataParameters
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> RedshiftDataParameters -> f RedshiftDataParameters
redshiftDataParameters_secretManagerArn = (RedshiftDataParameters -> Maybe Text)
-> (RedshiftDataParameters -> Maybe Text -> RedshiftDataParameters)
-> Lens
     RedshiftDataParameters
     RedshiftDataParameters
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> RedshiftDataParameters -> f RedshiftDataParameters
redshiftDataParameters_statementName = (RedshiftDataParameters -> Maybe Text)
-> (RedshiftDataParameters -> Maybe Text -> RedshiftDataParameters)
-> Lens
     RedshiftDataParameters
     RedshiftDataParameters
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Bool -> f (Maybe Bool))
-> RedshiftDataParameters -> f RedshiftDataParameters
redshiftDataParameters_withEvent = (RedshiftDataParameters -> Maybe Bool)
-> (RedshiftDataParameters -> Maybe Bool -> RedshiftDataParameters)
-> Lens
     RedshiftDataParameters
     RedshiftDataParameters
     (Maybe Bool)
     (Maybe Bool)
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 :: (Text -> f Text)
-> RedshiftDataParameters -> f RedshiftDataParameters
redshiftDataParameters_database = (RedshiftDataParameters -> Text)
-> (RedshiftDataParameters -> Text -> RedshiftDataParameters)
-> Lens RedshiftDataParameters RedshiftDataParameters Text Text
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 :: (Text -> f Text)
-> RedshiftDataParameters -> f RedshiftDataParameters
redshiftDataParameters_sql = (RedshiftDataParameters -> Text)
-> (RedshiftDataParameters -> Text -> RedshiftDataParameters)
-> Lens RedshiftDataParameters RedshiftDataParameters Text Text
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 Core.FromJSON RedshiftDataParameters where
  parseJSON :: Value -> Parser RedshiftDataParameters
parseJSON =
    String
-> (Object -> Parser RedshiftDataParameters)
-> Value
-> Parser RedshiftDataParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RedshiftDataParameters"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Text
-> Text
-> RedshiftDataParameters
RedshiftDataParameters'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Bool
 -> Text
 -> Text
 -> RedshiftDataParameters)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Bool
      -> Text
      -> Text
      -> RedshiftDataParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DbUser")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Bool
   -> Text
   -> Text
   -> RedshiftDataParameters)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Bool -> Text -> Text -> RedshiftDataParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SecretManagerArn")
            Parser
  (Maybe Text
   -> Maybe Bool -> Text -> Text -> RedshiftDataParameters)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> Text -> Text -> RedshiftDataParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatementName")
            Parser (Maybe Bool -> Text -> Text -> RedshiftDataParameters)
-> Parser (Maybe Bool)
-> Parser (Text -> Text -> RedshiftDataParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"WithEvent")
            Parser (Text -> Text -> RedshiftDataParameters)
-> Parser Text -> Parser (Text -> RedshiftDataParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Database")
            Parser (Text -> RedshiftDataParameters)
-> Parser Text -> Parser RedshiftDataParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Sql")
      )

instance Prelude.Hashable RedshiftDataParameters

instance Prelude.NFData RedshiftDataParameters

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DbUser" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dbUser,
            (Text
"SecretManagerArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
secretManagerArn,
            (Text
"StatementName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
statementName,
            (Text
"WithEvent" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
withEvent,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Database" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
database),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Sql" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sql)
          ]
      )