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

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

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

-- |
-- Create a value of 'DashboardSourceTemplate' 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', 'dashboardSourceTemplate_dataSetReferences' - Dataset references.
--
-- 'arn', 'dashboardSourceTemplate_arn' - The Amazon Resource Name (ARN) of the resource.
newDashboardSourceTemplate ::
  -- | 'dataSetReferences'
  Prelude.NonEmpty DataSetReference ->
  -- | 'arn'
  Prelude.Text ->
  DashboardSourceTemplate
newDashboardSourceTemplate :: NonEmpty DataSetReference -> Text -> DashboardSourceTemplate
newDashboardSourceTemplate NonEmpty DataSetReference
pDataSetReferences_ Text
pArn_ =
  DashboardSourceTemplate' :: NonEmpty DataSetReference -> Text -> DashboardSourceTemplate
DashboardSourceTemplate'
    { $sel:dataSetReferences:DashboardSourceTemplate' :: 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:DashboardSourceTemplate' :: Text
arn = Text
pArn_
    }

-- | Dataset references.
dashboardSourceTemplate_dataSetReferences :: Lens.Lens' DashboardSourceTemplate (Prelude.NonEmpty DataSetReference)
dashboardSourceTemplate_dataSetReferences :: (NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
-> DashboardSourceTemplate -> f DashboardSourceTemplate
dashboardSourceTemplate_dataSetReferences = (DashboardSourceTemplate -> NonEmpty DataSetReference)
-> (DashboardSourceTemplate
    -> NonEmpty DataSetReference -> DashboardSourceTemplate)
-> Lens
     DashboardSourceTemplate
     DashboardSourceTemplate
     (NonEmpty DataSetReference)
     (NonEmpty DataSetReference)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DashboardSourceTemplate' {NonEmpty DataSetReference
dataSetReferences :: NonEmpty DataSetReference
$sel:dataSetReferences:DashboardSourceTemplate' :: DashboardSourceTemplate -> NonEmpty DataSetReference
dataSetReferences} -> NonEmpty DataSetReference
dataSetReferences) (\s :: DashboardSourceTemplate
s@DashboardSourceTemplate' {} NonEmpty DataSetReference
a -> DashboardSourceTemplate
s {$sel:dataSetReferences:DashboardSourceTemplate' :: NonEmpty DataSetReference
dataSetReferences = NonEmpty DataSetReference
a} :: DashboardSourceTemplate) ((NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
 -> DashboardSourceTemplate -> f DashboardSourceTemplate)
-> ((NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
    -> NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
-> (NonEmpty DataSetReference -> f (NonEmpty DataSetReference))
-> DashboardSourceTemplate
-> f DashboardSourceTemplate
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 resource.
dashboardSourceTemplate_arn :: Lens.Lens' DashboardSourceTemplate Prelude.Text
dashboardSourceTemplate_arn :: (Text -> f Text)
-> DashboardSourceTemplate -> f DashboardSourceTemplate
dashboardSourceTemplate_arn = (DashboardSourceTemplate -> Text)
-> (DashboardSourceTemplate -> Text -> DashboardSourceTemplate)
-> Lens DashboardSourceTemplate DashboardSourceTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DashboardSourceTemplate' {Text
arn :: Text
$sel:arn:DashboardSourceTemplate' :: DashboardSourceTemplate -> Text
arn} -> Text
arn) (\s :: DashboardSourceTemplate
s@DashboardSourceTemplate' {} Text
a -> DashboardSourceTemplate
s {$sel:arn:DashboardSourceTemplate' :: Text
arn = Text
a} :: DashboardSourceTemplate)

instance Prelude.Hashable DashboardSourceTemplate

instance Prelude.NFData DashboardSourceTemplate

instance Core.ToJSON DashboardSourceTemplate where
  toJSON :: DashboardSourceTemplate -> Value
toJSON DashboardSourceTemplate' {NonEmpty DataSetReference
Text
arn :: Text
dataSetReferences :: NonEmpty DataSetReference
$sel:arn:DashboardSourceTemplate' :: DashboardSourceTemplate -> Text
$sel:dataSetReferences:DashboardSourceTemplate' :: DashboardSourceTemplate -> 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)
          ]
      )