{-# 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.HttpRetryPolicy where
import Amazonka.AppMesh.Types.Duration
import Amazonka.AppMesh.Types.TcpRetryPolicyEvent
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data HttpRetryPolicy = HttpRetryPolicy'
{
HttpRetryPolicy -> Maybe (NonEmpty Text)
httpRetryEvents :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
HttpRetryPolicy -> Maybe (NonEmpty TcpRetryPolicyEvent)
tcpRetryEvents :: Prelude.Maybe (Prelude.NonEmpty TcpRetryPolicyEvent),
HttpRetryPolicy -> Natural
maxRetries :: Prelude.Natural,
HttpRetryPolicy -> Duration
perRetryTimeout :: Duration
}
deriving (HttpRetryPolicy -> HttpRetryPolicy -> Bool
(HttpRetryPolicy -> HttpRetryPolicy -> Bool)
-> (HttpRetryPolicy -> HttpRetryPolicy -> Bool)
-> Eq HttpRetryPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpRetryPolicy -> HttpRetryPolicy -> Bool
$c/= :: HttpRetryPolicy -> HttpRetryPolicy -> Bool
== :: HttpRetryPolicy -> HttpRetryPolicy -> Bool
$c== :: HttpRetryPolicy -> HttpRetryPolicy -> Bool
Prelude.Eq, ReadPrec [HttpRetryPolicy]
ReadPrec HttpRetryPolicy
Int -> ReadS HttpRetryPolicy
ReadS [HttpRetryPolicy]
(Int -> ReadS HttpRetryPolicy)
-> ReadS [HttpRetryPolicy]
-> ReadPrec HttpRetryPolicy
-> ReadPrec [HttpRetryPolicy]
-> Read HttpRetryPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpRetryPolicy]
$creadListPrec :: ReadPrec [HttpRetryPolicy]
readPrec :: ReadPrec HttpRetryPolicy
$creadPrec :: ReadPrec HttpRetryPolicy
readList :: ReadS [HttpRetryPolicy]
$creadList :: ReadS [HttpRetryPolicy]
readsPrec :: Int -> ReadS HttpRetryPolicy
$creadsPrec :: Int -> ReadS HttpRetryPolicy
Prelude.Read, Int -> HttpRetryPolicy -> ShowS
[HttpRetryPolicy] -> ShowS
HttpRetryPolicy -> String
(Int -> HttpRetryPolicy -> ShowS)
-> (HttpRetryPolicy -> String)
-> ([HttpRetryPolicy] -> ShowS)
-> Show HttpRetryPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpRetryPolicy] -> ShowS
$cshowList :: [HttpRetryPolicy] -> ShowS
show :: HttpRetryPolicy -> String
$cshow :: HttpRetryPolicy -> String
showsPrec :: Int -> HttpRetryPolicy -> ShowS
$cshowsPrec :: Int -> HttpRetryPolicy -> ShowS
Prelude.Show, (forall x. HttpRetryPolicy -> Rep HttpRetryPolicy x)
-> (forall x. Rep HttpRetryPolicy x -> HttpRetryPolicy)
-> Generic HttpRetryPolicy
forall x. Rep HttpRetryPolicy x -> HttpRetryPolicy
forall x. HttpRetryPolicy -> Rep HttpRetryPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpRetryPolicy x -> HttpRetryPolicy
$cfrom :: forall x. HttpRetryPolicy -> Rep HttpRetryPolicy x
Prelude.Generic)
newHttpRetryPolicy ::
Prelude.Natural ->
Duration ->
HttpRetryPolicy
newHttpRetryPolicy :: Natural -> Duration -> HttpRetryPolicy
newHttpRetryPolicy Natural
pMaxRetries_ Duration
pPerRetryTimeout_ =
HttpRetryPolicy' :: Maybe (NonEmpty Text)
-> Maybe (NonEmpty TcpRetryPolicyEvent)
-> Natural
-> Duration
-> HttpRetryPolicy
HttpRetryPolicy'
{ $sel:httpRetryEvents:HttpRetryPolicy' :: Maybe (NonEmpty Text)
httpRetryEvents = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
$sel:tcpRetryEvents:HttpRetryPolicy' :: Maybe (NonEmpty TcpRetryPolicyEvent)
tcpRetryEvents = Maybe (NonEmpty TcpRetryPolicyEvent)
forall a. Maybe a
Prelude.Nothing,
$sel:maxRetries:HttpRetryPolicy' :: Natural
maxRetries = Natural
pMaxRetries_,
$sel:perRetryTimeout:HttpRetryPolicy' :: Duration
perRetryTimeout = Duration
pPerRetryTimeout_
}
httpRetryPolicy_httpRetryEvents :: Lens.Lens' HttpRetryPolicy (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
httpRetryPolicy_httpRetryEvents :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> HttpRetryPolicy -> f HttpRetryPolicy
httpRetryPolicy_httpRetryEvents = (HttpRetryPolicy -> Maybe (NonEmpty Text))
-> (HttpRetryPolicy -> Maybe (NonEmpty Text) -> HttpRetryPolicy)
-> Lens
HttpRetryPolicy
HttpRetryPolicy
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRetryPolicy' {Maybe (NonEmpty Text)
httpRetryEvents :: Maybe (NonEmpty Text)
$sel:httpRetryEvents:HttpRetryPolicy' :: HttpRetryPolicy -> Maybe (NonEmpty Text)
httpRetryEvents} -> Maybe (NonEmpty Text)
httpRetryEvents) (\s :: HttpRetryPolicy
s@HttpRetryPolicy' {} Maybe (NonEmpty Text)
a -> HttpRetryPolicy
s {$sel:httpRetryEvents:HttpRetryPolicy' :: Maybe (NonEmpty Text)
httpRetryEvents = Maybe (NonEmpty Text)
a} :: HttpRetryPolicy) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> HttpRetryPolicy -> f HttpRetryPolicy)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> HttpRetryPolicy
-> f HttpRetryPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
httpRetryPolicy_tcpRetryEvents :: Lens.Lens' HttpRetryPolicy (Prelude.Maybe (Prelude.NonEmpty TcpRetryPolicyEvent))
httpRetryPolicy_tcpRetryEvents :: (Maybe (NonEmpty TcpRetryPolicyEvent)
-> f (Maybe (NonEmpty TcpRetryPolicyEvent)))
-> HttpRetryPolicy -> f HttpRetryPolicy
httpRetryPolicy_tcpRetryEvents = (HttpRetryPolicy -> Maybe (NonEmpty TcpRetryPolicyEvent))
-> (HttpRetryPolicy
-> Maybe (NonEmpty TcpRetryPolicyEvent) -> HttpRetryPolicy)
-> Lens
HttpRetryPolicy
HttpRetryPolicy
(Maybe (NonEmpty TcpRetryPolicyEvent))
(Maybe (NonEmpty TcpRetryPolicyEvent))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRetryPolicy' {Maybe (NonEmpty TcpRetryPolicyEvent)
tcpRetryEvents :: Maybe (NonEmpty TcpRetryPolicyEvent)
$sel:tcpRetryEvents:HttpRetryPolicy' :: HttpRetryPolicy -> Maybe (NonEmpty TcpRetryPolicyEvent)
tcpRetryEvents} -> Maybe (NonEmpty TcpRetryPolicyEvent)
tcpRetryEvents) (\s :: HttpRetryPolicy
s@HttpRetryPolicy' {} Maybe (NonEmpty TcpRetryPolicyEvent)
a -> HttpRetryPolicy
s {$sel:tcpRetryEvents:HttpRetryPolicy' :: Maybe (NonEmpty TcpRetryPolicyEvent)
tcpRetryEvents = Maybe (NonEmpty TcpRetryPolicyEvent)
a} :: HttpRetryPolicy) ((Maybe (NonEmpty TcpRetryPolicyEvent)
-> f (Maybe (NonEmpty TcpRetryPolicyEvent)))
-> HttpRetryPolicy -> f HttpRetryPolicy)
-> ((Maybe (NonEmpty TcpRetryPolicyEvent)
-> f (Maybe (NonEmpty TcpRetryPolicyEvent)))
-> Maybe (NonEmpty TcpRetryPolicyEvent)
-> f (Maybe (NonEmpty TcpRetryPolicyEvent)))
-> (Maybe (NonEmpty TcpRetryPolicyEvent)
-> f (Maybe (NonEmpty TcpRetryPolicyEvent)))
-> HttpRetryPolicy
-> f HttpRetryPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty TcpRetryPolicyEvent)
(NonEmpty TcpRetryPolicyEvent)
(NonEmpty TcpRetryPolicyEvent)
(NonEmpty TcpRetryPolicyEvent)
-> Iso
(Maybe (NonEmpty TcpRetryPolicyEvent))
(Maybe (NonEmpty TcpRetryPolicyEvent))
(Maybe (NonEmpty TcpRetryPolicyEvent))
(Maybe (NonEmpty TcpRetryPolicyEvent))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
(NonEmpty TcpRetryPolicyEvent)
(NonEmpty TcpRetryPolicyEvent)
(NonEmpty TcpRetryPolicyEvent)
(NonEmpty TcpRetryPolicyEvent)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
httpRetryPolicy_maxRetries :: Lens.Lens' HttpRetryPolicy Prelude.Natural
httpRetryPolicy_maxRetries :: (Natural -> f Natural) -> HttpRetryPolicy -> f HttpRetryPolicy
httpRetryPolicy_maxRetries = (HttpRetryPolicy -> Natural)
-> (HttpRetryPolicy -> Natural -> HttpRetryPolicy)
-> Lens HttpRetryPolicy HttpRetryPolicy Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRetryPolicy' {Natural
maxRetries :: Natural
$sel:maxRetries:HttpRetryPolicy' :: HttpRetryPolicy -> Natural
maxRetries} -> Natural
maxRetries) (\s :: HttpRetryPolicy
s@HttpRetryPolicy' {} Natural
a -> HttpRetryPolicy
s {$sel:maxRetries:HttpRetryPolicy' :: Natural
maxRetries = Natural
a} :: HttpRetryPolicy)
httpRetryPolicy_perRetryTimeout :: Lens.Lens' HttpRetryPolicy Duration
httpRetryPolicy_perRetryTimeout :: (Duration -> f Duration) -> HttpRetryPolicy -> f HttpRetryPolicy
httpRetryPolicy_perRetryTimeout = (HttpRetryPolicy -> Duration)
-> (HttpRetryPolicy -> Duration -> HttpRetryPolicy)
-> Lens HttpRetryPolicy HttpRetryPolicy Duration Duration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpRetryPolicy' {Duration
perRetryTimeout :: Duration
$sel:perRetryTimeout:HttpRetryPolicy' :: HttpRetryPolicy -> Duration
perRetryTimeout} -> Duration
perRetryTimeout) (\s :: HttpRetryPolicy
s@HttpRetryPolicy' {} Duration
a -> HttpRetryPolicy
s {$sel:perRetryTimeout:HttpRetryPolicy' :: Duration
perRetryTimeout = Duration
a} :: HttpRetryPolicy)
instance Core.FromJSON HttpRetryPolicy where
parseJSON :: Value -> Parser HttpRetryPolicy
parseJSON =
String
-> (Object -> Parser HttpRetryPolicy)
-> Value
-> Parser HttpRetryPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"HttpRetryPolicy"
( \Object
x ->
Maybe (NonEmpty Text)
-> Maybe (NonEmpty TcpRetryPolicyEvent)
-> Natural
-> Duration
-> HttpRetryPolicy
HttpRetryPolicy'
(Maybe (NonEmpty Text)
-> Maybe (NonEmpty TcpRetryPolicyEvent)
-> Natural
-> Duration
-> HttpRetryPolicy)
-> Parser (Maybe (NonEmpty Text))
-> Parser
(Maybe (NonEmpty TcpRetryPolicyEvent)
-> Natural -> Duration -> HttpRetryPolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"httpRetryEvents")
Parser
(Maybe (NonEmpty TcpRetryPolicyEvent)
-> Natural -> Duration -> HttpRetryPolicy)
-> Parser (Maybe (NonEmpty TcpRetryPolicyEvent))
-> Parser (Natural -> Duration -> HttpRetryPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty TcpRetryPolicyEvent))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tcpRetryEvents")
Parser (Natural -> Duration -> HttpRetryPolicy)
-> Parser Natural -> Parser (Duration -> HttpRetryPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"maxRetries")
Parser (Duration -> HttpRetryPolicy)
-> Parser Duration -> Parser HttpRetryPolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Duration
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"perRetryTimeout")
)
instance Prelude.Hashable HttpRetryPolicy
instance Prelude.NFData HttpRetryPolicy
instance Core.ToJSON HttpRetryPolicy where
toJSON :: HttpRetryPolicy -> Value
toJSON HttpRetryPolicy' {Natural
Maybe (NonEmpty Text)
Maybe (NonEmpty TcpRetryPolicyEvent)
Duration
perRetryTimeout :: Duration
maxRetries :: Natural
tcpRetryEvents :: Maybe (NonEmpty TcpRetryPolicyEvent)
httpRetryEvents :: Maybe (NonEmpty Text)
$sel:perRetryTimeout:HttpRetryPolicy' :: HttpRetryPolicy -> Duration
$sel:maxRetries:HttpRetryPolicy' :: HttpRetryPolicy -> Natural
$sel:tcpRetryEvents:HttpRetryPolicy' :: HttpRetryPolicy -> Maybe (NonEmpty TcpRetryPolicyEvent)
$sel:httpRetryEvents:HttpRetryPolicy' :: HttpRetryPolicy -> Maybe (NonEmpty Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"httpRetryEvents" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
httpRetryEvents,
(Text
"tcpRetryEvents" Text -> NonEmpty TcpRetryPolicyEvent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(NonEmpty TcpRetryPolicyEvent -> Pair)
-> Maybe (NonEmpty TcpRetryPolicyEvent) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty TcpRetryPolicyEvent)
tcpRetryEvents,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"maxRetries" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maxRetries),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"perRetryTimeout" Text -> Duration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Duration
perRetryTimeout)
]
)