{-# 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.RouteSpec where
import Amazonka.AppMesh.Types.GrpcRoute
import Amazonka.AppMesh.Types.HttpRoute
import Amazonka.AppMesh.Types.TcpRoute
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data RouteSpec = RouteSpec'
{
RouteSpec -> Maybe Natural
priority :: Prelude.Maybe Prelude.Natural,
RouteSpec -> Maybe HttpRoute
http2Route :: Prelude.Maybe HttpRoute,
RouteSpec -> Maybe GrpcRoute
grpcRoute :: Prelude.Maybe GrpcRoute,
RouteSpec -> Maybe TcpRoute
tcpRoute :: Prelude.Maybe TcpRoute,
RouteSpec -> Maybe HttpRoute
httpRoute :: Prelude.Maybe HttpRoute
}
deriving (RouteSpec -> RouteSpec -> Bool
(RouteSpec -> RouteSpec -> Bool)
-> (RouteSpec -> RouteSpec -> Bool) -> Eq RouteSpec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RouteSpec -> RouteSpec -> Bool
$c/= :: RouteSpec -> RouteSpec -> Bool
== :: RouteSpec -> RouteSpec -> Bool
$c== :: RouteSpec -> RouteSpec -> Bool
Prelude.Eq, ReadPrec [RouteSpec]
ReadPrec RouteSpec
Int -> ReadS RouteSpec
ReadS [RouteSpec]
(Int -> ReadS RouteSpec)
-> ReadS [RouteSpec]
-> ReadPrec RouteSpec
-> ReadPrec [RouteSpec]
-> Read RouteSpec
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RouteSpec]
$creadListPrec :: ReadPrec [RouteSpec]
readPrec :: ReadPrec RouteSpec
$creadPrec :: ReadPrec RouteSpec
readList :: ReadS [RouteSpec]
$creadList :: ReadS [RouteSpec]
readsPrec :: Int -> ReadS RouteSpec
$creadsPrec :: Int -> ReadS RouteSpec
Prelude.Read, Int -> RouteSpec -> ShowS
[RouteSpec] -> ShowS
RouteSpec -> String
(Int -> RouteSpec -> ShowS)
-> (RouteSpec -> String)
-> ([RouteSpec] -> ShowS)
-> Show RouteSpec
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RouteSpec] -> ShowS
$cshowList :: [RouteSpec] -> ShowS
show :: RouteSpec -> String
$cshow :: RouteSpec -> String
showsPrec :: Int -> RouteSpec -> ShowS
$cshowsPrec :: Int -> RouteSpec -> ShowS
Prelude.Show, (forall x. RouteSpec -> Rep RouteSpec x)
-> (forall x. Rep RouteSpec x -> RouteSpec) -> Generic RouteSpec
forall x. Rep RouteSpec x -> RouteSpec
forall x. RouteSpec -> Rep RouteSpec x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RouteSpec x -> RouteSpec
$cfrom :: forall x. RouteSpec -> Rep RouteSpec x
Prelude.Generic)
newRouteSpec ::
RouteSpec
newRouteSpec :: RouteSpec
newRouteSpec =
RouteSpec' :: Maybe Natural
-> Maybe HttpRoute
-> Maybe GrpcRoute
-> Maybe TcpRoute
-> Maybe HttpRoute
-> RouteSpec
RouteSpec'
{ $sel:priority:RouteSpec' :: Maybe Natural
priority = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:http2Route:RouteSpec' :: Maybe HttpRoute
http2Route = Maybe HttpRoute
forall a. Maybe a
Prelude.Nothing,
$sel:grpcRoute:RouteSpec' :: Maybe GrpcRoute
grpcRoute = Maybe GrpcRoute
forall a. Maybe a
Prelude.Nothing,
$sel:tcpRoute:RouteSpec' :: Maybe TcpRoute
tcpRoute = Maybe TcpRoute
forall a. Maybe a
Prelude.Nothing,
$sel:httpRoute:RouteSpec' :: Maybe HttpRoute
httpRoute = Maybe HttpRoute
forall a. Maybe a
Prelude.Nothing
}
routeSpec_priority :: Lens.Lens' RouteSpec (Prelude.Maybe Prelude.Natural)
routeSpec_priority :: (Maybe Natural -> f (Maybe Natural)) -> RouteSpec -> f RouteSpec
routeSpec_priority = (RouteSpec -> Maybe Natural)
-> (RouteSpec -> Maybe Natural -> RouteSpec)
-> Lens RouteSpec RouteSpec (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSpec' {Maybe Natural
priority :: Maybe Natural
$sel:priority:RouteSpec' :: RouteSpec -> Maybe Natural
priority} -> Maybe Natural
priority) (\s :: RouteSpec
s@RouteSpec' {} Maybe Natural
a -> RouteSpec
s {$sel:priority:RouteSpec' :: Maybe Natural
priority = Maybe Natural
a} :: RouteSpec)
routeSpec_http2Route :: Lens.Lens' RouteSpec (Prelude.Maybe HttpRoute)
routeSpec_http2Route :: (Maybe HttpRoute -> f (Maybe HttpRoute))
-> RouteSpec -> f RouteSpec
routeSpec_http2Route = (RouteSpec -> Maybe HttpRoute)
-> (RouteSpec -> Maybe HttpRoute -> RouteSpec)
-> Lens RouteSpec RouteSpec (Maybe HttpRoute) (Maybe HttpRoute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSpec' {Maybe HttpRoute
http2Route :: Maybe HttpRoute
$sel:http2Route:RouteSpec' :: RouteSpec -> Maybe HttpRoute
http2Route} -> Maybe HttpRoute
http2Route) (\s :: RouteSpec
s@RouteSpec' {} Maybe HttpRoute
a -> RouteSpec
s {$sel:http2Route:RouteSpec' :: Maybe HttpRoute
http2Route = Maybe HttpRoute
a} :: RouteSpec)
routeSpec_grpcRoute :: Lens.Lens' RouteSpec (Prelude.Maybe GrpcRoute)
routeSpec_grpcRoute :: (Maybe GrpcRoute -> f (Maybe GrpcRoute))
-> RouteSpec -> f RouteSpec
routeSpec_grpcRoute = (RouteSpec -> Maybe GrpcRoute)
-> (RouteSpec -> Maybe GrpcRoute -> RouteSpec)
-> Lens RouteSpec RouteSpec (Maybe GrpcRoute) (Maybe GrpcRoute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSpec' {Maybe GrpcRoute
grpcRoute :: Maybe GrpcRoute
$sel:grpcRoute:RouteSpec' :: RouteSpec -> Maybe GrpcRoute
grpcRoute} -> Maybe GrpcRoute
grpcRoute) (\s :: RouteSpec
s@RouteSpec' {} Maybe GrpcRoute
a -> RouteSpec
s {$sel:grpcRoute:RouteSpec' :: Maybe GrpcRoute
grpcRoute = Maybe GrpcRoute
a} :: RouteSpec)
routeSpec_tcpRoute :: Lens.Lens' RouteSpec (Prelude.Maybe TcpRoute)
routeSpec_tcpRoute :: (Maybe TcpRoute -> f (Maybe TcpRoute)) -> RouteSpec -> f RouteSpec
routeSpec_tcpRoute = (RouteSpec -> Maybe TcpRoute)
-> (RouteSpec -> Maybe TcpRoute -> RouteSpec)
-> Lens RouteSpec RouteSpec (Maybe TcpRoute) (Maybe TcpRoute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSpec' {Maybe TcpRoute
tcpRoute :: Maybe TcpRoute
$sel:tcpRoute:RouteSpec' :: RouteSpec -> Maybe TcpRoute
tcpRoute} -> Maybe TcpRoute
tcpRoute) (\s :: RouteSpec
s@RouteSpec' {} Maybe TcpRoute
a -> RouteSpec
s {$sel:tcpRoute:RouteSpec' :: Maybe TcpRoute
tcpRoute = Maybe TcpRoute
a} :: RouteSpec)
routeSpec_httpRoute :: Lens.Lens' RouteSpec (Prelude.Maybe HttpRoute)
routeSpec_httpRoute :: (Maybe HttpRoute -> f (Maybe HttpRoute))
-> RouteSpec -> f RouteSpec
routeSpec_httpRoute = (RouteSpec -> Maybe HttpRoute)
-> (RouteSpec -> Maybe HttpRoute -> RouteSpec)
-> Lens RouteSpec RouteSpec (Maybe HttpRoute) (Maybe HttpRoute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteSpec' {Maybe HttpRoute
httpRoute :: Maybe HttpRoute
$sel:httpRoute:RouteSpec' :: RouteSpec -> Maybe HttpRoute
httpRoute} -> Maybe HttpRoute
httpRoute) (\s :: RouteSpec
s@RouteSpec' {} Maybe HttpRoute
a -> RouteSpec
s {$sel:httpRoute:RouteSpec' :: Maybe HttpRoute
httpRoute = Maybe HttpRoute
a} :: RouteSpec)
instance Core.FromJSON RouteSpec where
parseJSON :: Value -> Parser RouteSpec
parseJSON =
String -> (Object -> Parser RouteSpec) -> Value -> Parser RouteSpec
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RouteSpec"
( \Object
x ->
Maybe Natural
-> Maybe HttpRoute
-> Maybe GrpcRoute
-> Maybe TcpRoute
-> Maybe HttpRoute
-> RouteSpec
RouteSpec'
(Maybe Natural
-> Maybe HttpRoute
-> Maybe GrpcRoute
-> Maybe TcpRoute
-> Maybe HttpRoute
-> RouteSpec)
-> Parser (Maybe Natural)
-> Parser
(Maybe HttpRoute
-> Maybe GrpcRoute
-> Maybe TcpRoute
-> Maybe HttpRoute
-> RouteSpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"priority")
Parser
(Maybe HttpRoute
-> Maybe GrpcRoute
-> Maybe TcpRoute
-> Maybe HttpRoute
-> RouteSpec)
-> Parser (Maybe HttpRoute)
-> Parser
(Maybe GrpcRoute -> Maybe TcpRoute -> Maybe HttpRoute -> RouteSpec)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HttpRoute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"http2Route")
Parser
(Maybe GrpcRoute -> Maybe TcpRoute -> Maybe HttpRoute -> RouteSpec)
-> Parser (Maybe GrpcRoute)
-> Parser (Maybe TcpRoute -> Maybe HttpRoute -> RouteSpec)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe GrpcRoute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"grpcRoute")
Parser (Maybe TcpRoute -> Maybe HttpRoute -> RouteSpec)
-> Parser (Maybe TcpRoute) -> Parser (Maybe HttpRoute -> RouteSpec)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TcpRoute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tcpRoute")
Parser (Maybe HttpRoute -> RouteSpec)
-> Parser (Maybe HttpRoute) -> Parser RouteSpec
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HttpRoute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"httpRoute")
)
instance Prelude.Hashable RouteSpec
instance Prelude.NFData RouteSpec
instance Core.ToJSON RouteSpec where
toJSON :: RouteSpec -> Value
toJSON RouteSpec' {Maybe Natural
Maybe TcpRoute
Maybe HttpRoute
Maybe GrpcRoute
httpRoute :: Maybe HttpRoute
tcpRoute :: Maybe TcpRoute
grpcRoute :: Maybe GrpcRoute
http2Route :: Maybe HttpRoute
priority :: Maybe Natural
$sel:httpRoute:RouteSpec' :: RouteSpec -> Maybe HttpRoute
$sel:tcpRoute:RouteSpec' :: RouteSpec -> Maybe TcpRoute
$sel:grpcRoute:RouteSpec' :: RouteSpec -> Maybe GrpcRoute
$sel:http2Route:RouteSpec' :: RouteSpec -> Maybe HttpRoute
$sel:priority:RouteSpec' :: RouteSpec -> Maybe Natural
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"priority" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
priority,
(Text
"http2Route" Text -> HttpRoute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpRoute -> Pair) -> Maybe HttpRoute -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpRoute
http2Route,
(Text
"grpcRoute" Text -> GrpcRoute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (GrpcRoute -> Pair) -> Maybe GrpcRoute -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GrpcRoute
grpcRoute,
(Text
"tcpRoute" Text -> TcpRoute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TcpRoute -> Pair) -> Maybe TcpRoute -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TcpRoute
tcpRoute,
(Text
"httpRoute" Text -> HttpRoute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpRoute -> Pair) -> Maybe HttpRoute -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpRoute
httpRoute
]
)