{-# 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.SESV2.Types.EmailTemplateMetadata
-- 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.SESV2.Types.EmailTemplateMetadata 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:/ 'newEmailTemplateMetadata' smart constructor.
data EmailTemplateMetadata = EmailTemplateMetadata'
  { -- | The name of the template.
    EmailTemplateMetadata -> Maybe Text
templateName :: Prelude.Maybe Prelude.Text,
    -- | The time and date the template was created.
    EmailTemplateMetadata -> Maybe POSIX
createdTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (EmailTemplateMetadata -> EmailTemplateMetadata -> Bool
(EmailTemplateMetadata -> EmailTemplateMetadata -> Bool)
-> (EmailTemplateMetadata -> EmailTemplateMetadata -> Bool)
-> Eq EmailTemplateMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmailTemplateMetadata -> EmailTemplateMetadata -> Bool
$c/= :: EmailTemplateMetadata -> EmailTemplateMetadata -> Bool
== :: EmailTemplateMetadata -> EmailTemplateMetadata -> Bool
$c== :: EmailTemplateMetadata -> EmailTemplateMetadata -> Bool
Prelude.Eq, ReadPrec [EmailTemplateMetadata]
ReadPrec EmailTemplateMetadata
Int -> ReadS EmailTemplateMetadata
ReadS [EmailTemplateMetadata]
(Int -> ReadS EmailTemplateMetadata)
-> ReadS [EmailTemplateMetadata]
-> ReadPrec EmailTemplateMetadata
-> ReadPrec [EmailTemplateMetadata]
-> Read EmailTemplateMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EmailTemplateMetadata]
$creadListPrec :: ReadPrec [EmailTemplateMetadata]
readPrec :: ReadPrec EmailTemplateMetadata
$creadPrec :: ReadPrec EmailTemplateMetadata
readList :: ReadS [EmailTemplateMetadata]
$creadList :: ReadS [EmailTemplateMetadata]
readsPrec :: Int -> ReadS EmailTemplateMetadata
$creadsPrec :: Int -> ReadS EmailTemplateMetadata
Prelude.Read, Int -> EmailTemplateMetadata -> ShowS
[EmailTemplateMetadata] -> ShowS
EmailTemplateMetadata -> String
(Int -> EmailTemplateMetadata -> ShowS)
-> (EmailTemplateMetadata -> String)
-> ([EmailTemplateMetadata] -> ShowS)
-> Show EmailTemplateMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmailTemplateMetadata] -> ShowS
$cshowList :: [EmailTemplateMetadata] -> ShowS
show :: EmailTemplateMetadata -> String
$cshow :: EmailTemplateMetadata -> String
showsPrec :: Int -> EmailTemplateMetadata -> ShowS
$cshowsPrec :: Int -> EmailTemplateMetadata -> ShowS
Prelude.Show, (forall x. EmailTemplateMetadata -> Rep EmailTemplateMetadata x)
-> (forall x. Rep EmailTemplateMetadata x -> EmailTemplateMetadata)
-> Generic EmailTemplateMetadata
forall x. Rep EmailTemplateMetadata x -> EmailTemplateMetadata
forall x. EmailTemplateMetadata -> Rep EmailTemplateMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EmailTemplateMetadata x -> EmailTemplateMetadata
$cfrom :: forall x. EmailTemplateMetadata -> Rep EmailTemplateMetadata x
Prelude.Generic)

-- |
-- Create a value of 'EmailTemplateMetadata' 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:
--
-- 'templateName', 'emailTemplateMetadata_templateName' - The name of the template.
--
-- 'createdTimestamp', 'emailTemplateMetadata_createdTimestamp' - The time and date the template was created.
newEmailTemplateMetadata ::
  EmailTemplateMetadata
newEmailTemplateMetadata :: EmailTemplateMetadata
newEmailTemplateMetadata =
  EmailTemplateMetadata' :: Maybe Text -> Maybe POSIX -> EmailTemplateMetadata
EmailTemplateMetadata'
    { $sel:templateName:EmailTemplateMetadata' :: Maybe Text
templateName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTimestamp:EmailTemplateMetadata' :: Maybe POSIX
createdTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The time and date the template was created.
emailTemplateMetadata_createdTimestamp :: Lens.Lens' EmailTemplateMetadata (Prelude.Maybe Prelude.UTCTime)
emailTemplateMetadata_createdTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EmailTemplateMetadata -> f EmailTemplateMetadata
emailTemplateMetadata_createdTimestamp = (EmailTemplateMetadata -> Maybe POSIX)
-> (EmailTemplateMetadata -> Maybe POSIX -> EmailTemplateMetadata)
-> Lens
     EmailTemplateMetadata
     EmailTemplateMetadata
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmailTemplateMetadata' {Maybe POSIX
createdTimestamp :: Maybe POSIX
$sel:createdTimestamp:EmailTemplateMetadata' :: EmailTemplateMetadata -> Maybe POSIX
createdTimestamp} -> Maybe POSIX
createdTimestamp) (\s :: EmailTemplateMetadata
s@EmailTemplateMetadata' {} Maybe POSIX
a -> EmailTemplateMetadata
s {$sel:createdTimestamp:EmailTemplateMetadata' :: Maybe POSIX
createdTimestamp = Maybe POSIX
a} :: EmailTemplateMetadata) ((Maybe POSIX -> f (Maybe POSIX))
 -> EmailTemplateMetadata -> f EmailTemplateMetadata)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EmailTemplateMetadata
-> f EmailTemplateMetadata
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

instance Core.FromJSON EmailTemplateMetadata where
  parseJSON :: Value -> Parser EmailTemplateMetadata
parseJSON =
    String
-> (Object -> Parser EmailTemplateMetadata)
-> Value
-> Parser EmailTemplateMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EmailTemplateMetadata"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> EmailTemplateMetadata
EmailTemplateMetadata'
            (Maybe Text -> Maybe POSIX -> EmailTemplateMetadata)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> EmailTemplateMetadata)
forall (f :: * -> *) a b. Functor 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
"TemplateName")
            Parser (Maybe POSIX -> EmailTemplateMetadata)
-> Parser (Maybe POSIX) -> Parser EmailTemplateMetadata
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
"CreatedTimestamp")
      )

instance Prelude.Hashable EmailTemplateMetadata

instance Prelude.NFData EmailTemplateMetadata