{-# 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.GrpcGatewayRouteMatch
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppMesh.Types.GrpcGatewayRouteMatch where

import Amazonka.AppMesh.Types.GatewayRouteHostnameMatch
import Amazonka.AppMesh.Types.GrpcGatewayRouteMetadata
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the criteria for determining a request match.
--
-- /See:/ 'newGrpcGatewayRouteMatch' smart constructor.
data GrpcGatewayRouteMatch = GrpcGatewayRouteMatch'
  { -- | The gateway route host name to be matched on.
    GrpcGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch
hostname :: Prelude.Maybe GatewayRouteHostnameMatch,
    -- | The gateway route metadata to be matched on.
    GrpcGatewayRouteMatch -> Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata :: Prelude.Maybe (Prelude.NonEmpty GrpcGatewayRouteMetadata),
    -- | The port number to match from the request.
    GrpcGatewayRouteMatch -> Maybe Natural
port :: Prelude.Maybe Prelude.Natural,
    -- | The fully qualified domain name for the service to match from the
    -- request.
    GrpcGatewayRouteMatch -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text
  }
  deriving (GrpcGatewayRouteMatch -> GrpcGatewayRouteMatch -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrpcGatewayRouteMatch -> GrpcGatewayRouteMatch -> Bool
$c/= :: GrpcGatewayRouteMatch -> GrpcGatewayRouteMatch -> Bool
== :: GrpcGatewayRouteMatch -> GrpcGatewayRouteMatch -> Bool
$c== :: GrpcGatewayRouteMatch -> GrpcGatewayRouteMatch -> Bool
Prelude.Eq, ReadPrec [GrpcGatewayRouteMatch]
ReadPrec GrpcGatewayRouteMatch
Int -> ReadS GrpcGatewayRouteMatch
ReadS [GrpcGatewayRouteMatch]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GrpcGatewayRouteMatch]
$creadListPrec :: ReadPrec [GrpcGatewayRouteMatch]
readPrec :: ReadPrec GrpcGatewayRouteMatch
$creadPrec :: ReadPrec GrpcGatewayRouteMatch
readList :: ReadS [GrpcGatewayRouteMatch]
$creadList :: ReadS [GrpcGatewayRouteMatch]
readsPrec :: Int -> ReadS GrpcGatewayRouteMatch
$creadsPrec :: Int -> ReadS GrpcGatewayRouteMatch
Prelude.Read, Int -> GrpcGatewayRouteMatch -> ShowS
[GrpcGatewayRouteMatch] -> ShowS
GrpcGatewayRouteMatch -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrpcGatewayRouteMatch] -> ShowS
$cshowList :: [GrpcGatewayRouteMatch] -> ShowS
show :: GrpcGatewayRouteMatch -> String
$cshow :: GrpcGatewayRouteMatch -> String
showsPrec :: Int -> GrpcGatewayRouteMatch -> ShowS
$cshowsPrec :: Int -> GrpcGatewayRouteMatch -> ShowS
Prelude.Show, forall x. Rep GrpcGatewayRouteMatch x -> GrpcGatewayRouteMatch
forall x. GrpcGatewayRouteMatch -> Rep GrpcGatewayRouteMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GrpcGatewayRouteMatch x -> GrpcGatewayRouteMatch
$cfrom :: forall x. GrpcGatewayRouteMatch -> Rep GrpcGatewayRouteMatch x
Prelude.Generic)

-- |
-- Create a value of 'GrpcGatewayRouteMatch' 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', 'grpcGatewayRouteMatch_hostname' - The gateway route host name to be matched on.
--
-- 'metadata', 'grpcGatewayRouteMatch_metadata' - The gateway route metadata to be matched on.
--
-- 'port', 'grpcGatewayRouteMatch_port' - The port number to match from the request.
--
-- 'serviceName', 'grpcGatewayRouteMatch_serviceName' - The fully qualified domain name for the service to match from the
-- request.
newGrpcGatewayRouteMatch ::
  GrpcGatewayRouteMatch
newGrpcGatewayRouteMatch :: GrpcGatewayRouteMatch
newGrpcGatewayRouteMatch =
  GrpcGatewayRouteMatch'
    { $sel:hostname:GrpcGatewayRouteMatch' :: Maybe GatewayRouteHostnameMatch
hostname = forall a. Maybe a
Prelude.Nothing,
      $sel:metadata:GrpcGatewayRouteMatch' :: Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata = forall a. Maybe a
Prelude.Nothing,
      $sel:port:GrpcGatewayRouteMatch' :: Maybe Natural
port = forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:GrpcGatewayRouteMatch' :: Maybe Text
serviceName = forall a. Maybe a
Prelude.Nothing
    }

-- | The gateway route host name to be matched on.
grpcGatewayRouteMatch_hostname :: Lens.Lens' GrpcGatewayRouteMatch (Prelude.Maybe GatewayRouteHostnameMatch)
grpcGatewayRouteMatch_hostname :: Lens' GrpcGatewayRouteMatch (Maybe GatewayRouteHostnameMatch)
grpcGatewayRouteMatch_hostname = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcGatewayRouteMatch' {Maybe GatewayRouteHostnameMatch
hostname :: Maybe GatewayRouteHostnameMatch
$sel:hostname:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch
hostname} -> Maybe GatewayRouteHostnameMatch
hostname) (\s :: GrpcGatewayRouteMatch
s@GrpcGatewayRouteMatch' {} Maybe GatewayRouteHostnameMatch
a -> GrpcGatewayRouteMatch
s {$sel:hostname:GrpcGatewayRouteMatch' :: Maybe GatewayRouteHostnameMatch
hostname = Maybe GatewayRouteHostnameMatch
a} :: GrpcGatewayRouteMatch)

-- | The gateway route metadata to be matched on.
grpcGatewayRouteMatch_metadata :: Lens.Lens' GrpcGatewayRouteMatch (Prelude.Maybe (Prelude.NonEmpty GrpcGatewayRouteMetadata))
grpcGatewayRouteMatch_metadata :: Lens'
  GrpcGatewayRouteMatch (Maybe (NonEmpty GrpcGatewayRouteMetadata))
grpcGatewayRouteMatch_metadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcGatewayRouteMatch' {Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata :: Maybe (NonEmpty GrpcGatewayRouteMetadata)
$sel:metadata:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata} -> Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata) (\s :: GrpcGatewayRouteMatch
s@GrpcGatewayRouteMatch' {} Maybe (NonEmpty GrpcGatewayRouteMetadata)
a -> GrpcGatewayRouteMatch
s {$sel:metadata:GrpcGatewayRouteMatch' :: Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata = Maybe (NonEmpty GrpcGatewayRouteMetadata)
a} :: GrpcGatewayRouteMatch) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The port number to match from the request.
grpcGatewayRouteMatch_port :: Lens.Lens' GrpcGatewayRouteMatch (Prelude.Maybe Prelude.Natural)
grpcGatewayRouteMatch_port :: Lens' GrpcGatewayRouteMatch (Maybe Natural)
grpcGatewayRouteMatch_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcGatewayRouteMatch' {Maybe Natural
port :: Maybe Natural
$sel:port:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe Natural
port} -> Maybe Natural
port) (\s :: GrpcGatewayRouteMatch
s@GrpcGatewayRouteMatch' {} Maybe Natural
a -> GrpcGatewayRouteMatch
s {$sel:port:GrpcGatewayRouteMatch' :: Maybe Natural
port = Maybe Natural
a} :: GrpcGatewayRouteMatch)

-- | The fully qualified domain name for the service to match from the
-- request.
grpcGatewayRouteMatch_serviceName :: Lens.Lens' GrpcGatewayRouteMatch (Prelude.Maybe Prelude.Text)
grpcGatewayRouteMatch_serviceName :: Lens' GrpcGatewayRouteMatch (Maybe Text)
grpcGatewayRouteMatch_serviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcGatewayRouteMatch' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe Text
serviceName} -> Maybe Text
serviceName) (\s :: GrpcGatewayRouteMatch
s@GrpcGatewayRouteMatch' {} Maybe Text
a -> GrpcGatewayRouteMatch
s {$sel:serviceName:GrpcGatewayRouteMatch' :: Maybe Text
serviceName = Maybe Text
a} :: GrpcGatewayRouteMatch)

instance Data.FromJSON GrpcGatewayRouteMatch where
  parseJSON :: Value -> Parser GrpcGatewayRouteMatch
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GrpcGatewayRouteMatch"
      ( \Object
x ->
          Maybe GatewayRouteHostnameMatch
-> Maybe (NonEmpty GrpcGatewayRouteMetadata)
-> Maybe Natural
-> Maybe Text
-> GrpcGatewayRouteMatch
GrpcGatewayRouteMatch'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"hostname")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"metadata")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"port")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"serviceName")
      )

instance Prelude.Hashable GrpcGatewayRouteMatch where
  hashWithSalt :: Int -> GrpcGatewayRouteMatch -> Int
hashWithSalt Int
_salt GrpcGatewayRouteMatch' {Maybe Natural
Maybe (NonEmpty GrpcGatewayRouteMetadata)
Maybe Text
Maybe GatewayRouteHostnameMatch
serviceName :: Maybe Text
port :: Maybe Natural
metadata :: Maybe (NonEmpty GrpcGatewayRouteMetadata)
hostname :: Maybe GatewayRouteHostnameMatch
$sel:serviceName:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe Text
$sel:port:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe Natural
$sel:metadata:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe (NonEmpty GrpcGatewayRouteMetadata)
$sel:hostname:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GatewayRouteHostnameMatch
hostname
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
port
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serviceName

instance Prelude.NFData GrpcGatewayRouteMatch where
  rnf :: GrpcGatewayRouteMatch -> ()
rnf GrpcGatewayRouteMatch' {Maybe Natural
Maybe (NonEmpty GrpcGatewayRouteMetadata)
Maybe Text
Maybe GatewayRouteHostnameMatch
serviceName :: Maybe Text
port :: Maybe Natural
metadata :: Maybe (NonEmpty GrpcGatewayRouteMetadata)
hostname :: Maybe GatewayRouteHostnameMatch
$sel:serviceName:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe Text
$sel:port:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe Natural
$sel:metadata:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe (NonEmpty GrpcGatewayRouteMetadata)
$sel:hostname:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe GatewayRouteHostnameMatch
hostname
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
port
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serviceName

instance Data.ToJSON GrpcGatewayRouteMatch where
  toJSON :: GrpcGatewayRouteMatch -> Value
toJSON GrpcGatewayRouteMatch' {Maybe Natural
Maybe (NonEmpty GrpcGatewayRouteMetadata)
Maybe Text
Maybe GatewayRouteHostnameMatch
serviceName :: Maybe Text
port :: Maybe Natural
metadata :: Maybe (NonEmpty GrpcGatewayRouteMetadata)
hostname :: Maybe GatewayRouteHostnameMatch
$sel:serviceName:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe Text
$sel:port:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe Natural
$sel:metadata:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe (NonEmpty GrpcGatewayRouteMetadata)
$sel:hostname:GrpcGatewayRouteMatch' :: GrpcGatewayRouteMatch -> Maybe GatewayRouteHostnameMatch
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"hostname" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GatewayRouteHostnameMatch
hostname,
            (Key
"metadata" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty GrpcGatewayRouteMetadata)
metadata,
            (Key
"port" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
port,
            (Key
"serviceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
serviceName
          ]
      )