{-# 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.AssetModelHierarchy where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data AssetModelHierarchy = AssetModelHierarchy'
{
AssetModelHierarchy -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
AssetModelHierarchy -> Text
name :: Prelude.Text,
AssetModelHierarchy -> Text
childAssetModelId :: Prelude.Text
}
deriving (AssetModelHierarchy -> AssetModelHierarchy -> Bool
(AssetModelHierarchy -> AssetModelHierarchy -> Bool)
-> (AssetModelHierarchy -> AssetModelHierarchy -> Bool)
-> Eq AssetModelHierarchy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetModelHierarchy -> AssetModelHierarchy -> Bool
$c/= :: AssetModelHierarchy -> AssetModelHierarchy -> Bool
== :: AssetModelHierarchy -> AssetModelHierarchy -> Bool
$c== :: AssetModelHierarchy -> AssetModelHierarchy -> Bool
Prelude.Eq, ReadPrec [AssetModelHierarchy]
ReadPrec AssetModelHierarchy
Int -> ReadS AssetModelHierarchy
ReadS [AssetModelHierarchy]
(Int -> ReadS AssetModelHierarchy)
-> ReadS [AssetModelHierarchy]
-> ReadPrec AssetModelHierarchy
-> ReadPrec [AssetModelHierarchy]
-> Read AssetModelHierarchy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetModelHierarchy]
$creadListPrec :: ReadPrec [AssetModelHierarchy]
readPrec :: ReadPrec AssetModelHierarchy
$creadPrec :: ReadPrec AssetModelHierarchy
readList :: ReadS [AssetModelHierarchy]
$creadList :: ReadS [AssetModelHierarchy]
readsPrec :: Int -> ReadS AssetModelHierarchy
$creadsPrec :: Int -> ReadS AssetModelHierarchy
Prelude.Read, Int -> AssetModelHierarchy -> ShowS
[AssetModelHierarchy] -> ShowS
AssetModelHierarchy -> String
(Int -> AssetModelHierarchy -> ShowS)
-> (AssetModelHierarchy -> String)
-> ([AssetModelHierarchy] -> ShowS)
-> Show AssetModelHierarchy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetModelHierarchy] -> ShowS
$cshowList :: [AssetModelHierarchy] -> ShowS
show :: AssetModelHierarchy -> String
$cshow :: AssetModelHierarchy -> String
showsPrec :: Int -> AssetModelHierarchy -> ShowS
$cshowsPrec :: Int -> AssetModelHierarchy -> ShowS
Prelude.Show, (forall x. AssetModelHierarchy -> Rep AssetModelHierarchy x)
-> (forall x. Rep AssetModelHierarchy x -> AssetModelHierarchy)
-> Generic AssetModelHierarchy
forall x. Rep AssetModelHierarchy x -> AssetModelHierarchy
forall x. AssetModelHierarchy -> Rep AssetModelHierarchy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetModelHierarchy x -> AssetModelHierarchy
$cfrom :: forall x. AssetModelHierarchy -> Rep AssetModelHierarchy x
Prelude.Generic)
newAssetModelHierarchy ::
Prelude.Text ->
Prelude.Text ->
AssetModelHierarchy
newAssetModelHierarchy :: Text -> Text -> AssetModelHierarchy
newAssetModelHierarchy Text
pName_ Text
pChildAssetModelId_ =
AssetModelHierarchy' :: Maybe Text -> Text -> Text -> AssetModelHierarchy
AssetModelHierarchy'
{ $sel:id:AssetModelHierarchy' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:AssetModelHierarchy' :: Text
name = Text
pName_,
$sel:childAssetModelId:AssetModelHierarchy' :: Text
childAssetModelId = Text
pChildAssetModelId_
}
assetModelHierarchy_id :: Lens.Lens' AssetModelHierarchy (Prelude.Maybe Prelude.Text)
assetModelHierarchy_id :: (Maybe Text -> f (Maybe Text))
-> AssetModelHierarchy -> f AssetModelHierarchy
assetModelHierarchy_id = (AssetModelHierarchy -> Maybe Text)
-> (AssetModelHierarchy -> Maybe Text -> AssetModelHierarchy)
-> Lens
AssetModelHierarchy AssetModelHierarchy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelHierarchy' {Maybe Text
id :: Maybe Text
$sel:id:AssetModelHierarchy' :: AssetModelHierarchy -> Maybe Text
id} -> Maybe Text
id) (\s :: AssetModelHierarchy
s@AssetModelHierarchy' {} Maybe Text
a -> AssetModelHierarchy
s {$sel:id:AssetModelHierarchy' :: Maybe Text
id = Maybe Text
a} :: AssetModelHierarchy)
assetModelHierarchy_name :: Lens.Lens' AssetModelHierarchy Prelude.Text
assetModelHierarchy_name :: (Text -> f Text) -> AssetModelHierarchy -> f AssetModelHierarchy
assetModelHierarchy_name = (AssetModelHierarchy -> Text)
-> (AssetModelHierarchy -> Text -> AssetModelHierarchy)
-> Lens AssetModelHierarchy AssetModelHierarchy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelHierarchy' {Text
name :: Text
$sel:name:AssetModelHierarchy' :: AssetModelHierarchy -> Text
name} -> Text
name) (\s :: AssetModelHierarchy
s@AssetModelHierarchy' {} Text
a -> AssetModelHierarchy
s {$sel:name:AssetModelHierarchy' :: Text
name = Text
a} :: AssetModelHierarchy)
assetModelHierarchy_childAssetModelId :: Lens.Lens' AssetModelHierarchy Prelude.Text
assetModelHierarchy_childAssetModelId :: (Text -> f Text) -> AssetModelHierarchy -> f AssetModelHierarchy
assetModelHierarchy_childAssetModelId = (AssetModelHierarchy -> Text)
-> (AssetModelHierarchy -> Text -> AssetModelHierarchy)
-> Lens AssetModelHierarchy AssetModelHierarchy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelHierarchy' {Text
childAssetModelId :: Text
$sel:childAssetModelId:AssetModelHierarchy' :: AssetModelHierarchy -> Text
childAssetModelId} -> Text
childAssetModelId) (\s :: AssetModelHierarchy
s@AssetModelHierarchy' {} Text
a -> AssetModelHierarchy
s {$sel:childAssetModelId:AssetModelHierarchy' :: Text
childAssetModelId = Text
a} :: AssetModelHierarchy)
instance Core.FromJSON AssetModelHierarchy where
parseJSON :: Value -> Parser AssetModelHierarchy
parseJSON =
String
-> (Object -> Parser AssetModelHierarchy)
-> Value
-> Parser AssetModelHierarchy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AssetModelHierarchy"
( \Object
x ->
Maybe Text -> Text -> Text -> AssetModelHierarchy
AssetModelHierarchy'
(Maybe Text -> Text -> Text -> AssetModelHierarchy)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> AssetModelHierarchy)
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
"id")
Parser (Text -> Text -> AssetModelHierarchy)
-> Parser Text -> Parser (Text -> AssetModelHierarchy)
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 (Text -> AssetModelHierarchy)
-> Parser Text -> Parser AssetModelHierarchy
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
"childAssetModelId")
)
instance Prelude.Hashable AssetModelHierarchy
instance Prelude.NFData AssetModelHierarchy
instance Core.ToJSON AssetModelHierarchy where
toJSON :: AssetModelHierarchy -> Value
toJSON AssetModelHierarchy' {Maybe Text
Text
childAssetModelId :: Text
name :: Text
id :: Maybe Text
$sel:childAssetModelId:AssetModelHierarchy' :: AssetModelHierarchy -> Text
$sel:name:AssetModelHierarchy' :: AssetModelHierarchy -> Text
$sel:id:AssetModelHierarchy' :: AssetModelHierarchy -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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,
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
"childAssetModelId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
childAssetModelId)
]
)