{-# 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.IoT.Types.HttpActionHeader
-- 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.IoT.Types.HttpActionHeader where

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

-- | The HTTP action header.
--
-- /See:/ 'newHttpActionHeader' smart constructor.
data HttpActionHeader = HttpActionHeader'
  { -- | The HTTP header key.
    HttpActionHeader -> Text
key :: Prelude.Text,
    -- | The HTTP header value. Substitution templates are supported.
    HttpActionHeader -> Text
value :: Prelude.Text
  }
  deriving (HttpActionHeader -> HttpActionHeader -> Bool
(HttpActionHeader -> HttpActionHeader -> Bool)
-> (HttpActionHeader -> HttpActionHeader -> Bool)
-> Eq HttpActionHeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpActionHeader -> HttpActionHeader -> Bool
$c/= :: HttpActionHeader -> HttpActionHeader -> Bool
== :: HttpActionHeader -> HttpActionHeader -> Bool
$c== :: HttpActionHeader -> HttpActionHeader -> Bool
Prelude.Eq, ReadPrec [HttpActionHeader]
ReadPrec HttpActionHeader
Int -> ReadS HttpActionHeader
ReadS [HttpActionHeader]
(Int -> ReadS HttpActionHeader)
-> ReadS [HttpActionHeader]
-> ReadPrec HttpActionHeader
-> ReadPrec [HttpActionHeader]
-> Read HttpActionHeader
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpActionHeader]
$creadListPrec :: ReadPrec [HttpActionHeader]
readPrec :: ReadPrec HttpActionHeader
$creadPrec :: ReadPrec HttpActionHeader
readList :: ReadS [HttpActionHeader]
$creadList :: ReadS [HttpActionHeader]
readsPrec :: Int -> ReadS HttpActionHeader
$creadsPrec :: Int -> ReadS HttpActionHeader
Prelude.Read, Int -> HttpActionHeader -> ShowS
[HttpActionHeader] -> ShowS
HttpActionHeader -> String
(Int -> HttpActionHeader -> ShowS)
-> (HttpActionHeader -> String)
-> ([HttpActionHeader] -> ShowS)
-> Show HttpActionHeader
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpActionHeader] -> ShowS
$cshowList :: [HttpActionHeader] -> ShowS
show :: HttpActionHeader -> String
$cshow :: HttpActionHeader -> String
showsPrec :: Int -> HttpActionHeader -> ShowS
$cshowsPrec :: Int -> HttpActionHeader -> ShowS
Prelude.Show, (forall x. HttpActionHeader -> Rep HttpActionHeader x)
-> (forall x. Rep HttpActionHeader x -> HttpActionHeader)
-> Generic HttpActionHeader
forall x. Rep HttpActionHeader x -> HttpActionHeader
forall x. HttpActionHeader -> Rep HttpActionHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpActionHeader x -> HttpActionHeader
$cfrom :: forall x. HttpActionHeader -> Rep HttpActionHeader x
Prelude.Generic)

-- |
-- Create a value of 'HttpActionHeader' 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:
--
-- 'key', 'httpActionHeader_key' - The HTTP header key.
--
-- 'value', 'httpActionHeader_value' - The HTTP header value. Substitution templates are supported.
newHttpActionHeader ::
  -- | 'key'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  HttpActionHeader
newHttpActionHeader :: Text -> Text -> HttpActionHeader
newHttpActionHeader Text
pKey_ Text
pValue_ =
  HttpActionHeader' :: Text -> Text -> HttpActionHeader
HttpActionHeader' {$sel:key:HttpActionHeader' :: Text
key = Text
pKey_, $sel:value:HttpActionHeader' :: Text
value = Text
pValue_}

-- | The HTTP header key.
httpActionHeader_key :: Lens.Lens' HttpActionHeader Prelude.Text
httpActionHeader_key :: (Text -> f Text) -> HttpActionHeader -> f HttpActionHeader
httpActionHeader_key = (HttpActionHeader -> Text)
-> (HttpActionHeader -> Text -> HttpActionHeader)
-> Lens HttpActionHeader HttpActionHeader Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpActionHeader' {Text
key :: Text
$sel:key:HttpActionHeader' :: HttpActionHeader -> Text
key} -> Text
key) (\s :: HttpActionHeader
s@HttpActionHeader' {} Text
a -> HttpActionHeader
s {$sel:key:HttpActionHeader' :: Text
key = Text
a} :: HttpActionHeader)

-- | The HTTP header value. Substitution templates are supported.
httpActionHeader_value :: Lens.Lens' HttpActionHeader Prelude.Text
httpActionHeader_value :: (Text -> f Text) -> HttpActionHeader -> f HttpActionHeader
httpActionHeader_value = (HttpActionHeader -> Text)
-> (HttpActionHeader -> Text -> HttpActionHeader)
-> Lens HttpActionHeader HttpActionHeader Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpActionHeader' {Text
value :: Text
$sel:value:HttpActionHeader' :: HttpActionHeader -> Text
value} -> Text
value) (\s :: HttpActionHeader
s@HttpActionHeader' {} Text
a -> HttpActionHeader
s {$sel:value:HttpActionHeader' :: Text
value = Text
a} :: HttpActionHeader)

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

instance Prelude.Hashable HttpActionHeader

instance Prelude.NFData HttpActionHeader

instance Core.ToJSON HttpActionHeader where
  toJSON :: HttpActionHeader -> Value
toJSON HttpActionHeader' {Text
value :: Text
key :: Text
$sel:value:HttpActionHeader' :: HttpActionHeader -> Text
$sel:key:HttpActionHeader' :: HttpActionHeader -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )