{-# 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.Transform where
import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.ExpressionVariable
import Amazonka.IoTSiteWise.Types.TransformProcessingConfig
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Transform = Transform'
{
Transform -> Maybe TransformProcessingConfig
processingConfig :: Prelude.Maybe TransformProcessingConfig,
Transform -> Text
expression :: Prelude.Text,
Transform -> [ExpressionVariable]
variables :: [ExpressionVariable]
}
deriving (Transform -> Transform -> Bool
(Transform -> Transform -> Bool)
-> (Transform -> Transform -> Bool) -> Eq Transform
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Transform -> Transform -> Bool
$c/= :: Transform -> Transform -> Bool
== :: Transform -> Transform -> Bool
$c== :: Transform -> Transform -> Bool
Prelude.Eq, ReadPrec [Transform]
ReadPrec Transform
Int -> ReadS Transform
ReadS [Transform]
(Int -> ReadS Transform)
-> ReadS [Transform]
-> ReadPrec Transform
-> ReadPrec [Transform]
-> Read Transform
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Transform]
$creadListPrec :: ReadPrec [Transform]
readPrec :: ReadPrec Transform
$creadPrec :: ReadPrec Transform
readList :: ReadS [Transform]
$creadList :: ReadS [Transform]
readsPrec :: Int -> ReadS Transform
$creadsPrec :: Int -> ReadS Transform
Prelude.Read, Int -> Transform -> ShowS
[Transform] -> ShowS
Transform -> String
(Int -> Transform -> ShowS)
-> (Transform -> String)
-> ([Transform] -> ShowS)
-> Show Transform
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Transform] -> ShowS
$cshowList :: [Transform] -> ShowS
show :: Transform -> String
$cshow :: Transform -> String
showsPrec :: Int -> Transform -> ShowS
$cshowsPrec :: Int -> Transform -> ShowS
Prelude.Show, (forall x. Transform -> Rep Transform x)
-> (forall x. Rep Transform x -> Transform) -> Generic Transform
forall x. Rep Transform x -> Transform
forall x. Transform -> Rep Transform x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Transform x -> Transform
$cfrom :: forall x. Transform -> Rep Transform x
Prelude.Generic)
newTransform ::
Prelude.Text ->
Transform
newTransform :: Text -> Transform
newTransform Text
pExpression_ =
Transform' :: Maybe TransformProcessingConfig
-> Text -> [ExpressionVariable] -> Transform
Transform'
{ $sel:processingConfig:Transform' :: Maybe TransformProcessingConfig
processingConfig = Maybe TransformProcessingConfig
forall a. Maybe a
Prelude.Nothing,
$sel:expression:Transform' :: Text
expression = Text
pExpression_,
$sel:variables:Transform' :: [ExpressionVariable]
variables = [ExpressionVariable]
forall a. Monoid a => a
Prelude.mempty
}
transform_processingConfig :: Lens.Lens' Transform (Prelude.Maybe TransformProcessingConfig)
transform_processingConfig :: (Maybe TransformProcessingConfig
-> f (Maybe TransformProcessingConfig))
-> Transform -> f Transform
transform_processingConfig = (Transform -> Maybe TransformProcessingConfig)
-> (Transform -> Maybe TransformProcessingConfig -> Transform)
-> Lens
Transform
Transform
(Maybe TransformProcessingConfig)
(Maybe TransformProcessingConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Transform' {Maybe TransformProcessingConfig
processingConfig :: Maybe TransformProcessingConfig
$sel:processingConfig:Transform' :: Transform -> Maybe TransformProcessingConfig
processingConfig} -> Maybe TransformProcessingConfig
processingConfig) (\s :: Transform
s@Transform' {} Maybe TransformProcessingConfig
a -> Transform
s {$sel:processingConfig:Transform' :: Maybe TransformProcessingConfig
processingConfig = Maybe TransformProcessingConfig
a} :: Transform)
transform_expression :: Lens.Lens' Transform Prelude.Text
transform_expression :: (Text -> f Text) -> Transform -> f Transform
transform_expression = (Transform -> Text)
-> (Transform -> Text -> Transform)
-> Lens Transform Transform Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Transform' {Text
expression :: Text
$sel:expression:Transform' :: Transform -> Text
expression} -> Text
expression) (\s :: Transform
s@Transform' {} Text
a -> Transform
s {$sel:expression:Transform' :: Text
expression = Text
a} :: Transform)
transform_variables :: Lens.Lens' Transform [ExpressionVariable]
transform_variables :: ([ExpressionVariable] -> f [ExpressionVariable])
-> Transform -> f Transform
transform_variables = (Transform -> [ExpressionVariable])
-> (Transform -> [ExpressionVariable] -> Transform)
-> Lens
Transform Transform [ExpressionVariable] [ExpressionVariable]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Transform' {[ExpressionVariable]
variables :: [ExpressionVariable]
$sel:variables:Transform' :: Transform -> [ExpressionVariable]
variables} -> [ExpressionVariable]
variables) (\s :: Transform
s@Transform' {} [ExpressionVariable]
a -> Transform
s {$sel:variables:Transform' :: [ExpressionVariable]
variables = [ExpressionVariable]
a} :: Transform) (([ExpressionVariable] -> f [ExpressionVariable])
-> Transform -> f Transform)
-> (([ExpressionVariable] -> f [ExpressionVariable])
-> [ExpressionVariable] -> f [ExpressionVariable])
-> ([ExpressionVariable] -> f [ExpressionVariable])
-> Transform
-> f Transform
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ExpressionVariable] -> f [ExpressionVariable])
-> [ExpressionVariable] -> f [ExpressionVariable]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON Transform where
parseJSON :: Value -> Parser Transform
parseJSON =
String -> (Object -> Parser Transform) -> Value -> Parser Transform
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Transform"
( \Object
x ->
Maybe TransformProcessingConfig
-> Text -> [ExpressionVariable] -> Transform
Transform'
(Maybe TransformProcessingConfig
-> Text -> [ExpressionVariable] -> Transform)
-> Parser (Maybe TransformProcessingConfig)
-> Parser (Text -> [ExpressionVariable] -> Transform)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TransformProcessingConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"processingConfig")
Parser (Text -> [ExpressionVariable] -> Transform)
-> Parser Text -> Parser ([ExpressionVariable] -> Transform)
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
"expression")
Parser ([ExpressionVariable] -> Transform)
-> Parser [ExpressionVariable] -> Parser Transform
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [ExpressionVariable])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"variables" Parser (Maybe [ExpressionVariable])
-> [ExpressionVariable] -> Parser [ExpressionVariable]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [ExpressionVariable]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable Transform
instance Prelude.NFData Transform
instance Core.ToJSON Transform where
toJSON :: Transform -> Value
toJSON Transform' {[ExpressionVariable]
Maybe TransformProcessingConfig
Text
variables :: [ExpressionVariable]
expression :: Text
processingConfig :: Maybe TransformProcessingConfig
$sel:variables:Transform' :: Transform -> [ExpressionVariable]
$sel:expression:Transform' :: Transform -> Text
$sel:processingConfig:Transform' :: Transform -> Maybe TransformProcessingConfig
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"processingConfig" Text -> TransformProcessingConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(TransformProcessingConfig -> Pair)
-> Maybe TransformProcessingConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TransformProcessingConfig
processingConfig,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"expression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
expression),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"variables" Text -> [ExpressionVariable] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [ExpressionVariable]
variables)
]
)