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

-- | When included in a receipt rule, this action adds a header to the
-- received email.
--
-- For information about adding a header using a receipt rule, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-add-header.html Amazon SES Developer Guide>.
--
-- /See:/ 'newAddHeaderAction' smart constructor.
data AddHeaderAction = AddHeaderAction'
  { -- | 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.
    AddHeaderAction -> Text
headerName :: Prelude.Text,
    -- | Must be less than 2048 characters, and must not contain newline
    -- characters (\"\\r\" or \"\\n\").
    AddHeaderAction -> Text
headerValue :: Prelude.Text
  }
  deriving (AddHeaderAction -> AddHeaderAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddHeaderAction -> AddHeaderAction -> Bool
$c/= :: AddHeaderAction -> AddHeaderAction -> Bool
== :: AddHeaderAction -> AddHeaderAction -> Bool
$c== :: AddHeaderAction -> AddHeaderAction -> Bool
Prelude.Eq, ReadPrec [AddHeaderAction]
ReadPrec AddHeaderAction
Int -> ReadS AddHeaderAction
ReadS [AddHeaderAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddHeaderAction]
$creadListPrec :: ReadPrec [AddHeaderAction]
readPrec :: ReadPrec AddHeaderAction
$creadPrec :: ReadPrec AddHeaderAction
readList :: ReadS [AddHeaderAction]
$creadList :: ReadS [AddHeaderAction]
readsPrec :: Int -> ReadS AddHeaderAction
$creadsPrec :: Int -> ReadS AddHeaderAction
Prelude.Read, Int -> AddHeaderAction -> ShowS
[AddHeaderAction] -> ShowS
AddHeaderAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddHeaderAction] -> ShowS
$cshowList :: [AddHeaderAction] -> ShowS
show :: AddHeaderAction -> String
$cshow :: AddHeaderAction -> String
showsPrec :: Int -> AddHeaderAction -> ShowS
$cshowsPrec :: Int -> AddHeaderAction -> ShowS
Prelude.Show, forall x. Rep AddHeaderAction x -> AddHeaderAction
forall x. AddHeaderAction -> Rep AddHeaderAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddHeaderAction x -> AddHeaderAction
$cfrom :: forall x. AddHeaderAction -> Rep AddHeaderAction x
Prelude.Generic)

-- |
-- Create a value of 'AddHeaderAction' 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:
--
-- 'headerName', 'addHeaderAction_headerName' - 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.
--
-- 'headerValue', 'addHeaderAction_headerValue' - Must be less than 2048 characters, and must not contain newline
-- characters (\"\\r\" or \"\\n\").
newAddHeaderAction ::
  -- | 'headerName'
  Prelude.Text ->
  -- | 'headerValue'
  Prelude.Text ->
  AddHeaderAction
newAddHeaderAction :: Text -> Text -> AddHeaderAction
newAddHeaderAction Text
pHeaderName_ Text
pHeaderValue_ =
  AddHeaderAction'
    { $sel:headerName:AddHeaderAction' :: Text
headerName = Text
pHeaderName_,
      $sel:headerValue:AddHeaderAction' :: Text
headerValue = Text
pHeaderValue_
    }

-- | 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.
addHeaderAction_headerName :: Lens.Lens' AddHeaderAction Prelude.Text
addHeaderAction_headerName :: Lens' AddHeaderAction Text
addHeaderAction_headerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddHeaderAction' {Text
headerName :: Text
$sel:headerName:AddHeaderAction' :: AddHeaderAction -> Text
headerName} -> Text
headerName) (\s :: AddHeaderAction
s@AddHeaderAction' {} Text
a -> AddHeaderAction
s {$sel:headerName:AddHeaderAction' :: Text
headerName = Text
a} :: AddHeaderAction)

-- | Must be less than 2048 characters, and must not contain newline
-- characters (\"\\r\" or \"\\n\").
addHeaderAction_headerValue :: Lens.Lens' AddHeaderAction Prelude.Text
addHeaderAction_headerValue :: Lens' AddHeaderAction Text
addHeaderAction_headerValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddHeaderAction' {Text
headerValue :: Text
$sel:headerValue:AddHeaderAction' :: AddHeaderAction -> Text
headerValue} -> Text
headerValue) (\s :: AddHeaderAction
s@AddHeaderAction' {} Text
a -> AddHeaderAction
s {$sel:headerValue:AddHeaderAction' :: Text
headerValue = Text
a} :: AddHeaderAction)

instance Data.FromXML AddHeaderAction where
  parseXML :: [Node] -> Either String AddHeaderAction
parseXML [Node]
x =
    Text -> Text -> AddHeaderAction
AddHeaderAction'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"HeaderName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"HeaderValue")

instance Prelude.Hashable AddHeaderAction where
  hashWithSalt :: Int -> AddHeaderAction -> Int
hashWithSalt Int
_salt AddHeaderAction' {Text
headerValue :: Text
headerName :: Text
$sel:headerValue:AddHeaderAction' :: AddHeaderAction -> Text
$sel:headerName:AddHeaderAction' :: AddHeaderAction -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
headerName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
headerValue

instance Prelude.NFData AddHeaderAction where
  rnf :: AddHeaderAction -> ()
rnf AddHeaderAction' {Text
headerValue :: Text
headerName :: Text
$sel:headerValue:AddHeaderAction' :: AddHeaderAction -> Text
$sel:headerName:AddHeaderAction' :: AddHeaderAction -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
headerName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
headerValue

instance Data.ToQuery AddHeaderAction where
  toQuery :: AddHeaderAction -> QueryString
toQuery AddHeaderAction' {Text
headerValue :: Text
headerName :: Text
$sel:headerValue:AddHeaderAction' :: AddHeaderAction -> Text
$sel:headerName:AddHeaderAction' :: AddHeaderAction -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"HeaderName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
headerName,
        ByteString
"HeaderValue" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
headerValue
      ]