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

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 representing the TCP route to match.
--
-- /See:/ 'newTcpRouteMatch' smart constructor.
data TcpRouteMatch = TcpRouteMatch'
  { -- | The port number to match on.
    TcpRouteMatch -> Maybe Natural
port :: Prelude.Maybe Prelude.Natural
  }
  deriving (TcpRouteMatch -> TcpRouteMatch -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TcpRouteMatch -> TcpRouteMatch -> Bool
$c/= :: TcpRouteMatch -> TcpRouteMatch -> Bool
== :: TcpRouteMatch -> TcpRouteMatch -> Bool
$c== :: TcpRouteMatch -> TcpRouteMatch -> Bool
Prelude.Eq, ReadPrec [TcpRouteMatch]
ReadPrec TcpRouteMatch
Int -> ReadS TcpRouteMatch
ReadS [TcpRouteMatch]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TcpRouteMatch]
$creadListPrec :: ReadPrec [TcpRouteMatch]
readPrec :: ReadPrec TcpRouteMatch
$creadPrec :: ReadPrec TcpRouteMatch
readList :: ReadS [TcpRouteMatch]
$creadList :: ReadS [TcpRouteMatch]
readsPrec :: Int -> ReadS TcpRouteMatch
$creadsPrec :: Int -> ReadS TcpRouteMatch
Prelude.Read, Int -> TcpRouteMatch -> ShowS
[TcpRouteMatch] -> ShowS
TcpRouteMatch -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TcpRouteMatch] -> ShowS
$cshowList :: [TcpRouteMatch] -> ShowS
show :: TcpRouteMatch -> String
$cshow :: TcpRouteMatch -> String
showsPrec :: Int -> TcpRouteMatch -> ShowS
$cshowsPrec :: Int -> TcpRouteMatch -> ShowS
Prelude.Show, forall x. Rep TcpRouteMatch x -> TcpRouteMatch
forall x. TcpRouteMatch -> Rep TcpRouteMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TcpRouteMatch x -> TcpRouteMatch
$cfrom :: forall x. TcpRouteMatch -> Rep TcpRouteMatch x
Prelude.Generic)

-- |
-- Create a value of 'TcpRouteMatch' 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:
--
-- 'port', 'tcpRouteMatch_port' - The port number to match on.
newTcpRouteMatch ::
  TcpRouteMatch
newTcpRouteMatch :: TcpRouteMatch
newTcpRouteMatch =
  TcpRouteMatch' {$sel:port:TcpRouteMatch' :: Maybe Natural
port = forall a. Maybe a
Prelude.Nothing}

-- | The port number to match on.
tcpRouteMatch_port :: Lens.Lens' TcpRouteMatch (Prelude.Maybe Prelude.Natural)
tcpRouteMatch_port :: Lens' TcpRouteMatch (Maybe Natural)
tcpRouteMatch_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TcpRouteMatch' {Maybe Natural
port :: Maybe Natural
$sel:port:TcpRouteMatch' :: TcpRouteMatch -> Maybe Natural
port} -> Maybe Natural
port) (\s :: TcpRouteMatch
s@TcpRouteMatch' {} Maybe Natural
a -> TcpRouteMatch
s {$sel:port:TcpRouteMatch' :: Maybe Natural
port = Maybe Natural
a} :: TcpRouteMatch)

instance Data.FromJSON TcpRouteMatch where
  parseJSON :: Value -> Parser TcpRouteMatch
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TcpRouteMatch"
      ( \Object
x ->
          Maybe Natural -> TcpRouteMatch
TcpRouteMatch' 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
"port")
      )

instance Prelude.Hashable TcpRouteMatch where
  hashWithSalt :: Int -> TcpRouteMatch -> Int
hashWithSalt Int
_salt TcpRouteMatch' {Maybe Natural
port :: Maybe Natural
$sel:port:TcpRouteMatch' :: TcpRouteMatch -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
port

instance Prelude.NFData TcpRouteMatch where
  rnf :: TcpRouteMatch -> ()
rnf TcpRouteMatch' {Maybe Natural
port :: Maybe Natural
$sel:port:TcpRouteMatch' :: TcpRouteMatch -> Maybe Natural
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
port

instance Data.ToJSON TcpRouteMatch where
  toJSON :: TcpRouteMatch -> Value
toJSON TcpRouteMatch' {Maybe Natural
port :: Maybe Natural
$sel:port:TcpRouteMatch' :: TcpRouteMatch -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(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]
      )