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