{-# 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.AppMesh.Types.HttpGatewayRouteHeader
-- 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.AppMesh.Types.HttpGatewayRouteHeader where

import Amazonka.AppMesh.Types.HeaderMatchMethod
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the HTTP header in the gateway route.
--
-- /See:/ 'newHttpGatewayRouteHeader' smart constructor.
data HttpGatewayRouteHeader = HttpGatewayRouteHeader'
  { -- | Specify @True@ to match anything except the match criteria. The default
    -- value is @False@.
    HttpGatewayRouteHeader -> Maybe Bool
invert :: Prelude.Maybe Prelude.Bool,
    HttpGatewayRouteHeader -> Maybe HeaderMatchMethod
match :: Prelude.Maybe HeaderMatchMethod,
    -- | A name for the HTTP header in the gateway route that will be matched on.
    HttpGatewayRouteHeader -> Text
name :: Prelude.Text
  }
  deriving (HttpGatewayRouteHeader -> HttpGatewayRouteHeader -> Bool
(HttpGatewayRouteHeader -> HttpGatewayRouteHeader -> Bool)
-> (HttpGatewayRouteHeader -> HttpGatewayRouteHeader -> Bool)
-> Eq HttpGatewayRouteHeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpGatewayRouteHeader -> HttpGatewayRouteHeader -> Bool
$c/= :: HttpGatewayRouteHeader -> HttpGatewayRouteHeader -> Bool
== :: HttpGatewayRouteHeader -> HttpGatewayRouteHeader -> Bool
$c== :: HttpGatewayRouteHeader -> HttpGatewayRouteHeader -> Bool
Prelude.Eq, ReadPrec [HttpGatewayRouteHeader]
ReadPrec HttpGatewayRouteHeader
Int -> ReadS HttpGatewayRouteHeader
ReadS [HttpGatewayRouteHeader]
(Int -> ReadS HttpGatewayRouteHeader)
-> ReadS [HttpGatewayRouteHeader]
-> ReadPrec HttpGatewayRouteHeader
-> ReadPrec [HttpGatewayRouteHeader]
-> Read HttpGatewayRouteHeader
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpGatewayRouteHeader]
$creadListPrec :: ReadPrec [HttpGatewayRouteHeader]
readPrec :: ReadPrec HttpGatewayRouteHeader
$creadPrec :: ReadPrec HttpGatewayRouteHeader
readList :: ReadS [HttpGatewayRouteHeader]
$creadList :: ReadS [HttpGatewayRouteHeader]
readsPrec :: Int -> ReadS HttpGatewayRouteHeader
$creadsPrec :: Int -> ReadS HttpGatewayRouteHeader
Prelude.Read, Int -> HttpGatewayRouteHeader -> ShowS
[HttpGatewayRouteHeader] -> ShowS
HttpGatewayRouteHeader -> String
(Int -> HttpGatewayRouteHeader -> ShowS)
-> (HttpGatewayRouteHeader -> String)
-> ([HttpGatewayRouteHeader] -> ShowS)
-> Show HttpGatewayRouteHeader
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpGatewayRouteHeader] -> ShowS
$cshowList :: [HttpGatewayRouteHeader] -> ShowS
show :: HttpGatewayRouteHeader -> String
$cshow :: HttpGatewayRouteHeader -> String
showsPrec :: Int -> HttpGatewayRouteHeader -> ShowS
$cshowsPrec :: Int -> HttpGatewayRouteHeader -> ShowS
Prelude.Show, (forall x. HttpGatewayRouteHeader -> Rep HttpGatewayRouteHeader x)
-> (forall x.
    Rep HttpGatewayRouteHeader x -> HttpGatewayRouteHeader)
-> Generic HttpGatewayRouteHeader
forall x. Rep HttpGatewayRouteHeader x -> HttpGatewayRouteHeader
forall x. HttpGatewayRouteHeader -> Rep HttpGatewayRouteHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpGatewayRouteHeader x -> HttpGatewayRouteHeader
$cfrom :: forall x. HttpGatewayRouteHeader -> Rep HttpGatewayRouteHeader x
Prelude.Generic)

-- |
-- Create a value of 'HttpGatewayRouteHeader' 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:
--
-- 'invert', 'httpGatewayRouteHeader_invert' - Specify @True@ to match anything except the match criteria. The default
-- value is @False@.
--
-- 'match', 'httpGatewayRouteHeader_match' - Undocumented member.
--
-- 'name', 'httpGatewayRouteHeader_name' - A name for the HTTP header in the gateway route that will be matched on.
newHttpGatewayRouteHeader ::
  -- | 'name'
  Prelude.Text ->
  HttpGatewayRouteHeader
newHttpGatewayRouteHeader :: Text -> HttpGatewayRouteHeader
newHttpGatewayRouteHeader Text
pName_ =
  HttpGatewayRouteHeader' :: Maybe Bool
-> Maybe HeaderMatchMethod -> Text -> HttpGatewayRouteHeader
HttpGatewayRouteHeader'
    { $sel:invert:HttpGatewayRouteHeader' :: Maybe Bool
invert = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:match:HttpGatewayRouteHeader' :: Maybe HeaderMatchMethod
match = Maybe HeaderMatchMethod
forall a. Maybe a
Prelude.Nothing,
      $sel:name:HttpGatewayRouteHeader' :: Text
name = Text
pName_
    }

-- | Specify @True@ to match anything except the match criteria. The default
-- value is @False@.
httpGatewayRouteHeader_invert :: Lens.Lens' HttpGatewayRouteHeader (Prelude.Maybe Prelude.Bool)
httpGatewayRouteHeader_invert :: (Maybe Bool -> f (Maybe Bool))
-> HttpGatewayRouteHeader -> f HttpGatewayRouteHeader
httpGatewayRouteHeader_invert = (HttpGatewayRouteHeader -> Maybe Bool)
-> (HttpGatewayRouteHeader -> Maybe Bool -> HttpGatewayRouteHeader)
-> Lens
     HttpGatewayRouteHeader
     HttpGatewayRouteHeader
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteHeader' {Maybe Bool
invert :: Maybe Bool
$sel:invert:HttpGatewayRouteHeader' :: HttpGatewayRouteHeader -> Maybe Bool
invert} -> Maybe Bool
invert) (\s :: HttpGatewayRouteHeader
s@HttpGatewayRouteHeader' {} Maybe Bool
a -> HttpGatewayRouteHeader
s {$sel:invert:HttpGatewayRouteHeader' :: Maybe Bool
invert = Maybe Bool
a} :: HttpGatewayRouteHeader)

-- | Undocumented member.
httpGatewayRouteHeader_match :: Lens.Lens' HttpGatewayRouteHeader (Prelude.Maybe HeaderMatchMethod)
httpGatewayRouteHeader_match :: (Maybe HeaderMatchMethod -> f (Maybe HeaderMatchMethod))
-> HttpGatewayRouteHeader -> f HttpGatewayRouteHeader
httpGatewayRouteHeader_match = (HttpGatewayRouteHeader -> Maybe HeaderMatchMethod)
-> (HttpGatewayRouteHeader
    -> Maybe HeaderMatchMethod -> HttpGatewayRouteHeader)
-> Lens
     HttpGatewayRouteHeader
     HttpGatewayRouteHeader
     (Maybe HeaderMatchMethod)
     (Maybe HeaderMatchMethod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteHeader' {Maybe HeaderMatchMethod
match :: Maybe HeaderMatchMethod
$sel:match:HttpGatewayRouteHeader' :: HttpGatewayRouteHeader -> Maybe HeaderMatchMethod
match} -> Maybe HeaderMatchMethod
match) (\s :: HttpGatewayRouteHeader
s@HttpGatewayRouteHeader' {} Maybe HeaderMatchMethod
a -> HttpGatewayRouteHeader
s {$sel:match:HttpGatewayRouteHeader' :: Maybe HeaderMatchMethod
match = Maybe HeaderMatchMethod
a} :: HttpGatewayRouteHeader)

-- | A name for the HTTP header in the gateway route that will be matched on.
httpGatewayRouteHeader_name :: Lens.Lens' HttpGatewayRouteHeader Prelude.Text
httpGatewayRouteHeader_name :: (Text -> f Text)
-> HttpGatewayRouteHeader -> f HttpGatewayRouteHeader
httpGatewayRouteHeader_name = (HttpGatewayRouteHeader -> Text)
-> (HttpGatewayRouteHeader -> Text -> HttpGatewayRouteHeader)
-> Lens HttpGatewayRouteHeader HttpGatewayRouteHeader Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteHeader' {Text
name :: Text
$sel:name:HttpGatewayRouteHeader' :: HttpGatewayRouteHeader -> Text
name} -> Text
name) (\s :: HttpGatewayRouteHeader
s@HttpGatewayRouteHeader' {} Text
a -> HttpGatewayRouteHeader
s {$sel:name:HttpGatewayRouteHeader' :: Text
name = Text
a} :: HttpGatewayRouteHeader)

instance Core.FromJSON HttpGatewayRouteHeader where
  parseJSON :: Value -> Parser HttpGatewayRouteHeader
parseJSON =
    String
-> (Object -> Parser HttpGatewayRouteHeader)
-> Value
-> Parser HttpGatewayRouteHeader
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpGatewayRouteHeader"
      ( \Object
x ->
          Maybe Bool
-> Maybe HeaderMatchMethod -> Text -> HttpGatewayRouteHeader
HttpGatewayRouteHeader'
            (Maybe Bool
 -> Maybe HeaderMatchMethod -> Text -> HttpGatewayRouteHeader)
-> Parser (Maybe Bool)
-> Parser
     (Maybe HeaderMatchMethod -> Text -> HttpGatewayRouteHeader)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"invert")
            Parser (Maybe HeaderMatchMethod -> Text -> HttpGatewayRouteHeader)
-> Parser (Maybe HeaderMatchMethod)
-> Parser (Text -> HttpGatewayRouteHeader)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HeaderMatchMethod)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"match")
            Parser (Text -> HttpGatewayRouteHeader)
-> Parser Text -> Parser HttpGatewayRouteHeader
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
"name")
      )

instance Prelude.Hashable HttpGatewayRouteHeader

instance Prelude.NFData HttpGatewayRouteHeader

instance Core.ToJSON HttpGatewayRouteHeader where
  toJSON :: HttpGatewayRouteHeader -> Value
toJSON HttpGatewayRouteHeader' {Maybe Bool
Maybe HeaderMatchMethod
Text
name :: Text
match :: Maybe HeaderMatchMethod
invert :: Maybe Bool
$sel:name:HttpGatewayRouteHeader' :: HttpGatewayRouteHeader -> Text
$sel:match:HttpGatewayRouteHeader' :: HttpGatewayRouteHeader -> Maybe HeaderMatchMethod
$sel:invert:HttpGatewayRouteHeader' :: HttpGatewayRouteHeader -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"invert" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
invert,
            (Text
"match" Text -> HeaderMatchMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HeaderMatchMethod -> Pair)
-> Maybe HeaderMatchMethod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HeaderMatchMethod
match,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )