{-# 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.CloudWatchEvents.Types.RetryPolicy where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data RetryPolicy = RetryPolicy'
{
RetryPolicy -> Maybe Natural
maximumEventAgeInSeconds :: Prelude.Maybe Prelude.Natural,
RetryPolicy -> Maybe Natural
maximumRetryAttempts :: Prelude.Maybe Prelude.Natural
}
deriving (RetryPolicy -> RetryPolicy -> Bool
(RetryPolicy -> RetryPolicy -> Bool)
-> (RetryPolicy -> RetryPolicy -> Bool) -> Eq RetryPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetryPolicy -> RetryPolicy -> Bool
$c/= :: RetryPolicy -> RetryPolicy -> Bool
== :: RetryPolicy -> RetryPolicy -> Bool
$c== :: RetryPolicy -> RetryPolicy -> Bool
Prelude.Eq, ReadPrec [RetryPolicy]
ReadPrec RetryPolicy
Int -> ReadS RetryPolicy
ReadS [RetryPolicy]
(Int -> ReadS RetryPolicy)
-> ReadS [RetryPolicy]
-> ReadPrec RetryPolicy
-> ReadPrec [RetryPolicy]
-> Read RetryPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetryPolicy]
$creadListPrec :: ReadPrec [RetryPolicy]
readPrec :: ReadPrec RetryPolicy
$creadPrec :: ReadPrec RetryPolicy
readList :: ReadS [RetryPolicy]
$creadList :: ReadS [RetryPolicy]
readsPrec :: Int -> ReadS RetryPolicy
$creadsPrec :: Int -> ReadS RetryPolicy
Prelude.Read, Int -> RetryPolicy -> ShowS
[RetryPolicy] -> ShowS
RetryPolicy -> String
(Int -> RetryPolicy -> ShowS)
-> (RetryPolicy -> String)
-> ([RetryPolicy] -> ShowS)
-> Show RetryPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetryPolicy] -> ShowS
$cshowList :: [RetryPolicy] -> ShowS
show :: RetryPolicy -> String
$cshow :: RetryPolicy -> String
showsPrec :: Int -> RetryPolicy -> ShowS
$cshowsPrec :: Int -> RetryPolicy -> ShowS
Prelude.Show, (forall x. RetryPolicy -> Rep RetryPolicy x)
-> (forall x. Rep RetryPolicy x -> RetryPolicy)
-> Generic RetryPolicy
forall x. Rep RetryPolicy x -> RetryPolicy
forall x. RetryPolicy -> Rep RetryPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetryPolicy x -> RetryPolicy
$cfrom :: forall x. RetryPolicy -> Rep RetryPolicy x
Prelude.Generic)
newRetryPolicy ::
RetryPolicy
newRetryPolicy :: RetryPolicy
newRetryPolicy =
RetryPolicy' :: Maybe Natural -> Maybe Natural -> RetryPolicy
RetryPolicy'
{ $sel:maximumEventAgeInSeconds:RetryPolicy' :: Maybe Natural
maximumEventAgeInSeconds =
Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:maximumRetryAttempts:RetryPolicy' :: Maybe Natural
maximumRetryAttempts = Maybe Natural
forall a. Maybe a
Prelude.Nothing
}
retryPolicy_maximumEventAgeInSeconds :: Lens.Lens' RetryPolicy (Prelude.Maybe Prelude.Natural)
retryPolicy_maximumEventAgeInSeconds :: (Maybe Natural -> f (Maybe Natural))
-> RetryPolicy -> f RetryPolicy
retryPolicy_maximumEventAgeInSeconds = (RetryPolicy -> Maybe Natural)
-> (RetryPolicy -> Maybe Natural -> RetryPolicy)
-> Lens RetryPolicy RetryPolicy (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryPolicy' {Maybe Natural
maximumEventAgeInSeconds :: Maybe Natural
$sel:maximumEventAgeInSeconds:RetryPolicy' :: RetryPolicy -> Maybe Natural
maximumEventAgeInSeconds} -> Maybe Natural
maximumEventAgeInSeconds) (\s :: RetryPolicy
s@RetryPolicy' {} Maybe Natural
a -> RetryPolicy
s {$sel:maximumEventAgeInSeconds:RetryPolicy' :: Maybe Natural
maximumEventAgeInSeconds = Maybe Natural
a} :: RetryPolicy)
retryPolicy_maximumRetryAttempts :: Lens.Lens' RetryPolicy (Prelude.Maybe Prelude.Natural)
retryPolicy_maximumRetryAttempts :: (Maybe Natural -> f (Maybe Natural))
-> RetryPolicy -> f RetryPolicy
retryPolicy_maximumRetryAttempts = (RetryPolicy -> Maybe Natural)
-> (RetryPolicy -> Maybe Natural -> RetryPolicy)
-> Lens RetryPolicy RetryPolicy (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryPolicy' {Maybe Natural
maximumRetryAttempts :: Maybe Natural
$sel:maximumRetryAttempts:RetryPolicy' :: RetryPolicy -> Maybe Natural
maximumRetryAttempts} -> Maybe Natural
maximumRetryAttempts) (\s :: RetryPolicy
s@RetryPolicy' {} Maybe Natural
a -> RetryPolicy
s {$sel:maximumRetryAttempts:RetryPolicy' :: Maybe Natural
maximumRetryAttempts = Maybe Natural
a} :: RetryPolicy)
instance Core.FromJSON RetryPolicy where
parseJSON :: Value -> Parser RetryPolicy
parseJSON =
String
-> (Object -> Parser RetryPolicy) -> Value -> Parser RetryPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RetryPolicy"
( \Object
x ->
Maybe Natural -> Maybe Natural -> RetryPolicy
RetryPolicy'
(Maybe Natural -> Maybe Natural -> RetryPolicy)
-> Parser (Maybe Natural) -> Parser (Maybe Natural -> RetryPolicy)
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
"MaximumEventAgeInSeconds")
Parser (Maybe Natural -> RetryPolicy)
-> Parser (Maybe Natural) -> Parser RetryPolicy
forall (f :: * -> *) a b. Applicative f => 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
"MaximumRetryAttempts")
)
instance Prelude.Hashable RetryPolicy
instance Prelude.NFData RetryPolicy
instance Core.ToJSON RetryPolicy where
toJSON :: RetryPolicy -> Value
toJSON RetryPolicy' {Maybe Natural
maximumRetryAttempts :: Maybe Natural
maximumEventAgeInSeconds :: Maybe Natural
$sel:maximumRetryAttempts:RetryPolicy' :: RetryPolicy -> Maybe Natural
$sel:maximumEventAgeInSeconds:RetryPolicy' :: RetryPolicy -> Maybe Natural
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"MaximumEventAgeInSeconds" 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
maximumEventAgeInSeconds,
(Text
"MaximumRetryAttempts" 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
maximumRetryAttempts
]
)