{-# 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 #-}
module Amazonka.AppMesh.Types.TcpRoute where
import Amazonka.AppMesh.Types.TcpRouteAction
import Amazonka.AppMesh.Types.TcpTimeout
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data TcpRoute = TcpRoute'
{
TcpRoute -> Maybe TcpTimeout
timeout :: Prelude.Maybe TcpTimeout,
TcpRoute -> TcpRouteAction
action :: TcpRouteAction
}
deriving (TcpRoute -> TcpRoute -> Bool
(TcpRoute -> TcpRoute -> Bool)
-> (TcpRoute -> TcpRoute -> Bool) -> Eq TcpRoute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TcpRoute -> TcpRoute -> Bool
$c/= :: TcpRoute -> TcpRoute -> Bool
== :: TcpRoute -> TcpRoute -> Bool
$c== :: TcpRoute -> TcpRoute -> Bool
Prelude.Eq, ReadPrec [TcpRoute]
ReadPrec TcpRoute
Int -> ReadS TcpRoute
ReadS [TcpRoute]
(Int -> ReadS TcpRoute)
-> ReadS [TcpRoute]
-> ReadPrec TcpRoute
-> ReadPrec [TcpRoute]
-> Read TcpRoute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TcpRoute]
$creadListPrec :: ReadPrec [TcpRoute]
readPrec :: ReadPrec TcpRoute
$creadPrec :: ReadPrec TcpRoute
readList :: ReadS [TcpRoute]
$creadList :: ReadS [TcpRoute]
readsPrec :: Int -> ReadS TcpRoute
$creadsPrec :: Int -> ReadS TcpRoute
Prelude.Read, Int -> TcpRoute -> ShowS
[TcpRoute] -> ShowS
TcpRoute -> String
(Int -> TcpRoute -> ShowS)
-> (TcpRoute -> String) -> ([TcpRoute] -> ShowS) -> Show TcpRoute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TcpRoute] -> ShowS
$cshowList :: [TcpRoute] -> ShowS
show :: TcpRoute -> String
$cshow :: TcpRoute -> String
showsPrec :: Int -> TcpRoute -> ShowS
$cshowsPrec :: Int -> TcpRoute -> ShowS
Prelude.Show, (forall x. TcpRoute -> Rep TcpRoute x)
-> (forall x. Rep TcpRoute x -> TcpRoute) -> Generic TcpRoute
forall x. Rep TcpRoute x -> TcpRoute
forall x. TcpRoute -> Rep TcpRoute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TcpRoute x -> TcpRoute
$cfrom :: forall x. TcpRoute -> Rep TcpRoute x
Prelude.Generic)
newTcpRoute ::
TcpRouteAction ->
TcpRoute
newTcpRoute :: TcpRouteAction -> TcpRoute
newTcpRoute TcpRouteAction
pAction_ =
TcpRoute' :: Maybe TcpTimeout -> TcpRouteAction -> TcpRoute
TcpRoute'
{ $sel:timeout:TcpRoute' :: Maybe TcpTimeout
timeout = Maybe TcpTimeout
forall a. Maybe a
Prelude.Nothing,
$sel:action:TcpRoute' :: TcpRouteAction
action = TcpRouteAction
pAction_
}
tcpRoute_timeout :: Lens.Lens' TcpRoute (Prelude.Maybe TcpTimeout)
tcpRoute_timeout :: (Maybe TcpTimeout -> f (Maybe TcpTimeout))
-> TcpRoute -> f TcpRoute
tcpRoute_timeout = (TcpRoute -> Maybe TcpTimeout)
-> (TcpRoute -> Maybe TcpTimeout -> TcpRoute)
-> Lens TcpRoute TcpRoute (Maybe TcpTimeout) (Maybe TcpTimeout)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TcpRoute' {Maybe TcpTimeout
timeout :: Maybe TcpTimeout
$sel:timeout:TcpRoute' :: TcpRoute -> Maybe TcpTimeout
timeout} -> Maybe TcpTimeout
timeout) (\s :: TcpRoute
s@TcpRoute' {} Maybe TcpTimeout
a -> TcpRoute
s {$sel:timeout:TcpRoute' :: Maybe TcpTimeout
timeout = Maybe TcpTimeout
a} :: TcpRoute)
tcpRoute_action :: Lens.Lens' TcpRoute TcpRouteAction
tcpRoute_action :: (TcpRouteAction -> f TcpRouteAction) -> TcpRoute -> f TcpRoute
tcpRoute_action = (TcpRoute -> TcpRouteAction)
-> (TcpRoute -> TcpRouteAction -> TcpRoute)
-> Lens TcpRoute TcpRoute TcpRouteAction TcpRouteAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TcpRoute' {TcpRouteAction
action :: TcpRouteAction
$sel:action:TcpRoute' :: TcpRoute -> TcpRouteAction
action} -> TcpRouteAction
action) (\s :: TcpRoute
s@TcpRoute' {} TcpRouteAction
a -> TcpRoute
s {$sel:action:TcpRoute' :: TcpRouteAction
action = TcpRouteAction
a} :: TcpRoute)
instance Core.FromJSON TcpRoute where
parseJSON :: Value -> Parser TcpRoute
parseJSON =
String -> (Object -> Parser TcpRoute) -> Value -> Parser TcpRoute
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TcpRoute"
( \Object
x ->
Maybe TcpTimeout -> TcpRouteAction -> TcpRoute
TcpRoute'
(Maybe TcpTimeout -> TcpRouteAction -> TcpRoute)
-> Parser (Maybe TcpTimeout) -> Parser (TcpRouteAction -> TcpRoute)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TcpTimeout)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timeout")
Parser (TcpRouteAction -> TcpRoute)
-> Parser TcpRouteAction -> Parser TcpRoute
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TcpRouteAction
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"action")
)
instance Prelude.Hashable TcpRoute
instance Prelude.NFData TcpRoute
instance Core.ToJSON TcpRoute where
toJSON :: TcpRoute -> Value
toJSON TcpRoute' {Maybe TcpTimeout
TcpRouteAction
action :: TcpRouteAction
timeout :: Maybe TcpTimeout
$sel:action:TcpRoute' :: TcpRoute -> TcpRouteAction
$sel:timeout:TcpRoute' :: TcpRoute -> Maybe TcpTimeout
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"timeout" Text -> TcpTimeout -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TcpTimeout -> Pair) -> Maybe TcpTimeout -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TcpTimeout
timeout,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"action" Text -> TcpRouteAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TcpRouteAction
action)
]
)