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

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

-- | Contains a composite model definition in an asset model. This composite
-- model definition is applied to all assets created from the asset model.
--
-- /See:/ 'newAssetModelCompositeModelDefinition' smart constructor.
data AssetModelCompositeModelDefinition = AssetModelCompositeModelDefinition'
  { -- | The description of the composite model.
    AssetModelCompositeModelDefinition -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The asset property definitions for this composite model.
    AssetModelCompositeModelDefinition
-> Maybe [AssetModelPropertyDefinition]
properties :: Prelude.Maybe [AssetModelPropertyDefinition],
    -- | The name of the composite model.
    AssetModelCompositeModelDefinition -> Text
name :: Prelude.Text,
    -- | The type of the composite model. For alarm composite models, this type
    -- is @AWS\/ALARM@.
    AssetModelCompositeModelDefinition -> Text
type' :: Prelude.Text
  }
  deriving (AssetModelCompositeModelDefinition
-> AssetModelCompositeModelDefinition -> Bool
(AssetModelCompositeModelDefinition
 -> AssetModelCompositeModelDefinition -> Bool)
-> (AssetModelCompositeModelDefinition
    -> AssetModelCompositeModelDefinition -> Bool)
-> Eq AssetModelCompositeModelDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetModelCompositeModelDefinition
-> AssetModelCompositeModelDefinition -> Bool
$c/= :: AssetModelCompositeModelDefinition
-> AssetModelCompositeModelDefinition -> Bool
== :: AssetModelCompositeModelDefinition
-> AssetModelCompositeModelDefinition -> Bool
$c== :: AssetModelCompositeModelDefinition
-> AssetModelCompositeModelDefinition -> Bool
Prelude.Eq, ReadPrec [AssetModelCompositeModelDefinition]
ReadPrec AssetModelCompositeModelDefinition
Int -> ReadS AssetModelCompositeModelDefinition
ReadS [AssetModelCompositeModelDefinition]
(Int -> ReadS AssetModelCompositeModelDefinition)
-> ReadS [AssetModelCompositeModelDefinition]
-> ReadPrec AssetModelCompositeModelDefinition
-> ReadPrec [AssetModelCompositeModelDefinition]
-> Read AssetModelCompositeModelDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetModelCompositeModelDefinition]
$creadListPrec :: ReadPrec [AssetModelCompositeModelDefinition]
readPrec :: ReadPrec AssetModelCompositeModelDefinition
$creadPrec :: ReadPrec AssetModelCompositeModelDefinition
readList :: ReadS [AssetModelCompositeModelDefinition]
$creadList :: ReadS [AssetModelCompositeModelDefinition]
readsPrec :: Int -> ReadS AssetModelCompositeModelDefinition
$creadsPrec :: Int -> ReadS AssetModelCompositeModelDefinition
Prelude.Read, Int -> AssetModelCompositeModelDefinition -> ShowS
[AssetModelCompositeModelDefinition] -> ShowS
AssetModelCompositeModelDefinition -> String
(Int -> AssetModelCompositeModelDefinition -> ShowS)
-> (AssetModelCompositeModelDefinition -> String)
-> ([AssetModelCompositeModelDefinition] -> ShowS)
-> Show AssetModelCompositeModelDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetModelCompositeModelDefinition] -> ShowS
$cshowList :: [AssetModelCompositeModelDefinition] -> ShowS
show :: AssetModelCompositeModelDefinition -> String
$cshow :: AssetModelCompositeModelDefinition -> String
showsPrec :: Int -> AssetModelCompositeModelDefinition -> ShowS
$cshowsPrec :: Int -> AssetModelCompositeModelDefinition -> ShowS
Prelude.Show, (forall x.
 AssetModelCompositeModelDefinition
 -> Rep AssetModelCompositeModelDefinition x)
-> (forall x.
    Rep AssetModelCompositeModelDefinition x
    -> AssetModelCompositeModelDefinition)
-> Generic AssetModelCompositeModelDefinition
forall x.
Rep AssetModelCompositeModelDefinition x
-> AssetModelCompositeModelDefinition
forall x.
AssetModelCompositeModelDefinition
-> Rep AssetModelCompositeModelDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssetModelCompositeModelDefinition x
-> AssetModelCompositeModelDefinition
$cfrom :: forall x.
AssetModelCompositeModelDefinition
-> Rep AssetModelCompositeModelDefinition x
Prelude.Generic)

-- |
-- Create a value of 'AssetModelCompositeModelDefinition' 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', 'assetModelCompositeModelDefinition_description' - The description of the composite model.
--
-- 'properties', 'assetModelCompositeModelDefinition_properties' - The asset property definitions for this composite model.
--
-- 'name', 'assetModelCompositeModelDefinition_name' - The name of the composite model.
--
-- 'type'', 'assetModelCompositeModelDefinition_type' - The type of the composite model. For alarm composite models, this type
-- is @AWS\/ALARM@.
newAssetModelCompositeModelDefinition ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  Prelude.Text ->
  AssetModelCompositeModelDefinition
newAssetModelCompositeModelDefinition :: Text -> Text -> AssetModelCompositeModelDefinition
newAssetModelCompositeModelDefinition Text
pName_ Text
pType_ =
  AssetModelCompositeModelDefinition' :: Maybe Text
-> Maybe [AssetModelPropertyDefinition]
-> Text
-> Text
-> AssetModelCompositeModelDefinition
AssetModelCompositeModelDefinition'
    { $sel:description:AssetModelCompositeModelDefinition' :: Maybe Text
description =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:properties:AssetModelCompositeModelDefinition' :: Maybe [AssetModelPropertyDefinition]
properties = Maybe [AssetModelPropertyDefinition]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AssetModelCompositeModelDefinition' :: Text
name = Text
pName_,
      $sel:type':AssetModelCompositeModelDefinition' :: Text
type' = Text
pType_
    }

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

-- | The asset property definitions for this composite model.
assetModelCompositeModelDefinition_properties :: Lens.Lens' AssetModelCompositeModelDefinition (Prelude.Maybe [AssetModelPropertyDefinition])
assetModelCompositeModelDefinition_properties :: (Maybe [AssetModelPropertyDefinition]
 -> f (Maybe [AssetModelPropertyDefinition]))
-> AssetModelCompositeModelDefinition
-> f AssetModelCompositeModelDefinition
assetModelCompositeModelDefinition_properties = (AssetModelCompositeModelDefinition
 -> Maybe [AssetModelPropertyDefinition])
-> (AssetModelCompositeModelDefinition
    -> Maybe [AssetModelPropertyDefinition]
    -> AssetModelCompositeModelDefinition)
-> Lens
     AssetModelCompositeModelDefinition
     AssetModelCompositeModelDefinition
     (Maybe [AssetModelPropertyDefinition])
     (Maybe [AssetModelPropertyDefinition])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelCompositeModelDefinition' {Maybe [AssetModelPropertyDefinition]
properties :: Maybe [AssetModelPropertyDefinition]
$sel:properties:AssetModelCompositeModelDefinition' :: AssetModelCompositeModelDefinition
-> Maybe [AssetModelPropertyDefinition]
properties} -> Maybe [AssetModelPropertyDefinition]
properties) (\s :: AssetModelCompositeModelDefinition
s@AssetModelCompositeModelDefinition' {} Maybe [AssetModelPropertyDefinition]
a -> AssetModelCompositeModelDefinition
s {$sel:properties:AssetModelCompositeModelDefinition' :: Maybe [AssetModelPropertyDefinition]
properties = Maybe [AssetModelPropertyDefinition]
a} :: AssetModelCompositeModelDefinition) ((Maybe [AssetModelPropertyDefinition]
  -> f (Maybe [AssetModelPropertyDefinition]))
 -> AssetModelCompositeModelDefinition
 -> f AssetModelCompositeModelDefinition)
-> ((Maybe [AssetModelPropertyDefinition]
     -> f (Maybe [AssetModelPropertyDefinition]))
    -> Maybe [AssetModelPropertyDefinition]
    -> f (Maybe [AssetModelPropertyDefinition]))
-> (Maybe [AssetModelPropertyDefinition]
    -> f (Maybe [AssetModelPropertyDefinition]))
-> AssetModelCompositeModelDefinition
-> f AssetModelCompositeModelDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AssetModelPropertyDefinition]
  [AssetModelPropertyDefinition]
  [AssetModelPropertyDefinition]
  [AssetModelPropertyDefinition]
-> Iso
     (Maybe [AssetModelPropertyDefinition])
     (Maybe [AssetModelPropertyDefinition])
     (Maybe [AssetModelPropertyDefinition])
     (Maybe [AssetModelPropertyDefinition])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [AssetModelPropertyDefinition]
  [AssetModelPropertyDefinition]
  [AssetModelPropertyDefinition]
  [AssetModelPropertyDefinition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance
  Prelude.Hashable
    AssetModelCompositeModelDefinition

instance
  Prelude.NFData
    AssetModelCompositeModelDefinition

instance
  Core.ToJSON
    AssetModelCompositeModelDefinition
  where
  toJSON :: AssetModelCompositeModelDefinition -> Value
toJSON AssetModelCompositeModelDefinition' {Maybe [AssetModelPropertyDefinition]
Maybe Text
Text
type' :: Text
name :: Text
properties :: Maybe [AssetModelPropertyDefinition]
description :: Maybe Text
$sel:type':AssetModelCompositeModelDefinition' :: AssetModelCompositeModelDefinition -> Text
$sel:name:AssetModelCompositeModelDefinition' :: AssetModelCompositeModelDefinition -> Text
$sel:properties:AssetModelCompositeModelDefinition' :: AssetModelCompositeModelDefinition
-> Maybe [AssetModelPropertyDefinition]
$sel:description:AssetModelCompositeModelDefinition' :: AssetModelCompositeModelDefinition -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"properties" Text -> [AssetModelPropertyDefinition] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AssetModelPropertyDefinition] -> Pair)
-> Maybe [AssetModelPropertyDefinition] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AssetModelPropertyDefinition]
properties,
            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
"type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
type')
          ]
      )