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

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

-- | Additional X-headers to include in the Delivery Status Notification
-- (DSN) when an email that Amazon SES receives on your behalf bounces.
--
-- For information about receiving email through Amazon SES, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email.html Amazon SES Developer Guide>.
--
-- /See:/ 'newExtensionField' smart constructor.
data ExtensionField = ExtensionField'
  { -- | The name of the header to add. Must be between 1 and 50 characters,
    -- inclusive, and consist of alphanumeric (a-z, A-Z, 0-9) characters and
    -- dashes only.
    ExtensionField -> Text
name :: Prelude.Text,
    -- | The value of the header to add. Must be less than 2048 characters, and
    -- must not contain newline characters (\"\\r\" or \"\\n\").
    ExtensionField -> Text
value :: Prelude.Text
  }
  deriving (ExtensionField -> ExtensionField -> Bool
(ExtensionField -> ExtensionField -> Bool)
-> (ExtensionField -> ExtensionField -> Bool) -> Eq ExtensionField
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExtensionField -> ExtensionField -> Bool
$c/= :: ExtensionField -> ExtensionField -> Bool
== :: ExtensionField -> ExtensionField -> Bool
$c== :: ExtensionField -> ExtensionField -> Bool
Prelude.Eq, ReadPrec [ExtensionField]
ReadPrec ExtensionField
Int -> ReadS ExtensionField
ReadS [ExtensionField]
(Int -> ReadS ExtensionField)
-> ReadS [ExtensionField]
-> ReadPrec ExtensionField
-> ReadPrec [ExtensionField]
-> Read ExtensionField
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExtensionField]
$creadListPrec :: ReadPrec [ExtensionField]
readPrec :: ReadPrec ExtensionField
$creadPrec :: ReadPrec ExtensionField
readList :: ReadS [ExtensionField]
$creadList :: ReadS [ExtensionField]
readsPrec :: Int -> ReadS ExtensionField
$creadsPrec :: Int -> ReadS ExtensionField
Prelude.Read, Int -> ExtensionField -> ShowS
[ExtensionField] -> ShowS
ExtensionField -> String
(Int -> ExtensionField -> ShowS)
-> (ExtensionField -> String)
-> ([ExtensionField] -> ShowS)
-> Show ExtensionField
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExtensionField] -> ShowS
$cshowList :: [ExtensionField] -> ShowS
show :: ExtensionField -> String
$cshow :: ExtensionField -> String
showsPrec :: Int -> ExtensionField -> ShowS
$cshowsPrec :: Int -> ExtensionField -> ShowS
Prelude.Show, (forall x. ExtensionField -> Rep ExtensionField x)
-> (forall x. Rep ExtensionField x -> ExtensionField)
-> Generic ExtensionField
forall x. Rep ExtensionField x -> ExtensionField
forall x. ExtensionField -> Rep ExtensionField x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExtensionField x -> ExtensionField
$cfrom :: forall x. ExtensionField -> Rep ExtensionField x
Prelude.Generic)

-- |
-- Create a value of 'ExtensionField' 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', 'extensionField_name' - The name of the header to add. Must be between 1 and 50 characters,
-- inclusive, and consist of alphanumeric (a-z, A-Z, 0-9) characters and
-- dashes only.
--
-- 'value', 'extensionField_value' - The value of the header to add. Must be less than 2048 characters, and
-- must not contain newline characters (\"\\r\" or \"\\n\").
newExtensionField ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  ExtensionField
newExtensionField :: Text -> Text -> ExtensionField
newExtensionField Text
pName_ Text
pValue_ =
  ExtensionField' :: Text -> Text -> ExtensionField
ExtensionField' {$sel:name:ExtensionField' :: Text
name = Text
pName_, $sel:value:ExtensionField' :: Text
value = Text
pValue_}

-- | The name of the header to add. Must be between 1 and 50 characters,
-- inclusive, and consist of alphanumeric (a-z, A-Z, 0-9) characters and
-- dashes only.
extensionField_name :: Lens.Lens' ExtensionField Prelude.Text
extensionField_name :: (Text -> f Text) -> ExtensionField -> f ExtensionField
extensionField_name = (ExtensionField -> Text)
-> (ExtensionField -> Text -> ExtensionField)
-> Lens ExtensionField ExtensionField Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExtensionField' {Text
name :: Text
$sel:name:ExtensionField' :: ExtensionField -> Text
name} -> Text
name) (\s :: ExtensionField
s@ExtensionField' {} Text
a -> ExtensionField
s {$sel:name:ExtensionField' :: Text
name = Text
a} :: ExtensionField)

-- | The value of the header to add. Must be less than 2048 characters, and
-- must not contain newline characters (\"\\r\" or \"\\n\").
extensionField_value :: Lens.Lens' ExtensionField Prelude.Text
extensionField_value :: (Text -> f Text) -> ExtensionField -> f ExtensionField
extensionField_value = (ExtensionField -> Text)
-> (ExtensionField -> Text -> ExtensionField)
-> Lens ExtensionField ExtensionField Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExtensionField' {Text
value :: Text
$sel:value:ExtensionField' :: ExtensionField -> Text
value} -> Text
value) (\s :: ExtensionField
s@ExtensionField' {} Text
a -> ExtensionField
s {$sel:value:ExtensionField' :: Text
value = Text
a} :: ExtensionField)

instance Prelude.Hashable ExtensionField

instance Prelude.NFData ExtensionField

instance Core.ToQuery ExtensionField where
  toQuery :: ExtensionField -> QueryString
toQuery ExtensionField' {Text
value :: Text
name :: Text
$sel:value:ExtensionField' :: ExtensionField -> Text
$sel:name:ExtensionField' :: ExtensionField -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Name" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
name, ByteString
"Value" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
value]