{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTSiteWise.Types.AssetHierarchyInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:childAssetId:AssetHierarchyInfo' :: Maybe Text
childAssetId = forall a. Maybe a
Prelude.Nothing,
      $sel:parentAssetId:AssetHierarchyInfo' :: Maybe Text
parentAssetId = 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 :: Lens' AssetHierarchyInfo (Maybe Text)
assetHierarchyInfo_childAssetId = 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 :: Lens' AssetHierarchyInfo (Maybe Text)
assetHierarchyInfo_parentAssetId = 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 Data.FromJSON AssetHierarchyInfo where
  parseJSON :: Value -> Parser AssetHierarchyInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssetHierarchyInfo"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AssetHierarchyInfo
AssetHierarchyInfo'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"childAssetId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"parentAssetId")
      )

instance Prelude.Hashable AssetHierarchyInfo where
  hashWithSalt :: Int -> AssetHierarchyInfo -> Int
hashWithSalt Int
_salt AssetHierarchyInfo' {Maybe Text
parentAssetId :: Maybe Text
childAssetId :: Maybe Text
$sel:parentAssetId:AssetHierarchyInfo' :: AssetHierarchyInfo -> Maybe Text
$sel:childAssetId:AssetHierarchyInfo' :: AssetHierarchyInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
childAssetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parentAssetId

instance Prelude.NFData AssetHierarchyInfo where
  rnf :: AssetHierarchyInfo -> ()
rnf AssetHierarchyInfo' {Maybe Text
parentAssetId :: Maybe Text
childAssetId :: Maybe Text
$sel:parentAssetId:AssetHierarchyInfo' :: AssetHierarchyInfo -> Maybe Text
$sel:childAssetId:AssetHierarchyInfo' :: AssetHierarchyInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
childAssetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parentAssetId