{-# 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.CognitoIdentityProvider.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.CognitoIdentityProvider.Types.HttpHeader where

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

-- | The HTTP header.
--
-- /See:/ 'newHttpHeader' smart constructor.
data HttpHeader = HttpHeader'
  { -- | The header value.
    HttpHeader -> Maybe Text
headerValue :: Prelude.Maybe Prelude.Text,
    -- | The header name
    HttpHeader -> Maybe Text
headerName :: 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:
--
-- 'headerValue', 'httpHeader_headerValue' - The header value.
--
-- 'headerName', 'httpHeader_headerName' - The header name
newHttpHeader ::
  HttpHeader
newHttpHeader :: HttpHeader
newHttpHeader =
  HttpHeader' :: Maybe Text -> Maybe Text -> HttpHeader
HttpHeader'
    { $sel:headerValue:HttpHeader' :: Maybe Text
headerValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:headerName:HttpHeader' :: Maybe Text
headerName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The header value.
httpHeader_headerValue :: Lens.Lens' HttpHeader (Prelude.Maybe Prelude.Text)
httpHeader_headerValue :: (Maybe Text -> f (Maybe Text)) -> HttpHeader -> f HttpHeader
httpHeader_headerValue = (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
headerValue :: Maybe Text
$sel:headerValue:HttpHeader' :: HttpHeader -> Maybe Text
headerValue} -> Maybe Text
headerValue) (\s :: HttpHeader
s@HttpHeader' {} Maybe Text
a -> HttpHeader
s {$sel:headerValue:HttpHeader' :: Maybe Text
headerValue = Maybe Text
a} :: HttpHeader)

-- | The header name
httpHeader_headerName :: Lens.Lens' HttpHeader (Prelude.Maybe Prelude.Text)
httpHeader_headerName :: (Maybe Text -> f (Maybe Text)) -> HttpHeader -> f HttpHeader
httpHeader_headerName = (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
headerName :: Maybe Text
$sel:headerName:HttpHeader' :: HttpHeader -> Maybe Text
headerName} -> Maybe Text
headerName) (\s :: HttpHeader
s@HttpHeader' {} Maybe Text
a -> HttpHeader
s {$sel:headerName:HttpHeader' :: Maybe Text
headerName = Maybe Text
a} :: HttpHeader)

instance Prelude.Hashable HttpHeader

instance Prelude.NFData HttpHeader

instance Core.ToJSON HttpHeader where
  toJSON :: HttpHeader -> Value
toJSON HttpHeader' {Maybe Text
headerName :: Maybe Text
headerValue :: Maybe Text
$sel:headerName:HttpHeader' :: HttpHeader -> Maybe Text
$sel:headerValue:HttpHeader' :: HttpHeader -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"headerValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
headerValue,
            (Text
"headerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
headerName
          ]
      )