{-# 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.Kendra.Types.SqlConfiguration
-- 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.Kendra.Types.SqlConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.QueryIdentifiersEnclosingOption
import qualified Amazonka.Prelude as Prelude

-- | Provides the configuration information to use a SQL database.
--
-- /See:/ 'newSqlConfiguration' smart constructor.
data SqlConfiguration = SqlConfiguration'
  { -- | Determines whether Amazon Kendra encloses SQL identifiers for tables and
    -- column names in double quotes (\") when making a database query.
    --
    -- By default, Amazon Kendra passes SQL identifiers the way that they are
    -- entered into the data source configuration. It does not change the case
    -- of identifiers or enclose them in quotes.
    --
    -- PostgreSQL internally converts uppercase characters to lower case
    -- characters in identifiers unless they are quoted. Choosing this option
    -- encloses identifiers in quotes so that PostgreSQL does not convert the
    -- character\'s case.
    --
    -- For MySQL databases, you must enable the @ansi_quotes@ option when you
    -- set this field to @DOUBLE_QUOTES@.
    SqlConfiguration -> Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption :: Prelude.Maybe QueryIdentifiersEnclosingOption
  }
  deriving (SqlConfiguration -> SqlConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SqlConfiguration -> SqlConfiguration -> Bool
$c/= :: SqlConfiguration -> SqlConfiguration -> Bool
== :: SqlConfiguration -> SqlConfiguration -> Bool
$c== :: SqlConfiguration -> SqlConfiguration -> Bool
Prelude.Eq, ReadPrec [SqlConfiguration]
ReadPrec SqlConfiguration
Int -> ReadS SqlConfiguration
ReadS [SqlConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SqlConfiguration]
$creadListPrec :: ReadPrec [SqlConfiguration]
readPrec :: ReadPrec SqlConfiguration
$creadPrec :: ReadPrec SqlConfiguration
readList :: ReadS [SqlConfiguration]
$creadList :: ReadS [SqlConfiguration]
readsPrec :: Int -> ReadS SqlConfiguration
$creadsPrec :: Int -> ReadS SqlConfiguration
Prelude.Read, Int -> SqlConfiguration -> ShowS
[SqlConfiguration] -> ShowS
SqlConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqlConfiguration] -> ShowS
$cshowList :: [SqlConfiguration] -> ShowS
show :: SqlConfiguration -> String
$cshow :: SqlConfiguration -> String
showsPrec :: Int -> SqlConfiguration -> ShowS
$cshowsPrec :: Int -> SqlConfiguration -> ShowS
Prelude.Show, forall x. Rep SqlConfiguration x -> SqlConfiguration
forall x. SqlConfiguration -> Rep SqlConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SqlConfiguration x -> SqlConfiguration
$cfrom :: forall x. SqlConfiguration -> Rep SqlConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SqlConfiguration' 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:
--
-- 'queryIdentifiersEnclosingOption', 'sqlConfiguration_queryIdentifiersEnclosingOption' - Determines whether Amazon Kendra encloses SQL identifiers for tables and
-- column names in double quotes (\") when making a database query.
--
-- By default, Amazon Kendra passes SQL identifiers the way that they are
-- entered into the data source configuration. It does not change the case
-- of identifiers or enclose them in quotes.
--
-- PostgreSQL internally converts uppercase characters to lower case
-- characters in identifiers unless they are quoted. Choosing this option
-- encloses identifiers in quotes so that PostgreSQL does not convert the
-- character\'s case.
--
-- For MySQL databases, you must enable the @ansi_quotes@ option when you
-- set this field to @DOUBLE_QUOTES@.
newSqlConfiguration ::
  SqlConfiguration
newSqlConfiguration :: SqlConfiguration
newSqlConfiguration =
  SqlConfiguration'
    { $sel:queryIdentifiersEnclosingOption:SqlConfiguration' :: Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Determines whether Amazon Kendra encloses SQL identifiers for tables and
-- column names in double quotes (\") when making a database query.
--
-- By default, Amazon Kendra passes SQL identifiers the way that they are
-- entered into the data source configuration. It does not change the case
-- of identifiers or enclose them in quotes.
--
-- PostgreSQL internally converts uppercase characters to lower case
-- characters in identifiers unless they are quoted. Choosing this option
-- encloses identifiers in quotes so that PostgreSQL does not convert the
-- character\'s case.
--
-- For MySQL databases, you must enable the @ansi_quotes@ option when you
-- set this field to @DOUBLE_QUOTES@.
sqlConfiguration_queryIdentifiersEnclosingOption :: Lens.Lens' SqlConfiguration (Prelude.Maybe QueryIdentifiersEnclosingOption)
sqlConfiguration_queryIdentifiersEnclosingOption :: Lens' SqlConfiguration (Maybe QueryIdentifiersEnclosingOption)
sqlConfiguration_queryIdentifiersEnclosingOption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SqlConfiguration' {Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption :: Maybe QueryIdentifiersEnclosingOption
$sel:queryIdentifiersEnclosingOption:SqlConfiguration' :: SqlConfiguration -> Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption} -> Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption) (\s :: SqlConfiguration
s@SqlConfiguration' {} Maybe QueryIdentifiersEnclosingOption
a -> SqlConfiguration
s {$sel:queryIdentifiersEnclosingOption:SqlConfiguration' :: Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption = Maybe QueryIdentifiersEnclosingOption
a} :: SqlConfiguration)

instance Data.FromJSON SqlConfiguration where
  parseJSON :: Value -> Parser SqlConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SqlConfiguration"
      ( \Object
x ->
          Maybe QueryIdentifiersEnclosingOption -> SqlConfiguration
SqlConfiguration'
            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
"QueryIdentifiersEnclosingOption")
      )

instance Prelude.Hashable SqlConfiguration where
  hashWithSalt :: Int -> SqlConfiguration -> Int
hashWithSalt Int
_salt SqlConfiguration' {Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption :: Maybe QueryIdentifiersEnclosingOption
$sel:queryIdentifiersEnclosingOption:SqlConfiguration' :: SqlConfiguration -> Maybe QueryIdentifiersEnclosingOption
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption

instance Prelude.NFData SqlConfiguration where
  rnf :: SqlConfiguration -> ()
rnf SqlConfiguration' {Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption :: Maybe QueryIdentifiersEnclosingOption
$sel:queryIdentifiersEnclosingOption:SqlConfiguration' :: SqlConfiguration -> Maybe QueryIdentifiersEnclosingOption
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption

instance Data.ToJSON SqlConfiguration where
  toJSON :: SqlConfiguration -> Value
toJSON SqlConfiguration' {Maybe QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption :: Maybe QueryIdentifiersEnclosingOption
$sel:queryIdentifiersEnclosingOption:SqlConfiguration' :: SqlConfiguration -> Maybe QueryIdentifiersEnclosingOption
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"QueryIdentifiersEnclosingOption" 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 QueryIdentifiersEnclosingOption
queryIdentifiersEnclosingOption
          ]
      )