{-# 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.SES.Types.TemplateMetadata
-- 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.SES.Types.TemplateMetadata where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an email template.
--
-- /See:/ 'newTemplateMetadata' smart constructor.
data TemplateMetadata = TemplateMetadata'
  { -- | The name of the template.
    TemplateMetadata -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The time and date the template was created.
    TemplateMetadata -> Maybe ISO8601
createdTimestamp :: Prelude.Maybe Core.ISO8601
  }
  deriving (TemplateMetadata -> TemplateMetadata -> Bool
(TemplateMetadata -> TemplateMetadata -> Bool)
-> (TemplateMetadata -> TemplateMetadata -> Bool)
-> Eq TemplateMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TemplateMetadata -> TemplateMetadata -> Bool
$c/= :: TemplateMetadata -> TemplateMetadata -> Bool
== :: TemplateMetadata -> TemplateMetadata -> Bool
$c== :: TemplateMetadata -> TemplateMetadata -> Bool
Prelude.Eq, ReadPrec [TemplateMetadata]
ReadPrec TemplateMetadata
Int -> ReadS TemplateMetadata
ReadS [TemplateMetadata]
(Int -> ReadS TemplateMetadata)
-> ReadS [TemplateMetadata]
-> ReadPrec TemplateMetadata
-> ReadPrec [TemplateMetadata]
-> Read TemplateMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TemplateMetadata]
$creadListPrec :: ReadPrec [TemplateMetadata]
readPrec :: ReadPrec TemplateMetadata
$creadPrec :: ReadPrec TemplateMetadata
readList :: ReadS [TemplateMetadata]
$creadList :: ReadS [TemplateMetadata]
readsPrec :: Int -> ReadS TemplateMetadata
$creadsPrec :: Int -> ReadS TemplateMetadata
Prelude.Read, Int -> TemplateMetadata -> ShowS
[TemplateMetadata] -> ShowS
TemplateMetadata -> String
(Int -> TemplateMetadata -> ShowS)
-> (TemplateMetadata -> String)
-> ([TemplateMetadata] -> ShowS)
-> Show TemplateMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TemplateMetadata] -> ShowS
$cshowList :: [TemplateMetadata] -> ShowS
show :: TemplateMetadata -> String
$cshow :: TemplateMetadata -> String
showsPrec :: Int -> TemplateMetadata -> ShowS
$cshowsPrec :: Int -> TemplateMetadata -> ShowS
Prelude.Show, (forall x. TemplateMetadata -> Rep TemplateMetadata x)
-> (forall x. Rep TemplateMetadata x -> TemplateMetadata)
-> Generic TemplateMetadata
forall x. Rep TemplateMetadata x -> TemplateMetadata
forall x. TemplateMetadata -> Rep TemplateMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TemplateMetadata x -> TemplateMetadata
$cfrom :: forall x. TemplateMetadata -> Rep TemplateMetadata x
Prelude.Generic)

-- |
-- Create a value of 'TemplateMetadata' 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:
--
-- 'name', 'templateMetadata_name' - The name of the template.
--
-- 'createdTimestamp', 'templateMetadata_createdTimestamp' - The time and date the template was created.
newTemplateMetadata ::
  TemplateMetadata
newTemplateMetadata :: TemplateMetadata
newTemplateMetadata =
  TemplateMetadata' :: Maybe Text -> Maybe ISO8601 -> TemplateMetadata
TemplateMetadata'
    { $sel:name:TemplateMetadata' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTimestamp:TemplateMetadata' :: Maybe ISO8601
createdTimestamp = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The time and date the template was created.
templateMetadata_createdTimestamp :: Lens.Lens' TemplateMetadata (Prelude.Maybe Prelude.UTCTime)
templateMetadata_createdTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TemplateMetadata -> f TemplateMetadata
templateMetadata_createdTimestamp = (TemplateMetadata -> Maybe ISO8601)
-> (TemplateMetadata -> Maybe ISO8601 -> TemplateMetadata)
-> Lens
     TemplateMetadata TemplateMetadata (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateMetadata' {Maybe ISO8601
createdTimestamp :: Maybe ISO8601
$sel:createdTimestamp:TemplateMetadata' :: TemplateMetadata -> Maybe ISO8601
createdTimestamp} -> Maybe ISO8601
createdTimestamp) (\s :: TemplateMetadata
s@TemplateMetadata' {} Maybe ISO8601
a -> TemplateMetadata
s {$sel:createdTimestamp:TemplateMetadata' :: Maybe ISO8601
createdTimestamp = Maybe ISO8601
a} :: TemplateMetadata) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> TemplateMetadata -> f TemplateMetadata)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TemplateMetadata
-> f TemplateMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML TemplateMetadata where
  parseXML :: [Node] -> Either String TemplateMetadata
parseXML [Node]
x =
    Maybe Text -> Maybe ISO8601 -> TemplateMetadata
TemplateMetadata'
      (Maybe Text -> Maybe ISO8601 -> TemplateMetadata)
-> Either String (Maybe Text)
-> Either String (Maybe ISO8601 -> TemplateMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Name")
      Either String (Maybe ISO8601 -> TemplateMetadata)
-> Either String (Maybe ISO8601) -> Either String TemplateMetadata
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CreatedTimestamp")

instance Prelude.Hashable TemplateMetadata

instance Prelude.NFData TemplateMetadata