{-# 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.LogicalTableSource
-- 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.LogicalTableSource 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.JoinInstruction

-- | Information about the source of a logical table. This is a variant type
-- structure. For this structure to be valid, only one of the attributes
-- can be non-null.
--
-- /See:/ 'newLogicalTableSource' smart constructor.
data LogicalTableSource = LogicalTableSource'
  { -- | The Amazon Resource Number (ARN) of the parent dataset.
    LogicalTableSource -> Maybe Text
dataSetArn :: Prelude.Maybe Prelude.Text,
    -- | Specifies the result of a join of two logical tables.
    LogicalTableSource -> Maybe JoinInstruction
joinInstruction :: Prelude.Maybe JoinInstruction,
    -- | Physical table ID.
    LogicalTableSource -> Maybe Text
physicalTableId :: Prelude.Maybe Prelude.Text
  }
  deriving (LogicalTableSource -> LogicalTableSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogicalTableSource -> LogicalTableSource -> Bool
$c/= :: LogicalTableSource -> LogicalTableSource -> Bool
== :: LogicalTableSource -> LogicalTableSource -> Bool
$c== :: LogicalTableSource -> LogicalTableSource -> Bool
Prelude.Eq, ReadPrec [LogicalTableSource]
ReadPrec LogicalTableSource
Int -> ReadS LogicalTableSource
ReadS [LogicalTableSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogicalTableSource]
$creadListPrec :: ReadPrec [LogicalTableSource]
readPrec :: ReadPrec LogicalTableSource
$creadPrec :: ReadPrec LogicalTableSource
readList :: ReadS [LogicalTableSource]
$creadList :: ReadS [LogicalTableSource]
readsPrec :: Int -> ReadS LogicalTableSource
$creadsPrec :: Int -> ReadS LogicalTableSource
Prelude.Read, Int -> LogicalTableSource -> ShowS
[LogicalTableSource] -> ShowS
LogicalTableSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogicalTableSource] -> ShowS
$cshowList :: [LogicalTableSource] -> ShowS
show :: LogicalTableSource -> String
$cshow :: LogicalTableSource -> String
showsPrec :: Int -> LogicalTableSource -> ShowS
$cshowsPrec :: Int -> LogicalTableSource -> ShowS
Prelude.Show, forall x. Rep LogicalTableSource x -> LogicalTableSource
forall x. LogicalTableSource -> Rep LogicalTableSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogicalTableSource x -> LogicalTableSource
$cfrom :: forall x. LogicalTableSource -> Rep LogicalTableSource x
Prelude.Generic)

-- |
-- Create a value of 'LogicalTableSource' 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:
--
-- 'dataSetArn', 'logicalTableSource_dataSetArn' - The Amazon Resource Number (ARN) of the parent dataset.
--
-- 'joinInstruction', 'logicalTableSource_joinInstruction' - Specifies the result of a join of two logical tables.
--
-- 'physicalTableId', 'logicalTableSource_physicalTableId' - Physical table ID.
newLogicalTableSource ::
  LogicalTableSource
newLogicalTableSource :: LogicalTableSource
newLogicalTableSource =
  LogicalTableSource'
    { $sel:dataSetArn:LogicalTableSource' :: Maybe Text
dataSetArn = forall a. Maybe a
Prelude.Nothing,
      $sel:joinInstruction:LogicalTableSource' :: Maybe JoinInstruction
joinInstruction = forall a. Maybe a
Prelude.Nothing,
      $sel:physicalTableId:LogicalTableSource' :: Maybe Text
physicalTableId = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Number (ARN) of the parent dataset.
logicalTableSource_dataSetArn :: Lens.Lens' LogicalTableSource (Prelude.Maybe Prelude.Text)
logicalTableSource_dataSetArn :: Lens' LogicalTableSource (Maybe Text)
logicalTableSource_dataSetArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogicalTableSource' {Maybe Text
dataSetArn :: Maybe Text
$sel:dataSetArn:LogicalTableSource' :: LogicalTableSource -> Maybe Text
dataSetArn} -> Maybe Text
dataSetArn) (\s :: LogicalTableSource
s@LogicalTableSource' {} Maybe Text
a -> LogicalTableSource
s {$sel:dataSetArn:LogicalTableSource' :: Maybe Text
dataSetArn = Maybe Text
a} :: LogicalTableSource)

-- | Specifies the result of a join of two logical tables.
logicalTableSource_joinInstruction :: Lens.Lens' LogicalTableSource (Prelude.Maybe JoinInstruction)
logicalTableSource_joinInstruction :: Lens' LogicalTableSource (Maybe JoinInstruction)
logicalTableSource_joinInstruction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogicalTableSource' {Maybe JoinInstruction
joinInstruction :: Maybe JoinInstruction
$sel:joinInstruction:LogicalTableSource' :: LogicalTableSource -> Maybe JoinInstruction
joinInstruction} -> Maybe JoinInstruction
joinInstruction) (\s :: LogicalTableSource
s@LogicalTableSource' {} Maybe JoinInstruction
a -> LogicalTableSource
s {$sel:joinInstruction:LogicalTableSource' :: Maybe JoinInstruction
joinInstruction = Maybe JoinInstruction
a} :: LogicalTableSource)

-- | Physical table ID.
logicalTableSource_physicalTableId :: Lens.Lens' LogicalTableSource (Prelude.Maybe Prelude.Text)
logicalTableSource_physicalTableId :: Lens' LogicalTableSource (Maybe Text)
logicalTableSource_physicalTableId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogicalTableSource' {Maybe Text
physicalTableId :: Maybe Text
$sel:physicalTableId:LogicalTableSource' :: LogicalTableSource -> Maybe Text
physicalTableId} -> Maybe Text
physicalTableId) (\s :: LogicalTableSource
s@LogicalTableSource' {} Maybe Text
a -> LogicalTableSource
s {$sel:physicalTableId:LogicalTableSource' :: Maybe Text
physicalTableId = Maybe Text
a} :: LogicalTableSource)

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

instance Prelude.Hashable LogicalTableSource where
  hashWithSalt :: Int -> LogicalTableSource -> Int
hashWithSalt Int
_salt LogicalTableSource' {Maybe Text
Maybe JoinInstruction
physicalTableId :: Maybe Text
joinInstruction :: Maybe JoinInstruction
dataSetArn :: Maybe Text
$sel:physicalTableId:LogicalTableSource' :: LogicalTableSource -> Maybe Text
$sel:joinInstruction:LogicalTableSource' :: LogicalTableSource -> Maybe JoinInstruction
$sel:dataSetArn:LogicalTableSource' :: LogicalTableSource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dataSetArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JoinInstruction
joinInstruction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
physicalTableId

instance Prelude.NFData LogicalTableSource where
  rnf :: LogicalTableSource -> ()
rnf LogicalTableSource' {Maybe Text
Maybe JoinInstruction
physicalTableId :: Maybe Text
joinInstruction :: Maybe JoinInstruction
dataSetArn :: Maybe Text
$sel:physicalTableId:LogicalTableSource' :: LogicalTableSource -> Maybe Text
$sel:joinInstruction:LogicalTableSource' :: LogicalTableSource -> Maybe JoinInstruction
$sel:dataSetArn:LogicalTableSource' :: LogicalTableSource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataSetArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe JoinInstruction
joinInstruction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
physicalTableId

instance Data.ToJSON LogicalTableSource where
  toJSON :: LogicalTableSource -> Value
toJSON LogicalTableSource' {Maybe Text
Maybe JoinInstruction
physicalTableId :: Maybe Text
joinInstruction :: Maybe JoinInstruction
dataSetArn :: Maybe Text
$sel:physicalTableId:LogicalTableSource' :: LogicalTableSource -> Maybe Text
$sel:joinInstruction:LogicalTableSource' :: LogicalTableSource -> Maybe JoinInstruction
$sel:dataSetArn:LogicalTableSource' :: LogicalTableSource -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DataSetArn" 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
dataSetArn,
            (Key
"JoinInstruction" 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 JoinInstruction
joinInstruction,
            (Key
"PhysicalTableId" 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
physicalTableId
          ]
      )