{-# 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.FraudDetector.Types.Rule where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Rule = Rule'
{
Rule -> Text
detectorId :: Prelude.Text,
Rule -> Text
ruleId :: Prelude.Text,
Rule -> Text
ruleVersion :: Prelude.Text
}
deriving (Rule -> Rule -> Bool
(Rule -> Rule -> Bool) -> (Rule -> Rule -> Bool) -> Eq Rule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rule -> Rule -> Bool
$c/= :: Rule -> Rule -> Bool
== :: Rule -> Rule -> Bool
$c== :: Rule -> Rule -> Bool
Prelude.Eq, ReadPrec [Rule]
ReadPrec Rule
Int -> ReadS Rule
ReadS [Rule]
(Int -> ReadS Rule)
-> ReadS [Rule] -> ReadPrec Rule -> ReadPrec [Rule] -> Read Rule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rule]
$creadListPrec :: ReadPrec [Rule]
readPrec :: ReadPrec Rule
$creadPrec :: ReadPrec Rule
readList :: ReadS [Rule]
$creadList :: ReadS [Rule]
readsPrec :: Int -> ReadS Rule
$creadsPrec :: Int -> ReadS Rule
Prelude.Read, Int -> Rule -> ShowS
[Rule] -> ShowS
Rule -> String
(Int -> Rule -> ShowS)
-> (Rule -> String) -> ([Rule] -> ShowS) -> Show Rule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rule] -> ShowS
$cshowList :: [Rule] -> ShowS
show :: Rule -> String
$cshow :: Rule -> String
showsPrec :: Int -> Rule -> ShowS
$cshowsPrec :: Int -> Rule -> ShowS
Prelude.Show, (forall x. Rule -> Rep Rule x)
-> (forall x. Rep Rule x -> Rule) -> Generic Rule
forall x. Rep Rule x -> Rule
forall x. Rule -> Rep Rule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Rule x -> Rule
$cfrom :: forall x. Rule -> Rep Rule x
Prelude.Generic)
newRule ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
Rule
newRule :: Text -> Text -> Text -> Rule
newRule Text
pDetectorId_ Text
pRuleId_ Text
pRuleVersion_ =
Rule' :: Text -> Text -> Text -> Rule
Rule'
{ $sel:detectorId:Rule' :: Text
detectorId = Text
pDetectorId_,
$sel:ruleId:Rule' :: Text
ruleId = Text
pRuleId_,
$sel:ruleVersion:Rule' :: Text
ruleVersion = Text
pRuleVersion_
}
rule_detectorId :: Lens.Lens' Rule Prelude.Text
rule_detectorId :: (Text -> f Text) -> Rule -> f Rule
rule_detectorId = (Rule -> Text)
-> (Rule -> Text -> Rule) -> Lens Rule Rule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Text
detectorId :: Text
$sel:detectorId:Rule' :: Rule -> Text
detectorId} -> Text
detectorId) (\s :: Rule
s@Rule' {} Text
a -> Rule
s {$sel:detectorId:Rule' :: Text
detectorId = Text
a} :: Rule)
rule_ruleId :: Lens.Lens' Rule Prelude.Text
rule_ruleId :: (Text -> f Text) -> Rule -> f Rule
rule_ruleId = (Rule -> Text)
-> (Rule -> Text -> Rule) -> Lens Rule Rule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Text
ruleId :: Text
$sel:ruleId:Rule' :: Rule -> Text
ruleId} -> Text
ruleId) (\s :: Rule
s@Rule' {} Text
a -> Rule
s {$sel:ruleId:Rule' :: Text
ruleId = Text
a} :: Rule)
rule_ruleVersion :: Lens.Lens' Rule Prelude.Text
rule_ruleVersion :: (Text -> f Text) -> Rule -> f Rule
rule_ruleVersion = (Rule -> Text)
-> (Rule -> Text -> Rule) -> Lens Rule Rule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Text
ruleVersion :: Text
$sel:ruleVersion:Rule' :: Rule -> Text
ruleVersion} -> Text
ruleVersion) (\s :: Rule
s@Rule' {} Text
a -> Rule
s {$sel:ruleVersion:Rule' :: Text
ruleVersion = Text
a} :: Rule)
instance Core.FromJSON Rule where
parseJSON :: Value -> Parser Rule
parseJSON =
String -> (Object -> Parser Rule) -> Value -> Parser Rule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Rule"
( \Object
x ->
Text -> Text -> Text -> Rule
Rule'
(Text -> Text -> Text -> Rule)
-> Parser Text -> Parser (Text -> Text -> Rule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"detectorId")
Parser (Text -> Text -> Rule)
-> Parser Text -> Parser (Text -> Rule)
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
"ruleId")
Parser (Text -> Rule) -> Parser Text -> Parser Rule
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
"ruleVersion")
)
instance Prelude.Hashable Rule
instance Prelude.NFData Rule
instance Core.ToJSON Rule where
toJSON :: Rule -> Value
toJSON Rule' {Text
ruleVersion :: Text
ruleId :: Text
detectorId :: Text
$sel:ruleVersion:Rule' :: Rule -> Text
$sel:ruleId:Rule' :: Rule -> Text
$sel:detectorId:Rule' :: Rule -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"detectorId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
detectorId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ruleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ruleId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ruleVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ruleVersion)
]
)