{-# 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.Amplify.Types.CustomRule where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data CustomRule = CustomRule'
{
CustomRule -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
CustomRule -> Maybe Text
condition :: Prelude.Maybe Prelude.Text,
CustomRule -> Text
source :: Prelude.Text,
CustomRule -> Text
target :: Prelude.Text
}
deriving (CustomRule -> CustomRule -> Bool
(CustomRule -> CustomRule -> Bool)
-> (CustomRule -> CustomRule -> Bool) -> Eq CustomRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomRule -> CustomRule -> Bool
$c/= :: CustomRule -> CustomRule -> Bool
== :: CustomRule -> CustomRule -> Bool
$c== :: CustomRule -> CustomRule -> Bool
Prelude.Eq, ReadPrec [CustomRule]
ReadPrec CustomRule
Int -> ReadS CustomRule
ReadS [CustomRule]
(Int -> ReadS CustomRule)
-> ReadS [CustomRule]
-> ReadPrec CustomRule
-> ReadPrec [CustomRule]
-> Read CustomRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomRule]
$creadListPrec :: ReadPrec [CustomRule]
readPrec :: ReadPrec CustomRule
$creadPrec :: ReadPrec CustomRule
readList :: ReadS [CustomRule]
$creadList :: ReadS [CustomRule]
readsPrec :: Int -> ReadS CustomRule
$creadsPrec :: Int -> ReadS CustomRule
Prelude.Read, Int -> CustomRule -> ShowS
[CustomRule] -> ShowS
CustomRule -> String
(Int -> CustomRule -> ShowS)
-> (CustomRule -> String)
-> ([CustomRule] -> ShowS)
-> Show CustomRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomRule] -> ShowS
$cshowList :: [CustomRule] -> ShowS
show :: CustomRule -> String
$cshow :: CustomRule -> String
showsPrec :: Int -> CustomRule -> ShowS
$cshowsPrec :: Int -> CustomRule -> ShowS
Prelude.Show, (forall x. CustomRule -> Rep CustomRule x)
-> (forall x. Rep CustomRule x -> CustomRule) -> Generic CustomRule
forall x. Rep CustomRule x -> CustomRule
forall x. CustomRule -> Rep CustomRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomRule x -> CustomRule
$cfrom :: forall x. CustomRule -> Rep CustomRule x
Prelude.Generic)
newCustomRule ::
Prelude.Text ->
Prelude.Text ->
CustomRule
newCustomRule :: Text -> Text -> CustomRule
newCustomRule Text
pSource_ Text
pTarget_ =
CustomRule' :: Maybe Text -> Maybe Text -> Text -> Text -> CustomRule
CustomRule'
{ $sel:status:CustomRule' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:condition:CustomRule' :: Maybe Text
condition = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:source:CustomRule' :: Text
source = Text
pSource_,
$sel:target:CustomRule' :: Text
target = Text
pTarget_
}
customRule_status :: Lens.Lens' CustomRule (Prelude.Maybe Prelude.Text)
customRule_status :: (Maybe Text -> f (Maybe Text)) -> CustomRule -> f CustomRule
customRule_status = (CustomRule -> Maybe Text)
-> (CustomRule -> Maybe Text -> CustomRule)
-> Lens CustomRule CustomRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRule' {Maybe Text
status :: Maybe Text
$sel:status:CustomRule' :: CustomRule -> Maybe Text
status} -> Maybe Text
status) (\s :: CustomRule
s@CustomRule' {} Maybe Text
a -> CustomRule
s {$sel:status:CustomRule' :: Maybe Text
status = Maybe Text
a} :: CustomRule)
customRule_condition :: Lens.Lens' CustomRule (Prelude.Maybe Prelude.Text)
customRule_condition :: (Maybe Text -> f (Maybe Text)) -> CustomRule -> f CustomRule
customRule_condition = (CustomRule -> Maybe Text)
-> (CustomRule -> Maybe Text -> CustomRule)
-> Lens CustomRule CustomRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRule' {Maybe Text
condition :: Maybe Text
$sel:condition:CustomRule' :: CustomRule -> Maybe Text
condition} -> Maybe Text
condition) (\s :: CustomRule
s@CustomRule' {} Maybe Text
a -> CustomRule
s {$sel:condition:CustomRule' :: Maybe Text
condition = Maybe Text
a} :: CustomRule)
customRule_source :: Lens.Lens' CustomRule Prelude.Text
customRule_source :: (Text -> f Text) -> CustomRule -> f CustomRule
customRule_source = (CustomRule -> Text)
-> (CustomRule -> Text -> CustomRule)
-> Lens CustomRule CustomRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRule' {Text
source :: Text
$sel:source:CustomRule' :: CustomRule -> Text
source} -> Text
source) (\s :: CustomRule
s@CustomRule' {} Text
a -> CustomRule
s {$sel:source:CustomRule' :: Text
source = Text
a} :: CustomRule)
customRule_target :: Lens.Lens' CustomRule Prelude.Text
customRule_target :: (Text -> f Text) -> CustomRule -> f CustomRule
customRule_target = (CustomRule -> Text)
-> (CustomRule -> Text -> CustomRule)
-> Lens CustomRule CustomRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRule' {Text
target :: Text
$sel:target:CustomRule' :: CustomRule -> Text
target} -> Text
target) (\s :: CustomRule
s@CustomRule' {} Text
a -> CustomRule
s {$sel:target:CustomRule' :: Text
target = Text
a} :: CustomRule)
instance Core.FromJSON CustomRule where
parseJSON :: Value -> Parser CustomRule
parseJSON =
String
-> (Object -> Parser CustomRule) -> Value -> Parser CustomRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"CustomRule"
( \Object
x ->
Maybe Text -> Maybe Text -> Text -> Text -> CustomRule
CustomRule'
(Maybe Text -> Maybe Text -> Text -> Text -> CustomRule)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> Text -> CustomRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
Parser (Maybe Text -> Text -> Text -> CustomRule)
-> Parser (Maybe Text) -> Parser (Text -> Text -> CustomRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"condition")
Parser (Text -> Text -> CustomRule)
-> Parser Text -> Parser (Text -> CustomRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"source")
Parser (Text -> CustomRule) -> Parser Text -> Parser CustomRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"target")
)
instance Prelude.Hashable CustomRule
instance Prelude.NFData CustomRule
instance Core.ToJSON CustomRule where
toJSON :: CustomRule -> Value
toJSON CustomRule' {Maybe Text
Text
target :: Text
source :: Text
condition :: Maybe Text
status :: Maybe Text
$sel:target:CustomRule' :: CustomRule -> Text
$sel:source:CustomRule' :: CustomRule -> Text
$sel:condition:CustomRule' :: CustomRule -> Maybe Text
$sel:status:CustomRule' :: CustomRule -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"status" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
status,
(Text
"condition" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
condition,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"source" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
source),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"target" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
target)
]
)