{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.LogicalTableSource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LogicalTableSource -> LogicalTableSource -> Bool)
-> (LogicalTableSource -> LogicalTableSource -> Bool)
-> Eq LogicalTableSource
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]
(Int -> ReadS LogicalTableSource)
-> ReadS [LogicalTableSource]
-> ReadPrec LogicalTableSource
-> ReadPrec [LogicalTableSource]
-> Read 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
(Int -> LogicalTableSource -> ShowS)
-> (LogicalTableSource -> String)
-> ([LogicalTableSource] -> ShowS)
-> Show LogicalTableSource
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. LogicalTableSource -> Rep LogicalTableSource x)
-> (forall x. Rep LogicalTableSource x -> LogicalTableSource)
-> Generic LogicalTableSource
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' :: Maybe Text
-> Maybe JoinInstruction -> Maybe Text -> LogicalTableSource
LogicalTableSource'
    { $sel:dataSetArn:LogicalTableSource' :: Maybe Text
dataSetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:joinInstruction:LogicalTableSource' :: Maybe JoinInstruction
joinInstruction = Maybe JoinInstruction
forall a. Maybe a
Prelude.Nothing,
      $sel:physicalTableId:LogicalTableSource' :: Maybe Text
physicalTableId = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> LogicalTableSource -> f LogicalTableSource
logicalTableSource_dataSetArn = (LogicalTableSource -> Maybe Text)
-> (LogicalTableSource -> Maybe Text -> LogicalTableSource)
-> Lens
     LogicalTableSource LogicalTableSource (Maybe Text) (Maybe Text)
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 :: (Maybe JoinInstruction -> f (Maybe JoinInstruction))
-> LogicalTableSource -> f LogicalTableSource
logicalTableSource_joinInstruction = (LogicalTableSource -> Maybe JoinInstruction)
-> (LogicalTableSource
    -> Maybe JoinInstruction -> LogicalTableSource)
-> Lens
     LogicalTableSource
     LogicalTableSource
     (Maybe JoinInstruction)
     (Maybe 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 :: (Maybe Text -> f (Maybe Text))
-> LogicalTableSource -> f LogicalTableSource
logicalTableSource_physicalTableId = (LogicalTableSource -> Maybe Text)
-> (LogicalTableSource -> Maybe Text -> LogicalTableSource)
-> Lens
     LogicalTableSource LogicalTableSource (Maybe Text) (Maybe Text)
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 Core.FromJSON LogicalTableSource where
  parseJSON :: Value -> Parser LogicalTableSource
parseJSON =
    String
-> (Object -> Parser LogicalTableSource)
-> Value
-> Parser LogicalTableSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogicalTableSource"
      ( \Object
x ->
          Maybe Text
-> Maybe JoinInstruction -> Maybe Text -> LogicalTableSource
LogicalTableSource'
            (Maybe Text
 -> Maybe JoinInstruction -> Maybe Text -> LogicalTableSource)
-> Parser (Maybe Text)
-> Parser
     (Maybe JoinInstruction -> Maybe Text -> LogicalTableSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DataSetArn")
            Parser (Maybe JoinInstruction -> Maybe Text -> LogicalTableSource)
-> Parser (Maybe JoinInstruction)
-> Parser (Maybe Text -> LogicalTableSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JoinInstruction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"JoinInstruction")
            Parser (Maybe Text -> LogicalTableSource)
-> Parser (Maybe Text) -> Parser LogicalTableSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PhysicalTableId")
      )

instance Prelude.Hashable LogicalTableSource

instance Prelude.NFData LogicalTableSource

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DataSetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataSetArn,
            (Text
"JoinInstruction" Text -> JoinInstruction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (JoinInstruction -> Pair) -> Maybe JoinInstruction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JoinInstruction
joinInstruction,
            (Text
"PhysicalTableId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
physicalTableId
          ]
      )