{-# 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.AssetModelProperty where
import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.PropertyDataType
import Amazonka.IoTSiteWise.Types.PropertyType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data AssetModelProperty = AssetModelProperty'
{
AssetModelProperty -> Maybe Text
dataTypeSpec :: Prelude.Maybe Prelude.Text,
AssetModelProperty -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
AssetModelProperty -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
AssetModelProperty -> Text
name :: Prelude.Text,
AssetModelProperty -> PropertyDataType
dataType :: PropertyDataType,
AssetModelProperty -> PropertyType
type' :: PropertyType
}
deriving (AssetModelProperty -> AssetModelProperty -> Bool
(AssetModelProperty -> AssetModelProperty -> Bool)
-> (AssetModelProperty -> AssetModelProperty -> Bool)
-> Eq AssetModelProperty
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetModelProperty -> AssetModelProperty -> Bool
$c/= :: AssetModelProperty -> AssetModelProperty -> Bool
== :: AssetModelProperty -> AssetModelProperty -> Bool
$c== :: AssetModelProperty -> AssetModelProperty -> Bool
Prelude.Eq, ReadPrec [AssetModelProperty]
ReadPrec AssetModelProperty
Int -> ReadS AssetModelProperty
ReadS [AssetModelProperty]
(Int -> ReadS AssetModelProperty)
-> ReadS [AssetModelProperty]
-> ReadPrec AssetModelProperty
-> ReadPrec [AssetModelProperty]
-> Read AssetModelProperty
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetModelProperty]
$creadListPrec :: ReadPrec [AssetModelProperty]
readPrec :: ReadPrec AssetModelProperty
$creadPrec :: ReadPrec AssetModelProperty
readList :: ReadS [AssetModelProperty]
$creadList :: ReadS [AssetModelProperty]
readsPrec :: Int -> ReadS AssetModelProperty
$creadsPrec :: Int -> ReadS AssetModelProperty
Prelude.Read, Int -> AssetModelProperty -> ShowS
[AssetModelProperty] -> ShowS
AssetModelProperty -> String
(Int -> AssetModelProperty -> ShowS)
-> (AssetModelProperty -> String)
-> ([AssetModelProperty] -> ShowS)
-> Show AssetModelProperty
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetModelProperty] -> ShowS
$cshowList :: [AssetModelProperty] -> ShowS
show :: AssetModelProperty -> String
$cshow :: AssetModelProperty -> String
showsPrec :: Int -> AssetModelProperty -> ShowS
$cshowsPrec :: Int -> AssetModelProperty -> ShowS
Prelude.Show, (forall x. AssetModelProperty -> Rep AssetModelProperty x)
-> (forall x. Rep AssetModelProperty x -> AssetModelProperty)
-> Generic AssetModelProperty
forall x. Rep AssetModelProperty x -> AssetModelProperty
forall x. AssetModelProperty -> Rep AssetModelProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetModelProperty x -> AssetModelProperty
$cfrom :: forall x. AssetModelProperty -> Rep AssetModelProperty x
Prelude.Generic)
newAssetModelProperty ::
Prelude.Text ->
PropertyDataType ->
PropertyType ->
AssetModelProperty
newAssetModelProperty :: Text -> PropertyDataType -> PropertyType -> AssetModelProperty
newAssetModelProperty Text
pName_ PropertyDataType
pDataType_ PropertyType
pType_ =
AssetModelProperty' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> PropertyDataType
-> PropertyType
-> AssetModelProperty
AssetModelProperty'
{ $sel:dataTypeSpec:AssetModelProperty' :: Maybe Text
dataTypeSpec = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:id:AssetModelProperty' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:unit:AssetModelProperty' :: Maybe Text
unit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:AssetModelProperty' :: Text
name = Text
pName_,
$sel:dataType:AssetModelProperty' :: PropertyDataType
dataType = PropertyDataType
pDataType_,
$sel:type':AssetModelProperty' :: PropertyType
type' = PropertyType
pType_
}
assetModelProperty_dataTypeSpec :: Lens.Lens' AssetModelProperty (Prelude.Maybe Prelude.Text)
assetModelProperty_dataTypeSpec :: (Maybe Text -> f (Maybe Text))
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_dataTypeSpec = (AssetModelProperty -> Maybe Text)
-> (AssetModelProperty -> Maybe Text -> AssetModelProperty)
-> Lens
AssetModelProperty AssetModelProperty (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {Maybe Text
dataTypeSpec :: Maybe Text
$sel:dataTypeSpec:AssetModelProperty' :: AssetModelProperty -> Maybe Text
dataTypeSpec} -> Maybe Text
dataTypeSpec) (\s :: AssetModelProperty
s@AssetModelProperty' {} Maybe Text
a -> AssetModelProperty
s {$sel:dataTypeSpec:AssetModelProperty' :: Maybe Text
dataTypeSpec = Maybe Text
a} :: AssetModelProperty)
assetModelProperty_id :: Lens.Lens' AssetModelProperty (Prelude.Maybe Prelude.Text)
assetModelProperty_id :: (Maybe Text -> f (Maybe Text))
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_id = (AssetModelProperty -> Maybe Text)
-> (AssetModelProperty -> Maybe Text -> AssetModelProperty)
-> Lens
AssetModelProperty AssetModelProperty (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {Maybe Text
id :: Maybe Text
$sel:id:AssetModelProperty' :: AssetModelProperty -> Maybe Text
id} -> Maybe Text
id) (\s :: AssetModelProperty
s@AssetModelProperty' {} Maybe Text
a -> AssetModelProperty
s {$sel:id:AssetModelProperty' :: Maybe Text
id = Maybe Text
a} :: AssetModelProperty)
assetModelProperty_unit :: Lens.Lens' AssetModelProperty (Prelude.Maybe Prelude.Text)
assetModelProperty_unit :: (Maybe Text -> f (Maybe Text))
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_unit = (AssetModelProperty -> Maybe Text)
-> (AssetModelProperty -> Maybe Text -> AssetModelProperty)
-> Lens
AssetModelProperty AssetModelProperty (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {Maybe Text
unit :: Maybe Text
$sel:unit:AssetModelProperty' :: AssetModelProperty -> Maybe Text
unit} -> Maybe Text
unit) (\s :: AssetModelProperty
s@AssetModelProperty' {} Maybe Text
a -> AssetModelProperty
s {$sel:unit:AssetModelProperty' :: Maybe Text
unit = Maybe Text
a} :: AssetModelProperty)
assetModelProperty_name :: Lens.Lens' AssetModelProperty Prelude.Text
assetModelProperty_name :: (Text -> f Text) -> AssetModelProperty -> f AssetModelProperty
assetModelProperty_name = (AssetModelProperty -> Text)
-> (AssetModelProperty -> Text -> AssetModelProperty)
-> Lens AssetModelProperty AssetModelProperty Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {Text
name :: Text
$sel:name:AssetModelProperty' :: AssetModelProperty -> Text
name} -> Text
name) (\s :: AssetModelProperty
s@AssetModelProperty' {} Text
a -> AssetModelProperty
s {$sel:name:AssetModelProperty' :: Text
name = Text
a} :: AssetModelProperty)
assetModelProperty_dataType :: Lens.Lens' AssetModelProperty PropertyDataType
assetModelProperty_dataType :: (PropertyDataType -> f PropertyDataType)
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_dataType = (AssetModelProperty -> PropertyDataType)
-> (AssetModelProperty -> PropertyDataType -> AssetModelProperty)
-> Lens
AssetModelProperty
AssetModelProperty
PropertyDataType
PropertyDataType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {PropertyDataType
dataType :: PropertyDataType
$sel:dataType:AssetModelProperty' :: AssetModelProperty -> PropertyDataType
dataType} -> PropertyDataType
dataType) (\s :: AssetModelProperty
s@AssetModelProperty' {} PropertyDataType
a -> AssetModelProperty
s {$sel:dataType:AssetModelProperty' :: PropertyDataType
dataType = PropertyDataType
a} :: AssetModelProperty)
assetModelProperty_type :: Lens.Lens' AssetModelProperty PropertyType
assetModelProperty_type :: (PropertyType -> f PropertyType)
-> AssetModelProperty -> f AssetModelProperty
assetModelProperty_type = (AssetModelProperty -> PropertyType)
-> (AssetModelProperty -> PropertyType -> AssetModelProperty)
-> Lens
AssetModelProperty AssetModelProperty PropertyType PropertyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelProperty' {PropertyType
type' :: PropertyType
$sel:type':AssetModelProperty' :: AssetModelProperty -> PropertyType
type'} -> PropertyType
type') (\s :: AssetModelProperty
s@AssetModelProperty' {} PropertyType
a -> AssetModelProperty
s {$sel:type':AssetModelProperty' :: PropertyType
type' = PropertyType
a} :: AssetModelProperty)
instance Core.FromJSON AssetModelProperty where
parseJSON :: Value -> Parser AssetModelProperty
parseJSON =
String
-> (Object -> Parser AssetModelProperty)
-> Value
-> Parser AssetModelProperty
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AssetModelProperty"
( \Object
x ->
Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> PropertyDataType
-> PropertyType
-> AssetModelProperty
AssetModelProperty'
(Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> PropertyDataType
-> PropertyType
-> AssetModelProperty)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Maybe Text
-> Text
-> PropertyDataType
-> PropertyType
-> AssetModelProperty)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dataTypeSpec")
Parser
(Maybe Text
-> Maybe Text
-> Text
-> PropertyDataType
-> PropertyType
-> AssetModelProperty)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Text -> PropertyDataType -> PropertyType -> AssetModelProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"id")
Parser
(Maybe Text
-> Text -> PropertyDataType -> PropertyType -> AssetModelProperty)
-> Parser (Maybe Text)
-> Parser
(Text -> PropertyDataType -> PropertyType -> AssetModelProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"unit")
Parser
(Text -> PropertyDataType -> PropertyType -> AssetModelProperty)
-> Parser Text
-> Parser (PropertyDataType -> PropertyType -> AssetModelProperty)
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
"name")
Parser (PropertyDataType -> PropertyType -> AssetModelProperty)
-> Parser PropertyDataType
-> Parser (PropertyType -> AssetModelProperty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PropertyDataType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"dataType")
Parser (PropertyType -> AssetModelProperty)
-> Parser PropertyType -> Parser AssetModelProperty
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PropertyType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
)
instance Prelude.Hashable AssetModelProperty
instance Prelude.NFData AssetModelProperty
instance Core.ToJSON AssetModelProperty where
toJSON :: AssetModelProperty -> Value
toJSON AssetModelProperty' {Maybe Text
Text
PropertyDataType
PropertyType
type' :: PropertyType
dataType :: PropertyDataType
name :: Text
unit :: Maybe Text
id :: Maybe Text
dataTypeSpec :: Maybe Text
$sel:type':AssetModelProperty' :: AssetModelProperty -> PropertyType
$sel:dataType:AssetModelProperty' :: AssetModelProperty -> PropertyDataType
$sel:name:AssetModelProperty' :: AssetModelProperty -> Text
$sel:unit:AssetModelProperty' :: AssetModelProperty -> Maybe Text
$sel:id:AssetModelProperty' :: AssetModelProperty -> Maybe Text
$sel:dataTypeSpec:AssetModelProperty' :: AssetModelProperty -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"dataTypeSpec" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataTypeSpec,
(Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
id,
(Text
"unit" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
unit,
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
"dataType" Text -> PropertyDataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PropertyDataType
dataType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> PropertyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PropertyType
type')
]
)