{-# 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.WAF.Types.HTTPHeader
-- 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.WAF.Types.HTTPHeader where

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

-- | This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- The response from a GetSampledRequests request includes an @HTTPHeader@
-- complex type that appears as @Headers@ in the response syntax.
-- @HTTPHeader@ contains the names and values of all of the headers that
-- appear in one of the web requests that were returned by
-- @GetSampledRequests@.
--
-- /See:/ 'newHTTPHeader' smart constructor.
data HTTPHeader = HTTPHeader'
  { -- | The value of one of the headers in the sampled web request.
    HTTPHeader -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The name of one of the headers in the sampled web request.
    HTTPHeader -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (HTTPHeader -> HTTPHeader -> Bool
(HTTPHeader -> HTTPHeader -> Bool)
-> (HTTPHeader -> HTTPHeader -> Bool) -> Eq HTTPHeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HTTPHeader -> HTTPHeader -> Bool
$c/= :: HTTPHeader -> HTTPHeader -> Bool
== :: HTTPHeader -> HTTPHeader -> Bool
$c== :: HTTPHeader -> HTTPHeader -> Bool
Prelude.Eq, ReadPrec [HTTPHeader]
ReadPrec HTTPHeader
Int -> ReadS HTTPHeader
ReadS [HTTPHeader]
(Int -> ReadS HTTPHeader)
-> ReadS [HTTPHeader]
-> ReadPrec HTTPHeader
-> ReadPrec [HTTPHeader]
-> Read HTTPHeader
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HTTPHeader]
$creadListPrec :: ReadPrec [HTTPHeader]
readPrec :: ReadPrec HTTPHeader
$creadPrec :: ReadPrec HTTPHeader
readList :: ReadS [HTTPHeader]
$creadList :: ReadS [HTTPHeader]
readsPrec :: Int -> ReadS HTTPHeader
$creadsPrec :: Int -> ReadS HTTPHeader
Prelude.Read, Int -> HTTPHeader -> ShowS
[HTTPHeader] -> ShowS
HTTPHeader -> String
(Int -> HTTPHeader -> ShowS)
-> (HTTPHeader -> String)
-> ([HTTPHeader] -> ShowS)
-> Show HTTPHeader
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HTTPHeader] -> ShowS
$cshowList :: [HTTPHeader] -> ShowS
show :: HTTPHeader -> String
$cshow :: HTTPHeader -> String
showsPrec :: Int -> HTTPHeader -> ShowS
$cshowsPrec :: Int -> HTTPHeader -> ShowS
Prelude.Show, (forall x. HTTPHeader -> Rep HTTPHeader x)
-> (forall x. Rep HTTPHeader x -> HTTPHeader) -> Generic HTTPHeader
forall x. Rep HTTPHeader x -> HTTPHeader
forall x. HTTPHeader -> Rep HTTPHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HTTPHeader x -> HTTPHeader
$cfrom :: forall x. HTTPHeader -> Rep HTTPHeader x
Prelude.Generic)

-- |
-- Create a value of 'HTTPHeader' 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:
--
-- 'value', 'hTTPHeader_value' - The value of one of the headers in the sampled web request.
--
-- 'name', 'hTTPHeader_name' - The name of one of the headers in the sampled web request.
newHTTPHeader ::
  HTTPHeader
newHTTPHeader :: HTTPHeader
newHTTPHeader =
  HTTPHeader' :: Maybe Text -> Maybe Text -> HTTPHeader
HTTPHeader'
    { $sel:value:HTTPHeader' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:HTTPHeader' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of one of the headers in the sampled web request.
hTTPHeader_value :: Lens.Lens' HTTPHeader (Prelude.Maybe Prelude.Text)
hTTPHeader_value :: (Maybe Text -> f (Maybe Text)) -> HTTPHeader -> f HTTPHeader
hTTPHeader_value = (HTTPHeader -> Maybe Text)
-> (HTTPHeader -> Maybe Text -> HTTPHeader)
-> Lens HTTPHeader HTTPHeader (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HTTPHeader' {Maybe Text
value :: Maybe Text
$sel:value:HTTPHeader' :: HTTPHeader -> Maybe Text
value} -> Maybe Text
value) (\s :: HTTPHeader
s@HTTPHeader' {} Maybe Text
a -> HTTPHeader
s {$sel:value:HTTPHeader' :: Maybe Text
value = Maybe Text
a} :: HTTPHeader)

-- | The name of one of the headers in the sampled web request.
hTTPHeader_name :: Lens.Lens' HTTPHeader (Prelude.Maybe Prelude.Text)
hTTPHeader_name :: (Maybe Text -> f (Maybe Text)) -> HTTPHeader -> f HTTPHeader
hTTPHeader_name = (HTTPHeader -> Maybe Text)
-> (HTTPHeader -> Maybe Text -> HTTPHeader)
-> Lens HTTPHeader HTTPHeader (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HTTPHeader' {Maybe Text
name :: Maybe Text
$sel:name:HTTPHeader' :: HTTPHeader -> Maybe Text
name} -> Maybe Text
name) (\s :: HTTPHeader
s@HTTPHeader' {} Maybe Text
a -> HTTPHeader
s {$sel:name:HTTPHeader' :: Maybe Text
name = Maybe Text
a} :: HTTPHeader)

instance Core.FromJSON HTTPHeader where
  parseJSON :: Value -> Parser HTTPHeader
parseJSON =
    String
-> (Object -> Parser HTTPHeader) -> Value -> Parser HTTPHeader
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HTTPHeader"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> HTTPHeader
HTTPHeader'
            (Maybe Text -> Maybe Text -> HTTPHeader)
-> Parser (Maybe Text) -> Parser (Maybe Text -> HTTPHeader)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value") Parser (Maybe Text -> HTTPHeader)
-> Parser (Maybe Text) -> Parser HTTPHeader
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
      )

instance Prelude.Hashable HTTPHeader

instance Prelude.NFData HTTPHeader