{-# 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.RDSData.Types.SqlParameter
-- 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.RDSData.Types.SqlParameter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDSData.Types.Field
import Amazonka.RDSData.Types.TypeHint

-- | A parameter used in a SQL statement.
--
-- /See:/ 'newSqlParameter' smart constructor.
data SqlParameter = SqlParameter'
  { -- | The value of the parameter.
    SqlParameter -> Maybe Field
value :: Prelude.Maybe Field,
    -- | The name of the parameter.
    SqlParameter -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A hint that specifies the correct object type for data type mapping.
    -- Possible values are as follows:
    --
    -- -   @DATE@ - The corresponding @String@ parameter value is sent as an
    --     object of @DATE@ type to the database. The accepted format is
    --     @YYYY-MM-DD@.
    --
    -- -   @DECIMAL@ - The corresponding @String@ parameter value is sent as an
    --     object of @DECIMAL@ type to the database.
    --
    -- -   @JSON@ - The corresponding @String@ parameter value is sent as an
    --     object of @JSON@ type to the database.
    --
    -- -   @TIME@ - The corresponding @String@ parameter value is sent as an
    --     object of @TIME@ type to the database. The accepted format is
    --     @HH:MM:SS[.FFF]@.
    --
    -- -   @TIMESTAMP@ - The corresponding @String@ parameter value is sent as
    --     an object of @TIMESTAMP@ type to the database. The accepted format
    --     is @YYYY-MM-DD HH:MM:SS[.FFF]@.
    --
    -- -   @UUID@ - The corresponding @String@ parameter value is sent as an
    --     object of @UUID@ type to the database.
    SqlParameter -> Maybe TypeHint
typeHint :: Prelude.Maybe TypeHint
  }
  deriving (SqlParameter -> SqlParameter -> Bool
(SqlParameter -> SqlParameter -> Bool)
-> (SqlParameter -> SqlParameter -> Bool) -> Eq SqlParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SqlParameter -> SqlParameter -> Bool
$c/= :: SqlParameter -> SqlParameter -> Bool
== :: SqlParameter -> SqlParameter -> Bool
$c== :: SqlParameter -> SqlParameter -> Bool
Prelude.Eq, ReadPrec [SqlParameter]
ReadPrec SqlParameter
Int -> ReadS SqlParameter
ReadS [SqlParameter]
(Int -> ReadS SqlParameter)
-> ReadS [SqlParameter]
-> ReadPrec SqlParameter
-> ReadPrec [SqlParameter]
-> Read SqlParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SqlParameter]
$creadListPrec :: ReadPrec [SqlParameter]
readPrec :: ReadPrec SqlParameter
$creadPrec :: ReadPrec SqlParameter
readList :: ReadS [SqlParameter]
$creadList :: ReadS [SqlParameter]
readsPrec :: Int -> ReadS SqlParameter
$creadsPrec :: Int -> ReadS SqlParameter
Prelude.Read, Int -> SqlParameter -> ShowS
[SqlParameter] -> ShowS
SqlParameter -> String
(Int -> SqlParameter -> ShowS)
-> (SqlParameter -> String)
-> ([SqlParameter] -> ShowS)
-> Show SqlParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqlParameter] -> ShowS
$cshowList :: [SqlParameter] -> ShowS
show :: SqlParameter -> String
$cshow :: SqlParameter -> String
showsPrec :: Int -> SqlParameter -> ShowS
$cshowsPrec :: Int -> SqlParameter -> ShowS
Prelude.Show, (forall x. SqlParameter -> Rep SqlParameter x)
-> (forall x. Rep SqlParameter x -> SqlParameter)
-> Generic SqlParameter
forall x. Rep SqlParameter x -> SqlParameter
forall x. SqlParameter -> Rep SqlParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SqlParameter x -> SqlParameter
$cfrom :: forall x. SqlParameter -> Rep SqlParameter x
Prelude.Generic)

-- |
-- Create a value of 'SqlParameter' 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:
--
-- 'value', 'sqlParameter_value' - The value of the parameter.
--
-- 'name', 'sqlParameter_name' - The name of the parameter.
--
-- 'typeHint', 'sqlParameter_typeHint' - A hint that specifies the correct object type for data type mapping.
-- Possible values are as follows:
--
-- -   @DATE@ - The corresponding @String@ parameter value is sent as an
--     object of @DATE@ type to the database. The accepted format is
--     @YYYY-MM-DD@.
--
-- -   @DECIMAL@ - The corresponding @String@ parameter value is sent as an
--     object of @DECIMAL@ type to the database.
--
-- -   @JSON@ - The corresponding @String@ parameter value is sent as an
--     object of @JSON@ type to the database.
--
-- -   @TIME@ - The corresponding @String@ parameter value is sent as an
--     object of @TIME@ type to the database. The accepted format is
--     @HH:MM:SS[.FFF]@.
--
-- -   @TIMESTAMP@ - The corresponding @String@ parameter value is sent as
--     an object of @TIMESTAMP@ type to the database. The accepted format
--     is @YYYY-MM-DD HH:MM:SS[.FFF]@.
--
-- -   @UUID@ - The corresponding @String@ parameter value is sent as an
--     object of @UUID@ type to the database.
newSqlParameter ::
  SqlParameter
newSqlParameter :: SqlParameter
newSqlParameter =
  SqlParameter' :: Maybe Field -> Maybe Text -> Maybe TypeHint -> SqlParameter
SqlParameter'
    { $sel:value:SqlParameter' :: Maybe Field
value = Maybe Field
forall a. Maybe a
Prelude.Nothing,
      $sel:name:SqlParameter' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:typeHint:SqlParameter' :: Maybe TypeHint
typeHint = Maybe TypeHint
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the parameter.
sqlParameter_value :: Lens.Lens' SqlParameter (Prelude.Maybe Field)
sqlParameter_value :: (Maybe Field -> f (Maybe Field)) -> SqlParameter -> f SqlParameter
sqlParameter_value = (SqlParameter -> Maybe Field)
-> (SqlParameter -> Maybe Field -> SqlParameter)
-> Lens SqlParameter SqlParameter (Maybe Field) (Maybe Field)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SqlParameter' {Maybe Field
value :: Maybe Field
$sel:value:SqlParameter' :: SqlParameter -> Maybe Field
value} -> Maybe Field
value) (\s :: SqlParameter
s@SqlParameter' {} Maybe Field
a -> SqlParameter
s {$sel:value:SqlParameter' :: Maybe Field
value = Maybe Field
a} :: SqlParameter)

-- | The name of the parameter.
sqlParameter_name :: Lens.Lens' SqlParameter (Prelude.Maybe Prelude.Text)
sqlParameter_name :: (Maybe Text -> f (Maybe Text)) -> SqlParameter -> f SqlParameter
sqlParameter_name = (SqlParameter -> Maybe Text)
-> (SqlParameter -> Maybe Text -> SqlParameter)
-> Lens SqlParameter SqlParameter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SqlParameter' {Maybe Text
name :: Maybe Text
$sel:name:SqlParameter' :: SqlParameter -> Maybe Text
name} -> Maybe Text
name) (\s :: SqlParameter
s@SqlParameter' {} Maybe Text
a -> SqlParameter
s {$sel:name:SqlParameter' :: Maybe Text
name = Maybe Text
a} :: SqlParameter)

-- | A hint that specifies the correct object type for data type mapping.
-- Possible values are as follows:
--
-- -   @DATE@ - The corresponding @String@ parameter value is sent as an
--     object of @DATE@ type to the database. The accepted format is
--     @YYYY-MM-DD@.
--
-- -   @DECIMAL@ - The corresponding @String@ parameter value is sent as an
--     object of @DECIMAL@ type to the database.
--
-- -   @JSON@ - The corresponding @String@ parameter value is sent as an
--     object of @JSON@ type to the database.
--
-- -   @TIME@ - The corresponding @String@ parameter value is sent as an
--     object of @TIME@ type to the database. The accepted format is
--     @HH:MM:SS[.FFF]@.
--
-- -   @TIMESTAMP@ - The corresponding @String@ parameter value is sent as
--     an object of @TIMESTAMP@ type to the database. The accepted format
--     is @YYYY-MM-DD HH:MM:SS[.FFF]@.
--
-- -   @UUID@ - The corresponding @String@ parameter value is sent as an
--     object of @UUID@ type to the database.
sqlParameter_typeHint :: Lens.Lens' SqlParameter (Prelude.Maybe TypeHint)
sqlParameter_typeHint :: (Maybe TypeHint -> f (Maybe TypeHint))
-> SqlParameter -> f SqlParameter
sqlParameter_typeHint = (SqlParameter -> Maybe TypeHint)
-> (SqlParameter -> Maybe TypeHint -> SqlParameter)
-> Lens SqlParameter SqlParameter (Maybe TypeHint) (Maybe TypeHint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SqlParameter' {Maybe TypeHint
typeHint :: Maybe TypeHint
$sel:typeHint:SqlParameter' :: SqlParameter -> Maybe TypeHint
typeHint} -> Maybe TypeHint
typeHint) (\s :: SqlParameter
s@SqlParameter' {} Maybe TypeHint
a -> SqlParameter
s {$sel:typeHint:SqlParameter' :: Maybe TypeHint
typeHint = Maybe TypeHint
a} :: SqlParameter)

instance Prelude.Hashable SqlParameter

instance Prelude.NFData SqlParameter

instance Core.ToJSON SqlParameter where
  toJSON :: SqlParameter -> Value
toJSON SqlParameter' {Maybe Text
Maybe Field
Maybe TypeHint
typeHint :: Maybe TypeHint
name :: Maybe Text
value :: Maybe Field
$sel:typeHint:SqlParameter' :: SqlParameter -> Maybe TypeHint
$sel:name:SqlParameter' :: SqlParameter -> Maybe Text
$sel:value:SqlParameter' :: SqlParameter -> Maybe Field
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"value" Text -> Field -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Field -> Pair) -> Maybe Field -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Field
value,
            (Text
"name" 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
name,
            (Text
"typeHint" Text -> TypeHint -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TypeHint -> Pair) -> Maybe TypeHint -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TypeHint
typeHint
          ]
      )