{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoTSiteWise.Types.AssetHierarchyInfo
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTSiteWise.Types.AssetHierarchyInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a parent asset and a child asset that are
-- related through an asset hierarchy.
--
-- /See:/ 'newAssetHierarchyInfo' smart constructor.
data AssetHierarchyInfo = AssetHierarchyInfo'
  { -- | The ID of the child asset in this asset relationship.
    AssetHierarchyInfo -> Maybe Text
childAssetId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the parent asset in this asset relationship.
    AssetHierarchyInfo -> Maybe Text
parentAssetId :: Prelude.Maybe Prelude.Text
  }
  deriving (AssetHierarchyInfo -> AssetHierarchyInfo -> Bool
(AssetHierarchyInfo -> AssetHierarchyInfo -> Bool)
-> (AssetHierarchyInfo -> AssetHierarchyInfo -> Bool)
-> Eq AssetHierarchyInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetHierarchyInfo -> AssetHierarchyInfo -> Bool
$c/= :: AssetHierarchyInfo -> AssetHierarchyInfo -> Bool
== :: AssetHierarchyInfo -> AssetHierarchyInfo -> Bool
$c== :: AssetHierarchyInfo -> AssetHierarchyInfo -> Bool
Prelude.Eq, ReadPrec [AssetHierarchyInfo]
ReadPrec AssetHierarchyInfo
Int -> ReadS AssetHierarchyInfo
ReadS [AssetHierarchyInfo]
(Int -> ReadS AssetHierarchyInfo)
-> ReadS [AssetHierarchyInfo]
-> ReadPrec AssetHierarchyInfo
-> ReadPrec [AssetHierarchyInfo]
-> Read AssetHierarchyInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetHierarchyInfo]
$creadListPrec :: ReadPrec [AssetHierarchyInfo]
readPrec :: ReadPrec AssetHierarchyInfo
$creadPrec :: ReadPrec AssetHierarchyInfo
readList :: ReadS [AssetHierarchyInfo]
$creadList :: ReadS [AssetHierarchyInfo]
readsPrec :: Int -> ReadS AssetHierarchyInfo
$creadsPrec :: Int -> ReadS AssetHierarchyInfo
Prelude.Read, Int -> AssetHierarchyInfo -> ShowS
[AssetHierarchyInfo] -> ShowS
AssetHierarchyInfo -> String
(Int -> AssetHierarchyInfo -> ShowS)
-> (AssetHierarchyInfo -> String)
-> ([AssetHierarchyInfo] -> ShowS)
-> Show AssetHierarchyInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetHierarchyInfo] -> ShowS
$cshowList :: [AssetHierarchyInfo] -> ShowS
show :: AssetHierarchyInfo -> String
$cshow :: AssetHierarchyInfo -> String
showsPrec :: Int -> AssetHierarchyInfo -> ShowS
$cshowsPrec :: Int -> AssetHierarchyInfo -> ShowS
Prelude.Show, (forall x. AssetHierarchyInfo -> Rep AssetHierarchyInfo x)
-> (forall x. Rep AssetHierarchyInfo x -> AssetHierarchyInfo)
-> Generic AssetHierarchyInfo
forall x. Rep AssetHierarchyInfo x -> AssetHierarchyInfo
forall x. AssetHierarchyInfo -> Rep AssetHierarchyInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetHierarchyInfo x -> AssetHierarchyInfo
$cfrom :: forall x. AssetHierarchyInfo -> Rep AssetHierarchyInfo x
Prelude.Generic)

-- |
-- Create a value of 'AssetHierarchyInfo' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'childAssetId', 'assetHierarchyInfo_childAssetId' - The ID of the child asset in this asset relationship.
--
-- 'parentAssetId', 'assetHierarchyInfo_parentAssetId' - The ID of the parent asset in this asset relationship.
newAssetHierarchyInfo ::
  AssetHierarchyInfo
newAssetHierarchyInfo :: AssetHierarchyInfo
newAssetHierarchyInfo =
  AssetHierarchyInfo' :: Maybe Text -> Maybe Text -> AssetHierarchyInfo
AssetHierarchyInfo'
    { $sel:childAssetId:AssetHierarchyInfo' :: Maybe Text
childAssetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parentAssetId:AssetHierarchyInfo' :: Maybe Text
parentAssetId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the child asset in this asset relationship.
assetHierarchyInfo_childAssetId :: Lens.Lens' AssetHierarchyInfo (Prelude.Maybe Prelude.Text)
assetHierarchyInfo_childAssetId :: (Maybe Text -> f (Maybe Text))
-> AssetHierarchyInfo -> f AssetHierarchyInfo
assetHierarchyInfo_childAssetId = (AssetHierarchyInfo -> Maybe Text)
-> (AssetHierarchyInfo -> Maybe Text -> AssetHierarchyInfo)
-> Lens
     AssetHierarchyInfo AssetHierarchyInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetHierarchyInfo' {Maybe Text
childAssetId :: Maybe Text
$sel:childAssetId:AssetHierarchyInfo' :: AssetHierarchyInfo -> Maybe Text
childAssetId} -> Maybe Text
childAssetId) (\s :: AssetHierarchyInfo
s@AssetHierarchyInfo' {} Maybe Text
a -> AssetHierarchyInfo
s {$sel:childAssetId:AssetHierarchyInfo' :: Maybe Text
childAssetId = Maybe Text
a} :: AssetHierarchyInfo)

-- | The ID of the parent asset in this asset relationship.
assetHierarchyInfo_parentAssetId :: Lens.Lens' AssetHierarchyInfo (Prelude.Maybe Prelude.Text)
assetHierarchyInfo_parentAssetId :: (Maybe Text -> f (Maybe Text))
-> AssetHierarchyInfo -> f AssetHierarchyInfo
assetHierarchyInfo_parentAssetId = (AssetHierarchyInfo -> Maybe Text)
-> (AssetHierarchyInfo -> Maybe Text -> AssetHierarchyInfo)
-> Lens
     AssetHierarchyInfo AssetHierarchyInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetHierarchyInfo' {Maybe Text
parentAssetId :: Maybe Text
$sel:parentAssetId:AssetHierarchyInfo' :: AssetHierarchyInfo -> Maybe Text
parentAssetId} -> Maybe Text
parentAssetId) (\s :: AssetHierarchyInfo
s@AssetHierarchyInfo' {} Maybe Text
a -> AssetHierarchyInfo
s {$sel:parentAssetId:AssetHierarchyInfo' :: Maybe Text
parentAssetId = Maybe Text
a} :: AssetHierarchyInfo)

instance Core.FromJSON AssetHierarchyInfo where
  parseJSON :: Value -> Parser AssetHierarchyInfo
parseJSON =
    String
-> (Object -> Parser AssetHierarchyInfo)
-> Value
-> Parser AssetHierarchyInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssetHierarchyInfo"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AssetHierarchyInfo
AssetHierarchyInfo'
            (Maybe Text -> Maybe Text -> AssetHierarchyInfo)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AssetHierarchyInfo)
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
"childAssetId")
            Parser (Maybe Text -> AssetHierarchyInfo)
-> Parser (Maybe Text) -> Parser AssetHierarchyInfo
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
"parentAssetId")
      )

instance Prelude.Hashable AssetHierarchyInfo

instance Prelude.NFData AssetHierarchyInfo