{-# 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.CloudFront.Types.OriginCustomHeader
-- 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.CloudFront.Types.OriginCustomHeader where

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

-- | A complex type that contains @HeaderName@ and @HeaderValue@ elements, if
-- any, for this distribution.
--
-- /See:/ 'newOriginCustomHeader' smart constructor.
data OriginCustomHeader = OriginCustomHeader'
  { -- | The name of a header that you want CloudFront to send to your origin.
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/forward-custom-headers.html Adding Custom Headers to Origin Requests>
    -- in the /Amazon CloudFront Developer Guide/.
    OriginCustomHeader -> Text
headerName :: Prelude.Text,
    -- | The value for the header that you specified in the @HeaderName@ field.
    OriginCustomHeader -> Text
headerValue :: Prelude.Text
  }
  deriving (OriginCustomHeader -> OriginCustomHeader -> Bool
(OriginCustomHeader -> OriginCustomHeader -> Bool)
-> (OriginCustomHeader -> OriginCustomHeader -> Bool)
-> Eq OriginCustomHeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OriginCustomHeader -> OriginCustomHeader -> Bool
$c/= :: OriginCustomHeader -> OriginCustomHeader -> Bool
== :: OriginCustomHeader -> OriginCustomHeader -> Bool
$c== :: OriginCustomHeader -> OriginCustomHeader -> Bool
Prelude.Eq, ReadPrec [OriginCustomHeader]
ReadPrec OriginCustomHeader
Int -> ReadS OriginCustomHeader
ReadS [OriginCustomHeader]
(Int -> ReadS OriginCustomHeader)
-> ReadS [OriginCustomHeader]
-> ReadPrec OriginCustomHeader
-> ReadPrec [OriginCustomHeader]
-> Read OriginCustomHeader
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OriginCustomHeader]
$creadListPrec :: ReadPrec [OriginCustomHeader]
readPrec :: ReadPrec OriginCustomHeader
$creadPrec :: ReadPrec OriginCustomHeader
readList :: ReadS [OriginCustomHeader]
$creadList :: ReadS [OriginCustomHeader]
readsPrec :: Int -> ReadS OriginCustomHeader
$creadsPrec :: Int -> ReadS OriginCustomHeader
Prelude.Read, Int -> OriginCustomHeader -> ShowS
[OriginCustomHeader] -> ShowS
OriginCustomHeader -> String
(Int -> OriginCustomHeader -> ShowS)
-> (OriginCustomHeader -> String)
-> ([OriginCustomHeader] -> ShowS)
-> Show OriginCustomHeader
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OriginCustomHeader] -> ShowS
$cshowList :: [OriginCustomHeader] -> ShowS
show :: OriginCustomHeader -> String
$cshow :: OriginCustomHeader -> String
showsPrec :: Int -> OriginCustomHeader -> ShowS
$cshowsPrec :: Int -> OriginCustomHeader -> ShowS
Prelude.Show, (forall x. OriginCustomHeader -> Rep OriginCustomHeader x)
-> (forall x. Rep OriginCustomHeader x -> OriginCustomHeader)
-> Generic OriginCustomHeader
forall x. Rep OriginCustomHeader x -> OriginCustomHeader
forall x. OriginCustomHeader -> Rep OriginCustomHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OriginCustomHeader x -> OriginCustomHeader
$cfrom :: forall x. OriginCustomHeader -> Rep OriginCustomHeader x
Prelude.Generic)

-- |
-- Create a value of 'OriginCustomHeader' 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', 'originCustomHeader_headerName' - The name of a header that you want CloudFront to send to your origin.
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/forward-custom-headers.html Adding Custom Headers to Origin Requests>
-- in the /Amazon CloudFront Developer Guide/.
--
-- 'headerValue', 'originCustomHeader_headerValue' - The value for the header that you specified in the @HeaderName@ field.
newOriginCustomHeader ::
  -- | 'headerName'
  Prelude.Text ->
  -- | 'headerValue'
  Prelude.Text ->
  OriginCustomHeader
newOriginCustomHeader :: Text -> Text -> OriginCustomHeader
newOriginCustomHeader Text
pHeaderName_ Text
pHeaderValue_ =
  OriginCustomHeader' :: Text -> Text -> OriginCustomHeader
OriginCustomHeader'
    { $sel:headerName:OriginCustomHeader' :: Text
headerName = Text
pHeaderName_,
      $sel:headerValue:OriginCustomHeader' :: Text
headerValue = Text
pHeaderValue_
    }

-- | The name of a header that you want CloudFront to send to your origin.
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/forward-custom-headers.html Adding Custom Headers to Origin Requests>
-- in the /Amazon CloudFront Developer Guide/.
originCustomHeader_headerName :: Lens.Lens' OriginCustomHeader Prelude.Text
originCustomHeader_headerName :: (Text -> f Text) -> OriginCustomHeader -> f OriginCustomHeader
originCustomHeader_headerName = (OriginCustomHeader -> Text)
-> (OriginCustomHeader -> Text -> OriginCustomHeader)
-> Lens OriginCustomHeader OriginCustomHeader Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginCustomHeader' {Text
headerName :: Text
$sel:headerName:OriginCustomHeader' :: OriginCustomHeader -> Text
headerName} -> Text
headerName) (\s :: OriginCustomHeader
s@OriginCustomHeader' {} Text
a -> OriginCustomHeader
s {$sel:headerName:OriginCustomHeader' :: Text
headerName = Text
a} :: OriginCustomHeader)

-- | The value for the header that you specified in the @HeaderName@ field.
originCustomHeader_headerValue :: Lens.Lens' OriginCustomHeader Prelude.Text
originCustomHeader_headerValue :: (Text -> f Text) -> OriginCustomHeader -> f OriginCustomHeader
originCustomHeader_headerValue = (OriginCustomHeader -> Text)
-> (OriginCustomHeader -> Text -> OriginCustomHeader)
-> Lens OriginCustomHeader OriginCustomHeader Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginCustomHeader' {Text
headerValue :: Text
$sel:headerValue:OriginCustomHeader' :: OriginCustomHeader -> Text
headerValue} -> Text
headerValue) (\s :: OriginCustomHeader
s@OriginCustomHeader' {} Text
a -> OriginCustomHeader
s {$sel:headerValue:OriginCustomHeader' :: Text
headerValue = Text
a} :: OriginCustomHeader)

instance Core.FromXML OriginCustomHeader where
  parseXML :: [Node] -> Either String OriginCustomHeader
parseXML [Node]
x =
    Text -> Text -> OriginCustomHeader
OriginCustomHeader'
      (Text -> Text -> OriginCustomHeader)
-> Either String Text -> Either String (Text -> OriginCustomHeader)
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 -> OriginCustomHeader)
-> Either String Text -> Either String OriginCustomHeader
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 OriginCustomHeader

instance Prelude.NFData OriginCustomHeader

instance Core.ToXML OriginCustomHeader where
  toXML :: OriginCustomHeader -> XML
toXML OriginCustomHeader' {Text
headerValue :: Text
headerName :: Text
$sel:headerValue:OriginCustomHeader' :: OriginCustomHeader -> Text
$sel:headerName:OriginCustomHeader' :: OriginCustomHeader -> Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"HeaderName" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
headerName,
        Name
"HeaderValue" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
headerValue
      ]