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

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

-- | A template object. A /template/ is an entity in Amazon QuickSight that
-- encapsulates the metadata required to create an analysis and that you
-- can use to create a dashboard. A template adds a layer of abstraction by
-- using placeholders to replace the dataset associated with an analysis.
-- You can use templates to create dashboards by replacing dataset
-- placeholders with datasets that follow the same schema that was used to
-- create the source analysis and template.
--
-- You can share templates across Amazon Web Services accounts by allowing
-- users in other Amazon Web Services accounts to create a template or a
-- dashboard from an existing template.
--
-- /See:/ 'newTemplate' smart constructor.
data Template = Template'
  { -- | Time when this was last updated.
    Template -> Maybe POSIX
lastUpdatedTime :: Prelude.Maybe Core.POSIX,
    -- | The Amazon Resource Name (ARN) of the template.
    Template -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | Time when this was created.
    Template -> Maybe POSIX
createdTime :: Prelude.Maybe Core.POSIX,
    -- | The ID for the template. This is unique per Amazon Web Services Region
    -- for each Amazon Web Services account.
    Template -> Maybe Text
templateId :: Prelude.Maybe Prelude.Text,
    -- | The display name of the template.
    Template -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A structure describing the versions of the template.
    Template -> Maybe TemplateVersion
version :: Prelude.Maybe TemplateVersion
  }
  deriving (Template -> Template -> Bool
(Template -> Template -> Bool)
-> (Template -> Template -> Bool) -> Eq Template
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Template -> Template -> Bool
$c/= :: Template -> Template -> Bool
== :: Template -> Template -> Bool
$c== :: Template -> Template -> Bool
Prelude.Eq, ReadPrec [Template]
ReadPrec Template
Int -> ReadS Template
ReadS [Template]
(Int -> ReadS Template)
-> ReadS [Template]
-> ReadPrec Template
-> ReadPrec [Template]
-> Read Template
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Template]
$creadListPrec :: ReadPrec [Template]
readPrec :: ReadPrec Template
$creadPrec :: ReadPrec Template
readList :: ReadS [Template]
$creadList :: ReadS [Template]
readsPrec :: Int -> ReadS Template
$creadsPrec :: Int -> ReadS Template
Prelude.Read, Int -> Template -> ShowS
[Template] -> ShowS
Template -> String
(Int -> Template -> ShowS)
-> (Template -> String) -> ([Template] -> ShowS) -> Show Template
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Template] -> ShowS
$cshowList :: [Template] -> ShowS
show :: Template -> String
$cshow :: Template -> String
showsPrec :: Int -> Template -> ShowS
$cshowsPrec :: Int -> Template -> ShowS
Prelude.Show, (forall x. Template -> Rep Template x)
-> (forall x. Rep Template x -> Template) -> Generic Template
forall x. Rep Template x -> Template
forall x. Template -> Rep Template x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Template x -> Template
$cfrom :: forall x. Template -> Rep Template x
Prelude.Generic)

-- |
-- Create a value of 'Template' 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:
--
-- 'lastUpdatedTime', 'template_lastUpdatedTime' - Time when this was last updated.
--
-- 'arn', 'template_arn' - The Amazon Resource Name (ARN) of the template.
--
-- 'createdTime', 'template_createdTime' - Time when this was created.
--
-- 'templateId', 'template_templateId' - The ID for the template. This is unique per Amazon Web Services Region
-- for each Amazon Web Services account.
--
-- 'name', 'template_name' - The display name of the template.
--
-- 'version', 'template_version' - A structure describing the versions of the template.
newTemplate ::
  Template
newTemplate :: Template
newTemplate =
  Template' :: Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe TemplateVersion
-> Template
Template'
    { $sel:lastUpdatedTime:Template' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:Template' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTime:Template' :: Maybe POSIX
createdTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:templateId:Template' :: Maybe Text
templateId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Template' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:version:Template' :: Maybe TemplateVersion
version = Maybe TemplateVersion
forall a. Maybe a
Prelude.Nothing
    }

-- | Time when this was last updated.
template_lastUpdatedTime :: Lens.Lens' Template (Prelude.Maybe Prelude.UTCTime)
template_lastUpdatedTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Template -> f Template
template_lastUpdatedTime = (Template -> Maybe POSIX)
-> (Template -> Maybe POSIX -> Template)
-> Lens Template Template (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Maybe POSIX
lastUpdatedTime :: Maybe POSIX
$sel:lastUpdatedTime:Template' :: Template -> Maybe POSIX
lastUpdatedTime} -> Maybe POSIX
lastUpdatedTime) (\s :: Template
s@Template' {} Maybe POSIX
a -> Template
s {$sel:lastUpdatedTime:Template' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
a} :: Template) ((Maybe POSIX -> f (Maybe POSIX)) -> Template -> f Template)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Template
-> f Template
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

-- | Time when this was created.
template_createdTime :: Lens.Lens' Template (Prelude.Maybe Prelude.UTCTime)
template_createdTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Template -> f Template
template_createdTime = (Template -> Maybe POSIX)
-> (Template -> Maybe POSIX -> Template)
-> Lens Template Template (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Maybe POSIX
createdTime :: Maybe POSIX
$sel:createdTime:Template' :: Template -> Maybe POSIX
createdTime} -> Maybe POSIX
createdTime) (\s :: Template
s@Template' {} Maybe POSIX
a -> Template
s {$sel:createdTime:Template' :: Maybe POSIX
createdTime = Maybe POSIX
a} :: Template) ((Maybe POSIX -> f (Maybe POSIX)) -> Template -> f Template)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Template
-> f Template
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ID for the template. This is unique per Amazon Web Services Region
-- for each Amazon Web Services account.
template_templateId :: Lens.Lens' Template (Prelude.Maybe Prelude.Text)
template_templateId :: (Maybe Text -> f (Maybe Text)) -> Template -> f Template
template_templateId = (Template -> Maybe Text)
-> (Template -> Maybe Text -> Template)
-> Lens Template Template (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Maybe Text
templateId :: Maybe Text
$sel:templateId:Template' :: Template -> Maybe Text
templateId} -> Maybe Text
templateId) (\s :: Template
s@Template' {} Maybe Text
a -> Template
s {$sel:templateId:Template' :: Maybe Text
templateId = Maybe Text
a} :: Template)

-- | The display name of the template.
template_name :: Lens.Lens' Template (Prelude.Maybe Prelude.Text)
template_name :: (Maybe Text -> f (Maybe Text)) -> Template -> f Template
template_name = (Template -> Maybe Text)
-> (Template -> Maybe Text -> Template)
-> Lens Template Template (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Maybe Text
name :: Maybe Text
$sel:name:Template' :: Template -> Maybe Text
name} -> Maybe Text
name) (\s :: Template
s@Template' {} Maybe Text
a -> Template
s {$sel:name:Template' :: Maybe Text
name = Maybe Text
a} :: Template)

-- | A structure describing the versions of the template.
template_version :: Lens.Lens' Template (Prelude.Maybe TemplateVersion)
template_version :: (Maybe TemplateVersion -> f (Maybe TemplateVersion))
-> Template -> f Template
template_version = (Template -> Maybe TemplateVersion)
-> (Template -> Maybe TemplateVersion -> Template)
-> Lens
     Template Template (Maybe TemplateVersion) (Maybe TemplateVersion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Template' {Maybe TemplateVersion
version :: Maybe TemplateVersion
$sel:version:Template' :: Template -> Maybe TemplateVersion
version} -> Maybe TemplateVersion
version) (\s :: Template
s@Template' {} Maybe TemplateVersion
a -> Template
s {$sel:version:Template' :: Maybe TemplateVersion
version = Maybe TemplateVersion
a} :: Template)

instance Core.FromJSON Template where
  parseJSON :: Value -> Parser Template
parseJSON =
    String -> (Object -> Parser Template) -> Value -> Parser Template
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Template"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe TemplateVersion
-> Template
Template'
            (Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe TemplateVersion
 -> Template)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe TemplateVersion
      -> Template)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastUpdatedTime")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe TemplateVersion
   -> Template)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe Text -> Maybe TemplateVersion -> Template)
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
"Arn")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe Text -> Maybe TemplateVersion -> Template)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe TemplateVersion -> Template)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreatedTime")
            Parser
  (Maybe Text -> Maybe Text -> Maybe TemplateVersion -> Template)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe TemplateVersion -> Template)
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
"TemplateId")
            Parser (Maybe Text -> Maybe TemplateVersion -> Template)
-> Parser (Maybe Text)
-> Parser (Maybe TemplateVersion -> Template)
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
"Name")
            Parser (Maybe TemplateVersion -> Template)
-> Parser (Maybe TemplateVersion) -> Parser Template
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TemplateVersion)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Version")
      )

instance Prelude.Hashable Template

instance Prelude.NFData Template