{-# 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.IoTSiteWise.Types.ExpressionVariable where
import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.VariableValue
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data ExpressionVariable = ExpressionVariable'
{
ExpressionVariable -> Text
name :: Prelude.Text,
ExpressionVariable -> VariableValue
value :: VariableValue
}
deriving (ExpressionVariable -> ExpressionVariable -> Bool
(ExpressionVariable -> ExpressionVariable -> Bool)
-> (ExpressionVariable -> ExpressionVariable -> Bool)
-> Eq ExpressionVariable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExpressionVariable -> ExpressionVariable -> Bool
$c/= :: ExpressionVariable -> ExpressionVariable -> Bool
== :: ExpressionVariable -> ExpressionVariable -> Bool
$c== :: ExpressionVariable -> ExpressionVariable -> Bool
Prelude.Eq, ReadPrec [ExpressionVariable]
ReadPrec ExpressionVariable
Int -> ReadS ExpressionVariable
ReadS [ExpressionVariable]
(Int -> ReadS ExpressionVariable)
-> ReadS [ExpressionVariable]
-> ReadPrec ExpressionVariable
-> ReadPrec [ExpressionVariable]
-> Read ExpressionVariable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExpressionVariable]
$creadListPrec :: ReadPrec [ExpressionVariable]
readPrec :: ReadPrec ExpressionVariable
$creadPrec :: ReadPrec ExpressionVariable
readList :: ReadS [ExpressionVariable]
$creadList :: ReadS [ExpressionVariable]
readsPrec :: Int -> ReadS ExpressionVariable
$creadsPrec :: Int -> ReadS ExpressionVariable
Prelude.Read, Int -> ExpressionVariable -> ShowS
[ExpressionVariable] -> ShowS
ExpressionVariable -> String
(Int -> ExpressionVariable -> ShowS)
-> (ExpressionVariable -> String)
-> ([ExpressionVariable] -> ShowS)
-> Show ExpressionVariable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExpressionVariable] -> ShowS
$cshowList :: [ExpressionVariable] -> ShowS
show :: ExpressionVariable -> String
$cshow :: ExpressionVariable -> String
showsPrec :: Int -> ExpressionVariable -> ShowS
$cshowsPrec :: Int -> ExpressionVariable -> ShowS
Prelude.Show, (forall x. ExpressionVariable -> Rep ExpressionVariable x)
-> (forall x. Rep ExpressionVariable x -> ExpressionVariable)
-> Generic ExpressionVariable
forall x. Rep ExpressionVariable x -> ExpressionVariable
forall x. ExpressionVariable -> Rep ExpressionVariable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExpressionVariable x -> ExpressionVariable
$cfrom :: forall x. ExpressionVariable -> Rep ExpressionVariable x
Prelude.Generic)
newExpressionVariable ::
Prelude.Text ->
VariableValue ->
ExpressionVariable
newExpressionVariable :: Text -> VariableValue -> ExpressionVariable
newExpressionVariable Text
pName_ VariableValue
pValue_ =
ExpressionVariable' :: Text -> VariableValue -> ExpressionVariable
ExpressionVariable' {$sel:name:ExpressionVariable' :: Text
name = Text
pName_, $sel:value:ExpressionVariable' :: VariableValue
value = VariableValue
pValue_}
expressionVariable_name :: Lens.Lens' ExpressionVariable Prelude.Text
expressionVariable_name :: (Text -> f Text) -> ExpressionVariable -> f ExpressionVariable
expressionVariable_name = (ExpressionVariable -> Text)
-> (ExpressionVariable -> Text -> ExpressionVariable)
-> Lens ExpressionVariable ExpressionVariable Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExpressionVariable' {Text
name :: Text
$sel:name:ExpressionVariable' :: ExpressionVariable -> Text
name} -> Text
name) (\s :: ExpressionVariable
s@ExpressionVariable' {} Text
a -> ExpressionVariable
s {$sel:name:ExpressionVariable' :: Text
name = Text
a} :: ExpressionVariable)
expressionVariable_value :: Lens.Lens' ExpressionVariable VariableValue
expressionVariable_value :: (VariableValue -> f VariableValue)
-> ExpressionVariable -> f ExpressionVariable
expressionVariable_value = (ExpressionVariable -> VariableValue)
-> (ExpressionVariable -> VariableValue -> ExpressionVariable)
-> Lens
ExpressionVariable ExpressionVariable VariableValue VariableValue
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExpressionVariable' {VariableValue
value :: VariableValue
$sel:value:ExpressionVariable' :: ExpressionVariable -> VariableValue
value} -> VariableValue
value) (\s :: ExpressionVariable
s@ExpressionVariable' {} VariableValue
a -> ExpressionVariable
s {$sel:value:ExpressionVariable' :: VariableValue
value = VariableValue
a} :: ExpressionVariable)
instance Core.FromJSON ExpressionVariable where
parseJSON :: Value -> Parser ExpressionVariable
parseJSON =
String
-> (Object -> Parser ExpressionVariable)
-> Value
-> Parser ExpressionVariable
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"ExpressionVariable"
( \Object
x ->
Text -> VariableValue -> ExpressionVariable
ExpressionVariable'
(Text -> VariableValue -> ExpressionVariable)
-> Parser Text -> Parser (VariableValue -> ExpressionVariable)
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
"name") Parser (VariableValue -> ExpressionVariable)
-> Parser VariableValue -> Parser ExpressionVariable
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser VariableValue
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"value")
)
instance Prelude.Hashable ExpressionVariable
instance Prelude.NFData ExpressionVariable
instance Core.ToJSON ExpressionVariable where
toJSON :: ExpressionVariable -> Value
toJSON ExpressionVariable' {Text
VariableValue
value :: VariableValue
name :: Text
$sel:value:ExpressionVariable' :: ExpressionVariable -> VariableValue
$sel:name:ExpressionVariable' :: ExpressionVariable -> 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
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"value" Text -> VariableValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= VariableValue
value)
]
)