{-# 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.QuickSight.Types.RelationalTable
-- 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.QuickSight.Types.RelationalTable 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.QuickSight.Types.InputColumn

-- | A physical table type for relational data sources.
--
-- /See:/ 'newRelationalTable' smart constructor.
data RelationalTable = RelationalTable'
  { -- | The catalog associated with a table.
    RelationalTable -> Maybe Text
catalog :: Prelude.Maybe Prelude.Text,
    -- | The schema name. This name applies to certain relational database
    -- engines.
    RelationalTable -> Maybe Text
schema :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the data source.
    RelationalTable -> Text
dataSourceArn :: Prelude.Text,
    -- | The name of the relational table.
    RelationalTable -> Text
name :: Prelude.Text,
    -- | The column schema of the table.
    RelationalTable -> NonEmpty InputColumn
inputColumns :: Prelude.NonEmpty InputColumn
  }
  deriving (RelationalTable -> RelationalTable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelationalTable -> RelationalTable -> Bool
$c/= :: RelationalTable -> RelationalTable -> Bool
== :: RelationalTable -> RelationalTable -> Bool
$c== :: RelationalTable -> RelationalTable -> Bool
Prelude.Eq, ReadPrec [RelationalTable]
ReadPrec RelationalTable
Int -> ReadS RelationalTable
ReadS [RelationalTable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelationalTable]
$creadListPrec :: ReadPrec [RelationalTable]
readPrec :: ReadPrec RelationalTable
$creadPrec :: ReadPrec RelationalTable
readList :: ReadS [RelationalTable]
$creadList :: ReadS [RelationalTable]
readsPrec :: Int -> ReadS RelationalTable
$creadsPrec :: Int -> ReadS RelationalTable
Prelude.Read, Int -> RelationalTable -> ShowS
[RelationalTable] -> ShowS
RelationalTable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelationalTable] -> ShowS
$cshowList :: [RelationalTable] -> ShowS
show :: RelationalTable -> String
$cshow :: RelationalTable -> String
showsPrec :: Int -> RelationalTable -> ShowS
$cshowsPrec :: Int -> RelationalTable -> ShowS
Prelude.Show, forall x. Rep RelationalTable x -> RelationalTable
forall x. RelationalTable -> Rep RelationalTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RelationalTable x -> RelationalTable
$cfrom :: forall x. RelationalTable -> Rep RelationalTable x
Prelude.Generic)

-- |
-- Create a value of 'RelationalTable' 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:
--
-- 'catalog', 'relationalTable_catalog' - The catalog associated with a table.
--
-- 'schema', 'relationalTable_schema' - The schema name. This name applies to certain relational database
-- engines.
--
-- 'dataSourceArn', 'relationalTable_dataSourceArn' - The Amazon Resource Name (ARN) for the data source.
--
-- 'name', 'relationalTable_name' - The name of the relational table.
--
-- 'inputColumns', 'relationalTable_inputColumns' - The column schema of the table.
newRelationalTable ::
  -- | 'dataSourceArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'inputColumns'
  Prelude.NonEmpty InputColumn ->
  RelationalTable
newRelationalTable :: Text -> Text -> NonEmpty InputColumn -> RelationalTable
newRelationalTable
  Text
pDataSourceArn_
  Text
pName_
  NonEmpty InputColumn
pInputColumns_ =
    RelationalTable'
      { $sel:catalog:RelationalTable' :: Maybe Text
catalog = forall a. Maybe a
Prelude.Nothing,
        $sel:schema:RelationalTable' :: Maybe Text
schema = forall a. Maybe a
Prelude.Nothing,
        $sel:dataSourceArn:RelationalTable' :: Text
dataSourceArn = Text
pDataSourceArn_,
        $sel:name:RelationalTable' :: Text
name = Text
pName_,
        $sel:inputColumns:RelationalTable' :: NonEmpty InputColumn
inputColumns = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty InputColumn
pInputColumns_
      }

-- | The catalog associated with a table.
relationalTable_catalog :: Lens.Lens' RelationalTable (Prelude.Maybe Prelude.Text)
relationalTable_catalog :: Lens' RelationalTable (Maybe Text)
relationalTable_catalog = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalTable' {Maybe Text
catalog :: Maybe Text
$sel:catalog:RelationalTable' :: RelationalTable -> Maybe Text
catalog} -> Maybe Text
catalog) (\s :: RelationalTable
s@RelationalTable' {} Maybe Text
a -> RelationalTable
s {$sel:catalog:RelationalTable' :: Maybe Text
catalog = Maybe Text
a} :: RelationalTable)

-- | The schema name. This name applies to certain relational database
-- engines.
relationalTable_schema :: Lens.Lens' RelationalTable (Prelude.Maybe Prelude.Text)
relationalTable_schema :: Lens' RelationalTable (Maybe Text)
relationalTable_schema = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalTable' {Maybe Text
schema :: Maybe Text
$sel:schema:RelationalTable' :: RelationalTable -> Maybe Text
schema} -> Maybe Text
schema) (\s :: RelationalTable
s@RelationalTable' {} Maybe Text
a -> RelationalTable
s {$sel:schema:RelationalTable' :: Maybe Text
schema = Maybe Text
a} :: RelationalTable)

-- | The Amazon Resource Name (ARN) for the data source.
relationalTable_dataSourceArn :: Lens.Lens' RelationalTable Prelude.Text
relationalTable_dataSourceArn :: Lens' RelationalTable Text
relationalTable_dataSourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalTable' {Text
dataSourceArn :: Text
$sel:dataSourceArn:RelationalTable' :: RelationalTable -> Text
dataSourceArn} -> Text
dataSourceArn) (\s :: RelationalTable
s@RelationalTable' {} Text
a -> RelationalTable
s {$sel:dataSourceArn:RelationalTable' :: Text
dataSourceArn = Text
a} :: RelationalTable)

-- | The name of the relational table.
relationalTable_name :: Lens.Lens' RelationalTable Prelude.Text
relationalTable_name :: Lens' RelationalTable Text
relationalTable_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalTable' {Text
name :: Text
$sel:name:RelationalTable' :: RelationalTable -> Text
name} -> Text
name) (\s :: RelationalTable
s@RelationalTable' {} Text
a -> RelationalTable
s {$sel:name:RelationalTable' :: Text
name = Text
a} :: RelationalTable)

-- | The column schema of the table.
relationalTable_inputColumns :: Lens.Lens' RelationalTable (Prelude.NonEmpty InputColumn)
relationalTable_inputColumns :: Lens' RelationalTable (NonEmpty InputColumn)
relationalTable_inputColumns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalTable' {NonEmpty InputColumn
inputColumns :: NonEmpty InputColumn
$sel:inputColumns:RelationalTable' :: RelationalTable -> NonEmpty InputColumn
inputColumns} -> NonEmpty InputColumn
inputColumns) (\s :: RelationalTable
s@RelationalTable' {} NonEmpty InputColumn
a -> RelationalTable
s {$sel:inputColumns:RelationalTable' :: NonEmpty InputColumn
inputColumns = NonEmpty InputColumn
a} :: RelationalTable) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON RelationalTable where
  parseJSON :: Value -> Parser RelationalTable
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RelationalTable"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Text
-> Text
-> NonEmpty InputColumn
-> RelationalTable
RelationalTable'
            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
"Catalog")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Schema")
            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
"DataSourceArn")
            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
"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
"InputColumns")
      )

instance Prelude.Hashable RelationalTable where
  hashWithSalt :: Int -> RelationalTable -> Int
hashWithSalt Int
_salt RelationalTable' {Maybe Text
NonEmpty InputColumn
Text
inputColumns :: NonEmpty InputColumn
name :: Text
dataSourceArn :: Text
schema :: Maybe Text
catalog :: Maybe Text
$sel:inputColumns:RelationalTable' :: RelationalTable -> NonEmpty InputColumn
$sel:name:RelationalTable' :: RelationalTable -> Text
$sel:dataSourceArn:RelationalTable' :: RelationalTable -> Text
$sel:schema:RelationalTable' :: RelationalTable -> Maybe Text
$sel:catalog:RelationalTable' :: RelationalTable -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalog
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
schema
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dataSourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty InputColumn
inputColumns

instance Prelude.NFData RelationalTable where
  rnf :: RelationalTable -> ()
rnf RelationalTable' {Maybe Text
NonEmpty InputColumn
Text
inputColumns :: NonEmpty InputColumn
name :: Text
dataSourceArn :: Text
schema :: Maybe Text
catalog :: Maybe Text
$sel:inputColumns:RelationalTable' :: RelationalTable -> NonEmpty InputColumn
$sel:name:RelationalTable' :: RelationalTable -> Text
$sel:dataSourceArn:RelationalTable' :: RelationalTable -> Text
$sel:schema:RelationalTable' :: RelationalTable -> Maybe Text
$sel:catalog:RelationalTable' :: RelationalTable -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalog
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
schema
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
dataSourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 NonEmpty InputColumn
inputColumns

instance Data.ToJSON RelationalTable where
  toJSON :: RelationalTable -> Value
toJSON RelationalTable' {Maybe Text
NonEmpty InputColumn
Text
inputColumns :: NonEmpty InputColumn
name :: Text
dataSourceArn :: Text
schema :: Maybe Text
catalog :: Maybe Text
$sel:inputColumns:RelationalTable' :: RelationalTable -> NonEmpty InputColumn
$sel:name:RelationalTable' :: RelationalTable -> Text
$sel:dataSourceArn:RelationalTable' :: RelationalTable -> Text
$sel:schema:RelationalTable' :: RelationalTable -> Maybe Text
$sel:catalog:RelationalTable' :: RelationalTable -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Catalog" 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
catalog,
            (Key
"Schema" 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
schema,
            forall a. a -> Maybe a
Prelude.Just (Key
"DataSourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
dataSourceArn),
            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
"InputColumns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty InputColumn
inputColumns)
          ]
      )