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

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

instance Prelude.Hashable AssetHierarchy

instance Prelude.NFData AssetHierarchy