{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RDSData.Types.SqlParameter 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
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 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,
    -- | The value of the parameter.
    SqlParameter -> Maybe Field
value :: Prelude.Maybe Field
  }
  deriving (SqlParameter -> SqlParameter -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'value', 'sqlParameter_value' - The value of the parameter.
newSqlParameter ::
  SqlParameter
newSqlParameter :: SqlParameter
newSqlParameter =
  SqlParameter'
    { $sel:name:SqlParameter' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:typeHint:SqlParameter' :: Maybe TypeHint
typeHint = forall a. Maybe a
Prelude.Nothing,
      $sel:value:SqlParameter' :: Maybe Field
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the parameter.
sqlParameter_name :: Lens.Lens' SqlParameter (Prelude.Maybe Prelude.Text)
sqlParameter_name :: Lens' SqlParameter (Maybe Text)
sqlParameter_name = 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 :: Lens' SqlParameter (Maybe TypeHint)
sqlParameter_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)

-- | The value of the parameter.
sqlParameter_value :: Lens.Lens' SqlParameter (Prelude.Maybe Field)
sqlParameter_value :: Lens' SqlParameter (Maybe Field)
sqlParameter_value = 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)

instance Prelude.Hashable SqlParameter where
  hashWithSalt :: Int -> SqlParameter -> Int
hashWithSalt Int
_salt SqlParameter' {Maybe Text
Maybe Field
Maybe TypeHint
value :: Maybe Field
typeHint :: Maybe TypeHint
name :: Maybe Text
$sel:value:SqlParameter' :: SqlParameter -> Maybe Field
$sel:typeHint:SqlParameter' :: SqlParameter -> Maybe TypeHint
$sel:name:SqlParameter' :: SqlParameter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TypeHint
typeHint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Field
value

instance Prelude.NFData SqlParameter where
  rnf :: SqlParameter -> ()
rnf SqlParameter' {Maybe Text
Maybe Field
Maybe TypeHint
value :: Maybe Field
typeHint :: Maybe TypeHint
name :: Maybe Text
$sel:value:SqlParameter' :: SqlParameter -> Maybe Field
$sel:typeHint:SqlParameter' :: SqlParameter -> Maybe TypeHint
$sel:name:SqlParameter' :: SqlParameter -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TypeHint
typeHint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Field
value

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