{-# 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.Batch.Types.RetryStrategy where
import Amazonka.Batch.Types.EvaluateOnExit
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data RetryStrategy = RetryStrategy'
{
RetryStrategy -> Maybe [EvaluateOnExit]
evaluateOnExit :: Prelude.Maybe [EvaluateOnExit],
RetryStrategy -> Maybe Int
attempts :: Prelude.Maybe Prelude.Int
}
deriving (RetryStrategy -> RetryStrategy -> Bool
(RetryStrategy -> RetryStrategy -> Bool)
-> (RetryStrategy -> RetryStrategy -> Bool) -> Eq RetryStrategy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetryStrategy -> RetryStrategy -> Bool
$c/= :: RetryStrategy -> RetryStrategy -> Bool
== :: RetryStrategy -> RetryStrategy -> Bool
$c== :: RetryStrategy -> RetryStrategy -> Bool
Prelude.Eq, ReadPrec [RetryStrategy]
ReadPrec RetryStrategy
Int -> ReadS RetryStrategy
ReadS [RetryStrategy]
(Int -> ReadS RetryStrategy)
-> ReadS [RetryStrategy]
-> ReadPrec RetryStrategy
-> ReadPrec [RetryStrategy]
-> Read RetryStrategy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetryStrategy]
$creadListPrec :: ReadPrec [RetryStrategy]
readPrec :: ReadPrec RetryStrategy
$creadPrec :: ReadPrec RetryStrategy
readList :: ReadS [RetryStrategy]
$creadList :: ReadS [RetryStrategy]
readsPrec :: Int -> ReadS RetryStrategy
$creadsPrec :: Int -> ReadS RetryStrategy
Prelude.Read, Int -> RetryStrategy -> ShowS
[RetryStrategy] -> ShowS
RetryStrategy -> String
(Int -> RetryStrategy -> ShowS)
-> (RetryStrategy -> String)
-> ([RetryStrategy] -> ShowS)
-> Show RetryStrategy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetryStrategy] -> ShowS
$cshowList :: [RetryStrategy] -> ShowS
show :: RetryStrategy -> String
$cshow :: RetryStrategy -> String
showsPrec :: Int -> RetryStrategy -> ShowS
$cshowsPrec :: Int -> RetryStrategy -> ShowS
Prelude.Show, (forall x. RetryStrategy -> Rep RetryStrategy x)
-> (forall x. Rep RetryStrategy x -> RetryStrategy)
-> Generic RetryStrategy
forall x. Rep RetryStrategy x -> RetryStrategy
forall x. RetryStrategy -> Rep RetryStrategy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetryStrategy x -> RetryStrategy
$cfrom :: forall x. RetryStrategy -> Rep RetryStrategy x
Prelude.Generic)
newRetryStrategy ::
RetryStrategy
newRetryStrategy :: RetryStrategy
newRetryStrategy =
RetryStrategy' :: Maybe [EvaluateOnExit] -> Maybe Int -> RetryStrategy
RetryStrategy'
{ $sel:evaluateOnExit:RetryStrategy' :: Maybe [EvaluateOnExit]
evaluateOnExit = Maybe [EvaluateOnExit]
forall a. Maybe a
Prelude.Nothing,
$sel:attempts:RetryStrategy' :: Maybe Int
attempts = Maybe Int
forall a. Maybe a
Prelude.Nothing
}
retryStrategy_evaluateOnExit :: Lens.Lens' RetryStrategy (Prelude.Maybe [EvaluateOnExit])
retryStrategy_evaluateOnExit :: (Maybe [EvaluateOnExit] -> f (Maybe [EvaluateOnExit]))
-> RetryStrategy -> f RetryStrategy
retryStrategy_evaluateOnExit = (RetryStrategy -> Maybe [EvaluateOnExit])
-> (RetryStrategy -> Maybe [EvaluateOnExit] -> RetryStrategy)
-> Lens
RetryStrategy
RetryStrategy
(Maybe [EvaluateOnExit])
(Maybe [EvaluateOnExit])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryStrategy' {Maybe [EvaluateOnExit]
evaluateOnExit :: Maybe [EvaluateOnExit]
$sel:evaluateOnExit:RetryStrategy' :: RetryStrategy -> Maybe [EvaluateOnExit]
evaluateOnExit} -> Maybe [EvaluateOnExit]
evaluateOnExit) (\s :: RetryStrategy
s@RetryStrategy' {} Maybe [EvaluateOnExit]
a -> RetryStrategy
s {$sel:evaluateOnExit:RetryStrategy' :: Maybe [EvaluateOnExit]
evaluateOnExit = Maybe [EvaluateOnExit]
a} :: RetryStrategy) ((Maybe [EvaluateOnExit] -> f (Maybe [EvaluateOnExit]))
-> RetryStrategy -> f RetryStrategy)
-> ((Maybe [EvaluateOnExit] -> f (Maybe [EvaluateOnExit]))
-> Maybe [EvaluateOnExit] -> f (Maybe [EvaluateOnExit]))
-> (Maybe [EvaluateOnExit] -> f (Maybe [EvaluateOnExit]))
-> RetryStrategy
-> f RetryStrategy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[EvaluateOnExit] [EvaluateOnExit] [EvaluateOnExit] [EvaluateOnExit]
-> Iso
(Maybe [EvaluateOnExit])
(Maybe [EvaluateOnExit])
(Maybe [EvaluateOnExit])
(Maybe [EvaluateOnExit])
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
[EvaluateOnExit] [EvaluateOnExit] [EvaluateOnExit] [EvaluateOnExit]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
retryStrategy_attempts :: Lens.Lens' RetryStrategy (Prelude.Maybe Prelude.Int)
retryStrategy_attempts :: (Maybe Int -> f (Maybe Int)) -> RetryStrategy -> f RetryStrategy
retryStrategy_attempts = (RetryStrategy -> Maybe Int)
-> (RetryStrategy -> Maybe Int -> RetryStrategy)
-> Lens RetryStrategy RetryStrategy (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetryStrategy' {Maybe Int
attempts :: Maybe Int
$sel:attempts:RetryStrategy' :: RetryStrategy -> Maybe Int
attempts} -> Maybe Int
attempts) (\s :: RetryStrategy
s@RetryStrategy' {} Maybe Int
a -> RetryStrategy
s {$sel:attempts:RetryStrategy' :: Maybe Int
attempts = Maybe Int
a} :: RetryStrategy)
instance Core.FromJSON RetryStrategy where
parseJSON :: Value -> Parser RetryStrategy
parseJSON =
String
-> (Object -> Parser RetryStrategy)
-> Value
-> Parser RetryStrategy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RetryStrategy"
( \Object
x ->
Maybe [EvaluateOnExit] -> Maybe Int -> RetryStrategy
RetryStrategy'
(Maybe [EvaluateOnExit] -> Maybe Int -> RetryStrategy)
-> Parser (Maybe [EvaluateOnExit])
-> Parser (Maybe Int -> RetryStrategy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [EvaluateOnExit]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"evaluateOnExit" Parser (Maybe (Maybe [EvaluateOnExit]))
-> Maybe [EvaluateOnExit] -> Parser (Maybe [EvaluateOnExit])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [EvaluateOnExit]
forall a. Monoid a => a
Prelude.mempty)
Parser (Maybe Int -> RetryStrategy)
-> Parser (Maybe Int) -> Parser RetryStrategy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attempts")
)
instance Prelude.Hashable RetryStrategy
instance Prelude.NFData RetryStrategy
instance Core.ToJSON RetryStrategy where
toJSON :: RetryStrategy -> Value
toJSON RetryStrategy' {Maybe Int
Maybe [EvaluateOnExit]
attempts :: Maybe Int
evaluateOnExit :: Maybe [EvaluateOnExit]
$sel:attempts:RetryStrategy' :: RetryStrategy -> Maybe Int
$sel:evaluateOnExit:RetryStrategy' :: RetryStrategy -> Maybe [EvaluateOnExit]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"evaluateOnExit" Text -> [EvaluateOnExit] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([EvaluateOnExit] -> Pair) -> Maybe [EvaluateOnExit] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [EvaluateOnExit]
evaluateOnExit,
(Text
"attempts" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
attempts
]
)