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

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

-- | Contains an asset model hierarchy used in asset model creation. An asset
-- model hierarchy determines the kind (or type) of asset that can belong
-- to a hierarchy.
--
-- /See:/ 'newAssetModelHierarchyDefinition' smart constructor.
data AssetModelHierarchyDefinition = AssetModelHierarchyDefinition'
  { -- | The name of the asset model hierarchy definition (as specified in the
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_CreateAssetModel.html CreateAssetModel>
    -- or
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_UpdateAssetModel.html UpdateAssetModel>
    -- API operation).
    AssetModelHierarchyDefinition -> Text
name :: Prelude.Text,
    -- | The ID of an asset model for this hierarchy.
    AssetModelHierarchyDefinition -> Text
childAssetModelId :: Prelude.Text
  }
  deriving (AssetModelHierarchyDefinition
-> AssetModelHierarchyDefinition -> Bool
(AssetModelHierarchyDefinition
 -> AssetModelHierarchyDefinition -> Bool)
-> (AssetModelHierarchyDefinition
    -> AssetModelHierarchyDefinition -> Bool)
-> Eq AssetModelHierarchyDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetModelHierarchyDefinition
-> AssetModelHierarchyDefinition -> Bool
$c/= :: AssetModelHierarchyDefinition
-> AssetModelHierarchyDefinition -> Bool
== :: AssetModelHierarchyDefinition
-> AssetModelHierarchyDefinition -> Bool
$c== :: AssetModelHierarchyDefinition
-> AssetModelHierarchyDefinition -> Bool
Prelude.Eq, ReadPrec [AssetModelHierarchyDefinition]
ReadPrec AssetModelHierarchyDefinition
Int -> ReadS AssetModelHierarchyDefinition
ReadS [AssetModelHierarchyDefinition]
(Int -> ReadS AssetModelHierarchyDefinition)
-> ReadS [AssetModelHierarchyDefinition]
-> ReadPrec AssetModelHierarchyDefinition
-> ReadPrec [AssetModelHierarchyDefinition]
-> Read AssetModelHierarchyDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetModelHierarchyDefinition]
$creadListPrec :: ReadPrec [AssetModelHierarchyDefinition]
readPrec :: ReadPrec AssetModelHierarchyDefinition
$creadPrec :: ReadPrec AssetModelHierarchyDefinition
readList :: ReadS [AssetModelHierarchyDefinition]
$creadList :: ReadS [AssetModelHierarchyDefinition]
readsPrec :: Int -> ReadS AssetModelHierarchyDefinition
$creadsPrec :: Int -> ReadS AssetModelHierarchyDefinition
Prelude.Read, Int -> AssetModelHierarchyDefinition -> ShowS
[AssetModelHierarchyDefinition] -> ShowS
AssetModelHierarchyDefinition -> String
(Int -> AssetModelHierarchyDefinition -> ShowS)
-> (AssetModelHierarchyDefinition -> String)
-> ([AssetModelHierarchyDefinition] -> ShowS)
-> Show AssetModelHierarchyDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetModelHierarchyDefinition] -> ShowS
$cshowList :: [AssetModelHierarchyDefinition] -> ShowS
show :: AssetModelHierarchyDefinition -> String
$cshow :: AssetModelHierarchyDefinition -> String
showsPrec :: Int -> AssetModelHierarchyDefinition -> ShowS
$cshowsPrec :: Int -> AssetModelHierarchyDefinition -> ShowS
Prelude.Show, (forall x.
 AssetModelHierarchyDefinition
 -> Rep AssetModelHierarchyDefinition x)
-> (forall x.
    Rep AssetModelHierarchyDefinition x
    -> AssetModelHierarchyDefinition)
-> Generic AssetModelHierarchyDefinition
forall x.
Rep AssetModelHierarchyDefinition x
-> AssetModelHierarchyDefinition
forall x.
AssetModelHierarchyDefinition
-> Rep AssetModelHierarchyDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssetModelHierarchyDefinition x
-> AssetModelHierarchyDefinition
$cfrom :: forall x.
AssetModelHierarchyDefinition
-> Rep AssetModelHierarchyDefinition x
Prelude.Generic)

-- |
-- Create a value of 'AssetModelHierarchyDefinition' 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:
--
-- 'name', 'assetModelHierarchyDefinition_name' - The name of the asset model hierarchy definition (as specified in the
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_CreateAssetModel.html CreateAssetModel>
-- or
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_UpdateAssetModel.html UpdateAssetModel>
-- API operation).
--
-- 'childAssetModelId', 'assetModelHierarchyDefinition_childAssetModelId' - The ID of an asset model for this hierarchy.
newAssetModelHierarchyDefinition ::
  -- | 'name'
  Prelude.Text ->
  -- | 'childAssetModelId'
  Prelude.Text ->
  AssetModelHierarchyDefinition
newAssetModelHierarchyDefinition :: Text -> Text -> AssetModelHierarchyDefinition
newAssetModelHierarchyDefinition
  Text
pName_
  Text
pChildAssetModelId_ =
    AssetModelHierarchyDefinition' :: Text -> Text -> AssetModelHierarchyDefinition
AssetModelHierarchyDefinition'
      { $sel:name:AssetModelHierarchyDefinition' :: Text
name = Text
pName_,
        $sel:childAssetModelId:AssetModelHierarchyDefinition' :: Text
childAssetModelId = Text
pChildAssetModelId_
      }

-- | The name of the asset model hierarchy definition (as specified in the
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_CreateAssetModel.html CreateAssetModel>
-- or
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_UpdateAssetModel.html UpdateAssetModel>
-- API operation).
assetModelHierarchyDefinition_name :: Lens.Lens' AssetModelHierarchyDefinition Prelude.Text
assetModelHierarchyDefinition_name :: (Text -> f Text)
-> AssetModelHierarchyDefinition -> f AssetModelHierarchyDefinition
assetModelHierarchyDefinition_name = (AssetModelHierarchyDefinition -> Text)
-> (AssetModelHierarchyDefinition
    -> Text -> AssetModelHierarchyDefinition)
-> Lens
     AssetModelHierarchyDefinition
     AssetModelHierarchyDefinition
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelHierarchyDefinition' {Text
name :: Text
$sel:name:AssetModelHierarchyDefinition' :: AssetModelHierarchyDefinition -> Text
name} -> Text
name) (\s :: AssetModelHierarchyDefinition
s@AssetModelHierarchyDefinition' {} Text
a -> AssetModelHierarchyDefinition
s {$sel:name:AssetModelHierarchyDefinition' :: Text
name = Text
a} :: AssetModelHierarchyDefinition)

-- | The ID of an asset model for this hierarchy.
assetModelHierarchyDefinition_childAssetModelId :: Lens.Lens' AssetModelHierarchyDefinition Prelude.Text
assetModelHierarchyDefinition_childAssetModelId :: (Text -> f Text)
-> AssetModelHierarchyDefinition -> f AssetModelHierarchyDefinition
assetModelHierarchyDefinition_childAssetModelId = (AssetModelHierarchyDefinition -> Text)
-> (AssetModelHierarchyDefinition
    -> Text -> AssetModelHierarchyDefinition)
-> Lens
     AssetModelHierarchyDefinition
     AssetModelHierarchyDefinition
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelHierarchyDefinition' {Text
childAssetModelId :: Text
$sel:childAssetModelId:AssetModelHierarchyDefinition' :: AssetModelHierarchyDefinition -> Text
childAssetModelId} -> Text
childAssetModelId) (\s :: AssetModelHierarchyDefinition
s@AssetModelHierarchyDefinition' {} Text
a -> AssetModelHierarchyDefinition
s {$sel:childAssetModelId:AssetModelHierarchyDefinition' :: Text
childAssetModelId = Text
a} :: AssetModelHierarchyDefinition)

instance
  Prelude.Hashable
    AssetModelHierarchyDefinition

instance Prelude.NFData AssetModelHierarchyDefinition

instance Core.ToJSON AssetModelHierarchyDefinition where
  toJSON :: AssetModelHierarchyDefinition -> Value
toJSON AssetModelHierarchyDefinition' {Text
childAssetModelId :: Text
name :: Text
$sel:childAssetModelId:AssetModelHierarchyDefinition' :: AssetModelHierarchyDefinition -> Text
$sel:name:AssetModelHierarchyDefinition' :: AssetModelHierarchyDefinition -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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)
          ]
      )