{-# 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.IoTEvents.Types.DetectorModelDefinition where
import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.State
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data DetectorModelDefinition = DetectorModelDefinition'
{
DetectorModelDefinition -> NonEmpty State
states :: Prelude.NonEmpty State,
DetectorModelDefinition -> Text
initialStateName :: Prelude.Text
}
deriving (DetectorModelDefinition -> DetectorModelDefinition -> Bool
(DetectorModelDefinition -> DetectorModelDefinition -> Bool)
-> (DetectorModelDefinition -> DetectorModelDefinition -> Bool)
-> Eq DetectorModelDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectorModelDefinition -> DetectorModelDefinition -> Bool
$c/= :: DetectorModelDefinition -> DetectorModelDefinition -> Bool
== :: DetectorModelDefinition -> DetectorModelDefinition -> Bool
$c== :: DetectorModelDefinition -> DetectorModelDefinition -> Bool
Prelude.Eq, ReadPrec [DetectorModelDefinition]
ReadPrec DetectorModelDefinition
Int -> ReadS DetectorModelDefinition
ReadS [DetectorModelDefinition]
(Int -> ReadS DetectorModelDefinition)
-> ReadS [DetectorModelDefinition]
-> ReadPrec DetectorModelDefinition
-> ReadPrec [DetectorModelDefinition]
-> Read DetectorModelDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectorModelDefinition]
$creadListPrec :: ReadPrec [DetectorModelDefinition]
readPrec :: ReadPrec DetectorModelDefinition
$creadPrec :: ReadPrec DetectorModelDefinition
readList :: ReadS [DetectorModelDefinition]
$creadList :: ReadS [DetectorModelDefinition]
readsPrec :: Int -> ReadS DetectorModelDefinition
$creadsPrec :: Int -> ReadS DetectorModelDefinition
Prelude.Read, Int -> DetectorModelDefinition -> ShowS
[DetectorModelDefinition] -> ShowS
DetectorModelDefinition -> String
(Int -> DetectorModelDefinition -> ShowS)
-> (DetectorModelDefinition -> String)
-> ([DetectorModelDefinition] -> ShowS)
-> Show DetectorModelDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectorModelDefinition] -> ShowS
$cshowList :: [DetectorModelDefinition] -> ShowS
show :: DetectorModelDefinition -> String
$cshow :: DetectorModelDefinition -> String
showsPrec :: Int -> DetectorModelDefinition -> ShowS
$cshowsPrec :: Int -> DetectorModelDefinition -> ShowS
Prelude.Show, (forall x.
DetectorModelDefinition -> Rep DetectorModelDefinition x)
-> (forall x.
Rep DetectorModelDefinition x -> DetectorModelDefinition)
-> Generic DetectorModelDefinition
forall x. Rep DetectorModelDefinition x -> DetectorModelDefinition
forall x. DetectorModelDefinition -> Rep DetectorModelDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectorModelDefinition x -> DetectorModelDefinition
$cfrom :: forall x. DetectorModelDefinition -> Rep DetectorModelDefinition x
Prelude.Generic)
newDetectorModelDefinition ::
Prelude.NonEmpty State ->
Prelude.Text ->
DetectorModelDefinition
newDetectorModelDefinition :: NonEmpty State -> Text -> DetectorModelDefinition
newDetectorModelDefinition
NonEmpty State
pStates_
Text
pInitialStateName_ =
DetectorModelDefinition' :: NonEmpty State -> Text -> DetectorModelDefinition
DetectorModelDefinition'
{ $sel:states:DetectorModelDefinition' :: NonEmpty State
states =
Tagged (NonEmpty State) (Identity (NonEmpty State))
-> Tagged (NonEmpty State) (Identity (NonEmpty State))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty State) (Identity (NonEmpty State))
-> Tagged (NonEmpty State) (Identity (NonEmpty State)))
-> NonEmpty State -> NonEmpty State
forall t b. AReview t b -> b -> t
Lens.# NonEmpty State
pStates_,
$sel:initialStateName:DetectorModelDefinition' :: Text
initialStateName = Text
pInitialStateName_
}
detectorModelDefinition_states :: Lens.Lens' DetectorModelDefinition (Prelude.NonEmpty State)
detectorModelDefinition_states :: (NonEmpty State -> f (NonEmpty State))
-> DetectorModelDefinition -> f DetectorModelDefinition
detectorModelDefinition_states = (DetectorModelDefinition -> NonEmpty State)
-> (DetectorModelDefinition
-> NonEmpty State -> DetectorModelDefinition)
-> Lens
DetectorModelDefinition
DetectorModelDefinition
(NonEmpty State)
(NonEmpty State)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectorModelDefinition' {NonEmpty State
states :: NonEmpty State
$sel:states:DetectorModelDefinition' :: DetectorModelDefinition -> NonEmpty State
states} -> NonEmpty State
states) (\s :: DetectorModelDefinition
s@DetectorModelDefinition' {} NonEmpty State
a -> DetectorModelDefinition
s {$sel:states:DetectorModelDefinition' :: NonEmpty State
states = NonEmpty State
a} :: DetectorModelDefinition) ((NonEmpty State -> f (NonEmpty State))
-> DetectorModelDefinition -> f DetectorModelDefinition)
-> ((NonEmpty State -> f (NonEmpty State))
-> NonEmpty State -> f (NonEmpty State))
-> (NonEmpty State -> f (NonEmpty State))
-> DetectorModelDefinition
-> f DetectorModelDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty State -> f (NonEmpty State))
-> NonEmpty State -> f (NonEmpty State)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detectorModelDefinition_initialStateName :: Lens.Lens' DetectorModelDefinition Prelude.Text
detectorModelDefinition_initialStateName :: (Text -> f Text)
-> DetectorModelDefinition -> f DetectorModelDefinition
detectorModelDefinition_initialStateName = (DetectorModelDefinition -> Text)
-> (DetectorModelDefinition -> Text -> DetectorModelDefinition)
-> Lens DetectorModelDefinition DetectorModelDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectorModelDefinition' {Text
initialStateName :: Text
$sel:initialStateName:DetectorModelDefinition' :: DetectorModelDefinition -> Text
initialStateName} -> Text
initialStateName) (\s :: DetectorModelDefinition
s@DetectorModelDefinition' {} Text
a -> DetectorModelDefinition
s {$sel:initialStateName:DetectorModelDefinition' :: Text
initialStateName = Text
a} :: DetectorModelDefinition)
instance Core.FromJSON DetectorModelDefinition where
parseJSON :: Value -> Parser DetectorModelDefinition
parseJSON =
String
-> (Object -> Parser DetectorModelDefinition)
-> Value
-> Parser DetectorModelDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"DetectorModelDefinition"
( \Object
x ->
NonEmpty State -> Text -> DetectorModelDefinition
DetectorModelDefinition'
(NonEmpty State -> Text -> DetectorModelDefinition)
-> Parser (NonEmpty State)
-> Parser (Text -> DetectorModelDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (NonEmpty State)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"states")
Parser (Text -> DetectorModelDefinition)
-> Parser Text -> Parser DetectorModelDefinition
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
"initialStateName")
)
instance Prelude.Hashable DetectorModelDefinition
instance Prelude.NFData DetectorModelDefinition
instance Core.ToJSON DetectorModelDefinition where
toJSON :: DetectorModelDefinition -> Value
toJSON DetectorModelDefinition' {NonEmpty State
Text
initialStateName :: Text
states :: NonEmpty State
$sel:initialStateName:DetectorModelDefinition' :: DetectorModelDefinition -> Text
$sel:states:DetectorModelDefinition' :: DetectorModelDefinition -> NonEmpty State
..} =
[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
"states" Text -> NonEmpty State -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty State
states),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"initialStateName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
initialStateName)
]
)