{-# 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.AssetRelationshipSummary
-- 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.AssetRelationshipSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTSiteWise.Types.AssetHierarchyInfo
import Amazonka.IoTSiteWise.Types.AssetRelationshipType
import qualified Amazonka.Prelude as Prelude

-- | Contains information about assets that are related to one another.
--
-- /See:/ 'newAssetRelationshipSummary' smart constructor.
data AssetRelationshipSummary = AssetRelationshipSummary'
  { -- | The assets that are related through an asset hierarchy.
    --
    -- This object is present if the @relationshipType@ is @HIERARCHY@.
    AssetRelationshipSummary -> Maybe AssetHierarchyInfo
hierarchyInfo :: Prelude.Maybe AssetHierarchyInfo,
    -- | The relationship type of the assets in this relationship. This value is
    -- one of the following:
    --
    -- -   @HIERARCHY@ – The assets are related through an asset hierarchy. If
    --     you specify this relationship type, this asset relationship includes
    --     the @hierarchyInfo@ object.
    AssetRelationshipSummary -> AssetRelationshipType
relationshipType :: AssetRelationshipType
  }
  deriving (AssetRelationshipSummary -> AssetRelationshipSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetRelationshipSummary -> AssetRelationshipSummary -> Bool
$c/= :: AssetRelationshipSummary -> AssetRelationshipSummary -> Bool
== :: AssetRelationshipSummary -> AssetRelationshipSummary -> Bool
$c== :: AssetRelationshipSummary -> AssetRelationshipSummary -> Bool
Prelude.Eq, ReadPrec [AssetRelationshipSummary]
ReadPrec AssetRelationshipSummary
Int -> ReadS AssetRelationshipSummary
ReadS [AssetRelationshipSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetRelationshipSummary]
$creadListPrec :: ReadPrec [AssetRelationshipSummary]
readPrec :: ReadPrec AssetRelationshipSummary
$creadPrec :: ReadPrec AssetRelationshipSummary
readList :: ReadS [AssetRelationshipSummary]
$creadList :: ReadS [AssetRelationshipSummary]
readsPrec :: Int -> ReadS AssetRelationshipSummary
$creadsPrec :: Int -> ReadS AssetRelationshipSummary
Prelude.Read, Int -> AssetRelationshipSummary -> ShowS
[AssetRelationshipSummary] -> ShowS
AssetRelationshipSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetRelationshipSummary] -> ShowS
$cshowList :: [AssetRelationshipSummary] -> ShowS
show :: AssetRelationshipSummary -> String
$cshow :: AssetRelationshipSummary -> String
showsPrec :: Int -> AssetRelationshipSummary -> ShowS
$cshowsPrec :: Int -> AssetRelationshipSummary -> ShowS
Prelude.Show, forall x.
Rep AssetRelationshipSummary x -> AssetRelationshipSummary
forall x.
AssetRelationshipSummary -> Rep AssetRelationshipSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssetRelationshipSummary x -> AssetRelationshipSummary
$cfrom :: forall x.
AssetRelationshipSummary -> Rep AssetRelationshipSummary x
Prelude.Generic)

-- |
-- Create a value of 'AssetRelationshipSummary' 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:
--
-- 'hierarchyInfo', 'assetRelationshipSummary_hierarchyInfo' - The assets that are related through an asset hierarchy.
--
-- This object is present if the @relationshipType@ is @HIERARCHY@.
--
-- 'relationshipType', 'assetRelationshipSummary_relationshipType' - The relationship type of the assets in this relationship. This value is
-- one of the following:
--
-- -   @HIERARCHY@ – The assets are related through an asset hierarchy. If
--     you specify this relationship type, this asset relationship includes
--     the @hierarchyInfo@ object.
newAssetRelationshipSummary ::
  -- | 'relationshipType'
  AssetRelationshipType ->
  AssetRelationshipSummary
newAssetRelationshipSummary :: AssetRelationshipType -> AssetRelationshipSummary
newAssetRelationshipSummary AssetRelationshipType
pRelationshipType_ =
  AssetRelationshipSummary'
    { $sel:hierarchyInfo:AssetRelationshipSummary' :: Maybe AssetHierarchyInfo
hierarchyInfo =
        forall a. Maybe a
Prelude.Nothing,
      $sel:relationshipType:AssetRelationshipSummary' :: AssetRelationshipType
relationshipType = AssetRelationshipType
pRelationshipType_
    }

-- | The assets that are related through an asset hierarchy.
--
-- This object is present if the @relationshipType@ is @HIERARCHY@.
assetRelationshipSummary_hierarchyInfo :: Lens.Lens' AssetRelationshipSummary (Prelude.Maybe AssetHierarchyInfo)
assetRelationshipSummary_hierarchyInfo :: Lens' AssetRelationshipSummary (Maybe AssetHierarchyInfo)
assetRelationshipSummary_hierarchyInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetRelationshipSummary' {Maybe AssetHierarchyInfo
hierarchyInfo :: Maybe AssetHierarchyInfo
$sel:hierarchyInfo:AssetRelationshipSummary' :: AssetRelationshipSummary -> Maybe AssetHierarchyInfo
hierarchyInfo} -> Maybe AssetHierarchyInfo
hierarchyInfo) (\s :: AssetRelationshipSummary
s@AssetRelationshipSummary' {} Maybe AssetHierarchyInfo
a -> AssetRelationshipSummary
s {$sel:hierarchyInfo:AssetRelationshipSummary' :: Maybe AssetHierarchyInfo
hierarchyInfo = Maybe AssetHierarchyInfo
a} :: AssetRelationshipSummary)

-- | The relationship type of the assets in this relationship. This value is
-- one of the following:
--
-- -   @HIERARCHY@ – The assets are related through an asset hierarchy. If
--     you specify this relationship type, this asset relationship includes
--     the @hierarchyInfo@ object.
assetRelationshipSummary_relationshipType :: Lens.Lens' AssetRelationshipSummary AssetRelationshipType
assetRelationshipSummary_relationshipType :: Lens' AssetRelationshipSummary AssetRelationshipType
assetRelationshipSummary_relationshipType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetRelationshipSummary' {AssetRelationshipType
relationshipType :: AssetRelationshipType
$sel:relationshipType:AssetRelationshipSummary' :: AssetRelationshipSummary -> AssetRelationshipType
relationshipType} -> AssetRelationshipType
relationshipType) (\s :: AssetRelationshipSummary
s@AssetRelationshipSummary' {} AssetRelationshipType
a -> AssetRelationshipSummary
s {$sel:relationshipType:AssetRelationshipSummary' :: AssetRelationshipType
relationshipType = AssetRelationshipType
a} :: AssetRelationshipSummary)

instance Data.FromJSON AssetRelationshipSummary where
  parseJSON :: Value -> Parser AssetRelationshipSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssetRelationshipSummary"
      ( \Object
x ->
          Maybe AssetHierarchyInfo
-> AssetRelationshipType -> AssetRelationshipSummary
AssetRelationshipSummary'
            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
"hierarchyInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"relationshipType")
      )

instance Prelude.Hashable AssetRelationshipSummary where
  hashWithSalt :: Int -> AssetRelationshipSummary -> Int
hashWithSalt Int
_salt AssetRelationshipSummary' {Maybe AssetHierarchyInfo
AssetRelationshipType
relationshipType :: AssetRelationshipType
hierarchyInfo :: Maybe AssetHierarchyInfo
$sel:relationshipType:AssetRelationshipSummary' :: AssetRelationshipSummary -> AssetRelationshipType
$sel:hierarchyInfo:AssetRelationshipSummary' :: AssetRelationshipSummary -> Maybe AssetHierarchyInfo
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AssetHierarchyInfo
hierarchyInfo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AssetRelationshipType
relationshipType

instance Prelude.NFData AssetRelationshipSummary where
  rnf :: AssetRelationshipSummary -> ()
rnf AssetRelationshipSummary' {Maybe AssetHierarchyInfo
AssetRelationshipType
relationshipType :: AssetRelationshipType
hierarchyInfo :: Maybe AssetHierarchyInfo
$sel:relationshipType:AssetRelationshipSummary' :: AssetRelationshipSummary -> AssetRelationshipType
$sel:hierarchyInfo:AssetRelationshipSummary' :: AssetRelationshipSummary -> Maybe AssetHierarchyInfo
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AssetHierarchyInfo
hierarchyInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AssetRelationshipType
relationshipType