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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.AssetProperty
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a composite model in an asset. This object
-- contains the asset\'s properties that you define in the composite model.
--
-- /See:/ 'newAssetCompositeModel' smart constructor.
data AssetCompositeModel = AssetCompositeModel'
  { -- | The description of the composite model.
    AssetCompositeModel -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the composite model.
    AssetCompositeModel -> Text
name :: Prelude.Text,
    -- | The type of the composite model. For alarm composite models, this type
    -- is @AWS\/ALARM@.
    AssetCompositeModel -> Text
type' :: Prelude.Text,
    -- | The asset properties that this composite model defines.
    AssetCompositeModel -> [AssetProperty]
properties :: [AssetProperty]
  }
  deriving (AssetCompositeModel -> AssetCompositeModel -> Bool
(AssetCompositeModel -> AssetCompositeModel -> Bool)
-> (AssetCompositeModel -> AssetCompositeModel -> Bool)
-> Eq AssetCompositeModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetCompositeModel -> AssetCompositeModel -> Bool
$c/= :: AssetCompositeModel -> AssetCompositeModel -> Bool
== :: AssetCompositeModel -> AssetCompositeModel -> Bool
$c== :: AssetCompositeModel -> AssetCompositeModel -> Bool
Prelude.Eq, ReadPrec [AssetCompositeModel]
ReadPrec AssetCompositeModel
Int -> ReadS AssetCompositeModel
ReadS [AssetCompositeModel]
(Int -> ReadS AssetCompositeModel)
-> ReadS [AssetCompositeModel]
-> ReadPrec AssetCompositeModel
-> ReadPrec [AssetCompositeModel]
-> Read AssetCompositeModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetCompositeModel]
$creadListPrec :: ReadPrec [AssetCompositeModel]
readPrec :: ReadPrec AssetCompositeModel
$creadPrec :: ReadPrec AssetCompositeModel
readList :: ReadS [AssetCompositeModel]
$creadList :: ReadS [AssetCompositeModel]
readsPrec :: Int -> ReadS AssetCompositeModel
$creadsPrec :: Int -> ReadS AssetCompositeModel
Prelude.Read, Int -> AssetCompositeModel -> ShowS
[AssetCompositeModel] -> ShowS
AssetCompositeModel -> String
(Int -> AssetCompositeModel -> ShowS)
-> (AssetCompositeModel -> String)
-> ([AssetCompositeModel] -> ShowS)
-> Show AssetCompositeModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetCompositeModel] -> ShowS
$cshowList :: [AssetCompositeModel] -> ShowS
show :: AssetCompositeModel -> String
$cshow :: AssetCompositeModel -> String
showsPrec :: Int -> AssetCompositeModel -> ShowS
$cshowsPrec :: Int -> AssetCompositeModel -> ShowS
Prelude.Show, (forall x. AssetCompositeModel -> Rep AssetCompositeModel x)
-> (forall x. Rep AssetCompositeModel x -> AssetCompositeModel)
-> Generic AssetCompositeModel
forall x. Rep AssetCompositeModel x -> AssetCompositeModel
forall x. AssetCompositeModel -> Rep AssetCompositeModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetCompositeModel x -> AssetCompositeModel
$cfrom :: forall x. AssetCompositeModel -> Rep AssetCompositeModel x
Prelude.Generic)

-- |
-- Create a value of 'AssetCompositeModel' 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:
--
-- 'description', 'assetCompositeModel_description' - The description of the composite model.
--
-- 'name', 'assetCompositeModel_name' - The name of the composite model.
--
-- 'type'', 'assetCompositeModel_type' - The type of the composite model. For alarm composite models, this type
-- is @AWS\/ALARM@.
--
-- 'properties', 'assetCompositeModel_properties' - The asset properties that this composite model defines.
newAssetCompositeModel ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  Prelude.Text ->
  AssetCompositeModel
newAssetCompositeModel :: Text -> Text -> AssetCompositeModel
newAssetCompositeModel Text
pName_ Text
pType_ =
  AssetCompositeModel' :: Maybe Text
-> Text -> Text -> [AssetProperty] -> AssetCompositeModel
AssetCompositeModel'
    { $sel:description:AssetCompositeModel' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AssetCompositeModel' :: Text
name = Text
pName_,
      $sel:type':AssetCompositeModel' :: Text
type' = Text
pType_,
      $sel:properties:AssetCompositeModel' :: [AssetProperty]
properties = [AssetProperty]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The description of the composite model.
assetCompositeModel_description :: Lens.Lens' AssetCompositeModel (Prelude.Maybe Prelude.Text)
assetCompositeModel_description :: (Maybe Text -> f (Maybe Text))
-> AssetCompositeModel -> f AssetCompositeModel
assetCompositeModel_description = (AssetCompositeModel -> Maybe Text)
-> (AssetCompositeModel -> Maybe Text -> AssetCompositeModel)
-> Lens
     AssetCompositeModel AssetCompositeModel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetCompositeModel' {Maybe Text
description :: Maybe Text
$sel:description:AssetCompositeModel' :: AssetCompositeModel -> Maybe Text
description} -> Maybe Text
description) (\s :: AssetCompositeModel
s@AssetCompositeModel' {} Maybe Text
a -> AssetCompositeModel
s {$sel:description:AssetCompositeModel' :: Maybe Text
description = Maybe Text
a} :: AssetCompositeModel)

-- | The name of the composite model.
assetCompositeModel_name :: Lens.Lens' AssetCompositeModel Prelude.Text
assetCompositeModel_name :: (Text -> f Text) -> AssetCompositeModel -> f AssetCompositeModel
assetCompositeModel_name = (AssetCompositeModel -> Text)
-> (AssetCompositeModel -> Text -> AssetCompositeModel)
-> Lens AssetCompositeModel AssetCompositeModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetCompositeModel' {Text
name :: Text
$sel:name:AssetCompositeModel' :: AssetCompositeModel -> Text
name} -> Text
name) (\s :: AssetCompositeModel
s@AssetCompositeModel' {} Text
a -> AssetCompositeModel
s {$sel:name:AssetCompositeModel' :: Text
name = Text
a} :: AssetCompositeModel)

-- | The type of the composite model. For alarm composite models, this type
-- is @AWS\/ALARM@.
assetCompositeModel_type :: Lens.Lens' AssetCompositeModel Prelude.Text
assetCompositeModel_type :: (Text -> f Text) -> AssetCompositeModel -> f AssetCompositeModel
assetCompositeModel_type = (AssetCompositeModel -> Text)
-> (AssetCompositeModel -> Text -> AssetCompositeModel)
-> Lens AssetCompositeModel AssetCompositeModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetCompositeModel' {Text
type' :: Text
$sel:type':AssetCompositeModel' :: AssetCompositeModel -> Text
type'} -> Text
type') (\s :: AssetCompositeModel
s@AssetCompositeModel' {} Text
a -> AssetCompositeModel
s {$sel:type':AssetCompositeModel' :: Text
type' = Text
a} :: AssetCompositeModel)

-- | The asset properties that this composite model defines.
assetCompositeModel_properties :: Lens.Lens' AssetCompositeModel [AssetProperty]
assetCompositeModel_properties :: ([AssetProperty] -> f [AssetProperty])
-> AssetCompositeModel -> f AssetCompositeModel
assetCompositeModel_properties = (AssetCompositeModel -> [AssetProperty])
-> (AssetCompositeModel -> [AssetProperty] -> AssetCompositeModel)
-> Lens
     AssetCompositeModel
     AssetCompositeModel
     [AssetProperty]
     [AssetProperty]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetCompositeModel' {[AssetProperty]
properties :: [AssetProperty]
$sel:properties:AssetCompositeModel' :: AssetCompositeModel -> [AssetProperty]
properties} -> [AssetProperty]
properties) (\s :: AssetCompositeModel
s@AssetCompositeModel' {} [AssetProperty]
a -> AssetCompositeModel
s {$sel:properties:AssetCompositeModel' :: [AssetProperty]
properties = [AssetProperty]
a} :: AssetCompositeModel) (([AssetProperty] -> f [AssetProperty])
 -> AssetCompositeModel -> f AssetCompositeModel)
-> (([AssetProperty] -> f [AssetProperty])
    -> [AssetProperty] -> f [AssetProperty])
-> ([AssetProperty] -> f [AssetProperty])
-> AssetCompositeModel
-> f AssetCompositeModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AssetProperty] -> f [AssetProperty])
-> [AssetProperty] -> f [AssetProperty]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AssetCompositeModel where
  parseJSON :: Value -> Parser AssetCompositeModel
parseJSON =
    String
-> (Object -> Parser AssetCompositeModel)
-> Value
-> Parser AssetCompositeModel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssetCompositeModel"
      ( \Object
x ->
          Maybe Text
-> Text -> Text -> [AssetProperty] -> AssetCompositeModel
AssetCompositeModel'
            (Maybe Text
 -> Text -> Text -> [AssetProperty] -> AssetCompositeModel)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> [AssetProperty] -> AssetCompositeModel)
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
"description")
            Parser (Text -> Text -> [AssetProperty] -> AssetCompositeModel)
-> Parser Text
-> Parser (Text -> [AssetProperty] -> AssetCompositeModel)
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")
            Parser (Text -> [AssetProperty] -> AssetCompositeModel)
-> Parser Text -> Parser ([AssetProperty] -> AssetCompositeModel)
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
"type")
            Parser ([AssetProperty] -> AssetCompositeModel)
-> Parser [AssetProperty] -> Parser AssetCompositeModel
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [AssetProperty])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"properties" Parser (Maybe [AssetProperty])
-> [AssetProperty] -> Parser [AssetProperty]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [AssetProperty]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AssetCompositeModel

instance Prelude.NFData AssetCompositeModel