{-# 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.PropertyType where
import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.Attribute
import Amazonka.IoTSiteWise.Types.Measurement
import Amazonka.IoTSiteWise.Types.Metric
import Amazonka.IoTSiteWise.Types.Transform
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data PropertyType = PropertyType'
{
PropertyType -> Maybe Attribute
attribute :: Prelude.Maybe Attribute,
PropertyType -> Maybe Transform
transform :: Prelude.Maybe Transform,
PropertyType -> Maybe Metric
metric :: Prelude.Maybe Metric,
PropertyType -> Maybe Measurement
measurement :: Prelude.Maybe Measurement
}
deriving (PropertyType -> PropertyType -> Bool
(PropertyType -> PropertyType -> Bool)
-> (PropertyType -> PropertyType -> Bool) -> Eq PropertyType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyType -> PropertyType -> Bool
$c/= :: PropertyType -> PropertyType -> Bool
== :: PropertyType -> PropertyType -> Bool
$c== :: PropertyType -> PropertyType -> Bool
Prelude.Eq, ReadPrec [PropertyType]
ReadPrec PropertyType
Int -> ReadS PropertyType
ReadS [PropertyType]
(Int -> ReadS PropertyType)
-> ReadS [PropertyType]
-> ReadPrec PropertyType
-> ReadPrec [PropertyType]
-> Read PropertyType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyType]
$creadListPrec :: ReadPrec [PropertyType]
readPrec :: ReadPrec PropertyType
$creadPrec :: ReadPrec PropertyType
readList :: ReadS [PropertyType]
$creadList :: ReadS [PropertyType]
readsPrec :: Int -> ReadS PropertyType
$creadsPrec :: Int -> ReadS PropertyType
Prelude.Read, Int -> PropertyType -> ShowS
[PropertyType] -> ShowS
PropertyType -> String
(Int -> PropertyType -> ShowS)
-> (PropertyType -> String)
-> ([PropertyType] -> ShowS)
-> Show PropertyType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyType] -> ShowS
$cshowList :: [PropertyType] -> ShowS
show :: PropertyType -> String
$cshow :: PropertyType -> String
showsPrec :: Int -> PropertyType -> ShowS
$cshowsPrec :: Int -> PropertyType -> ShowS
Prelude.Show, (forall x. PropertyType -> Rep PropertyType x)
-> (forall x. Rep PropertyType x -> PropertyType)
-> Generic PropertyType
forall x. Rep PropertyType x -> PropertyType
forall x. PropertyType -> Rep PropertyType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyType x -> PropertyType
$cfrom :: forall x. PropertyType -> Rep PropertyType x
Prelude.Generic)
newPropertyType ::
PropertyType
newPropertyType :: PropertyType
newPropertyType =
PropertyType' :: Maybe Attribute
-> Maybe Transform
-> Maybe Metric
-> Maybe Measurement
-> PropertyType
PropertyType'
{ $sel:attribute:PropertyType' :: Maybe Attribute
attribute = Maybe Attribute
forall a. Maybe a
Prelude.Nothing,
$sel:transform:PropertyType' :: Maybe Transform
transform = Maybe Transform
forall a. Maybe a
Prelude.Nothing,
$sel:metric:PropertyType' :: Maybe Metric
metric = Maybe Metric
forall a. Maybe a
Prelude.Nothing,
$sel:measurement:PropertyType' :: Maybe Measurement
measurement = Maybe Measurement
forall a. Maybe a
Prelude.Nothing
}
propertyType_attribute :: Lens.Lens' PropertyType (Prelude.Maybe Attribute)
propertyType_attribute :: (Maybe Attribute -> f (Maybe Attribute))
-> PropertyType -> f PropertyType
propertyType_attribute = (PropertyType -> Maybe Attribute)
-> (PropertyType -> Maybe Attribute -> PropertyType)
-> Lens
PropertyType PropertyType (Maybe Attribute) (Maybe Attribute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyType' {Maybe Attribute
attribute :: Maybe Attribute
$sel:attribute:PropertyType' :: PropertyType -> Maybe Attribute
attribute} -> Maybe Attribute
attribute) (\s :: PropertyType
s@PropertyType' {} Maybe Attribute
a -> PropertyType
s {$sel:attribute:PropertyType' :: Maybe Attribute
attribute = Maybe Attribute
a} :: PropertyType)
propertyType_transform :: Lens.Lens' PropertyType (Prelude.Maybe Transform)
propertyType_transform :: (Maybe Transform -> f (Maybe Transform))
-> PropertyType -> f PropertyType
propertyType_transform = (PropertyType -> Maybe Transform)
-> (PropertyType -> Maybe Transform -> PropertyType)
-> Lens
PropertyType PropertyType (Maybe Transform) (Maybe Transform)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyType' {Maybe Transform
transform :: Maybe Transform
$sel:transform:PropertyType' :: PropertyType -> Maybe Transform
transform} -> Maybe Transform
transform) (\s :: PropertyType
s@PropertyType' {} Maybe Transform
a -> PropertyType
s {$sel:transform:PropertyType' :: Maybe Transform
transform = Maybe Transform
a} :: PropertyType)
propertyType_metric :: Lens.Lens' PropertyType (Prelude.Maybe Metric)
propertyType_metric :: (Maybe Metric -> f (Maybe Metric))
-> PropertyType -> f PropertyType
propertyType_metric = (PropertyType -> Maybe Metric)
-> (PropertyType -> Maybe Metric -> PropertyType)
-> Lens PropertyType PropertyType (Maybe Metric) (Maybe Metric)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyType' {Maybe Metric
metric :: Maybe Metric
$sel:metric:PropertyType' :: PropertyType -> Maybe Metric
metric} -> Maybe Metric
metric) (\s :: PropertyType
s@PropertyType' {} Maybe Metric
a -> PropertyType
s {$sel:metric:PropertyType' :: Maybe Metric
metric = Maybe Metric
a} :: PropertyType)
propertyType_measurement :: Lens.Lens' PropertyType (Prelude.Maybe Measurement)
propertyType_measurement :: (Maybe Measurement -> f (Maybe Measurement))
-> PropertyType -> f PropertyType
propertyType_measurement = (PropertyType -> Maybe Measurement)
-> (PropertyType -> Maybe Measurement -> PropertyType)
-> Lens
PropertyType PropertyType (Maybe Measurement) (Maybe Measurement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyType' {Maybe Measurement
measurement :: Maybe Measurement
$sel:measurement:PropertyType' :: PropertyType -> Maybe Measurement
measurement} -> Maybe Measurement
measurement) (\s :: PropertyType
s@PropertyType' {} Maybe Measurement
a -> PropertyType
s {$sel:measurement:PropertyType' :: Maybe Measurement
measurement = Maybe Measurement
a} :: PropertyType)
instance Core.FromJSON PropertyType where
parseJSON :: Value -> Parser PropertyType
parseJSON =
String
-> (Object -> Parser PropertyType) -> Value -> Parser PropertyType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"PropertyType"
( \Object
x ->
Maybe Attribute
-> Maybe Transform
-> Maybe Metric
-> Maybe Measurement
-> PropertyType
PropertyType'
(Maybe Attribute
-> Maybe Transform
-> Maybe Metric
-> Maybe Measurement
-> PropertyType)
-> Parser (Maybe Attribute)
-> Parser
(Maybe Transform
-> Maybe Metric -> Maybe Measurement -> PropertyType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Attribute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attribute")
Parser
(Maybe Transform
-> Maybe Metric -> Maybe Measurement -> PropertyType)
-> Parser (Maybe Transform)
-> Parser (Maybe Metric -> Maybe Measurement -> PropertyType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Transform)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"transform")
Parser (Maybe Metric -> Maybe Measurement -> PropertyType)
-> Parser (Maybe Metric)
-> Parser (Maybe Measurement -> PropertyType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Metric)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"metric")
Parser (Maybe Measurement -> PropertyType)
-> Parser (Maybe Measurement) -> Parser PropertyType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Measurement)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"measurement")
)
instance Prelude.Hashable PropertyType
instance Prelude.NFData PropertyType
instance Core.ToJSON PropertyType where
toJSON :: PropertyType -> Value
toJSON PropertyType' {Maybe Attribute
Maybe Measurement
Maybe Transform
Maybe Metric
measurement :: Maybe Measurement
metric :: Maybe Metric
transform :: Maybe Transform
attribute :: Maybe Attribute
$sel:measurement:PropertyType' :: PropertyType -> Maybe Measurement
$sel:metric:PropertyType' :: PropertyType -> Maybe Metric
$sel:transform:PropertyType' :: PropertyType -> Maybe Transform
$sel:attribute:PropertyType' :: PropertyType -> Maybe Attribute
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"attribute" Text -> Attribute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Attribute -> Pair) -> Maybe Attribute -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Attribute
attribute,
(Text
"transform" Text -> Transform -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Transform -> Pair) -> Maybe Transform -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Transform
transform,
(Text
"metric" Text -> Metric -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Metric -> Pair) -> Maybe Metric -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Metric
metric,
(Text
"measurement" Text -> Measurement -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Measurement -> Pair) -> Maybe Measurement -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Measurement
measurement
]
)