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

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

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

-- |
-- Create a value of 'AssetModelCompositeModel' 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', 'assetModelCompositeModel_description' - The description of the composite model.
--
-- 'properties', 'assetModelCompositeModel_properties' - The asset property definitions for this composite model.
--
-- 'name', 'assetModelCompositeModel_name' - The name of the composite model.
--
-- 'type'', 'assetModelCompositeModel_type' - The type of the composite model. For alarm composite models, this type
-- is @AWS\/ALARM@.
newAssetModelCompositeModel ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  Prelude.Text ->
  AssetModelCompositeModel
newAssetModelCompositeModel :: Text -> Text -> AssetModelCompositeModel
newAssetModelCompositeModel Text
pName_ Text
pType_ =
  AssetModelCompositeModel' :: Maybe Text
-> Maybe [AssetModelProperty]
-> Text
-> Text
-> AssetModelCompositeModel
AssetModelCompositeModel'
    { $sel:description:AssetModelCompositeModel' :: Maybe Text
description =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:properties:AssetModelCompositeModel' :: Maybe [AssetModelProperty]
properties = Maybe [AssetModelProperty]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AssetModelCompositeModel' :: Text
name = Text
pName_,
      $sel:type':AssetModelCompositeModel' :: Text
type' = Text
pType_
    }

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

-- | The asset property definitions for this composite model.
assetModelCompositeModel_properties :: Lens.Lens' AssetModelCompositeModel (Prelude.Maybe [AssetModelProperty])
assetModelCompositeModel_properties :: (Maybe [AssetModelProperty] -> f (Maybe [AssetModelProperty]))
-> AssetModelCompositeModel -> f AssetModelCompositeModel
assetModelCompositeModel_properties = (AssetModelCompositeModel -> Maybe [AssetModelProperty])
-> (AssetModelCompositeModel
    -> Maybe [AssetModelProperty] -> AssetModelCompositeModel)
-> Lens
     AssetModelCompositeModel
     AssetModelCompositeModel
     (Maybe [AssetModelProperty])
     (Maybe [AssetModelProperty])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelCompositeModel' {Maybe [AssetModelProperty]
properties :: Maybe [AssetModelProperty]
$sel:properties:AssetModelCompositeModel' :: AssetModelCompositeModel -> Maybe [AssetModelProperty]
properties} -> Maybe [AssetModelProperty]
properties) (\s :: AssetModelCompositeModel
s@AssetModelCompositeModel' {} Maybe [AssetModelProperty]
a -> AssetModelCompositeModel
s {$sel:properties:AssetModelCompositeModel' :: Maybe [AssetModelProperty]
properties = Maybe [AssetModelProperty]
a} :: AssetModelCompositeModel) ((Maybe [AssetModelProperty] -> f (Maybe [AssetModelProperty]))
 -> AssetModelCompositeModel -> f AssetModelCompositeModel)
-> ((Maybe [AssetModelProperty] -> f (Maybe [AssetModelProperty]))
    -> Maybe [AssetModelProperty] -> f (Maybe [AssetModelProperty]))
-> (Maybe [AssetModelProperty] -> f (Maybe [AssetModelProperty]))
-> AssetModelCompositeModel
-> f AssetModelCompositeModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AssetModelProperty]
  [AssetModelProperty]
  [AssetModelProperty]
  [AssetModelProperty]
-> Iso
     (Maybe [AssetModelProperty])
     (Maybe [AssetModelProperty])
     (Maybe [AssetModelProperty])
     (Maybe [AssetModelProperty])
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
  [AssetModelProperty]
  [AssetModelProperty]
  [AssetModelProperty]
  [AssetModelProperty]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

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

instance Prelude.Hashable AssetModelCompositeModel

instance Prelude.NFData AssetModelCompositeModel

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