{-# 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.TemplateSourceEntity
-- 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.TemplateSourceEntity where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.TemplateSourceAnalysis
import Amazonka.QuickSight.Types.TemplateSourceTemplate

-- | The source entity of the template.
--
-- /See:/ 'newTemplateSourceEntity' smart constructor.
data TemplateSourceEntity = TemplateSourceEntity'
  { -- | The source analysis, if it is based on an analysis.
    TemplateSourceEntity -> Maybe TemplateSourceAnalysis
sourceAnalysis :: Prelude.Maybe TemplateSourceAnalysis,
    -- | The source template, if it is based on an template.
    TemplateSourceEntity -> Maybe TemplateSourceTemplate
sourceTemplate :: Prelude.Maybe TemplateSourceTemplate
  }
  deriving (TemplateSourceEntity -> TemplateSourceEntity -> Bool
(TemplateSourceEntity -> TemplateSourceEntity -> Bool)
-> (TemplateSourceEntity -> TemplateSourceEntity -> Bool)
-> Eq TemplateSourceEntity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TemplateSourceEntity -> TemplateSourceEntity -> Bool
$c/= :: TemplateSourceEntity -> TemplateSourceEntity -> Bool
== :: TemplateSourceEntity -> TemplateSourceEntity -> Bool
$c== :: TemplateSourceEntity -> TemplateSourceEntity -> Bool
Prelude.Eq, ReadPrec [TemplateSourceEntity]
ReadPrec TemplateSourceEntity
Int -> ReadS TemplateSourceEntity
ReadS [TemplateSourceEntity]
(Int -> ReadS TemplateSourceEntity)
-> ReadS [TemplateSourceEntity]
-> ReadPrec TemplateSourceEntity
-> ReadPrec [TemplateSourceEntity]
-> Read TemplateSourceEntity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TemplateSourceEntity]
$creadListPrec :: ReadPrec [TemplateSourceEntity]
readPrec :: ReadPrec TemplateSourceEntity
$creadPrec :: ReadPrec TemplateSourceEntity
readList :: ReadS [TemplateSourceEntity]
$creadList :: ReadS [TemplateSourceEntity]
readsPrec :: Int -> ReadS TemplateSourceEntity
$creadsPrec :: Int -> ReadS TemplateSourceEntity
Prelude.Read, Int -> TemplateSourceEntity -> ShowS
[TemplateSourceEntity] -> ShowS
TemplateSourceEntity -> String
(Int -> TemplateSourceEntity -> ShowS)
-> (TemplateSourceEntity -> String)
-> ([TemplateSourceEntity] -> ShowS)
-> Show TemplateSourceEntity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TemplateSourceEntity] -> ShowS
$cshowList :: [TemplateSourceEntity] -> ShowS
show :: TemplateSourceEntity -> String
$cshow :: TemplateSourceEntity -> String
showsPrec :: Int -> TemplateSourceEntity -> ShowS
$cshowsPrec :: Int -> TemplateSourceEntity -> ShowS
Prelude.Show, (forall x. TemplateSourceEntity -> Rep TemplateSourceEntity x)
-> (forall x. Rep TemplateSourceEntity x -> TemplateSourceEntity)
-> Generic TemplateSourceEntity
forall x. Rep TemplateSourceEntity x -> TemplateSourceEntity
forall x. TemplateSourceEntity -> Rep TemplateSourceEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TemplateSourceEntity x -> TemplateSourceEntity
$cfrom :: forall x. TemplateSourceEntity -> Rep TemplateSourceEntity x
Prelude.Generic)

-- |
-- Create a value of 'TemplateSourceEntity' 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:
--
-- 'sourceAnalysis', 'templateSourceEntity_sourceAnalysis' - The source analysis, if it is based on an analysis.
--
-- 'sourceTemplate', 'templateSourceEntity_sourceTemplate' - The source template, if it is based on an template.
newTemplateSourceEntity ::
  TemplateSourceEntity
newTemplateSourceEntity :: TemplateSourceEntity
newTemplateSourceEntity =
  TemplateSourceEntity' :: Maybe TemplateSourceAnalysis
-> Maybe TemplateSourceTemplate -> TemplateSourceEntity
TemplateSourceEntity'
    { $sel:sourceAnalysis:TemplateSourceEntity' :: Maybe TemplateSourceAnalysis
sourceAnalysis =
        Maybe TemplateSourceAnalysis
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceTemplate:TemplateSourceEntity' :: Maybe TemplateSourceTemplate
sourceTemplate = Maybe TemplateSourceTemplate
forall a. Maybe a
Prelude.Nothing
    }

-- | The source analysis, if it is based on an analysis.
templateSourceEntity_sourceAnalysis :: Lens.Lens' TemplateSourceEntity (Prelude.Maybe TemplateSourceAnalysis)
templateSourceEntity_sourceAnalysis :: (Maybe TemplateSourceAnalysis -> f (Maybe TemplateSourceAnalysis))
-> TemplateSourceEntity -> f TemplateSourceEntity
templateSourceEntity_sourceAnalysis = (TemplateSourceEntity -> Maybe TemplateSourceAnalysis)
-> (TemplateSourceEntity
    -> Maybe TemplateSourceAnalysis -> TemplateSourceEntity)
-> Lens
     TemplateSourceEntity
     TemplateSourceEntity
     (Maybe TemplateSourceAnalysis)
     (Maybe TemplateSourceAnalysis)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateSourceEntity' {Maybe TemplateSourceAnalysis
sourceAnalysis :: Maybe TemplateSourceAnalysis
$sel:sourceAnalysis:TemplateSourceEntity' :: TemplateSourceEntity -> Maybe TemplateSourceAnalysis
sourceAnalysis} -> Maybe TemplateSourceAnalysis
sourceAnalysis) (\s :: TemplateSourceEntity
s@TemplateSourceEntity' {} Maybe TemplateSourceAnalysis
a -> TemplateSourceEntity
s {$sel:sourceAnalysis:TemplateSourceEntity' :: Maybe TemplateSourceAnalysis
sourceAnalysis = Maybe TemplateSourceAnalysis
a} :: TemplateSourceEntity)

-- | The source template, if it is based on an template.
templateSourceEntity_sourceTemplate :: Lens.Lens' TemplateSourceEntity (Prelude.Maybe TemplateSourceTemplate)
templateSourceEntity_sourceTemplate :: (Maybe TemplateSourceTemplate -> f (Maybe TemplateSourceTemplate))
-> TemplateSourceEntity -> f TemplateSourceEntity
templateSourceEntity_sourceTemplate = (TemplateSourceEntity -> Maybe TemplateSourceTemplate)
-> (TemplateSourceEntity
    -> Maybe TemplateSourceTemplate -> TemplateSourceEntity)
-> Lens
     TemplateSourceEntity
     TemplateSourceEntity
     (Maybe TemplateSourceTemplate)
     (Maybe TemplateSourceTemplate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateSourceEntity' {Maybe TemplateSourceTemplate
sourceTemplate :: Maybe TemplateSourceTemplate
$sel:sourceTemplate:TemplateSourceEntity' :: TemplateSourceEntity -> Maybe TemplateSourceTemplate
sourceTemplate} -> Maybe TemplateSourceTemplate
sourceTemplate) (\s :: TemplateSourceEntity
s@TemplateSourceEntity' {} Maybe TemplateSourceTemplate
a -> TemplateSourceEntity
s {$sel:sourceTemplate:TemplateSourceEntity' :: Maybe TemplateSourceTemplate
sourceTemplate = Maybe TemplateSourceTemplate
a} :: TemplateSourceEntity)

instance Prelude.Hashable TemplateSourceEntity

instance Prelude.NFData TemplateSourceEntity

instance Core.ToJSON TemplateSourceEntity where
  toJSON :: TemplateSourceEntity -> Value
toJSON TemplateSourceEntity' {Maybe TemplateSourceAnalysis
Maybe TemplateSourceTemplate
sourceTemplate :: Maybe TemplateSourceTemplate
sourceAnalysis :: Maybe TemplateSourceAnalysis
$sel:sourceTemplate:TemplateSourceEntity' :: TemplateSourceEntity -> Maybe TemplateSourceTemplate
$sel:sourceAnalysis:TemplateSourceEntity' :: TemplateSourceEntity -> Maybe TemplateSourceAnalysis
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SourceAnalysis" Text -> TemplateSourceAnalysis -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TemplateSourceAnalysis -> Pair)
-> Maybe TemplateSourceAnalysis -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TemplateSourceAnalysis
sourceAnalysis,
            (Text
"SourceTemplate" Text -> TemplateSourceTemplate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TemplateSourceTemplate -> Pair)
-> Maybe TemplateSourceTemplate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TemplateSourceTemplate
sourceTemplate
          ]
      )