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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.PropertyDataType
import Amazonka.IoTSiteWise.Types.PropertyType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains an asset model property definition. This property definition is
-- applied to all assets created from the asset model.
--
-- /See:/ 'newAssetModelPropertyDefinition' smart constructor.
data AssetModelPropertyDefinition = AssetModelPropertyDefinition'
  { -- | The data type of the structure for this property. This parameter is
    -- required on properties that have the @STRUCT@ data type.
    --
    -- The options for this parameter depend on the type of the composite model
    -- in which you define this property. Use @AWS\/ALARM_STATE@ for alarm
    -- state in alarm composite models.
    AssetModelPropertyDefinition -> Maybe Text
dataTypeSpec :: Prelude.Maybe Prelude.Text,
    -- | The unit of the property definition, such as @Newtons@ or @RPM@.
    AssetModelPropertyDefinition -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
    -- | The name of the property definition.
    AssetModelPropertyDefinition -> Text
name :: Prelude.Text,
    -- | The data type of the property definition.
    --
    -- If you specify @STRUCT@, you must also specify @dataTypeSpec@ to
    -- identify the type of the structure for this property.
    AssetModelPropertyDefinition -> PropertyDataType
dataType :: PropertyDataType,
    -- | The property definition type (see @PropertyType@). You can only specify
    -- one type in a property definition.
    AssetModelPropertyDefinition -> PropertyType
type' :: PropertyType
  }
  deriving (AssetModelPropertyDefinition
-> AssetModelPropertyDefinition -> Bool
(AssetModelPropertyDefinition
 -> AssetModelPropertyDefinition -> Bool)
-> (AssetModelPropertyDefinition
    -> AssetModelPropertyDefinition -> Bool)
-> Eq AssetModelPropertyDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetModelPropertyDefinition
-> AssetModelPropertyDefinition -> Bool
$c/= :: AssetModelPropertyDefinition
-> AssetModelPropertyDefinition -> Bool
== :: AssetModelPropertyDefinition
-> AssetModelPropertyDefinition -> Bool
$c== :: AssetModelPropertyDefinition
-> AssetModelPropertyDefinition -> Bool
Prelude.Eq, ReadPrec [AssetModelPropertyDefinition]
ReadPrec AssetModelPropertyDefinition
Int -> ReadS AssetModelPropertyDefinition
ReadS [AssetModelPropertyDefinition]
(Int -> ReadS AssetModelPropertyDefinition)
-> ReadS [AssetModelPropertyDefinition]
-> ReadPrec AssetModelPropertyDefinition
-> ReadPrec [AssetModelPropertyDefinition]
-> Read AssetModelPropertyDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetModelPropertyDefinition]
$creadListPrec :: ReadPrec [AssetModelPropertyDefinition]
readPrec :: ReadPrec AssetModelPropertyDefinition
$creadPrec :: ReadPrec AssetModelPropertyDefinition
readList :: ReadS [AssetModelPropertyDefinition]
$creadList :: ReadS [AssetModelPropertyDefinition]
readsPrec :: Int -> ReadS AssetModelPropertyDefinition
$creadsPrec :: Int -> ReadS AssetModelPropertyDefinition
Prelude.Read, Int -> AssetModelPropertyDefinition -> ShowS
[AssetModelPropertyDefinition] -> ShowS
AssetModelPropertyDefinition -> String
(Int -> AssetModelPropertyDefinition -> ShowS)
-> (AssetModelPropertyDefinition -> String)
-> ([AssetModelPropertyDefinition] -> ShowS)
-> Show AssetModelPropertyDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetModelPropertyDefinition] -> ShowS
$cshowList :: [AssetModelPropertyDefinition] -> ShowS
show :: AssetModelPropertyDefinition -> String
$cshow :: AssetModelPropertyDefinition -> String
showsPrec :: Int -> AssetModelPropertyDefinition -> ShowS
$cshowsPrec :: Int -> AssetModelPropertyDefinition -> ShowS
Prelude.Show, (forall x.
 AssetModelPropertyDefinition -> Rep AssetModelPropertyDefinition x)
-> (forall x.
    Rep AssetModelPropertyDefinition x -> AssetModelPropertyDefinition)
-> Generic AssetModelPropertyDefinition
forall x.
Rep AssetModelPropertyDefinition x -> AssetModelPropertyDefinition
forall x.
AssetModelPropertyDefinition -> Rep AssetModelPropertyDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssetModelPropertyDefinition x -> AssetModelPropertyDefinition
$cfrom :: forall x.
AssetModelPropertyDefinition -> Rep AssetModelPropertyDefinition x
Prelude.Generic)

-- |
-- Create a value of 'AssetModelPropertyDefinition' 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:
--
-- 'dataTypeSpec', 'assetModelPropertyDefinition_dataTypeSpec' - The data type of the structure for this property. This parameter is
-- required on properties that have the @STRUCT@ data type.
--
-- The options for this parameter depend on the type of the composite model
-- in which you define this property. Use @AWS\/ALARM_STATE@ for alarm
-- state in alarm composite models.
--
-- 'unit', 'assetModelPropertyDefinition_unit' - The unit of the property definition, such as @Newtons@ or @RPM@.
--
-- 'name', 'assetModelPropertyDefinition_name' - The name of the property definition.
--
-- 'dataType', 'assetModelPropertyDefinition_dataType' - The data type of the property definition.
--
-- If you specify @STRUCT@, you must also specify @dataTypeSpec@ to
-- identify the type of the structure for this property.
--
-- 'type'', 'assetModelPropertyDefinition_type' - The property definition type (see @PropertyType@). You can only specify
-- one type in a property definition.
newAssetModelPropertyDefinition ::
  -- | 'name'
  Prelude.Text ->
  -- | 'dataType'
  PropertyDataType ->
  -- | 'type''
  PropertyType ->
  AssetModelPropertyDefinition
newAssetModelPropertyDefinition :: Text
-> PropertyDataType -> PropertyType -> AssetModelPropertyDefinition
newAssetModelPropertyDefinition
  Text
pName_
  PropertyDataType
pDataType_
  PropertyType
pType_ =
    AssetModelPropertyDefinition' :: Maybe Text
-> Maybe Text
-> Text
-> PropertyDataType
-> PropertyType
-> AssetModelPropertyDefinition
AssetModelPropertyDefinition'
      { $sel:dataTypeSpec:AssetModelPropertyDefinition' :: Maybe Text
dataTypeSpec =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:unit:AssetModelPropertyDefinition' :: Maybe Text
unit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:AssetModelPropertyDefinition' :: Text
name = Text
pName_,
        $sel:dataType:AssetModelPropertyDefinition' :: PropertyDataType
dataType = PropertyDataType
pDataType_,
        $sel:type':AssetModelPropertyDefinition' :: PropertyType
type' = PropertyType
pType_
      }

-- | The data type of the structure for this property. This parameter is
-- required on properties that have the @STRUCT@ data type.
--
-- The options for this parameter depend on the type of the composite model
-- in which you define this property. Use @AWS\/ALARM_STATE@ for alarm
-- state in alarm composite models.
assetModelPropertyDefinition_dataTypeSpec :: Lens.Lens' AssetModelPropertyDefinition (Prelude.Maybe Prelude.Text)
assetModelPropertyDefinition_dataTypeSpec :: (Maybe Text -> f (Maybe Text))
-> AssetModelPropertyDefinition -> f AssetModelPropertyDefinition
assetModelPropertyDefinition_dataTypeSpec = (AssetModelPropertyDefinition -> Maybe Text)
-> (AssetModelPropertyDefinition
    -> Maybe Text -> AssetModelPropertyDefinition)
-> Lens
     AssetModelPropertyDefinition
     AssetModelPropertyDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelPropertyDefinition' {Maybe Text
dataTypeSpec :: Maybe Text
$sel:dataTypeSpec:AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> Maybe Text
dataTypeSpec} -> Maybe Text
dataTypeSpec) (\s :: AssetModelPropertyDefinition
s@AssetModelPropertyDefinition' {} Maybe Text
a -> AssetModelPropertyDefinition
s {$sel:dataTypeSpec:AssetModelPropertyDefinition' :: Maybe Text
dataTypeSpec = Maybe Text
a} :: AssetModelPropertyDefinition)

-- | The unit of the property definition, such as @Newtons@ or @RPM@.
assetModelPropertyDefinition_unit :: Lens.Lens' AssetModelPropertyDefinition (Prelude.Maybe Prelude.Text)
assetModelPropertyDefinition_unit :: (Maybe Text -> f (Maybe Text))
-> AssetModelPropertyDefinition -> f AssetModelPropertyDefinition
assetModelPropertyDefinition_unit = (AssetModelPropertyDefinition -> Maybe Text)
-> (AssetModelPropertyDefinition
    -> Maybe Text -> AssetModelPropertyDefinition)
-> Lens
     AssetModelPropertyDefinition
     AssetModelPropertyDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelPropertyDefinition' {Maybe Text
unit :: Maybe Text
$sel:unit:AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> Maybe Text
unit} -> Maybe Text
unit) (\s :: AssetModelPropertyDefinition
s@AssetModelPropertyDefinition' {} Maybe Text
a -> AssetModelPropertyDefinition
s {$sel:unit:AssetModelPropertyDefinition' :: Maybe Text
unit = Maybe Text
a} :: AssetModelPropertyDefinition)

-- | The name of the property definition.
assetModelPropertyDefinition_name :: Lens.Lens' AssetModelPropertyDefinition Prelude.Text
assetModelPropertyDefinition_name :: (Text -> f Text)
-> AssetModelPropertyDefinition -> f AssetModelPropertyDefinition
assetModelPropertyDefinition_name = (AssetModelPropertyDefinition -> Text)
-> (AssetModelPropertyDefinition
    -> Text -> AssetModelPropertyDefinition)
-> Lens
     AssetModelPropertyDefinition AssetModelPropertyDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelPropertyDefinition' {Text
name :: Text
$sel:name:AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> Text
name} -> Text
name) (\s :: AssetModelPropertyDefinition
s@AssetModelPropertyDefinition' {} Text
a -> AssetModelPropertyDefinition
s {$sel:name:AssetModelPropertyDefinition' :: Text
name = Text
a} :: AssetModelPropertyDefinition)

-- | The data type of the property definition.
--
-- If you specify @STRUCT@, you must also specify @dataTypeSpec@ to
-- identify the type of the structure for this property.
assetModelPropertyDefinition_dataType :: Lens.Lens' AssetModelPropertyDefinition PropertyDataType
assetModelPropertyDefinition_dataType :: (PropertyDataType -> f PropertyDataType)
-> AssetModelPropertyDefinition -> f AssetModelPropertyDefinition
assetModelPropertyDefinition_dataType = (AssetModelPropertyDefinition -> PropertyDataType)
-> (AssetModelPropertyDefinition
    -> PropertyDataType -> AssetModelPropertyDefinition)
-> Lens
     AssetModelPropertyDefinition
     AssetModelPropertyDefinition
     PropertyDataType
     PropertyDataType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelPropertyDefinition' {PropertyDataType
dataType :: PropertyDataType
$sel:dataType:AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> PropertyDataType
dataType} -> PropertyDataType
dataType) (\s :: AssetModelPropertyDefinition
s@AssetModelPropertyDefinition' {} PropertyDataType
a -> AssetModelPropertyDefinition
s {$sel:dataType:AssetModelPropertyDefinition' :: PropertyDataType
dataType = PropertyDataType
a} :: AssetModelPropertyDefinition)

-- | The property definition type (see @PropertyType@). You can only specify
-- one type in a property definition.
assetModelPropertyDefinition_type :: Lens.Lens' AssetModelPropertyDefinition PropertyType
assetModelPropertyDefinition_type :: (PropertyType -> f PropertyType)
-> AssetModelPropertyDefinition -> f AssetModelPropertyDefinition
assetModelPropertyDefinition_type = (AssetModelPropertyDefinition -> PropertyType)
-> (AssetModelPropertyDefinition
    -> PropertyType -> AssetModelPropertyDefinition)
-> Lens
     AssetModelPropertyDefinition
     AssetModelPropertyDefinition
     PropertyType
     PropertyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetModelPropertyDefinition' {PropertyType
type' :: PropertyType
$sel:type':AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> PropertyType
type'} -> PropertyType
type') (\s :: AssetModelPropertyDefinition
s@AssetModelPropertyDefinition' {} PropertyType
a -> AssetModelPropertyDefinition
s {$sel:type':AssetModelPropertyDefinition' :: PropertyType
type' = PropertyType
a} :: AssetModelPropertyDefinition)

instance
  Prelude.Hashable
    AssetModelPropertyDefinition

instance Prelude.NFData AssetModelPropertyDefinition

instance Core.ToJSON AssetModelPropertyDefinition where
  toJSON :: AssetModelPropertyDefinition -> Value
toJSON AssetModelPropertyDefinition' {Maybe Text
Text
PropertyDataType
PropertyType
type' :: PropertyType
dataType :: PropertyDataType
name :: Text
unit :: Maybe Text
dataTypeSpec :: Maybe Text
$sel:type':AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> PropertyType
$sel:dataType:AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> PropertyDataType
$sel:name:AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> Text
$sel:unit:AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> Maybe Text
$sel:dataTypeSpec:AssetModelPropertyDefinition' :: AssetModelPropertyDefinition -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"dataTypeSpec" 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
dataTypeSpec,
            (Text
"unit" 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
unit,
            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
"dataType" Text -> PropertyDataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PropertyDataType
dataType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> PropertyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PropertyType
type')
          ]
      )