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

import Amazonka.AppMesh.Types.GatewayRouteHostnameMatch
import Amazonka.AppMesh.Types.HttpGatewayRouteHeader
import Amazonka.AppMesh.Types.HttpMethod
import Amazonka.AppMesh.Types.HttpPathMatch
import Amazonka.AppMesh.Types.HttpQueryParameter
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the criteria for determining a request match.
--
-- /See:/ 'newHttpGatewayRouteMatch' smart constructor.
data HttpGatewayRouteMatch = HttpGatewayRouteMatch'
  { -- | The host name to match on.
    HttpGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch
hostname :: Prelude.Maybe GatewayRouteHostnameMatch,
    -- | The path to match on.
    HttpGatewayRouteMatch -> Maybe HttpPathMatch
path :: Prelude.Maybe HttpPathMatch,
    -- | Specifies the path to match requests with. This parameter must always
    -- start with @\/@, which by itself matches all requests to the virtual
    -- service name. You can also match for path-based routing of requests. For
    -- example, if your virtual service name is @my-service.local@ and you want
    -- the route to match requests to @my-service.local\/metrics@, your prefix
    -- should be @\/metrics@.
    HttpGatewayRouteMatch -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | The query parameter to match on.
    HttpGatewayRouteMatch -> Maybe (NonEmpty HttpQueryParameter)
queryParameters :: Prelude.Maybe (Prelude.NonEmpty HttpQueryParameter),
    -- | The client request headers to match on.
    HttpGatewayRouteMatch -> Maybe (NonEmpty HttpGatewayRouteHeader)
headers :: Prelude.Maybe (Prelude.NonEmpty HttpGatewayRouteHeader),
    -- | The method to match on.
    HttpGatewayRouteMatch -> Maybe HttpMethod
method :: Prelude.Maybe HttpMethod
  }
  deriving (HttpGatewayRouteMatch -> HttpGatewayRouteMatch -> Bool
(HttpGatewayRouteMatch -> HttpGatewayRouteMatch -> Bool)
-> (HttpGatewayRouteMatch -> HttpGatewayRouteMatch -> Bool)
-> Eq HttpGatewayRouteMatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpGatewayRouteMatch -> HttpGatewayRouteMatch -> Bool
$c/= :: HttpGatewayRouteMatch -> HttpGatewayRouteMatch -> Bool
== :: HttpGatewayRouteMatch -> HttpGatewayRouteMatch -> Bool
$c== :: HttpGatewayRouteMatch -> HttpGatewayRouteMatch -> Bool
Prelude.Eq, ReadPrec [HttpGatewayRouteMatch]
ReadPrec HttpGatewayRouteMatch
Int -> ReadS HttpGatewayRouteMatch
ReadS [HttpGatewayRouteMatch]
(Int -> ReadS HttpGatewayRouteMatch)
-> ReadS [HttpGatewayRouteMatch]
-> ReadPrec HttpGatewayRouteMatch
-> ReadPrec [HttpGatewayRouteMatch]
-> Read HttpGatewayRouteMatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpGatewayRouteMatch]
$creadListPrec :: ReadPrec [HttpGatewayRouteMatch]
readPrec :: ReadPrec HttpGatewayRouteMatch
$creadPrec :: ReadPrec HttpGatewayRouteMatch
readList :: ReadS [HttpGatewayRouteMatch]
$creadList :: ReadS [HttpGatewayRouteMatch]
readsPrec :: Int -> ReadS HttpGatewayRouteMatch
$creadsPrec :: Int -> ReadS HttpGatewayRouteMatch
Prelude.Read, Int -> HttpGatewayRouteMatch -> ShowS
[HttpGatewayRouteMatch] -> ShowS
HttpGatewayRouteMatch -> String
(Int -> HttpGatewayRouteMatch -> ShowS)
-> (HttpGatewayRouteMatch -> String)
-> ([HttpGatewayRouteMatch] -> ShowS)
-> Show HttpGatewayRouteMatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpGatewayRouteMatch] -> ShowS
$cshowList :: [HttpGatewayRouteMatch] -> ShowS
show :: HttpGatewayRouteMatch -> String
$cshow :: HttpGatewayRouteMatch -> String
showsPrec :: Int -> HttpGatewayRouteMatch -> ShowS
$cshowsPrec :: Int -> HttpGatewayRouteMatch -> ShowS
Prelude.Show, (forall x. HttpGatewayRouteMatch -> Rep HttpGatewayRouteMatch x)
-> (forall x. Rep HttpGatewayRouteMatch x -> HttpGatewayRouteMatch)
-> Generic HttpGatewayRouteMatch
forall x. Rep HttpGatewayRouteMatch x -> HttpGatewayRouteMatch
forall x. HttpGatewayRouteMatch -> Rep HttpGatewayRouteMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpGatewayRouteMatch x -> HttpGatewayRouteMatch
$cfrom :: forall x. HttpGatewayRouteMatch -> Rep HttpGatewayRouteMatch x
Prelude.Generic)

-- |
-- Create a value of 'HttpGatewayRouteMatch' 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:
--
-- 'hostname', 'httpGatewayRouteMatch_hostname' - The host name to match on.
--
-- 'path', 'httpGatewayRouteMatch_path' - The path to match on.
--
-- 'prefix', 'httpGatewayRouteMatch_prefix' - Specifies the path to match requests with. This parameter must always
-- start with @\/@, which by itself matches all requests to the virtual
-- service name. You can also match for path-based routing of requests. For
-- example, if your virtual service name is @my-service.local@ and you want
-- the route to match requests to @my-service.local\/metrics@, your prefix
-- should be @\/metrics@.
--
-- 'queryParameters', 'httpGatewayRouteMatch_queryParameters' - The query parameter to match on.
--
-- 'headers', 'httpGatewayRouteMatch_headers' - The client request headers to match on.
--
-- 'method', 'httpGatewayRouteMatch_method' - The method to match on.
newHttpGatewayRouteMatch ::
  HttpGatewayRouteMatch
newHttpGatewayRouteMatch :: HttpGatewayRouteMatch
newHttpGatewayRouteMatch =
  HttpGatewayRouteMatch' :: Maybe GatewayRouteHostnameMatch
-> Maybe HttpPathMatch
-> Maybe Text
-> Maybe (NonEmpty HttpQueryParameter)
-> Maybe (NonEmpty HttpGatewayRouteHeader)
-> Maybe HttpMethod
-> HttpGatewayRouteMatch
HttpGatewayRouteMatch'
    { $sel:hostname:HttpGatewayRouteMatch' :: Maybe GatewayRouteHostnameMatch
hostname = Maybe GatewayRouteHostnameMatch
forall a. Maybe a
Prelude.Nothing,
      $sel:path:HttpGatewayRouteMatch' :: Maybe HttpPathMatch
path = Maybe HttpPathMatch
forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:HttpGatewayRouteMatch' :: Maybe Text
prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:queryParameters:HttpGatewayRouteMatch' :: Maybe (NonEmpty HttpQueryParameter)
queryParameters = Maybe (NonEmpty HttpQueryParameter)
forall a. Maybe a
Prelude.Nothing,
      $sel:headers:HttpGatewayRouteMatch' :: Maybe (NonEmpty HttpGatewayRouteHeader)
headers = Maybe (NonEmpty HttpGatewayRouteHeader)
forall a. Maybe a
Prelude.Nothing,
      $sel:method:HttpGatewayRouteMatch' :: Maybe HttpMethod
method = Maybe HttpMethod
forall a. Maybe a
Prelude.Nothing
    }

-- | The host name to match on.
httpGatewayRouteMatch_hostname :: Lens.Lens' HttpGatewayRouteMatch (Prelude.Maybe GatewayRouteHostnameMatch)
httpGatewayRouteMatch_hostname :: (Maybe GatewayRouteHostnameMatch
 -> f (Maybe GatewayRouteHostnameMatch))
-> HttpGatewayRouteMatch -> f HttpGatewayRouteMatch
httpGatewayRouteMatch_hostname = (HttpGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch)
-> (HttpGatewayRouteMatch
    -> Maybe GatewayRouteHostnameMatch -> HttpGatewayRouteMatch)
-> Lens
     HttpGatewayRouteMatch
     HttpGatewayRouteMatch
     (Maybe GatewayRouteHostnameMatch)
     (Maybe GatewayRouteHostnameMatch)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteMatch' {Maybe GatewayRouteHostnameMatch
hostname :: Maybe GatewayRouteHostnameMatch
$sel:hostname:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch
hostname} -> Maybe GatewayRouteHostnameMatch
hostname) (\s :: HttpGatewayRouteMatch
s@HttpGatewayRouteMatch' {} Maybe GatewayRouteHostnameMatch
a -> HttpGatewayRouteMatch
s {$sel:hostname:HttpGatewayRouteMatch' :: Maybe GatewayRouteHostnameMatch
hostname = Maybe GatewayRouteHostnameMatch
a} :: HttpGatewayRouteMatch)

-- | The path to match on.
httpGatewayRouteMatch_path :: Lens.Lens' HttpGatewayRouteMatch (Prelude.Maybe HttpPathMatch)
httpGatewayRouteMatch_path :: (Maybe HttpPathMatch -> f (Maybe HttpPathMatch))
-> HttpGatewayRouteMatch -> f HttpGatewayRouteMatch
httpGatewayRouteMatch_path = (HttpGatewayRouteMatch -> Maybe HttpPathMatch)
-> (HttpGatewayRouteMatch
    -> Maybe HttpPathMatch -> HttpGatewayRouteMatch)
-> Lens
     HttpGatewayRouteMatch
     HttpGatewayRouteMatch
     (Maybe HttpPathMatch)
     (Maybe HttpPathMatch)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteMatch' {Maybe HttpPathMatch
path :: Maybe HttpPathMatch
$sel:path:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe HttpPathMatch
path} -> Maybe HttpPathMatch
path) (\s :: HttpGatewayRouteMatch
s@HttpGatewayRouteMatch' {} Maybe HttpPathMatch
a -> HttpGatewayRouteMatch
s {$sel:path:HttpGatewayRouteMatch' :: Maybe HttpPathMatch
path = Maybe HttpPathMatch
a} :: HttpGatewayRouteMatch)

-- | Specifies the path to match requests with. This parameter must always
-- start with @\/@, which by itself matches all requests to the virtual
-- service name. You can also match for path-based routing of requests. For
-- example, if your virtual service name is @my-service.local@ and you want
-- the route to match requests to @my-service.local\/metrics@, your prefix
-- should be @\/metrics@.
httpGatewayRouteMatch_prefix :: Lens.Lens' HttpGatewayRouteMatch (Prelude.Maybe Prelude.Text)
httpGatewayRouteMatch_prefix :: (Maybe Text -> f (Maybe Text))
-> HttpGatewayRouteMatch -> f HttpGatewayRouteMatch
httpGatewayRouteMatch_prefix = (HttpGatewayRouteMatch -> Maybe Text)
-> (HttpGatewayRouteMatch -> Maybe Text -> HttpGatewayRouteMatch)
-> Lens
     HttpGatewayRouteMatch
     HttpGatewayRouteMatch
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteMatch' {Maybe Text
prefix :: Maybe Text
$sel:prefix:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: HttpGatewayRouteMatch
s@HttpGatewayRouteMatch' {} Maybe Text
a -> HttpGatewayRouteMatch
s {$sel:prefix:HttpGatewayRouteMatch' :: Maybe Text
prefix = Maybe Text
a} :: HttpGatewayRouteMatch)

-- | The query parameter to match on.
httpGatewayRouteMatch_queryParameters :: Lens.Lens' HttpGatewayRouteMatch (Prelude.Maybe (Prelude.NonEmpty HttpQueryParameter))
httpGatewayRouteMatch_queryParameters :: (Maybe (NonEmpty HttpQueryParameter)
 -> f (Maybe (NonEmpty HttpQueryParameter)))
-> HttpGatewayRouteMatch -> f HttpGatewayRouteMatch
httpGatewayRouteMatch_queryParameters = (HttpGatewayRouteMatch -> Maybe (NonEmpty HttpQueryParameter))
-> (HttpGatewayRouteMatch
    -> Maybe (NonEmpty HttpQueryParameter) -> HttpGatewayRouteMatch)
-> Lens
     HttpGatewayRouteMatch
     HttpGatewayRouteMatch
     (Maybe (NonEmpty HttpQueryParameter))
     (Maybe (NonEmpty HttpQueryParameter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteMatch' {Maybe (NonEmpty HttpQueryParameter)
queryParameters :: Maybe (NonEmpty HttpQueryParameter)
$sel:queryParameters:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe (NonEmpty HttpQueryParameter)
queryParameters} -> Maybe (NonEmpty HttpQueryParameter)
queryParameters) (\s :: HttpGatewayRouteMatch
s@HttpGatewayRouteMatch' {} Maybe (NonEmpty HttpQueryParameter)
a -> HttpGatewayRouteMatch
s {$sel:queryParameters:HttpGatewayRouteMatch' :: Maybe (NonEmpty HttpQueryParameter)
queryParameters = Maybe (NonEmpty HttpQueryParameter)
a} :: HttpGatewayRouteMatch) ((Maybe (NonEmpty HttpQueryParameter)
  -> f (Maybe (NonEmpty HttpQueryParameter)))
 -> HttpGatewayRouteMatch -> f HttpGatewayRouteMatch)
-> ((Maybe (NonEmpty HttpQueryParameter)
     -> f (Maybe (NonEmpty HttpQueryParameter)))
    -> Maybe (NonEmpty HttpQueryParameter)
    -> f (Maybe (NonEmpty HttpQueryParameter)))
-> (Maybe (NonEmpty HttpQueryParameter)
    -> f (Maybe (NonEmpty HttpQueryParameter)))
-> HttpGatewayRouteMatch
-> f HttpGatewayRouteMatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
-> Iso
     (Maybe (NonEmpty HttpQueryParameter))
     (Maybe (NonEmpty HttpQueryParameter))
     (Maybe (NonEmpty HttpQueryParameter))
     (Maybe (NonEmpty HttpQueryParameter))
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 AnIso
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
  (NonEmpty HttpQueryParameter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The client request headers to match on.
httpGatewayRouteMatch_headers :: Lens.Lens' HttpGatewayRouteMatch (Prelude.Maybe (Prelude.NonEmpty HttpGatewayRouteHeader))
httpGatewayRouteMatch_headers :: (Maybe (NonEmpty HttpGatewayRouteHeader)
 -> f (Maybe (NonEmpty HttpGatewayRouteHeader)))
-> HttpGatewayRouteMatch -> f HttpGatewayRouteMatch
httpGatewayRouteMatch_headers = (HttpGatewayRouteMatch -> Maybe (NonEmpty HttpGatewayRouteHeader))
-> (HttpGatewayRouteMatch
    -> Maybe (NonEmpty HttpGatewayRouteHeader)
    -> HttpGatewayRouteMatch)
-> Lens
     HttpGatewayRouteMatch
     HttpGatewayRouteMatch
     (Maybe (NonEmpty HttpGatewayRouteHeader))
     (Maybe (NonEmpty HttpGatewayRouteHeader))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteMatch' {Maybe (NonEmpty HttpGatewayRouteHeader)
headers :: Maybe (NonEmpty HttpGatewayRouteHeader)
$sel:headers:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe (NonEmpty HttpGatewayRouteHeader)
headers} -> Maybe (NonEmpty HttpGatewayRouteHeader)
headers) (\s :: HttpGatewayRouteMatch
s@HttpGatewayRouteMatch' {} Maybe (NonEmpty HttpGatewayRouteHeader)
a -> HttpGatewayRouteMatch
s {$sel:headers:HttpGatewayRouteMatch' :: Maybe (NonEmpty HttpGatewayRouteHeader)
headers = Maybe (NonEmpty HttpGatewayRouteHeader)
a} :: HttpGatewayRouteMatch) ((Maybe (NonEmpty HttpGatewayRouteHeader)
  -> f (Maybe (NonEmpty HttpGatewayRouteHeader)))
 -> HttpGatewayRouteMatch -> f HttpGatewayRouteMatch)
-> ((Maybe (NonEmpty HttpGatewayRouteHeader)
     -> f (Maybe (NonEmpty HttpGatewayRouteHeader)))
    -> Maybe (NonEmpty HttpGatewayRouteHeader)
    -> f (Maybe (NonEmpty HttpGatewayRouteHeader)))
-> (Maybe (NonEmpty HttpGatewayRouteHeader)
    -> f (Maybe (NonEmpty HttpGatewayRouteHeader)))
-> HttpGatewayRouteMatch
-> f HttpGatewayRouteMatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty HttpGatewayRouteHeader)
  (NonEmpty HttpGatewayRouteHeader)
  (NonEmpty HttpGatewayRouteHeader)
  (NonEmpty HttpGatewayRouteHeader)
-> Iso
     (Maybe (NonEmpty HttpGatewayRouteHeader))
     (Maybe (NonEmpty HttpGatewayRouteHeader))
     (Maybe (NonEmpty HttpGatewayRouteHeader))
     (Maybe (NonEmpty HttpGatewayRouteHeader))
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 AnIso
  (NonEmpty HttpGatewayRouteHeader)
  (NonEmpty HttpGatewayRouteHeader)
  (NonEmpty HttpGatewayRouteHeader)
  (NonEmpty HttpGatewayRouteHeader)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The method to match on.
httpGatewayRouteMatch_method :: Lens.Lens' HttpGatewayRouteMatch (Prelude.Maybe HttpMethod)
httpGatewayRouteMatch_method :: (Maybe HttpMethod -> f (Maybe HttpMethod))
-> HttpGatewayRouteMatch -> f HttpGatewayRouteMatch
httpGatewayRouteMatch_method = (HttpGatewayRouteMatch -> Maybe HttpMethod)
-> (HttpGatewayRouteMatch
    -> Maybe HttpMethod -> HttpGatewayRouteMatch)
-> Lens
     HttpGatewayRouteMatch
     HttpGatewayRouteMatch
     (Maybe HttpMethod)
     (Maybe HttpMethod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteMatch' {Maybe HttpMethod
method :: Maybe HttpMethod
$sel:method:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe HttpMethod
method} -> Maybe HttpMethod
method) (\s :: HttpGatewayRouteMatch
s@HttpGatewayRouteMatch' {} Maybe HttpMethod
a -> HttpGatewayRouteMatch
s {$sel:method:HttpGatewayRouteMatch' :: Maybe HttpMethod
method = Maybe HttpMethod
a} :: HttpGatewayRouteMatch)

instance Core.FromJSON HttpGatewayRouteMatch where
  parseJSON :: Value -> Parser HttpGatewayRouteMatch
parseJSON =
    String
-> (Object -> Parser HttpGatewayRouteMatch)
-> Value
-> Parser HttpGatewayRouteMatch
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpGatewayRouteMatch"
      ( \Object
x ->
          Maybe GatewayRouteHostnameMatch
-> Maybe HttpPathMatch
-> Maybe Text
-> Maybe (NonEmpty HttpQueryParameter)
-> Maybe (NonEmpty HttpGatewayRouteHeader)
-> Maybe HttpMethod
-> HttpGatewayRouteMatch
HttpGatewayRouteMatch'
            (Maybe GatewayRouteHostnameMatch
 -> Maybe HttpPathMatch
 -> Maybe Text
 -> Maybe (NonEmpty HttpQueryParameter)
 -> Maybe (NonEmpty HttpGatewayRouteHeader)
 -> Maybe HttpMethod
 -> HttpGatewayRouteMatch)
-> Parser (Maybe GatewayRouteHostnameMatch)
-> Parser
     (Maybe HttpPathMatch
      -> Maybe Text
      -> Maybe (NonEmpty HttpQueryParameter)
      -> Maybe (NonEmpty HttpGatewayRouteHeader)
      -> Maybe HttpMethod
      -> HttpGatewayRouteMatch)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe GatewayRouteHostnameMatch)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"hostname")
            Parser
  (Maybe HttpPathMatch
   -> Maybe Text
   -> Maybe (NonEmpty HttpQueryParameter)
   -> Maybe (NonEmpty HttpGatewayRouteHeader)
   -> Maybe HttpMethod
   -> HttpGatewayRouteMatch)
-> Parser (Maybe HttpPathMatch)
-> Parser
     (Maybe Text
      -> Maybe (NonEmpty HttpQueryParameter)
      -> Maybe (NonEmpty HttpGatewayRouteHeader)
      -> Maybe HttpMethod
      -> HttpGatewayRouteMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HttpPathMatch)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"path")
            Parser
  (Maybe Text
   -> Maybe (NonEmpty HttpQueryParameter)
   -> Maybe (NonEmpty HttpGatewayRouteHeader)
   -> Maybe HttpMethod
   -> HttpGatewayRouteMatch)
-> Parser (Maybe Text)
-> Parser
     (Maybe (NonEmpty HttpQueryParameter)
      -> Maybe (NonEmpty HttpGatewayRouteHeader)
      -> Maybe HttpMethod
      -> HttpGatewayRouteMatch)
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
"prefix")
            Parser
  (Maybe (NonEmpty HttpQueryParameter)
   -> Maybe (NonEmpty HttpGatewayRouteHeader)
   -> Maybe HttpMethod
   -> HttpGatewayRouteMatch)
-> Parser (Maybe (NonEmpty HttpQueryParameter))
-> Parser
     (Maybe (NonEmpty HttpGatewayRouteHeader)
      -> Maybe HttpMethod -> HttpGatewayRouteMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty HttpQueryParameter))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"queryParameters")
            Parser
  (Maybe (NonEmpty HttpGatewayRouteHeader)
   -> Maybe HttpMethod -> HttpGatewayRouteMatch)
-> Parser (Maybe (NonEmpty HttpGatewayRouteHeader))
-> Parser (Maybe HttpMethod -> HttpGatewayRouteMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty HttpGatewayRouteHeader))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"headers")
            Parser (Maybe HttpMethod -> HttpGatewayRouteMatch)
-> Parser (Maybe HttpMethod) -> Parser HttpGatewayRouteMatch
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HttpMethod)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"method")
      )

instance Prelude.Hashable HttpGatewayRouteMatch

instance Prelude.NFData HttpGatewayRouteMatch

instance Core.ToJSON HttpGatewayRouteMatch where
  toJSON :: HttpGatewayRouteMatch -> Value
toJSON HttpGatewayRouteMatch' {Maybe (NonEmpty HttpGatewayRouteHeader)
Maybe (NonEmpty HttpQueryParameter)
Maybe Text
Maybe GatewayRouteHostnameMatch
Maybe HttpMethod
Maybe HttpPathMatch
method :: Maybe HttpMethod
headers :: Maybe (NonEmpty HttpGatewayRouteHeader)
queryParameters :: Maybe (NonEmpty HttpQueryParameter)
prefix :: Maybe Text
path :: Maybe HttpPathMatch
hostname :: Maybe GatewayRouteHostnameMatch
$sel:method:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe HttpMethod
$sel:headers:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe (NonEmpty HttpGatewayRouteHeader)
$sel:queryParameters:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe (NonEmpty HttpQueryParameter)
$sel:prefix:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe Text
$sel:path:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe HttpPathMatch
$sel:hostname:HttpGatewayRouteMatch' :: HttpGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"hostname" Text -> GatewayRouteHostnameMatch -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (GatewayRouteHostnameMatch -> Pair)
-> Maybe GatewayRouteHostnameMatch -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GatewayRouteHostnameMatch
hostname,
            (Text
"path" Text -> HttpPathMatch -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpPathMatch -> Pair) -> Maybe HttpPathMatch -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpPathMatch
path,
            (Text
"prefix" 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
prefix,
            (Text
"queryParameters" Text -> NonEmpty HttpQueryParameter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty HttpQueryParameter -> Pair)
-> Maybe (NonEmpty HttpQueryParameter) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty HttpQueryParameter)
queryParameters,
            (Text
"headers" Text -> NonEmpty HttpGatewayRouteHeader -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty HttpGatewayRouteHeader -> Pair)
-> Maybe (NonEmpty HttpGatewayRouteHeader) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty HttpGatewayRouteHeader)
headers,
            (Text
"method" Text -> HttpMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpMethod -> Pair) -> Maybe HttpMethod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpMethod
method
          ]
      )