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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.DataSetReference

-- | The source template of an analysis.
--
-- /See:/ 'newAnalysisSourceTemplate' smart constructor.
data AnalysisSourceTemplate = AnalysisSourceTemplate'
  { -- | The dataset references of the source template of an analysis.
    AnalysisSourceTemplate -> NonEmpty DataSetReference
dataSetReferences :: Prelude.NonEmpty DataSetReference,
    -- | The Amazon Resource Name (ARN) of the source template of an analysis.
    AnalysisSourceTemplate -> Text
arn :: Prelude.Text
  }
  deriving (AnalysisSourceTemplate -> AnalysisSourceTemplate -> Bool
(AnalysisSourceTemplate -> AnalysisSourceTemplate -> Bool)
-> (AnalysisSourceTemplate -> AnalysisSourceTemplate -> Bool)
-> Eq AnalysisSourceTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalysisSourceTemplate -> AnalysisSourceTemplate -> Bool
$c/= :: AnalysisSourceTemplate -> AnalysisSourceTemplate -> Bool
== :: AnalysisSourceTemplate -> AnalysisSourceTemplate -> Bool
$c== :: AnalysisSourceTemplate -> AnalysisSourceTemplate -> Bool
Prelude.Eq, ReadPrec [AnalysisSourceTemplate]
ReadPrec AnalysisSourceTemplate
Int -> ReadS AnalysisSourceTemplate
ReadS [AnalysisSourceTemplate]
(Int -> ReadS AnalysisSourceTemplate)
-> ReadS [AnalysisSourceTemplate]
-> ReadPrec AnalysisSourceTemplate
-> ReadPrec [AnalysisSourceTemplate]
-> Read AnalysisSourceTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalysisSourceTemplate]
$creadListPrec :: ReadPrec [AnalysisSourceTemplate]
readPrec :: ReadPrec AnalysisSourceTemplate
$creadPrec :: ReadPrec AnalysisSourceTemplate
readList :: ReadS [AnalysisSourceTemplate]
$creadList :: ReadS [AnalysisSourceTemplate]
readsPrec :: Int -> ReadS AnalysisSourceTemplate
$creadsPrec :: Int -> ReadS AnalysisSourceTemplate
Prelude.Read, Int -> AnalysisSourceTemplate -> ShowS
[AnalysisSourceTemplate] -> ShowS
AnalysisSourceTemplate -> String
(Int -> AnalysisSourceTemplate -> ShowS)
-> (AnalysisSourceTemplate -> String)
-> ([AnalysisSourceTemplate] -> ShowS)
-> Show AnalysisSourceTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalysisSourceTemplate] -> ShowS
$cshowList :: [AnalysisSourceTemplate] -> ShowS
show :: AnalysisSourceTemplate -> String
$cshow :: AnalysisSourceTemplate -> String
showsPrec :: Int -> AnalysisSourceTemplate -> ShowS
$cshowsPrec :: Int -> AnalysisSourceTemplate -> ShowS
Prelude.Show, (forall x. AnalysisSourceTemplate -> Rep AnalysisSourceTemplate x)
-> (forall x.
    Rep AnalysisSourceTemplate x -> AnalysisSourceTemplate)
-> Generic AnalysisSourceTemplate
forall x. Rep AnalysisSourceTemplate x -> AnalysisSourceTemplate
forall x. AnalysisSourceTemplate -> Rep AnalysisSourceTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalysisSourceTemplate x -> AnalysisSourceTemplate
$cfrom :: forall x. AnalysisSourceTemplate -> Rep AnalysisSourceTemplate x
Prelude.Generic)

-- |
-- Create a value of 'AnalysisSourceTemplate' 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:
--
-- 'dataSetReferences', 'analysisSourceTemplate_dataSetReferences' - The dataset references of the source template of an analysis.
--
-- 'arn', 'analysisSourceTemplate_arn' - The Amazon Resource Name (ARN) of the source template of an analysis.
newAnalysisSourceTemplate ::
  -- | 'dataSetReferences'
  Prelude.NonEmpty DataSetReference ->
  -- | 'arn'
  Prelude.Text ->
  AnalysisSourceTemplate
newAnalysisSourceTemplate :: NonEmpty DataSetReference -> Text -> AnalysisSourceTemplate
newAnalysisSourceTemplate NonEmpty DataSetReference
pDataSetReferences_ Text
pArn_ =
  AnalysisSourceTemplate' :: NonEmpty DataSetReference -> Text -> AnalysisSourceTemplate
AnalysisSourceTemplate'
    { $sel:dataSetReferences:AnalysisSourceTemplate' :: NonEmpty DataSetReference
dataSetReferences =
        Tagged
  (NonEmpty DataSetReference) (Identity (NonEmpty DataSetReference))
-> Tagged
     (NonEmpty DataSetReference) (Identity (NonEmpty DataSetReference))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty DataSetReference) (Identity (NonEmpty DataSetReference))
 -> Tagged
      (NonEmpty DataSetReference) (Identity (NonEmpty DataSetReference)))
-> NonEmpty DataSetReference -> NonEmpty DataSetReference
forall t b. AReview t b -> b -> t
Lens.# NonEmpty DataSetReference
pDataSetReferences_,
      $sel:arn:AnalysisSourceTemplate' :: Text
arn = Text
pArn_
    }

-- | The dataset references of the source template of an analysis.
analysisSourceTemplate_dataSetReferences :: Lens.Lens' AnalysisSourceTemplate (Prelude.NonEmpty DataSetReference)
analysisSourceTemplate_dataSetReferences :: (NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
-> AnalysisSourceTemplate -> f AnalysisSourceTemplate
analysisSourceTemplate_dataSetReferences = (AnalysisSourceTemplate -> NonEmpty DataSetReference)
-> (AnalysisSourceTemplate
    -> NonEmpty DataSetReference -> AnalysisSourceTemplate)
-> Lens
     AnalysisSourceTemplate
     AnalysisSourceTemplate
     (NonEmpty DataSetReference)
     (NonEmpty DataSetReference)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisSourceTemplate' {NonEmpty DataSetReference
dataSetReferences :: NonEmpty DataSetReference
$sel:dataSetReferences:AnalysisSourceTemplate' :: AnalysisSourceTemplate -> NonEmpty DataSetReference
dataSetReferences} -> NonEmpty DataSetReference
dataSetReferences) (\s :: AnalysisSourceTemplate
s@AnalysisSourceTemplate' {} NonEmpty DataSetReference
a -> AnalysisSourceTemplate
s {$sel:dataSetReferences:AnalysisSourceTemplate' :: NonEmpty DataSetReference
dataSetReferences = NonEmpty DataSetReference
a} :: AnalysisSourceTemplate) ((NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
 -> AnalysisSourceTemplate -> f AnalysisSourceTemplate)
-> ((NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
    -> NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
-> (NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
-> AnalysisSourceTemplate
-> f AnalysisSourceTemplate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
-> NonEmpty DataSetReference -> f (NonEmpty DataSetReference)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the source template of an analysis.
analysisSourceTemplate_arn :: Lens.Lens' AnalysisSourceTemplate Prelude.Text
analysisSourceTemplate_arn :: (Text -> f Text)
-> AnalysisSourceTemplate -> f AnalysisSourceTemplate
analysisSourceTemplate_arn = (AnalysisSourceTemplate -> Text)
-> (AnalysisSourceTemplate -> Text -> AnalysisSourceTemplate)
-> Lens AnalysisSourceTemplate AnalysisSourceTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalysisSourceTemplate' {Text
arn :: Text
$sel:arn:AnalysisSourceTemplate' :: AnalysisSourceTemplate -> Text
arn} -> Text
arn) (\s :: AnalysisSourceTemplate
s@AnalysisSourceTemplate' {} Text
a -> AnalysisSourceTemplate
s {$sel:arn:AnalysisSourceTemplate' :: Text
arn = Text
a} :: AnalysisSourceTemplate)

instance Prelude.Hashable AnalysisSourceTemplate

instance Prelude.NFData AnalysisSourceTemplate

instance Core.ToJSON AnalysisSourceTemplate where
  toJSON :: AnalysisSourceTemplate -> Value
toJSON AnalysisSourceTemplate' {NonEmpty DataSetReference
Text
arn :: Text
dataSetReferences :: NonEmpty DataSetReference
$sel:arn:AnalysisSourceTemplate' :: AnalysisSourceTemplate -> Text
$sel:dataSetReferences:AnalysisSourceTemplate' :: AnalysisSourceTemplate -> NonEmpty DataSetReference
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DataSetReferences" Text -> NonEmpty DataSetReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty DataSetReference
dataSetReferences),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)
          ]
      )