{-# 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.AssetHierarchy
-- 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.AssetHierarchy 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

-- | Describes an asset hierarchy that contains a hierarchy\'s name and ID.
--
-- /See:/ 'newAssetHierarchy' smart constructor.
data AssetHierarchy = AssetHierarchy'
  { -- | The ID of the hierarchy. This ID is a @hierarchyId@.
    AssetHierarchy -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The hierarchy name provided 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.
    AssetHierarchy -> Text
name :: Prelude.Text
  }
  deriving (AssetHierarchy -> AssetHierarchy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetHierarchy -> AssetHierarchy -> Bool
$c/= :: AssetHierarchy -> AssetHierarchy -> Bool
== :: AssetHierarchy -> AssetHierarchy -> Bool
$c== :: AssetHierarchy -> AssetHierarchy -> Bool
Prelude.Eq, ReadPrec [AssetHierarchy]
ReadPrec AssetHierarchy
Int -> ReadS AssetHierarchy
ReadS [AssetHierarchy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetHierarchy]
$creadListPrec :: ReadPrec [AssetHierarchy]
readPrec :: ReadPrec AssetHierarchy
$creadPrec :: ReadPrec AssetHierarchy
readList :: ReadS [AssetHierarchy]
$creadList :: ReadS [AssetHierarchy]
readsPrec :: Int -> ReadS AssetHierarchy
$creadsPrec :: Int -> ReadS AssetHierarchy
Prelude.Read, Int -> AssetHierarchy -> ShowS
[AssetHierarchy] -> ShowS
AssetHierarchy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetHierarchy] -> ShowS
$cshowList :: [AssetHierarchy] -> ShowS
show :: AssetHierarchy -> String
$cshow :: AssetHierarchy -> String
showsPrec :: Int -> AssetHierarchy -> ShowS
$cshowsPrec :: Int -> AssetHierarchy -> ShowS
Prelude.Show, forall x. Rep AssetHierarchy x -> AssetHierarchy
forall x. AssetHierarchy -> Rep AssetHierarchy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetHierarchy x -> AssetHierarchy
$cfrom :: forall x. AssetHierarchy -> Rep AssetHierarchy x
Prelude.Generic)

-- |
-- Create a value of 'AssetHierarchy' 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:
--
-- 'id', 'assetHierarchy_id' - The ID of the hierarchy. This ID is a @hierarchyId@.
--
-- 'name', 'assetHierarchy_name' - The hierarchy name provided 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.
newAssetHierarchy ::
  -- | 'name'
  Prelude.Text ->
  AssetHierarchy
newAssetHierarchy :: Text -> AssetHierarchy
newAssetHierarchy Text
pName_ =
  AssetHierarchy'
    { $sel:id:AssetHierarchy' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:AssetHierarchy' :: Text
name = Text
pName_
    }

-- | The ID of the hierarchy. This ID is a @hierarchyId@.
assetHierarchy_id :: Lens.Lens' AssetHierarchy (Prelude.Maybe Prelude.Text)
assetHierarchy_id :: Lens' AssetHierarchy (Maybe Text)
assetHierarchy_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetHierarchy' {Maybe Text
id :: Maybe Text
$sel:id:AssetHierarchy' :: AssetHierarchy -> Maybe Text
id} -> Maybe Text
id) (\s :: AssetHierarchy
s@AssetHierarchy' {} Maybe Text
a -> AssetHierarchy
s {$sel:id:AssetHierarchy' :: Maybe Text
id = Maybe Text
a} :: AssetHierarchy)

-- | The hierarchy name provided 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.
assetHierarchy_name :: Lens.Lens' AssetHierarchy Prelude.Text
assetHierarchy_name :: Lens' AssetHierarchy Text
assetHierarchy_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetHierarchy' {Text
name :: Text
$sel:name:AssetHierarchy' :: AssetHierarchy -> Text
name} -> Text
name) (\s :: AssetHierarchy
s@AssetHierarchy' {} Text
a -> AssetHierarchy
s {$sel:name:AssetHierarchy' :: Text
name = Text
a} :: AssetHierarchy)

instance Data.FromJSON AssetHierarchy where
  parseJSON :: Value -> Parser AssetHierarchy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssetHierarchy"
      ( \Object
x ->
          Maybe Text -> Text -> AssetHierarchy
AssetHierarchy'
            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
"id")
            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
"name")
      )

instance Prelude.Hashable AssetHierarchy where
  hashWithSalt :: Int -> AssetHierarchy -> Int
hashWithSalt Int
_salt AssetHierarchy' {Maybe Text
Text
name :: Text
id :: Maybe Text
$sel:name:AssetHierarchy' :: AssetHierarchy -> Text
$sel:id:AssetHierarchy' :: AssetHierarchy -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

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