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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.AssetHierarchyInfo
import Amazonka.IoTSiteWise.Types.AssetRelationshipType
import qualified Amazonka.Lens as Lens
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
(AssetRelationshipSummary -> AssetRelationshipSummary -> Bool)
-> (AssetRelationshipSummary -> AssetRelationshipSummary -> Bool)
-> Eq AssetRelationshipSummary
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]
(Int -> ReadS AssetRelationshipSummary)
-> ReadS [AssetRelationshipSummary]
-> ReadPrec AssetRelationshipSummary
-> ReadPrec [AssetRelationshipSummary]
-> Read 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
(Int -> AssetRelationshipSummary -> ShowS)
-> (AssetRelationshipSummary -> String)
-> ([AssetRelationshipSummary] -> ShowS)
-> Show AssetRelationshipSummary
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.
 AssetRelationshipSummary -> Rep AssetRelationshipSummary x)
-> (forall x.
    Rep AssetRelationshipSummary x -> AssetRelationshipSummary)
-> Generic AssetRelationshipSummary
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' :: Maybe AssetHierarchyInfo
-> AssetRelationshipType -> AssetRelationshipSummary
AssetRelationshipSummary'
    { $sel:hierarchyInfo:AssetRelationshipSummary' :: Maybe AssetHierarchyInfo
hierarchyInfo =
        Maybe AssetHierarchyInfo
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 :: (Maybe AssetHierarchyInfo -> f (Maybe AssetHierarchyInfo))
-> AssetRelationshipSummary -> f AssetRelationshipSummary
assetRelationshipSummary_hierarchyInfo = (AssetRelationshipSummary -> Maybe AssetHierarchyInfo)
-> (AssetRelationshipSummary
    -> Maybe AssetHierarchyInfo -> AssetRelationshipSummary)
-> Lens
     AssetRelationshipSummary
     AssetRelationshipSummary
     (Maybe AssetHierarchyInfo)
     (Maybe AssetHierarchyInfo)
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 :: (AssetRelationshipType -> f AssetRelationshipType)
-> AssetRelationshipSummary -> f AssetRelationshipSummary
assetRelationshipSummary_relationshipType = (AssetRelationshipSummary -> AssetRelationshipType)
-> (AssetRelationshipSummary
    -> AssetRelationshipType -> AssetRelationshipSummary)
-> Lens
     AssetRelationshipSummary
     AssetRelationshipSummary
     AssetRelationshipType
     AssetRelationshipType
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 Core.FromJSON AssetRelationshipSummary where
  parseJSON :: Value -> Parser AssetRelationshipSummary
parseJSON =
    String
-> (Object -> Parser AssetRelationshipSummary)
-> Value
-> Parser AssetRelationshipSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssetRelationshipSummary"
      ( \Object
x ->
          Maybe AssetHierarchyInfo
-> AssetRelationshipType -> AssetRelationshipSummary
AssetRelationshipSummary'
            (Maybe AssetHierarchyInfo
 -> AssetRelationshipType -> AssetRelationshipSummary)
-> Parser (Maybe AssetHierarchyInfo)
-> Parser (AssetRelationshipType -> AssetRelationshipSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AssetHierarchyInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"hierarchyInfo")
            Parser (AssetRelationshipType -> AssetRelationshipSummary)
-> Parser AssetRelationshipType -> Parser AssetRelationshipSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AssetRelationshipType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"relationshipType")
      )

instance Prelude.Hashable AssetRelationshipSummary

instance Prelude.NFData AssetRelationshipSummary