{-# 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.MessageTag
-- 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.SESV2.Types.MessageTag 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

-- | Contains the name and value of a tag that you apply to an email. You can
-- use message tags when you publish email sending events.
--
-- /See:/ 'newMessageTag' smart constructor.
data MessageTag = MessageTag'
  { -- | The name of the message tag. The message tag name has to meet the
    -- following criteria:
    --
    -- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
    --     underscores (_), or dashes (-).
    --
    -- -   It can contain no more than 256 characters.
    MessageTag -> Text
name :: Prelude.Text,
    -- | The value of the message tag. The message tag value has to meet the
    -- following criteria:
    --
    -- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
    --     underscores (_), or dashes (-).
    --
    -- -   It can contain no more than 256 characters.
    MessageTag -> Text
value :: Prelude.Text
  }
  deriving (MessageTag -> MessageTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageTag -> MessageTag -> Bool
$c/= :: MessageTag -> MessageTag -> Bool
== :: MessageTag -> MessageTag -> Bool
$c== :: MessageTag -> MessageTag -> Bool
Prelude.Eq, ReadPrec [MessageTag]
ReadPrec MessageTag
Int -> ReadS MessageTag
ReadS [MessageTag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageTag]
$creadListPrec :: ReadPrec [MessageTag]
readPrec :: ReadPrec MessageTag
$creadPrec :: ReadPrec MessageTag
readList :: ReadS [MessageTag]
$creadList :: ReadS [MessageTag]
readsPrec :: Int -> ReadS MessageTag
$creadsPrec :: Int -> ReadS MessageTag
Prelude.Read, Int -> MessageTag -> ShowS
[MessageTag] -> ShowS
MessageTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageTag] -> ShowS
$cshowList :: [MessageTag] -> ShowS
show :: MessageTag -> String
$cshow :: MessageTag -> String
showsPrec :: Int -> MessageTag -> ShowS
$cshowsPrec :: Int -> MessageTag -> ShowS
Prelude.Show, forall x. Rep MessageTag x -> MessageTag
forall x. MessageTag -> Rep MessageTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MessageTag x -> MessageTag
$cfrom :: forall x. MessageTag -> Rep MessageTag x
Prelude.Generic)

-- |
-- Create a value of 'MessageTag' 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', 'messageTag_name' - The name of the message tag. The message tag name has to meet the
-- following criteria:
--
-- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
--     underscores (_), or dashes (-).
--
-- -   It can contain no more than 256 characters.
--
-- 'value', 'messageTag_value' - The value of the message tag. The message tag value has to meet the
-- following criteria:
--
-- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
--     underscores (_), or dashes (-).
--
-- -   It can contain no more than 256 characters.
newMessageTag ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  MessageTag
newMessageTag :: Text -> Text -> MessageTag
newMessageTag Text
pName_ Text
pValue_ =
  MessageTag' {$sel:name:MessageTag' :: Text
name = Text
pName_, $sel:value:MessageTag' :: Text
value = Text
pValue_}

-- | The name of the message tag. The message tag name has to meet the
-- following criteria:
--
-- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
--     underscores (_), or dashes (-).
--
-- -   It can contain no more than 256 characters.
messageTag_name :: Lens.Lens' MessageTag Prelude.Text
messageTag_name :: Lens' MessageTag Text
messageTag_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageTag' {Text
name :: Text
$sel:name:MessageTag' :: MessageTag -> Text
name} -> Text
name) (\s :: MessageTag
s@MessageTag' {} Text
a -> MessageTag
s {$sel:name:MessageTag' :: Text
name = Text
a} :: MessageTag)

-- | The value of the message tag. The message tag value has to meet the
-- following criteria:
--
-- -   It can only contain ASCII letters (a–z, A–Z), numbers (0–9),
--     underscores (_), or dashes (-).
--
-- -   It can contain no more than 256 characters.
messageTag_value :: Lens.Lens' MessageTag Prelude.Text
messageTag_value :: Lens' MessageTag Text
messageTag_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageTag' {Text
value :: Text
$sel:value:MessageTag' :: MessageTag -> Text
value} -> Text
value) (\s :: MessageTag
s@MessageTag' {} Text
a -> MessageTag
s {$sel:value:MessageTag' :: Text
value = Text
a} :: MessageTag)

instance Prelude.Hashable MessageTag where
  hashWithSalt :: Int -> MessageTag -> Int
hashWithSalt Int
_salt MessageTag' {Text
value :: Text
name :: Text
$sel:value:MessageTag' :: MessageTag -> Text
$sel:name:MessageTag' :: MessageTag -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData MessageTag where
  rnf :: MessageTag -> ()
rnf MessageTag' {Text
value :: Text
name :: Text
$sel:value:MessageTag' :: MessageTag -> Text
$sel:name:MessageTag' :: MessageTag -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON MessageTag where
  toJSON :: MessageTag -> Value
toJSON MessageTag' {Text
value :: Text
name :: Text
$sel:value:MessageTag' :: MessageTag -> Text
$sel:name:MessageTag' :: MessageTag -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )