{-# 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.Athena.Types.PreparedStatement
-- 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.Athena.Types.PreparedStatement where

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

-- | A prepared SQL statement for use with Athena.
--
-- /See:/ 'newPreparedStatement' smart constructor.
data PreparedStatement = PreparedStatement'
  { -- | The last modified time of the prepared statement.
    PreparedStatement -> Maybe POSIX
lastModifiedTime :: Prelude.Maybe Core.POSIX,
    -- | The query string for the prepared statement.
    PreparedStatement -> Maybe Text
queryStatement :: Prelude.Maybe Prelude.Text,
    -- | The name of the prepared statement.
    PreparedStatement -> Maybe Text
statementName :: Prelude.Maybe Prelude.Text,
    -- | The description of the prepared statement.
    PreparedStatement -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the workgroup to which the prepared statement belongs.
    PreparedStatement -> Maybe Text
workGroupName :: Prelude.Maybe Prelude.Text
  }
  deriving (PreparedStatement -> PreparedStatement -> Bool
(PreparedStatement -> PreparedStatement -> Bool)
-> (PreparedStatement -> PreparedStatement -> Bool)
-> Eq PreparedStatement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PreparedStatement -> PreparedStatement -> Bool
$c/= :: PreparedStatement -> PreparedStatement -> Bool
== :: PreparedStatement -> PreparedStatement -> Bool
$c== :: PreparedStatement -> PreparedStatement -> Bool
Prelude.Eq, ReadPrec [PreparedStatement]
ReadPrec PreparedStatement
Int -> ReadS PreparedStatement
ReadS [PreparedStatement]
(Int -> ReadS PreparedStatement)
-> ReadS [PreparedStatement]
-> ReadPrec PreparedStatement
-> ReadPrec [PreparedStatement]
-> Read PreparedStatement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PreparedStatement]
$creadListPrec :: ReadPrec [PreparedStatement]
readPrec :: ReadPrec PreparedStatement
$creadPrec :: ReadPrec PreparedStatement
readList :: ReadS [PreparedStatement]
$creadList :: ReadS [PreparedStatement]
readsPrec :: Int -> ReadS PreparedStatement
$creadsPrec :: Int -> ReadS PreparedStatement
Prelude.Read, Int -> PreparedStatement -> ShowS
[PreparedStatement] -> ShowS
PreparedStatement -> String
(Int -> PreparedStatement -> ShowS)
-> (PreparedStatement -> String)
-> ([PreparedStatement] -> ShowS)
-> Show PreparedStatement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PreparedStatement] -> ShowS
$cshowList :: [PreparedStatement] -> ShowS
show :: PreparedStatement -> String
$cshow :: PreparedStatement -> String
showsPrec :: Int -> PreparedStatement -> ShowS
$cshowsPrec :: Int -> PreparedStatement -> ShowS
Prelude.Show, (forall x. PreparedStatement -> Rep PreparedStatement x)
-> (forall x. Rep PreparedStatement x -> PreparedStatement)
-> Generic PreparedStatement
forall x. Rep PreparedStatement x -> PreparedStatement
forall x. PreparedStatement -> Rep PreparedStatement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PreparedStatement x -> PreparedStatement
$cfrom :: forall x. PreparedStatement -> Rep PreparedStatement x
Prelude.Generic)

-- |
-- Create a value of 'PreparedStatement' 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:
--
-- 'lastModifiedTime', 'preparedStatement_lastModifiedTime' - The last modified time of the prepared statement.
--
-- 'queryStatement', 'preparedStatement_queryStatement' - The query string for the prepared statement.
--
-- 'statementName', 'preparedStatement_statementName' - The name of the prepared statement.
--
-- 'description', 'preparedStatement_description' - The description of the prepared statement.
--
-- 'workGroupName', 'preparedStatement_workGroupName' - The name of the workgroup to which the prepared statement belongs.
newPreparedStatement ::
  PreparedStatement
newPreparedStatement :: PreparedStatement
newPreparedStatement =
  PreparedStatement' :: Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PreparedStatement
PreparedStatement'
    { $sel:lastModifiedTime:PreparedStatement' :: Maybe POSIX
lastModifiedTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:queryStatement:PreparedStatement' :: Maybe Text
queryStatement = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statementName:PreparedStatement' :: Maybe Text
statementName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:PreparedStatement' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:workGroupName:PreparedStatement' :: Maybe Text
workGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The last modified time of the prepared statement.
preparedStatement_lastModifiedTime :: Lens.Lens' PreparedStatement (Prelude.Maybe Prelude.UTCTime)
preparedStatement_lastModifiedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PreparedStatement -> f PreparedStatement
preparedStatement_lastModifiedTime = (PreparedStatement -> Maybe POSIX)
-> (PreparedStatement -> Maybe POSIX -> PreparedStatement)
-> Lens
     PreparedStatement PreparedStatement (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PreparedStatement' {Maybe POSIX
lastModifiedTime :: Maybe POSIX
$sel:lastModifiedTime:PreparedStatement' :: PreparedStatement -> Maybe POSIX
lastModifiedTime} -> Maybe POSIX
lastModifiedTime) (\s :: PreparedStatement
s@PreparedStatement' {} Maybe POSIX
a -> PreparedStatement
s {$sel:lastModifiedTime:PreparedStatement' :: Maybe POSIX
lastModifiedTime = Maybe POSIX
a} :: PreparedStatement) ((Maybe POSIX -> f (Maybe POSIX))
 -> PreparedStatement -> f PreparedStatement)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PreparedStatement
-> f PreparedStatement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The query string for the prepared statement.
preparedStatement_queryStatement :: Lens.Lens' PreparedStatement (Prelude.Maybe Prelude.Text)
preparedStatement_queryStatement :: (Maybe Text -> f (Maybe Text))
-> PreparedStatement -> f PreparedStatement
preparedStatement_queryStatement = (PreparedStatement -> Maybe Text)
-> (PreparedStatement -> Maybe Text -> PreparedStatement)
-> Lens
     PreparedStatement PreparedStatement (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PreparedStatement' {Maybe Text
queryStatement :: Maybe Text
$sel:queryStatement:PreparedStatement' :: PreparedStatement -> Maybe Text
queryStatement} -> Maybe Text
queryStatement) (\s :: PreparedStatement
s@PreparedStatement' {} Maybe Text
a -> PreparedStatement
s {$sel:queryStatement:PreparedStatement' :: Maybe Text
queryStatement = Maybe Text
a} :: PreparedStatement)

-- | The name of the prepared statement.
preparedStatement_statementName :: Lens.Lens' PreparedStatement (Prelude.Maybe Prelude.Text)
preparedStatement_statementName :: (Maybe Text -> f (Maybe Text))
-> PreparedStatement -> f PreparedStatement
preparedStatement_statementName = (PreparedStatement -> Maybe Text)
-> (PreparedStatement -> Maybe Text -> PreparedStatement)
-> Lens
     PreparedStatement PreparedStatement (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PreparedStatement' {Maybe Text
statementName :: Maybe Text
$sel:statementName:PreparedStatement' :: PreparedStatement -> Maybe Text
statementName} -> Maybe Text
statementName) (\s :: PreparedStatement
s@PreparedStatement' {} Maybe Text
a -> PreparedStatement
s {$sel:statementName:PreparedStatement' :: Maybe Text
statementName = Maybe Text
a} :: PreparedStatement)

-- | The description of the prepared statement.
preparedStatement_description :: Lens.Lens' PreparedStatement (Prelude.Maybe Prelude.Text)
preparedStatement_description :: (Maybe Text -> f (Maybe Text))
-> PreparedStatement -> f PreparedStatement
preparedStatement_description = (PreparedStatement -> Maybe Text)
-> (PreparedStatement -> Maybe Text -> PreparedStatement)
-> Lens
     PreparedStatement PreparedStatement (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PreparedStatement' {Maybe Text
description :: Maybe Text
$sel:description:PreparedStatement' :: PreparedStatement -> Maybe Text
description} -> Maybe Text
description) (\s :: PreparedStatement
s@PreparedStatement' {} Maybe Text
a -> PreparedStatement
s {$sel:description:PreparedStatement' :: Maybe Text
description = Maybe Text
a} :: PreparedStatement)

-- | The name of the workgroup to which the prepared statement belongs.
preparedStatement_workGroupName :: Lens.Lens' PreparedStatement (Prelude.Maybe Prelude.Text)
preparedStatement_workGroupName :: (Maybe Text -> f (Maybe Text))
-> PreparedStatement -> f PreparedStatement
preparedStatement_workGroupName = (PreparedStatement -> Maybe Text)
-> (PreparedStatement -> Maybe Text -> PreparedStatement)
-> Lens
     PreparedStatement PreparedStatement (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PreparedStatement' {Maybe Text
workGroupName :: Maybe Text
$sel:workGroupName:PreparedStatement' :: PreparedStatement -> Maybe Text
workGroupName} -> Maybe Text
workGroupName) (\s :: PreparedStatement
s@PreparedStatement' {} Maybe Text
a -> PreparedStatement
s {$sel:workGroupName:PreparedStatement' :: Maybe Text
workGroupName = Maybe Text
a} :: PreparedStatement)

instance Core.FromJSON PreparedStatement where
  parseJSON :: Value -> Parser PreparedStatement
parseJSON =
    String
-> (Object -> Parser PreparedStatement)
-> Value
-> Parser PreparedStatement
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PreparedStatement"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PreparedStatement
PreparedStatement'
            (Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> PreparedStatement)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> PreparedStatement)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastModifiedTime")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> PreparedStatement)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> PreparedStatement)
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
"QueryStatement")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> PreparedStatement)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> PreparedStatement)
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 Text -> Maybe Text -> PreparedStatement)
-> Parser (Maybe Text) -> Parser (Maybe Text -> PreparedStatement)
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
"Description")
            Parser (Maybe Text -> PreparedStatement)
-> Parser (Maybe Text) -> Parser PreparedStatement
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
"WorkGroupName")
      )

instance Prelude.Hashable PreparedStatement

instance Prelude.NFData PreparedStatement