{-# 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.PhysicalTable
-- 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.PhysicalTable 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.CustomSql
import Amazonka.QuickSight.Types.RelationalTable
import Amazonka.QuickSight.Types.S3Source

-- | A view of a data source that contains information about the shape of the
-- data in the underlying source. This is a variant type structure. For
-- this structure to be valid, only one of the attributes can be non-null.
--
-- /See:/ 'newPhysicalTable' smart constructor.
data PhysicalTable = PhysicalTable'
  { -- | A physical table type built from the results of the custom SQL query.
    PhysicalTable -> Maybe CustomSql
customSql :: Prelude.Maybe CustomSql,
    -- | A physical table type for relational data sources.
    PhysicalTable -> Maybe RelationalTable
relationalTable :: Prelude.Maybe RelationalTable,
    -- | A physical table type for as S3 data source.
    PhysicalTable -> Maybe S3Source
s3Source :: Prelude.Maybe S3Source
  }
  deriving (PhysicalTable -> PhysicalTable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalTable -> PhysicalTable -> Bool
$c/= :: PhysicalTable -> PhysicalTable -> Bool
== :: PhysicalTable -> PhysicalTable -> Bool
$c== :: PhysicalTable -> PhysicalTable -> Bool
Prelude.Eq, ReadPrec [PhysicalTable]
ReadPrec PhysicalTable
Int -> ReadS PhysicalTable
ReadS [PhysicalTable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PhysicalTable]
$creadListPrec :: ReadPrec [PhysicalTable]
readPrec :: ReadPrec PhysicalTable
$creadPrec :: ReadPrec PhysicalTable
readList :: ReadS [PhysicalTable]
$creadList :: ReadS [PhysicalTable]
readsPrec :: Int -> ReadS PhysicalTable
$creadsPrec :: Int -> ReadS PhysicalTable
Prelude.Read, Int -> PhysicalTable -> ShowS
[PhysicalTable] -> ShowS
PhysicalTable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhysicalTable] -> ShowS
$cshowList :: [PhysicalTable] -> ShowS
show :: PhysicalTable -> String
$cshow :: PhysicalTable -> String
showsPrec :: Int -> PhysicalTable -> ShowS
$cshowsPrec :: Int -> PhysicalTable -> ShowS
Prelude.Show, forall x. Rep PhysicalTable x -> PhysicalTable
forall x. PhysicalTable -> Rep PhysicalTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhysicalTable x -> PhysicalTable
$cfrom :: forall x. PhysicalTable -> Rep PhysicalTable x
Prelude.Generic)

-- |
-- Create a value of 'PhysicalTable' 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:
--
-- 'customSql', 'physicalTable_customSql' - A physical table type built from the results of the custom SQL query.
--
-- 'relationalTable', 'physicalTable_relationalTable' - A physical table type for relational data sources.
--
-- 's3Source', 'physicalTable_s3Source' - A physical table type for as S3 data source.
newPhysicalTable ::
  PhysicalTable
newPhysicalTable :: PhysicalTable
newPhysicalTable =
  PhysicalTable'
    { $sel:customSql:PhysicalTable' :: Maybe CustomSql
customSql = forall a. Maybe a
Prelude.Nothing,
      $sel:relationalTable:PhysicalTable' :: Maybe RelationalTable
relationalTable = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Source:PhysicalTable' :: Maybe S3Source
s3Source = forall a. Maybe a
Prelude.Nothing
    }

-- | A physical table type built from the results of the custom SQL query.
physicalTable_customSql :: Lens.Lens' PhysicalTable (Prelude.Maybe CustomSql)
physicalTable_customSql :: Lens' PhysicalTable (Maybe CustomSql)
physicalTable_customSql = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhysicalTable' {Maybe CustomSql
customSql :: Maybe CustomSql
$sel:customSql:PhysicalTable' :: PhysicalTable -> Maybe CustomSql
customSql} -> Maybe CustomSql
customSql) (\s :: PhysicalTable
s@PhysicalTable' {} Maybe CustomSql
a -> PhysicalTable
s {$sel:customSql:PhysicalTable' :: Maybe CustomSql
customSql = Maybe CustomSql
a} :: PhysicalTable)

-- | A physical table type for relational data sources.
physicalTable_relationalTable :: Lens.Lens' PhysicalTable (Prelude.Maybe RelationalTable)
physicalTable_relationalTable :: Lens' PhysicalTable (Maybe RelationalTable)
physicalTable_relationalTable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhysicalTable' {Maybe RelationalTable
relationalTable :: Maybe RelationalTable
$sel:relationalTable:PhysicalTable' :: PhysicalTable -> Maybe RelationalTable
relationalTable} -> Maybe RelationalTable
relationalTable) (\s :: PhysicalTable
s@PhysicalTable' {} Maybe RelationalTable
a -> PhysicalTable
s {$sel:relationalTable:PhysicalTable' :: Maybe RelationalTable
relationalTable = Maybe RelationalTable
a} :: PhysicalTable)

-- | A physical table type for as S3 data source.
physicalTable_s3Source :: Lens.Lens' PhysicalTable (Prelude.Maybe S3Source)
physicalTable_s3Source :: Lens' PhysicalTable (Maybe S3Source)
physicalTable_s3Source = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhysicalTable' {Maybe S3Source
s3Source :: Maybe S3Source
$sel:s3Source:PhysicalTable' :: PhysicalTable -> Maybe S3Source
s3Source} -> Maybe S3Source
s3Source) (\s :: PhysicalTable
s@PhysicalTable' {} Maybe S3Source
a -> PhysicalTable
s {$sel:s3Source:PhysicalTable' :: Maybe S3Source
s3Source = Maybe S3Source
a} :: PhysicalTable)

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

instance Prelude.Hashable PhysicalTable where
  hashWithSalt :: Int -> PhysicalTable -> Int
hashWithSalt Int
_salt PhysicalTable' {Maybe CustomSql
Maybe RelationalTable
Maybe S3Source
s3Source :: Maybe S3Source
relationalTable :: Maybe RelationalTable
customSql :: Maybe CustomSql
$sel:s3Source:PhysicalTable' :: PhysicalTable -> Maybe S3Source
$sel:relationalTable:PhysicalTable' :: PhysicalTable -> Maybe RelationalTable
$sel:customSql:PhysicalTable' :: PhysicalTable -> Maybe CustomSql
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CustomSql
customSql
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RelationalTable
relationalTable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3Source
s3Source

instance Prelude.NFData PhysicalTable where
  rnf :: PhysicalTable -> ()
rnf PhysicalTable' {Maybe CustomSql
Maybe RelationalTable
Maybe S3Source
s3Source :: Maybe S3Source
relationalTable :: Maybe RelationalTable
customSql :: Maybe CustomSql
$sel:s3Source:PhysicalTable' :: PhysicalTable -> Maybe S3Source
$sel:relationalTable:PhysicalTable' :: PhysicalTable -> Maybe RelationalTable
$sel:customSql:PhysicalTable' :: PhysicalTable -> Maybe CustomSql
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CustomSql
customSql
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RelationalTable
relationalTable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe S3Source
s3Source

instance Data.ToJSON PhysicalTable where
  toJSON :: PhysicalTable -> Value
toJSON PhysicalTable' {Maybe CustomSql
Maybe RelationalTable
Maybe S3Source
s3Source :: Maybe S3Source
relationalTable :: Maybe RelationalTable
customSql :: Maybe CustomSql
$sel:s3Source:PhysicalTable' :: PhysicalTable -> Maybe S3Source
$sel:relationalTable:PhysicalTable' :: PhysicalTable -> Maybe RelationalTable
$sel:customSql:PhysicalTable' :: PhysicalTable -> Maybe CustomSql
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CustomSql" 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 CustomSql
customSql,
            (Key
"RelationalTable" 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 RelationalTable
relationalTable,
            (Key
"S3Source" 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 S3Source
s3Source
          ]
      )