{-# 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.Glue.Types.MicrosoftSQLServerCatalogSource
-- 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.Glue.Types.MicrosoftSQLServerCatalogSource 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

-- | Specifies a Microsoft SQL server data source in the Glue Data Catalog.
--
-- /See:/ 'newMicrosoftSQLServerCatalogSource' smart constructor.
data MicrosoftSQLServerCatalogSource = MicrosoftSQLServerCatalogSource'
  { -- | The name of the data source.
    MicrosoftSQLServerCatalogSource -> Text
name :: Prelude.Text,
    -- | The name of the database to read from.
    MicrosoftSQLServerCatalogSource -> Text
database :: Prelude.Text,
    -- | The name of the table in the database to read from.
    MicrosoftSQLServerCatalogSource -> Text
table :: Prelude.Text
  }
  deriving (MicrosoftSQLServerCatalogSource
-> MicrosoftSQLServerCatalogSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MicrosoftSQLServerCatalogSource
-> MicrosoftSQLServerCatalogSource -> Bool
$c/= :: MicrosoftSQLServerCatalogSource
-> MicrosoftSQLServerCatalogSource -> Bool
== :: MicrosoftSQLServerCatalogSource
-> MicrosoftSQLServerCatalogSource -> Bool
$c== :: MicrosoftSQLServerCatalogSource
-> MicrosoftSQLServerCatalogSource -> Bool
Prelude.Eq, ReadPrec [MicrosoftSQLServerCatalogSource]
ReadPrec MicrosoftSQLServerCatalogSource
Int -> ReadS MicrosoftSQLServerCatalogSource
ReadS [MicrosoftSQLServerCatalogSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MicrosoftSQLServerCatalogSource]
$creadListPrec :: ReadPrec [MicrosoftSQLServerCatalogSource]
readPrec :: ReadPrec MicrosoftSQLServerCatalogSource
$creadPrec :: ReadPrec MicrosoftSQLServerCatalogSource
readList :: ReadS [MicrosoftSQLServerCatalogSource]
$creadList :: ReadS [MicrosoftSQLServerCatalogSource]
readsPrec :: Int -> ReadS MicrosoftSQLServerCatalogSource
$creadsPrec :: Int -> ReadS MicrosoftSQLServerCatalogSource
Prelude.Read, Int -> MicrosoftSQLServerCatalogSource -> ShowS
[MicrosoftSQLServerCatalogSource] -> ShowS
MicrosoftSQLServerCatalogSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MicrosoftSQLServerCatalogSource] -> ShowS
$cshowList :: [MicrosoftSQLServerCatalogSource] -> ShowS
show :: MicrosoftSQLServerCatalogSource -> String
$cshow :: MicrosoftSQLServerCatalogSource -> String
showsPrec :: Int -> MicrosoftSQLServerCatalogSource -> ShowS
$cshowsPrec :: Int -> MicrosoftSQLServerCatalogSource -> ShowS
Prelude.Show, forall x.
Rep MicrosoftSQLServerCatalogSource x
-> MicrosoftSQLServerCatalogSource
forall x.
MicrosoftSQLServerCatalogSource
-> Rep MicrosoftSQLServerCatalogSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep MicrosoftSQLServerCatalogSource x
-> MicrosoftSQLServerCatalogSource
$cfrom :: forall x.
MicrosoftSQLServerCatalogSource
-> Rep MicrosoftSQLServerCatalogSource x
Prelude.Generic)

-- |
-- Create a value of 'MicrosoftSQLServerCatalogSource' 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', 'microsoftSQLServerCatalogSource_name' - The name of the data source.
--
-- 'database', 'microsoftSQLServerCatalogSource_database' - The name of the database to read from.
--
-- 'table', 'microsoftSQLServerCatalogSource_table' - The name of the table in the database to read from.
newMicrosoftSQLServerCatalogSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  MicrosoftSQLServerCatalogSource
newMicrosoftSQLServerCatalogSource :: Text -> Text -> Text -> MicrosoftSQLServerCatalogSource
newMicrosoftSQLServerCatalogSource
  Text
pName_
  Text
pDatabase_
  Text
pTable_ =
    MicrosoftSQLServerCatalogSource'
      { $sel:name:MicrosoftSQLServerCatalogSource' :: Text
name = Text
pName_,
        $sel:database:MicrosoftSQLServerCatalogSource' :: Text
database = Text
pDatabase_,
        $sel:table:MicrosoftSQLServerCatalogSource' :: Text
table = Text
pTable_
      }

-- | The name of the data source.
microsoftSQLServerCatalogSource_name :: Lens.Lens' MicrosoftSQLServerCatalogSource Prelude.Text
microsoftSQLServerCatalogSource_name :: Lens' MicrosoftSQLServerCatalogSource Text
microsoftSQLServerCatalogSource_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MicrosoftSQLServerCatalogSource' {Text
name :: Text
$sel:name:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
name} -> Text
name) (\s :: MicrosoftSQLServerCatalogSource
s@MicrosoftSQLServerCatalogSource' {} Text
a -> MicrosoftSQLServerCatalogSource
s {$sel:name:MicrosoftSQLServerCatalogSource' :: Text
name = Text
a} :: MicrosoftSQLServerCatalogSource)

-- | The name of the database to read from.
microsoftSQLServerCatalogSource_database :: Lens.Lens' MicrosoftSQLServerCatalogSource Prelude.Text
microsoftSQLServerCatalogSource_database :: Lens' MicrosoftSQLServerCatalogSource Text
microsoftSQLServerCatalogSource_database = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MicrosoftSQLServerCatalogSource' {Text
database :: Text
$sel:database:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
database} -> Text
database) (\s :: MicrosoftSQLServerCatalogSource
s@MicrosoftSQLServerCatalogSource' {} Text
a -> MicrosoftSQLServerCatalogSource
s {$sel:database:MicrosoftSQLServerCatalogSource' :: Text
database = Text
a} :: MicrosoftSQLServerCatalogSource)

-- | The name of the table in the database to read from.
microsoftSQLServerCatalogSource_table :: Lens.Lens' MicrosoftSQLServerCatalogSource Prelude.Text
microsoftSQLServerCatalogSource_table :: Lens' MicrosoftSQLServerCatalogSource Text
microsoftSQLServerCatalogSource_table = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MicrosoftSQLServerCatalogSource' {Text
table :: Text
$sel:table:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
table} -> Text
table) (\s :: MicrosoftSQLServerCatalogSource
s@MicrosoftSQLServerCatalogSource' {} Text
a -> MicrosoftSQLServerCatalogSource
s {$sel:table:MicrosoftSQLServerCatalogSource' :: Text
table = Text
a} :: MicrosoftSQLServerCatalogSource)

instance
  Data.FromJSON
    MicrosoftSQLServerCatalogSource
  where
  parseJSON :: Value -> Parser MicrosoftSQLServerCatalogSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MicrosoftSQLServerCatalogSource"
      ( \Object
x ->
          Text -> Text -> Text -> MicrosoftSQLServerCatalogSource
MicrosoftSQLServerCatalogSource'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Database")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Table")
      )

instance
  Prelude.Hashable
    MicrosoftSQLServerCatalogSource
  where
  hashWithSalt :: Int -> MicrosoftSQLServerCatalogSource -> Int
hashWithSalt
    Int
_salt
    MicrosoftSQLServerCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
$sel:database:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
$sel:name:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
database
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
table

instance
  Prelude.NFData
    MicrosoftSQLServerCatalogSource
  where
  rnf :: MicrosoftSQLServerCatalogSource -> ()
rnf MicrosoftSQLServerCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
$sel:database:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
$sel:name:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
database
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
table

instance Data.ToJSON MicrosoftSQLServerCatalogSource where
  toJSON :: MicrosoftSQLServerCatalogSource -> Value
toJSON MicrosoftSQLServerCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
$sel:database:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
$sel:name:MicrosoftSQLServerCatalogSource' :: MicrosoftSQLServerCatalogSource -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Database" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
database),
            forall a. a -> Maybe a
Prelude.Just (Key
"Table" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
table)
          ]
      )