{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTSiteWise.Types.AssetModelPropertyDefinition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTSiteWise.Types.PropertyDataType
import Amazonka.IoTSiteWise.Types.PropertyType
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
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]
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
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.
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'
      { $sel:dataTypeSpec:AssetModelPropertyDefinition' :: Maybe Text
dataTypeSpec =
          forall a. Maybe a
Prelude.Nothing,
        $sel:unit:AssetModelPropertyDefinition' :: Maybe Text
unit = 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 :: Lens' AssetModelPropertyDefinition (Maybe Text)
assetModelPropertyDefinition_dataTypeSpec = 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 :: Lens' AssetModelPropertyDefinition (Maybe Text)
assetModelPropertyDefinition_unit = 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 :: Lens' AssetModelPropertyDefinition Text
assetModelPropertyDefinition_name = 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 :: Lens' AssetModelPropertyDefinition PropertyDataType
assetModelPropertyDefinition_dataType = 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 :: Lens' AssetModelPropertyDefinition PropertyType
assetModelPropertyDefinition_type = 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
  where
  hashWithSalt :: Int -> AssetModelPropertyDefinition -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dataTypeSpec
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
unit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PropertyDataType
dataType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PropertyType
type'

instance Prelude.NFData AssetModelPropertyDefinition where
  rnf :: AssetModelPropertyDefinition -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataTypeSpec
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
unit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PropertyDataType
dataType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PropertyType
type'

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"dataTypeSpec" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataTypeSpec,
            (Key
"unit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
unit,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"dataType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PropertyDataType
dataType),
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PropertyType
type')
          ]
      )