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

import Amazonka.CloudFront.Types.ResponseHeadersPolicyCustomHeader
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

-- | A list of HTTP response header names and their values. CloudFront
-- includes these headers in HTTP responses that it sends for requests that
-- match a cache behavior that\'s associated with this response headers
-- policy.
--
-- /See:/ 'newResponseHeadersPolicyCustomHeadersConfig' smart constructor.
data ResponseHeadersPolicyCustomHeadersConfig = ResponseHeadersPolicyCustomHeadersConfig'
  { -- | The list of HTTP response headers and their values.
    ResponseHeadersPolicyCustomHeadersConfig
-> Maybe [ResponseHeadersPolicyCustomHeader]
items :: Prelude.Maybe [ResponseHeadersPolicyCustomHeader],
    -- | The number of HTTP response headers in the list.
    ResponseHeadersPolicyCustomHeadersConfig -> Int
quantity :: Prelude.Int
  }
  deriving (ResponseHeadersPolicyCustomHeadersConfig
-> ResponseHeadersPolicyCustomHeadersConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseHeadersPolicyCustomHeadersConfig
-> ResponseHeadersPolicyCustomHeadersConfig -> Bool
$c/= :: ResponseHeadersPolicyCustomHeadersConfig
-> ResponseHeadersPolicyCustomHeadersConfig -> Bool
== :: ResponseHeadersPolicyCustomHeadersConfig
-> ResponseHeadersPolicyCustomHeadersConfig -> Bool
$c== :: ResponseHeadersPolicyCustomHeadersConfig
-> ResponseHeadersPolicyCustomHeadersConfig -> Bool
Prelude.Eq, ReadPrec [ResponseHeadersPolicyCustomHeadersConfig]
ReadPrec ResponseHeadersPolicyCustomHeadersConfig
Int -> ReadS ResponseHeadersPolicyCustomHeadersConfig
ReadS [ResponseHeadersPolicyCustomHeadersConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResponseHeadersPolicyCustomHeadersConfig]
$creadListPrec :: ReadPrec [ResponseHeadersPolicyCustomHeadersConfig]
readPrec :: ReadPrec ResponseHeadersPolicyCustomHeadersConfig
$creadPrec :: ReadPrec ResponseHeadersPolicyCustomHeadersConfig
readList :: ReadS [ResponseHeadersPolicyCustomHeadersConfig]
$creadList :: ReadS [ResponseHeadersPolicyCustomHeadersConfig]
readsPrec :: Int -> ReadS ResponseHeadersPolicyCustomHeadersConfig
$creadsPrec :: Int -> ReadS ResponseHeadersPolicyCustomHeadersConfig
Prelude.Read, Int -> ResponseHeadersPolicyCustomHeadersConfig -> ShowS
[ResponseHeadersPolicyCustomHeadersConfig] -> ShowS
ResponseHeadersPolicyCustomHeadersConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseHeadersPolicyCustomHeadersConfig] -> ShowS
$cshowList :: [ResponseHeadersPolicyCustomHeadersConfig] -> ShowS
show :: ResponseHeadersPolicyCustomHeadersConfig -> String
$cshow :: ResponseHeadersPolicyCustomHeadersConfig -> String
showsPrec :: Int -> ResponseHeadersPolicyCustomHeadersConfig -> ShowS
$cshowsPrec :: Int -> ResponseHeadersPolicyCustomHeadersConfig -> ShowS
Prelude.Show, forall x.
Rep ResponseHeadersPolicyCustomHeadersConfig x
-> ResponseHeadersPolicyCustomHeadersConfig
forall x.
ResponseHeadersPolicyCustomHeadersConfig
-> Rep ResponseHeadersPolicyCustomHeadersConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResponseHeadersPolicyCustomHeadersConfig x
-> ResponseHeadersPolicyCustomHeadersConfig
$cfrom :: forall x.
ResponseHeadersPolicyCustomHeadersConfig
-> Rep ResponseHeadersPolicyCustomHeadersConfig x
Prelude.Generic)

-- |
-- Create a value of 'ResponseHeadersPolicyCustomHeadersConfig' 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:
--
-- 'items', 'responseHeadersPolicyCustomHeadersConfig_items' - The list of HTTP response headers and their values.
--
-- 'quantity', 'responseHeadersPolicyCustomHeadersConfig_quantity' - The number of HTTP response headers in the list.
newResponseHeadersPolicyCustomHeadersConfig ::
  -- | 'quantity'
  Prelude.Int ->
  ResponseHeadersPolicyCustomHeadersConfig
newResponseHeadersPolicyCustomHeadersConfig :: Int -> ResponseHeadersPolicyCustomHeadersConfig
newResponseHeadersPolicyCustomHeadersConfig
  Int
pQuantity_ =
    ResponseHeadersPolicyCustomHeadersConfig'
      { $sel:items:ResponseHeadersPolicyCustomHeadersConfig' :: Maybe [ResponseHeadersPolicyCustomHeader]
items =
          forall a. Maybe a
Prelude.Nothing,
        $sel:quantity:ResponseHeadersPolicyCustomHeadersConfig' :: Int
quantity = Int
pQuantity_
      }

-- | The list of HTTP response headers and their values.
responseHeadersPolicyCustomHeadersConfig_items :: Lens.Lens' ResponseHeadersPolicyCustomHeadersConfig (Prelude.Maybe [ResponseHeadersPolicyCustomHeader])
responseHeadersPolicyCustomHeadersConfig_items :: Lens'
  ResponseHeadersPolicyCustomHeadersConfig
  (Maybe [ResponseHeadersPolicyCustomHeader])
responseHeadersPolicyCustomHeadersConfig_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyCustomHeadersConfig' {Maybe [ResponseHeadersPolicyCustomHeader]
items :: Maybe [ResponseHeadersPolicyCustomHeader]
$sel:items:ResponseHeadersPolicyCustomHeadersConfig' :: ResponseHeadersPolicyCustomHeadersConfig
-> Maybe [ResponseHeadersPolicyCustomHeader]
items} -> Maybe [ResponseHeadersPolicyCustomHeader]
items) (\s :: ResponseHeadersPolicyCustomHeadersConfig
s@ResponseHeadersPolicyCustomHeadersConfig' {} Maybe [ResponseHeadersPolicyCustomHeader]
a -> ResponseHeadersPolicyCustomHeadersConfig
s {$sel:items:ResponseHeadersPolicyCustomHeadersConfig' :: Maybe [ResponseHeadersPolicyCustomHeader]
items = Maybe [ResponseHeadersPolicyCustomHeader]
a} :: ResponseHeadersPolicyCustomHeadersConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The number of HTTP response headers in the list.
responseHeadersPolicyCustomHeadersConfig_quantity :: Lens.Lens' ResponseHeadersPolicyCustomHeadersConfig Prelude.Int
responseHeadersPolicyCustomHeadersConfig_quantity :: Lens' ResponseHeadersPolicyCustomHeadersConfig Int
responseHeadersPolicyCustomHeadersConfig_quantity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseHeadersPolicyCustomHeadersConfig' {Int
quantity :: Int
$sel:quantity:ResponseHeadersPolicyCustomHeadersConfig' :: ResponseHeadersPolicyCustomHeadersConfig -> Int
quantity} -> Int
quantity) (\s :: ResponseHeadersPolicyCustomHeadersConfig
s@ResponseHeadersPolicyCustomHeadersConfig' {} Int
a -> ResponseHeadersPolicyCustomHeadersConfig
s {$sel:quantity:ResponseHeadersPolicyCustomHeadersConfig' :: Int
quantity = Int
a} :: ResponseHeadersPolicyCustomHeadersConfig)

instance
  Data.FromXML
    ResponseHeadersPolicyCustomHeadersConfig
  where
  parseXML :: [Node] -> Either String ResponseHeadersPolicyCustomHeadersConfig
parseXML [Node]
x =
    Maybe [ResponseHeadersPolicyCustomHeader]
-> Int -> ResponseHeadersPolicyCustomHeadersConfig
ResponseHeadersPolicyCustomHeadersConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Items"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may
                        ( forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList
                            Text
"ResponseHeadersPolicyCustomHeader"
                        )
                  )
      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
"Quantity")

instance
  Prelude.Hashable
    ResponseHeadersPolicyCustomHeadersConfig
  where
  hashWithSalt :: Int -> ResponseHeadersPolicyCustomHeadersConfig -> Int
hashWithSalt
    Int
_salt
    ResponseHeadersPolicyCustomHeadersConfig' {Int
Maybe [ResponseHeadersPolicyCustomHeader]
quantity :: Int
items :: Maybe [ResponseHeadersPolicyCustomHeader]
$sel:quantity:ResponseHeadersPolicyCustomHeadersConfig' :: ResponseHeadersPolicyCustomHeadersConfig -> Int
$sel:items:ResponseHeadersPolicyCustomHeadersConfig' :: ResponseHeadersPolicyCustomHeadersConfig
-> Maybe [ResponseHeadersPolicyCustomHeader]
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ResponseHeadersPolicyCustomHeader]
items
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity

instance
  Prelude.NFData
    ResponseHeadersPolicyCustomHeadersConfig
  where
  rnf :: ResponseHeadersPolicyCustomHeadersConfig -> ()
rnf ResponseHeadersPolicyCustomHeadersConfig' {Int
Maybe [ResponseHeadersPolicyCustomHeader]
quantity :: Int
items :: Maybe [ResponseHeadersPolicyCustomHeader]
$sel:quantity:ResponseHeadersPolicyCustomHeadersConfig' :: ResponseHeadersPolicyCustomHeadersConfig -> Int
$sel:items:ResponseHeadersPolicyCustomHeadersConfig' :: ResponseHeadersPolicyCustomHeadersConfig
-> Maybe [ResponseHeadersPolicyCustomHeader]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ResponseHeadersPolicyCustomHeader]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
quantity

instance
  Data.ToXML
    ResponseHeadersPolicyCustomHeadersConfig
  where
  toXML :: ResponseHeadersPolicyCustomHeadersConfig -> XML
toXML ResponseHeadersPolicyCustomHeadersConfig' {Int
Maybe [ResponseHeadersPolicyCustomHeader]
quantity :: Int
items :: Maybe [ResponseHeadersPolicyCustomHeader]
$sel:quantity:ResponseHeadersPolicyCustomHeadersConfig' :: ResponseHeadersPolicyCustomHeadersConfig -> Int
$sel:items:ResponseHeadersPolicyCustomHeadersConfig' :: ResponseHeadersPolicyCustomHeadersConfig
-> Maybe [ResponseHeadersPolicyCustomHeader]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Items"
          forall a. ToXML a => Name -> a -> XML
Data.@= forall a. ToXML a => a -> XML
Data.toXML
            ( forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"ResponseHeadersPolicyCustomHeader"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ResponseHeadersPolicyCustomHeader]
items
            ),
        Name
"Quantity" forall a. ToXML a => Name -> a -> XML
Data.@= Int
quantity
      ]