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