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