{-# 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-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.AnalysisSourceTemplate 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.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
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]
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
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. 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'
    { $sel:dataSetReferences:AnalysisSourceTemplate' :: NonEmpty DataSetReference
dataSetReferences =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced 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 :: Lens' AnalysisSourceTemplate (NonEmpty DataSetReference)
analysisSourceTemplate_dataSetReferences = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: Lens' AnalysisSourceTemplate Text
analysisSourceTemplate_arn = 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 where
  hashWithSalt :: Int -> AnalysisSourceTemplate -> Int
hashWithSalt Int
_salt AnalysisSourceTemplate' {NonEmpty DataSetReference
Text
arn :: Text
dataSetReferences :: NonEmpty DataSetReference
$sel:arn:AnalysisSourceTemplate' :: AnalysisSourceTemplate -> Text
$sel:dataSetReferences:AnalysisSourceTemplate' :: AnalysisSourceTemplate -> NonEmpty DataSetReference
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty DataSetReference
dataSetReferences
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData AnalysisSourceTemplate where
  rnf :: AnalysisSourceTemplate -> ()
rnf AnalysisSourceTemplate' {NonEmpty DataSetReference
Text
arn :: Text
dataSetReferences :: NonEmpty DataSetReference
$sel:arn:AnalysisSourceTemplate' :: AnalysisSourceTemplate -> Text
$sel:dataSetReferences:AnalysisSourceTemplate' :: AnalysisSourceTemplate -> NonEmpty DataSetReference
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty DataSetReference
dataSetReferences
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"DataSetReferences" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty DataSetReference
dataSetReferences),
            forall a. a -> Maybe a
Prelude.Just (Key
"Arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)
          ]
      )