{-# 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTEvents.Types.State
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
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]
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
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. 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'
{ $sel:states:DetectorModelDefinition' :: NonEmpty State
states =
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced 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 :: Lens' DetectorModelDefinition (NonEmpty State)
detectorModelDefinition_states = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: Lens' DetectorModelDefinition Text
detectorModelDefinition_initialStateName = 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 Data.FromJSON DetectorModelDefinition where
parseJSON :: Value -> Parser DetectorModelDefinition
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"DetectorModelDefinition"
( \Object
x ->
NonEmpty State -> Text -> DetectorModelDefinition
DetectorModelDefinition'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"states")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"initialStateName")
)
instance Prelude.Hashable DetectorModelDefinition where
hashWithSalt :: Int -> DetectorModelDefinition -> Int
hashWithSalt Int
_salt DetectorModelDefinition' {NonEmpty State
Text
initialStateName :: Text
states :: NonEmpty State
$sel:initialStateName:DetectorModelDefinition' :: DetectorModelDefinition -> Text
$sel:states:DetectorModelDefinition' :: DetectorModelDefinition -> NonEmpty State
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty State
states
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
initialStateName
instance Prelude.NFData DetectorModelDefinition where
rnf :: DetectorModelDefinition -> ()
rnf DetectorModelDefinition' {NonEmpty State
Text
initialStateName :: Text
states :: NonEmpty State
$sel:initialStateName:DetectorModelDefinition' :: DetectorModelDefinition -> Text
$sel:states:DetectorModelDefinition' :: DetectorModelDefinition -> NonEmpty State
..} =
forall a. NFData a => a -> ()
Prelude.rnf NonEmpty State
states
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
initialStateName
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"states" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty State
states),
forall a. a -> Maybe a
Prelude.Just
(Key
"initialStateName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
initialStateName)
]
)