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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(AddHeaderAction -> AddHeaderAction -> Bool)
-> (AddHeaderAction -> AddHeaderAction -> Bool)
-> Eq AddHeaderAction
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]
(Int -> ReadS AddHeaderAction)
-> ReadS [AddHeaderAction]
-> ReadPrec AddHeaderAction
-> ReadPrec [AddHeaderAction]
-> Read 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
(Int -> AddHeaderAction -> ShowS)
-> (AddHeaderAction -> String)
-> ([AddHeaderAction] -> ShowS)
-> Show AddHeaderAction
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. AddHeaderAction -> Rep AddHeaderAction x)
-> (forall x. Rep AddHeaderAction x -> AddHeaderAction)
-> Generic AddHeaderAction
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' :: Text -> Text -> AddHeaderAction
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 :: (Text -> f Text) -> AddHeaderAction -> f AddHeaderAction
addHeaderAction_headerName = (AddHeaderAction -> Text)
-> (AddHeaderAction -> Text -> AddHeaderAction)
-> Lens AddHeaderAction AddHeaderAction Text Text
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 :: (Text -> f Text) -> AddHeaderAction -> f AddHeaderAction
addHeaderAction_headerValue = (AddHeaderAction -> Text)
-> (AddHeaderAction -> Text -> AddHeaderAction)
-> Lens AddHeaderAction AddHeaderAction Text Text
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 Core.FromXML AddHeaderAction where
  parseXML :: [Node] -> Either String AddHeaderAction
parseXML [Node]
x =
    Text -> Text -> AddHeaderAction
AddHeaderAction'
      (Text -> Text -> AddHeaderAction)
-> Either String Text -> Either String (Text -> AddHeaderAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"HeaderName")
      Either String (Text -> AddHeaderAction)
-> Either String Text -> Either String AddHeaderAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"HeaderValue")

instance Prelude.Hashable AddHeaderAction

instance Prelude.NFData AddHeaderAction

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