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

-- | An HTTP response header name and its value. CloudFront includes this
-- header in HTTP responses that it sends for requests that match a cache
-- behavior that\'s associated with this response headers policy.
--
-- /See:/ 'newResponseHeadersPolicyCustomHeader' smart constructor.
data ResponseHeadersPolicyCustomHeader = ResponseHeadersPolicyCustomHeader'
  { -- | The HTTP response header name.
    ResponseHeadersPolicyCustomHeader -> Text
header :: Prelude.Text,
    -- | The value for the HTTP response header.
    ResponseHeadersPolicyCustomHeader -> Text
value :: Prelude.Text,
    -- | A Boolean that determines whether CloudFront overrides a response header
    -- with the same name received from the origin with the header specified
    -- here.
    ResponseHeadersPolicyCustomHeader -> Bool
override :: Prelude.Bool
  }
  deriving (ResponseHeadersPolicyCustomHeader
-> ResponseHeadersPolicyCustomHeader -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseHeadersPolicyCustomHeader
-> ResponseHeadersPolicyCustomHeader -> Bool
$c/= :: ResponseHeadersPolicyCustomHeader
-> ResponseHeadersPolicyCustomHeader -> Bool
== :: ResponseHeadersPolicyCustomHeader
-> ResponseHeadersPolicyCustomHeader -> Bool
$c== :: ResponseHeadersPolicyCustomHeader
-> ResponseHeadersPolicyCustomHeader -> Bool
Prelude.Eq, ReadPrec [ResponseHeadersPolicyCustomHeader]
ReadPrec ResponseHeadersPolicyCustomHeader
Int -> ReadS ResponseHeadersPolicyCustomHeader
ReadS [ResponseHeadersPolicyCustomHeader]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResponseHeadersPolicyCustomHeader]
$creadListPrec :: ReadPrec [ResponseHeadersPolicyCustomHeader]
readPrec :: ReadPrec ResponseHeadersPolicyCustomHeader
$creadPrec :: ReadPrec ResponseHeadersPolicyCustomHeader
readList :: ReadS [ResponseHeadersPolicyCustomHeader]
$creadList :: ReadS [ResponseHeadersPolicyCustomHeader]
readsPrec :: Int -> ReadS ResponseHeadersPolicyCustomHeader
$creadsPrec :: Int -> ReadS ResponseHeadersPolicyCustomHeader
Prelude.Read, Int -> ResponseHeadersPolicyCustomHeader -> ShowS
[ResponseHeadersPolicyCustomHeader] -> ShowS
ResponseHeadersPolicyCustomHeader -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseHeadersPolicyCustomHeader] -> ShowS
$cshowList :: [ResponseHeadersPolicyCustomHeader] -> ShowS
show :: ResponseHeadersPolicyCustomHeader -> String
$cshow :: ResponseHeadersPolicyCustomHeader -> String
showsPrec :: Int -> ResponseHeadersPolicyCustomHeader -> ShowS
$cshowsPrec :: Int -> ResponseHeadersPolicyCustomHeader -> ShowS
Prelude.Show, forall x.
Rep ResponseHeadersPolicyCustomHeader x
-> ResponseHeadersPolicyCustomHeader
forall x.
ResponseHeadersPolicyCustomHeader
-> Rep ResponseHeadersPolicyCustomHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResponseHeadersPolicyCustomHeader x
-> ResponseHeadersPolicyCustomHeader
$cfrom :: forall x.
ResponseHeadersPolicyCustomHeader
-> Rep ResponseHeadersPolicyCustomHeader x
Prelude.Generic)

-- |
-- Create a value of 'ResponseHeadersPolicyCustomHeader' 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:
--
-- 'header', 'responseHeadersPolicyCustomHeader_header' - The HTTP response header name.
--
-- 'value', 'responseHeadersPolicyCustomHeader_value' - The value for the HTTP response header.
--
-- 'override', 'responseHeadersPolicyCustomHeader_override' - A Boolean that determines whether CloudFront overrides a response header
-- with the same name received from the origin with the header specified
-- here.
newResponseHeadersPolicyCustomHeader ::
  -- | 'header'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  -- | 'override'
  Prelude.Bool ->
  ResponseHeadersPolicyCustomHeader
newResponseHeadersPolicyCustomHeader :: Text -> Text -> Bool -> ResponseHeadersPolicyCustomHeader
newResponseHeadersPolicyCustomHeader
  Text
pHeader_
  Text
pValue_
  Bool
pOverride_ =
    ResponseHeadersPolicyCustomHeader'
      { $sel:header:ResponseHeadersPolicyCustomHeader' :: Text
header =
          Text
pHeader_,
        $sel:value:ResponseHeadersPolicyCustomHeader' :: Text
value = Text
pValue_,
        $sel:override:ResponseHeadersPolicyCustomHeader' :: Bool
override = Bool
pOverride_
      }

-- | The HTTP response header name.
responseHeadersPolicyCustomHeader_header :: Lens.Lens' ResponseHeadersPolicyCustomHeader Prelude.Text
responseHeadersPolicyCustomHeader_header :: Lens' ResponseHeadersPolicyCustomHeader Text
responseHeadersPolicyCustomHeader_header = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyCustomHeader' {Text
header :: Text
$sel:header:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Text
header} -> Text
header) (\s :: ResponseHeadersPolicyCustomHeader
s@ResponseHeadersPolicyCustomHeader' {} Text
a -> ResponseHeadersPolicyCustomHeader
s {$sel:header:ResponseHeadersPolicyCustomHeader' :: Text
header = Text
a} :: ResponseHeadersPolicyCustomHeader)

-- | The value for the HTTP response header.
responseHeadersPolicyCustomHeader_value :: Lens.Lens' ResponseHeadersPolicyCustomHeader Prelude.Text
responseHeadersPolicyCustomHeader_value :: Lens' ResponseHeadersPolicyCustomHeader Text
responseHeadersPolicyCustomHeader_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyCustomHeader' {Text
value :: Text
$sel:value:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Text
value} -> Text
value) (\s :: ResponseHeadersPolicyCustomHeader
s@ResponseHeadersPolicyCustomHeader' {} Text
a -> ResponseHeadersPolicyCustomHeader
s {$sel:value:ResponseHeadersPolicyCustomHeader' :: Text
value = Text
a} :: ResponseHeadersPolicyCustomHeader)

-- | A Boolean that determines whether CloudFront overrides a response header
-- with the same name received from the origin with the header specified
-- here.
responseHeadersPolicyCustomHeader_override :: Lens.Lens' ResponseHeadersPolicyCustomHeader Prelude.Bool
responseHeadersPolicyCustomHeader_override :: Lens' ResponseHeadersPolicyCustomHeader Bool
responseHeadersPolicyCustomHeader_override = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyCustomHeader' {Bool
override :: Bool
$sel:override:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Bool
override} -> Bool
override) (\s :: ResponseHeadersPolicyCustomHeader
s@ResponseHeadersPolicyCustomHeader' {} Bool
a -> ResponseHeadersPolicyCustomHeader
s {$sel:override:ResponseHeadersPolicyCustomHeader' :: Bool
override = Bool
a} :: ResponseHeadersPolicyCustomHeader)

instance
  Data.FromXML
    ResponseHeadersPolicyCustomHeader
  where
  parseXML :: [Node] -> Either String ResponseHeadersPolicyCustomHeader
parseXML [Node]
x =
    Text -> Text -> Bool -> ResponseHeadersPolicyCustomHeader
ResponseHeadersPolicyCustomHeader'
      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
"Header")
      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
"Value")
      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
"Override")

instance
  Prelude.Hashable
    ResponseHeadersPolicyCustomHeader
  where
  hashWithSalt :: Int -> ResponseHeadersPolicyCustomHeader -> Int
hashWithSalt
    Int
_salt
    ResponseHeadersPolicyCustomHeader' {Bool
Text
override :: Bool
value :: Text
header :: Text
$sel:override:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Bool
$sel:value:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Text
$sel:header:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
header
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
override

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

instance Data.ToXML ResponseHeadersPolicyCustomHeader where
  toXML :: ResponseHeadersPolicyCustomHeader -> XML
toXML ResponseHeadersPolicyCustomHeader' {Bool
Text
override :: Bool
value :: Text
header :: Text
$sel:override:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Bool
$sel:value:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Text
$sel:header:ResponseHeadersPolicyCustomHeader' :: ResponseHeadersPolicyCustomHeader -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Header" forall a. ToXML a => Name -> a -> XML
Data.@= Text
header,
        Name
"Value" forall a. ToXML a => Name -> a -> XML
Data.@= Text
value,
        Name
"Override" forall a. ToXML a => Name -> a -> XML
Data.@= Bool
override
      ]